#ifndef _ETHARP_H_
#define _ETHARP_H_

#include <stdint.h>
#include <stddef.h>
#include <aos/aos.h>
#include <netutil/types.h>


//#define ETHARP_DEBUG_OPTION 1

#if defined(ETHARP_DEBUG_OPTION)
#define ETHARP_DEBUG(x...) debug_printf("[etharp] " x);
#else
#define ETHARP_DEBUG(fmt, ...) ((void)0)
#endif

#define ETH_HLEN 14     /* Default size for ip header */
#define ETH_CRC_LEN 4

#define ETH_TYPE(hdr)  ((hdr)->type)

#define ETH_TYPE_ARP 0x0806
#define ETH_TYPE_IP 0x0800

#define ETH_ADDR_LEN 6

struct eth_hdr {
    struct eth_addr_net dst;
    struct eth_addr_net src;
    struct uint16_net type;
} __attribute__((__packed__));

#define ARP_HW_TYPE_ETH 0x1
#define ARP_PROT_IP 0x0800
#define ARP_OP_REQ 0x1
#define ARP_OP_REP 0x2
#define ARP_HLEN 28

struct arp_hdr {
    struct uint16_net hwtype;
    struct uint16_net proto;
    uint8_t hwlen;
    uint8_t protolen;
    struct uint16_net opcode;
    struct eth_addr_net eth_src;
    struct uint32_net ip_src;
    struct eth_addr_net eth_dst;
    struct uint32_net ip_dst;
} __attribute__((__packed__));


#endif
