diff options
author | Anton Kling <anton@kling.gg> | 2023-10-27 19:41:26 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-10-30 21:49:48 +0100 |
commit | 4f9ed7087cb58683d9423ab771ad76b31dac5514 (patch) | |
tree | 5364217b7d491c4321830025020ab13513067cb1 /network/ipv4.c | |
parent | 715274d3a77c58510b97c3f87cd604dde9de7a4f (diff) |
Kernel: Expose source information of incoming UDP packets
Diffstat (limited to 'network/ipv4.c')
-rw-r--r-- | network/ipv4.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/network/ipv4.c b/network/ipv4.c index 27b38ec..e7ef2c2 100644 --- a/network/ipv4.c +++ b/network/ipv4.c @@ -2,6 +2,7 @@ #include <network/bytes.h> #include <network/ipv4.h> #include <network/udp.h> +#include <string.h> void handle_ipv4(const uint8_t *payload, uint32_t packet_length) { assert(packet_length > 4); @@ -15,10 +16,13 @@ void handle_ipv4(const uint8_t *payload, uint32_t packet_length) { // Make sure the ipv4 header is not trying to get uninitalized memory assert(ipv4_total_length <= packet_length); + uint8_t src_ip[4]; + memcpy(src_ip, payload + 12, sizeof(uint8_t[4])); + uint8_t protocol = *(payload + 9); switch (protocol) { case 0x11: - handle_udp(payload + 20, ipv4_total_length - 20); + handle_udp(src_ip, payload + 20, ipv4_total_length - 20); break; default: kprintf("Protocol given in IPv4 header not handeld: %x\n", protocol); |