feat(phase-6): implement TCP/IP network stack, PCI bus driver & native AiraLang VM
- Implement PCI Bus Controller (drivers/pci.c, include/airlys/pci.h) with Type 1 config mechanism (0xCF8/0xCFC) - Implement IPv4 packet framing, checksum calculation, and protocol routing (net/ipv4.c) - Implement ICMP Echo Request/Reply ping engine (net/icmp.c) - Implement UDP transmission and reception (net/udp.c) - Implement TCP SYN handshake connection initiator (net/tcp.c) - Implement DHCPDISCOVER client broadcasting (net/dhcp.c) - Implement native embedded AiraLang bytecode VM & runtime v1.4.0 (kernel/airalang.c, include/airlys/airalang.h) - Add /home/user/demo.aira sample script to RamFS initramfs - Wire commands to airlys-sh shell: pci, ping, dhcp, airalang, airarun - Zero-warning freestanding verification with clang & ld.lld (bin/airlys.elf: 814 KB) Co-Authored-By: Er. Adam Eehan <adameehanairagroup@gmail.com> Co-Authored-By: Sovereign AI Aira 3 Ultra (Engine v3.6)
This commit is contained in:
committed
1 parent
aa1c82f81e
commit
b083b7ff6e
17 files changed
+1146
-27
No files matched your search
+46
@@ -0,0 +1,46 @@
|
||||
#include <airlys/net.h>
|
||||
#include <airlys/string.h>
|
||||
#include <airlys/printk.h>
|
||||
|
||||
typedef struct {
|
||||
uint8_t op; /* 1 = BOOTREQUEST */
|
||||
uint8_t htype; /* 1 = 10Mb Ethernet */
|
||||
uint8_t hlen; /* 6 */
|
||||
uint8_t hops;
|
||||
uint32_t xid; /* Transaction ID */
|
||||
uint16_t secs;
|
||||
uint16_t flags; /* 0x8000 = Broadcast */
|
||||
uint32_t ciaddr; /* Client IP */
|
||||
uint32_t yiaddr; /* Your IP */
|
||||
uint32_t siaddr; /* Server IP */
|
||||
uint32_t giaddr; /* Gateway IP */
|
||||
uint8_t chaddr[16]; /* Client hardware address */
|
||||
char sname[64];
|
||||
char file[128];
|
||||
uint32_t magic_cookie; /* 0x63825363 */
|
||||
uint8_t options[64];
|
||||
} __attribute__((packed)) dhcp_packet_t;
|
||||
|
||||
int dhcp_send_discover(net_device_t* dev) {
|
||||
if (!dev) return -1;
|
||||
|
||||
dhcp_packet_t packet;
|
||||
kmemset(&packet, 0, sizeof(packet));
|
||||
|
||||
packet.op = 1; /* Request */
|
||||
packet.htype = 1;
|
||||
packet.hlen = 6;
|
||||
packet.xid = 0x3903F301;
|
||||
packet.flags = 0x0080; /* Broadcast flag in network byte order */
|
||||
kmemcpy(packet.chaddr, dev->dev_addr, 6);
|
||||
packet.magic_cookie = 0x63538263; /* Magic cookie (DHCP) */
|
||||
|
||||
/* Options: Option 53 (Message Type = 1: Discover), Option 255 (End) */
|
||||
packet.options[0] = 53; /* DHCP Message Type */
|
||||
packet.options[1] = 1; /* Length 1 */
|
||||
packet.options[2] = 1; /* DHCP Discover */
|
||||
packet.options[3] = 255;/* End */
|
||||
|
||||
printk(KERN_INFO "dhcp: Broadcasting DHCPDISCOVER on %s (Port 68 -> 67)\n", dev->name);
|
||||
return udp_send(dev, 0xFFFFFFFF, 68, 67, &packet, sizeof(packet));
|
||||
}
|
||||
Reference in new issue
Block a user