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
+58
@@ -0,0 +1,58 @@
|
||||
#include <airlys/net.h>
|
||||
#include <airlys/string.h>
|
||||
#include <airlys/printk.h>
|
||||
|
||||
int icmp_send_ping(net_device_t* dev, uint32_t dest_ip, uint16_t seq) {
|
||||
if (!dev) return -1;
|
||||
|
||||
struct {
|
||||
icmphdr_t hdr;
|
||||
char payload[32];
|
||||
} packet;
|
||||
|
||||
packet.hdr.type = 8; /* Echo Request */
|
||||
packet.hdr.code = 0;
|
||||
packet.hdr.checksum = 0;
|
||||
packet.hdr.id = 0x1337;
|
||||
packet.hdr.sequence = seq;
|
||||
kmemcpy(packet.payload, "AirlysSovereignKernelPingPing!", 31);
|
||||
packet.payload[31] = '\0';
|
||||
|
||||
packet.hdr.checksum = net_checksum(&packet, sizeof(packet));
|
||||
|
||||
return ipv4_send(dev, dest_ip, IPPROTO_ICMP, &packet, sizeof(packet));
|
||||
}
|
||||
|
||||
int icmp_process(net_device_t* dev, const iphdr_t* ip, const uint8_t* payload, size_t len) {
|
||||
if (!dev || !ip || !payload || len < sizeof(icmphdr_t)) return -1;
|
||||
|
||||
const icmphdr_t* req = (const icmphdr_t*)payload;
|
||||
|
||||
/* Handle Echo Request (Ping from outside) */
|
||||
if (req->type == 8) {
|
||||
struct {
|
||||
icmphdr_t hdr;
|
||||
uint8_t data[64];
|
||||
} reply;
|
||||
|
||||
size_t data_len = len - sizeof(icmphdr_t);
|
||||
if (data_len > sizeof(reply.data)) data_len = sizeof(reply.data);
|
||||
|
||||
reply.hdr.type = 0; /* Echo Reply */
|
||||
reply.hdr.code = 0;
|
||||
reply.hdr.checksum = 0;
|
||||
reply.hdr.id = req->id;
|
||||
reply.hdr.sequence = req->sequence;
|
||||
|
||||
if (data_len > 0) {
|
||||
kmemcpy(reply.data, payload + sizeof(icmphdr_t), data_len);
|
||||
}
|
||||
|
||||
size_t total_reply_len = sizeof(icmphdr_t) + data_len;
|
||||
reply.hdr.checksum = net_checksum(&reply, total_reply_len);
|
||||
|
||||
return ipv4_send(dev, ip->saddr, IPPROTO_ICMP, &reply, total_reply_len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user