From 112ca29a3bb2ab38693943ed33ee51f4fd7d2d81 Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 25 Sep 2018 12:43:03 +0200 Subject: arp replies working! --- net/arp.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 net/arp.h (limited to 'net/arp.h') diff --git a/net/arp.h b/net/arp.h new file mode 100644 index 0000000..a690ac0 --- /dev/null +++ b/net/arp.h @@ -0,0 +1,28 @@ +// 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); -- cgit v1.2.3