1 typedef unsigned char uint8_t; 2 typedef unsigned short uint16_t; 3 typedef unsigned int uint32_t; 4 typedef unsigned long long uint64_t; 5 6 #define ETHER_ADDR_LEN 6 /**< Length of Ethernet address. */ 7 8 /** 9 * Ethernet address: 10 * A universally administered address is uniquely assigned to a device by its 11 * manufacturer. The first three octets (in transmission order) contain the 12 * Organizationally Unique Identifier (OUI). The following three (MAC-48 and 13 * EUI-48) octets are assigned by that organization with the only constraint 14 * of uniqueness. 15 * A locally administered address is assigned to a device by a network 16 * administrator and does not contain OUIs. 17 * See http://standards.ieee.org/regauth/groupmac/tutorial.html 18 */ 19 struct ether_addr { 20 uint8_t addr_bytes[ETHER_ADDR_LEN]; /**< Addr bytes in tx order */ 21 } __attribute__((__packed__)); 22 23 /** 24 * ARP header IPv4 payload. 25 */ 26 struct arp_ipv4 { 27 struct ether_addr arp_sha; /**< sender hardware address */ 28 uint32_t arp_sip; /**< sender IP address */ 29 struct ether_addr arp_tha; /**< target hardware address */ 30 uint32_t arp_tip; /**< target IP address */ 31 } __attribute__((__packed__)); 32 33 /** 34 * ARP header. 35 */ 36 struct arp_hdr { 37 uint16_t arp_hrd; /* format of hardware address */ 38 #define ARP_HRD_ETHER 1 /* ARP Ethernet address format */ 39 40 uint16_t arp_pro; /* format of protocol address */ 41 uint8_t arp_hln; /* length of hardware address */ 42 uint8_t arp_pln; /* length of protocol address */ 43 uint16_t arp_op; /* ARP opcode (command) */ 44 #define ARP_OP_REQUEST 1 /* request to resolve address */ 45 #define ARP_OP_REPLY 2 /* response to previous request */ 46 #define ARP_OP_REVREQUEST 3 /* request proto addr given hardware */ 47 #define ARP_OP_REVREPLY 4 /* response giving protocol address */ 48 #define ARP_OP_INVREQUEST 8 /* request to identify peer */ 49 #define ARP_OP_INVREPLY 9 /* response identifying peer */ 50 51 struct arp_ipv4 arp_data; 52 } __attribute__((__packed__));