1-- Copyright (c) 2018-2021, OARC, Inc. 2-- All rights reserved. 3-- 4-- This file is part of dnsjit. 5-- 6-- dnsjit is free software: you can redistribute it and/or modify 7-- it under the terms of the GNU General Public License as published by 8-- the Free Software Foundation, either version 3 of the License, or 9-- (at your option) any later version. 10-- 11-- dnsjit is distributed in the hope that it will be useful, 12-- but WITHOUT ANY WARRANTY; without even the implied warranty of 13-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14-- GNU General Public License for more details. 15-- 16-- You should have received a copy of the GNU General Public License 17-- along with dnsjit. If not, see <http://www.gnu.org/licenses/>. 18 19-- dnsjit.core.object.ether 20-- Ether part of a packet 21-- 22-- The ether part of a packet that usually can be found in the object chain 23-- after parsing with, for example, Layer filter. 24-- .SS Attributes 25-- .TP 26-- dhost 27-- The destination ether address. 28-- .TP 29-- shost 30-- The source ether address. 31-- .TP 32-- type 33-- The packet type ID field / EtherType field. 34module(...,package.seeall) 35 36require("dnsjit.core.object.ether_h") 37local ffi = require("ffi") 38local C = ffi.C 39 40local t_name = "core_object_ether_t" 41local core_object_ether_t 42local Ether = {} 43 44-- Return the textual type of the object. 45function Ether:type() 46 return "ether" 47end 48 49-- Return the previous object. 50function Ether:prev() 51 return self.obj_prev 52end 53 54-- Cast the object to the underlining object module and return it. 55function Ether:cast() 56 return self 57end 58 59-- Cast the object to the generic object module and return it. 60function Ether:uncast() 61 return ffi.cast("core_object_t*", self) 62end 63 64-- Make a copy of the object and return it. 65function Ether:copy() 66 return C.core_object_ether_copy(self) 67end 68 69-- Free the object, should only be used on copies or otherwise allocated. 70function Ether:free() 71 C.core_object_ether_free(self) 72end 73 74core_object_ether_t = ffi.metatype(t_name, { __index = Ether }) 75 76-- dnsjit.core.object (3), 77-- dnsjit.filter.layer (3) 78return Ether 79