112a9d9c8Sopenharmony_citypedef unsigned char uint8_t;
212a9d9c8Sopenharmony_citypedef unsigned short uint16_t;
312a9d9c8Sopenharmony_citypedef unsigned int uint32_t;
412a9d9c8Sopenharmony_citypedef unsigned long long uint64_t;
512a9d9c8Sopenharmony_ci
612a9d9c8Sopenharmony_ci#define ETHER_ADDR_LEN  6 /**< Length of Ethernet address. */
712a9d9c8Sopenharmony_ci
812a9d9c8Sopenharmony_ci/**
912a9d9c8Sopenharmony_ci * Ethernet address:
1012a9d9c8Sopenharmony_ci * A universally administered address is uniquely assigned to a device by its
1112a9d9c8Sopenharmony_ci * manufacturer. The first three octets (in transmission order) contain the
1212a9d9c8Sopenharmony_ci * Organizationally Unique Identifier (OUI). The following three (MAC-48 and
1312a9d9c8Sopenharmony_ci * EUI-48) octets are assigned by that organization with the only constraint
1412a9d9c8Sopenharmony_ci * of uniqueness.
1512a9d9c8Sopenharmony_ci * A locally administered address is assigned to a device by a network
1612a9d9c8Sopenharmony_ci * administrator and does not contain OUIs.
1712a9d9c8Sopenharmony_ci * See http://standards.ieee.org/regauth/groupmac/tutorial.html
1812a9d9c8Sopenharmony_ci */
1912a9d9c8Sopenharmony_cistruct ether_addr {
2012a9d9c8Sopenharmony_ci	uint8_t addr_bytes[ETHER_ADDR_LEN]; /**< Addr bytes in tx order */
2112a9d9c8Sopenharmony_ci} __attribute__((__packed__));
2212a9d9c8Sopenharmony_ci
2312a9d9c8Sopenharmony_ci/**
2412a9d9c8Sopenharmony_ci * ARP header IPv4 payload.
2512a9d9c8Sopenharmony_ci */
2612a9d9c8Sopenharmony_cistruct arp_ipv4 {
2712a9d9c8Sopenharmony_ci	struct ether_addr arp_sha;  /**< sender hardware address */
2812a9d9c8Sopenharmony_ci	uint32_t          arp_sip;  /**< sender IP address */
2912a9d9c8Sopenharmony_ci	struct ether_addr arp_tha;  /**< target hardware address */
3012a9d9c8Sopenharmony_ci	uint32_t          arp_tip;  /**< target IP address */
3112a9d9c8Sopenharmony_ci} __attribute__((__packed__));
3212a9d9c8Sopenharmony_ci
3312a9d9c8Sopenharmony_ci/**
3412a9d9c8Sopenharmony_ci * ARP header.
3512a9d9c8Sopenharmony_ci */
3612a9d9c8Sopenharmony_cistruct arp_hdr {
3712a9d9c8Sopenharmony_ci	uint16_t arp_hrd;    /* format of hardware address */
3812a9d9c8Sopenharmony_ci#define ARP_HRD_ETHER     1  /* ARP Ethernet address format */
3912a9d9c8Sopenharmony_ci
4012a9d9c8Sopenharmony_ci	uint16_t arp_pro;    /* format of protocol address */
4112a9d9c8Sopenharmony_ci	uint8_t  arp_hln;    /* length of hardware address */
4212a9d9c8Sopenharmony_ci	uint8_t  arp_pln;    /* length of protocol address */
4312a9d9c8Sopenharmony_ci	uint16_t arp_op;     /* ARP opcode (command) */
4412a9d9c8Sopenharmony_ci#define	ARP_OP_REQUEST    1 /* request to resolve address */
4512a9d9c8Sopenharmony_ci#define	ARP_OP_REPLY      2 /* response to previous request */
4612a9d9c8Sopenharmony_ci#define	ARP_OP_REVREQUEST 3 /* request proto addr given hardware */
4712a9d9c8Sopenharmony_ci#define	ARP_OP_REVREPLY   4 /* response giving protocol address */
4812a9d9c8Sopenharmony_ci#define	ARP_OP_INVREQUEST 8 /* request to identify peer */
4912a9d9c8Sopenharmony_ci#define	ARP_OP_INVREPLY   9 /* response identifying peer */
5012a9d9c8Sopenharmony_ci
5112a9d9c8Sopenharmony_ci	struct arp_ipv4 arp_data;
5212a9d9c8Sopenharmony_ci} __attribute__((__packed__));