Implement IPv4 stack and ip app (AI)

- Created src/ipv4.h: IPv4 header struct, protocol numbers, checksum,
  address conversion (ipv4_aton/ntoa), send/receive/routing API,
  protocol handler registration
- Created src/ipv4.c: packet construction with header checksum,
  simple routing (direct subnet + gateway), incoming packet validation
  and dispatch to registered protocol handlers
- Created apps/ip/ip.c: displays network interface config from
  /sys/net (MAC, link, IP, netmask, gateway); supports 'ip set'
  to configure interface via sysfs writes
- Added ipv4.c to kernel build, kernel calls ipv4_init() at boot
- Tested: clean boot, IPv4 initialized, ip app in CPIO
This commit is contained in:
AI
2026-02-24 07:28:33 +00:00
parent 35bafdcad9
commit 1825448528
7 changed files with 659 additions and 5 deletions

View File

@@ -23,6 +23,7 @@
#include "fat32.h"
#include "keyboard.h"
#include "ethernet.h"
#include "ipv4.h"
#include "framebuffer.h"
/* Global framebuffer info, parsed from multiboot2 tags. */
@@ -419,6 +420,9 @@ void kernel_main(uint32_t magic, uint32_t addr) {
ethernet_init();
offset_print("Ethernet subsystem initialized\n");
ipv4_init();
offset_print("IPv4 stack initialized\n");
init_drivers();
EARLY_PRINT("DRV ");
offset_print("Drivers initialized\n");