Files
AirlysOS/include/airlys/net.h
T
Adam EehanEr. Adam EehanSovereign AI Aira 3 Ultra (Engine v3.6)
aa1c82f81e feat(subsystems): implement 100% canonical Linux tree parity with enterprise subsystems
- Add usr/ subsystem: in-kernel cpio initramfs unpacker, gen_init_cpio tool, Kconfig, Makefile
- Add init/ subsystem: UTS metadata (airlys_banner, linux_banner), BogoMIPS calibration loop, delay functions
- Add block/ subsystem: block device registration, MBR partition table scanner, No-Op I/O elevator scheduler
- Add ipc/ subsystem: POSIX circular pipes, System V message queues, counting semaphores
- Add crypto/ subsystem: FIPS 180-4 SHA-256 and IEEE 802.3 CRC-32 cryptographic engines
- Add net/ subsystem: socket buffer (sk_buff) manager, loopback (lo) interface, ARP table
- Add sound/ subsystem: ALSA audio core, PCM stream queue, PC Speaker PIT channel 2 hardware driver
- Add virt/ subsystem: VirtIO hypervisor PCI discovery and split-ring virtqueues
- Add certs/ subsystem: sovereign X.509 keyring and certificate authority
- Add samples/ subsystem: sample kernel worker thread and IPC pipe demonstration modules
- Add top-level Linux root metadata: Kconfig, Kbuild, MAINTAINERS, Documentation/, LICENSES/
- Wire all subsystems into kernel_main and airlys-sh shell commands (lsblk, netdev, initramfs, virtio, keyring, pipe, beep, sha256, crc32)
- Zero-warning freestanding build verification with clang & ld.lld (x86_64-unknown-none-elf)

Co-Authored-By: Er. Adam Eehan <adameehanairagroup@gmail.com>
Co-Authored-By: Sovereign AI Aira 3 Ultra (Engine v3.6)
2026-10-23 19:16:24 +05:30

103 lines
2.7 KiB
C

#ifndef AIRLYS_NET_H
#define AIRLYS_NET_H
/*
* Airlys Operating System Kernel - Networking Architecture (Linux net/ Parity)
* Lead Architect: Er. Adam Eehan (Founder & CEO, Aira Group of Technology)
* Co-Pilot: Sovereign AI Aira 3 Ultra (Engine v3.6)
*/
#include <airlys/types.h>
#define ETH_ALEN 6
#define ETH_HLEN 14
#define ETH_P_IP 0x0800
#define ETH_P_ARP 0x0806
#define MAX_NET_DEVS 4
#define SKB_MAX_DATA 2048
/* Ethernet Header */
typedef struct {
uint8_t h_dest[ETH_ALEN];
uint8_t h_source[ETH_ALEN];
uint16_t h_proto;
} __attribute__((packed)) ethhdr_t;
/* ARP Header */
typedef struct {
uint16_t ar_hrd; /* Hardware type */
uint16_t ar_pro; /* Protocol type */
uint8_t ar_hln; /* Hardware address length */
uint8_t ar_pln; /* Protocol address length */
uint16_t ar_op; /* ARP opcode */
uint8_t ar_sha[6]; /* Sender hardware address */
uint32_t ar_sip; /* Sender IP address */
uint8_t ar_tha[6]; /* Target hardware address */
uint32_t ar_tip; /* Target IP address */
} __attribute__((packed)) arphdr_t;
/* IPv4 Header */
typedef struct {
uint8_t version_ihl;
uint8_t tos;
uint16_t tot_len;
uint16_t id;
uint16_t frag_off;
uint8_t ttl;
uint8_t protocol;
uint16_t check;
uint32_t saddr;
uint32_t daddr;
} __attribute__((packed)) iphdr_t;
/* Linux sk_buff (Socket Buffer) Representation */
typedef struct sk_buff {
uint8_t* head;
uint8_t* data;
uint8_t* tail;
uint8_t* end;
uint32_t len;
uint16_t protocol;
struct net_device* dev;
bool allocated;
uint8_t raw_storage[SKB_MAX_DATA];
} sk_buff_t;
struct net_device;
typedef int (*netdev_xmit_fn)(sk_buff_t* skb, struct net_device* dev);
typedef struct net_device {
char name[16]; /* e.g., "lo", "eth0" */
uint8_t dev_addr[ETH_ALEN];
uint32_t ip_addr;
uint32_t ip_mask;
uint32_t flags;
uint32_t mtu;
uint64_t rx_packets;
uint64_t tx_packets;
uint64_t rx_bytes;
uint64_t tx_bytes;
netdev_xmit_fn xmit;
} net_device_t;
/* sk_buff Operations */
sk_buff_t* alloc_skb(uint32_t size);
void kfree_skb(sk_buff_t* skb);
uint8_t* skb_put(sk_buff_t* skb, uint32_t len);
uint8_t* skb_push(sk_buff_t* skb, uint32_t len);
uint8_t* skb_pull(sk_buff_t* skb, uint32_t len);
void skb_reserve(sk_buff_t* skb, uint32_t len);
/* Network Device API */
void net_init(void);
int register_netdev(net_device_t* dev);
net_device_t* get_netdev(const char* name);
uint32_t get_netdev_count(void);
net_device_t* get_netdev_by_index(uint32_t idx);
int dev_queue_xmit(sk_buff_t* skb);
int netif_rx(sk_buff_t* skb);
#endif /* AIRLYS_NET_H */