summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-11-01 21:43:17 +0100
committerAnton Kling <anton@kling.gg>2023-11-13 14:55:59 +0100
commit359ea12aeee4dd6dfb79c9ba44d7059714e4fa95 (patch)
tree879c4be0d7869601963108683faea776027335ce
parent027b5e0fb4be55a314d2168c92e99772cc80f442 (diff)
ARP: Save the IP, MAC of incoming ARP requests
-rw-r--r--kernel/network/arp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/network/arp.c b/kernel/network/arp.c
index ddeb553..dfa1131 100644
--- a/kernel/network/arp.c
+++ b/kernel/network/arp.c
@@ -120,7 +120,12 @@ void handle_arp(const u8 *payload) {
print_mac("dsthw: ", data->dsthw);
print_ip("dstpr: ", data->dstpr);
- assert(0 == memcmp(data->dstpr, ip_address, sizeof(u8[4])));
+ struct ARP_TABLE_ENTRY *entry = find_arp_entry_to_use();
+ entry->is_used = 1;
+ memcpy(entry->mac, data->srchw, sizeof(uint8_t[6]));
+ memcpy(entry->ip, data->srcpr, sizeof(uint8_t[4]));
+
+ assert(0 == memcmp(data->dstpr, ip_address, sizeof(uint8_t[4])));
// Now we have to construct a ARP response
struct ARP_DATA response;