summaryrefslogtreecommitdiff
path: root/net/arp.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/arp.h')
-rw-r--r--net/arp.h28
1 files changed, 28 insertions, 0 deletions
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 <stdint.h>
+
+#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);