X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fethernet.h;h=cb9d5274e6dee0e29b2d7769f892aa61e92f67ac;hb=2f2bda4d1953617b945f1222e008cb53edee162a;hp=085e96ad2bc11ed2eb6be65169eb44bb3d8a093a;hpb=95921696a49d1eff058880c90a80efd208de959d;p=tinc diff --git a/src/ethernet.h b/src/ethernet.h index 085e96ad..cb9d5274 100644 --- a/src/ethernet.h +++ b/src/ethernet.h @@ -1,3 +1,6 @@ +#ifndef TINC_ETHERNET_H +#define TINC_ETHERNET_H + /* ethernet.h -- missing Ethernet related definitions Copyright (C) 2005 Ivo Timmermans @@ -18,13 +21,21 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __TINC_ETHERNET_H__ -#define __TINC_ETHERNET_H__ +#include "system.h" #ifndef ETH_ALEN #define ETH_ALEN 6 #endif +#ifndef ETH_HLEN +#define ETH_HLEN 14 +#endif + +#ifndef ETHER_TYPE_LEN +#define ETHER_TYPE_LEN 2 +#endif + + #ifndef ARPHRD_ETHER #define ARPHRD_ETHER 1 #endif @@ -45,23 +56,28 @@ #define ETH_P_8021Q 0x8100 #endif +#ifndef ETH_P_MAX +#define ETH_P_MAX 0xFFFF +#endif + #ifndef HAVE_STRUCT_ETHER_HEADER -struct ether_header { +PACKED(struct ether_header { uint8_t ether_dhost[ETH_ALEN]; uint8_t ether_shost[ETH_ALEN]; uint16_t ether_type; -} __attribute__ ((__gcc_struct__, __packed__)); +}); #endif +STATIC_ASSERT(sizeof(struct ether_header) == 14, "ether_header has incorrect size"); + #ifndef HAVE_STRUCT_ARPHDR -struct arphdr { +PACKED(struct arphdr { uint16_t ar_hrd; uint16_t ar_pro; uint8_t ar_hln; uint8_t ar_pln; uint16_t ar_op; -} __attribute__ ((__gcc_struct__, __packed__)); - +}); #define ARPOP_REQUEST 1 #define ARPOP_REPLY 2 #define ARPOP_RREQUEST 3 @@ -71,14 +87,16 @@ struct arphdr { #define ARPOP_NAK 10 #endif +STATIC_ASSERT(sizeof(struct arphdr) == 8, "arphdr has incorrect size"); + #ifndef HAVE_STRUCT_ETHER_ARP -struct ether_arp { +PACKED(struct ether_arp { struct arphdr ea_hdr; uint8_t arp_sha[ETH_ALEN]; uint8_t arp_spa[4]; uint8_t arp_tha[ETH_ALEN]; uint8_t arp_tpa[4]; -} __attribute__ ((__gcc_struct__, __packed__)); +}); #define arp_hrd ea_hdr.ar_hrd #define arp_pro ea_hdr.ar_pro #define arp_hln ea_hdr.ar_hln @@ -86,4 +104,6 @@ struct ether_arp { #define arp_op ea_hdr.ar_op #endif -#endif /* __TINC_ETHERNET_H__ */ +STATIC_ASSERT(sizeof(struct ether_arp) == 28, "ether_arp has incorrect size"); + +#endif