summaryrefslogtreecommitdiff
path: root/net/arp.h
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-25 12:43:03 +0200
committerMiguel <m.i@gmx.at>2018-09-25 12:43:03 +0200
commit112ca29a3bb2ab38693943ed33ee51f4fd7d2d81 (patch)
treec843051f9291ebe2de6e603c45d924d843d35ea4 /net/arp.h
parent2ba77c01a33c3454aeed42d5394dd5ccede10851 (diff)
arp replies working!
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);