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

30 lines
815 B
C

#include <airlys/net.h>
#include <airlys/string.h>
static uint16_t swap16(uint16_t v) {
return (uint16_t)((v << 8) | (v >> 8));
}
static uint32_t swap32(uint32_t v) {
return ((v >> 24) & 0xFF) | ((v >> 8) & 0xFF00) |
((v << 8) & 0xFF0000) | ((v << 24) & 0xFF000000);
}
int tcp_send_syn(net_device_t* dev, uint32_t dest_ip, uint16_t src_port, uint16_t dest_port) {
if (!dev) return -1;
tcphdr_t tcp;
kmemset(&tcp, 0, sizeof(tcp));
tcp.source = swap16(src_port);
tcp.dest = swap16(dest_port);
tcp.seq = swap32(100000);
tcp.ack_seq = 0;
tcp.flags = swap16((5 << 12) | TCP_SYN); /* 5 32-bit words header length + SYN */
tcp.window = swap16(65535);
tcp.check = 0;
tcp.urg_ptr = 0;
return ipv4_send(dev, dest_ip, IPPROTO_TCP, &tcp, sizeof(tcp));
}