// http://www.saminiir.com/lets-code-tcp-ip-stack-1-ethernet-arp/ // #include #include "netdev.h" struct arp_hdr { uint16_t hwtype; // link layer type (1 - ethernet) uint16_t protype; // protocol (0x800 - ipv4) unsigned char hwsize; // hardware field size (6 bytes mac) unsigned char prosize; // protocol field size (4 byte ip) uint16_t opcode; // arp message type (1- arp request, 2- arp reply, 3- rarp request, 4- rarp reply) unsigned char data[]; // payload } __attribute__((packed)); // arp ipv4 payload struct arp_ipv4 { unsigned char smac[6]; // sender mac uint32_t sip; // sender ip unsigned char dmac[6]; // receiver mac uint32_t dip; // receiver ip } __attribute__((packed)); void arp_incoming(struct netdev *netdev, struct eth_hdr *hdr); void arp_reply(struct netdev *netdev, struct eth_hdr *hdr, struct arp_hdr *arphdr);