diff --git a/Makefile b/Makefile index 21f6548..8cb373a 100644 --- a/Makefile +++ b/Makefile @@ -123,6 +123,12 @@ run-server: $(IMAGE) -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80 \ -device e1000,netdev=net0 -serial stdio -display none +run-remote: $(IMAGE) + qemu-system-x86_64 -drive format=raw,file=$(IMAGE) \ + -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80 \ + -device e1000,netdev=net0 \ + -serial telnet:0.0.0.0:2222,server,nowait -display none + debug: $(IMAGE) qemu-system-x86_64 -drive format=raw,file=$(IMAGE) \ -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80 \ diff --git a/net/core/net.c b/net/core/net.c index da818dc..523d9a9 100644 --- a/net/core/net.c +++ b/net/core/net.c @@ -235,6 +235,9 @@ void net_receive(const uint8_t* packet, uint16_t length) { const ip_header_t* ip = (const ip_header_t*)payload; uint8_t ihl = (ip->ihl_version & 0x0F) * 4; if (payload_len >= ihl) { + // Dynamically learn sender's MAC address in ARP cache + arp_cache_insert(ip->src_ip, eth->src_mac); + // NetFilter inspection hook if (filter_evaluate(FILTER_HOOK_LOCAL_IN, ip->protocol, ip->src_ip, ip->dst_ip, 0, 0, payload_len) == FILTER_ACTION_DROP) { return; // Dropped by firewall @@ -315,8 +318,8 @@ void net_init(void) { primary_if.dns = ip_parse("10.0.2.3"); primary_if.is_up = true; - // Seed gateway in ARP cache - uint8_t qemu_gw[6] = {0x52, 0x54, 0x00, 0x12, 0x34, 0x56}; + // Seed gateway in ARP cache (QEMU Virtual Router MAC) + uint8_t qemu_gw[6] = {0x52, 0x55, 0x0A, 0x00, 0x02, 0x02}; arp_cache_insert(primary_if.gateway, qemu_gw); printk(KERN_INFO "NET: eth0 configured (IP: 10.0.2.15, GW: 10.0.2.2, Mask: 255.255.255.0)\n");