Files
Adam EehanEr. Adam EehanSovereign AI Aira 3 Ultra (Engine v3.6)
b083b7ff6e 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)
2026-10-23 19:40:16 +05:30

25 lines
755 B
C

#include <airlys/net.h>
#include <airlys/string.h>
static uint16_t swap16(uint16_t v) {
return (uint16_t)((v << 8) | (v >> 8));
}
int udp_send(net_device_t* dev, uint32_t dest_ip, uint16_t src_port, uint16_t dest_port, const void* data, size_t len) {
if (!dev || (!data && len > 0) || len > 1024) return -1;
uint8_t buffer[1024 + sizeof(udphdr_t)];
udphdr_t* udp = (udphdr_t*)buffer;
udp->source = swap16(src_port);
udp->dest = swap16(dest_port);
udp->len = swap16((uint16_t)(sizeof(udphdr_t) + len));
udp->check = 0; /* UDP checksum optional in IPv4 */
if (len > 0) {
kmemcpy(buffer + sizeof(udphdr_t), data, len);
}
return ipv4_send(dev, dest_ip, IPPROTO_UDP, buffer, sizeof(udphdr_t) + len);
}