1 //-------------------------------------------------------------------------- 2 // Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 3 // 4 // This program is free software; you can redistribute it and/or modify it 5 // under the terms of the GNU General Public License Version 2 as published 6 // by the Free Software Foundation. You may not use, modify or distribute 7 // this program under any other version of the GNU General Public License. 8 // 9 // This program is distributed in the hope that it will be useful, but 10 // WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 // General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License along 15 // with this program; if not, write to the Free Software Foundation, Inc., 16 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 //-------------------------------------------------------------------------- 18 // eth.h author Josh Rosenbaum <jrosenba@cisco.com> 19 20 #ifndef PROTOCOLS_ETH_H 21 #define PROTOCOLS_ETH_H 22 23 #include <arpa/inet.h> 24 #include "protocols/protocol_ids.h" 25 26 #define ETHERNET_HEADER_LEN 14 27 #define ETHERNET_MTU 1500 28 29 namespace snort 30 { 31 namespace eth 32 { 33 constexpr uint16_t MTU_LEN = 1500; 34 constexpr uint16_t MAX_FRAME_LENGTH = 1500; 35 constexpr uint16_t ETH_HEADER_LEN = 14; 36 37 struct EtherHdr 38 { 39 uint8_t ether_dst[6]; 40 uint8_t ether_src[6]; 41 uint16_t ether_type; 42 43 /* return data in byte order */ ethertypeEtherHdr44 inline ProtocolId ethertype() const 45 { return (ProtocolId)ntohs(ether_type); } 46 47 /* return data in network order */ raw_ethertypeEtherHdr48 inline uint16_t raw_ethertype() const 49 { return ether_type; } 50 }; 51 } // namespace eth 52 } // namespace snort 53 54 #endif 55 56