aa1c82f81e
- 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)
59 lines
1.5 KiB
C
59 lines
1.5 KiB
C
#include <airlys/net.h>
|
|
#include <airlys/string.h>
|
|
|
|
#define SKB_POOL_SIZE 16
|
|
static sk_buff_t s_skb_pool[SKB_POOL_SIZE];
|
|
|
|
sk_buff_t* alloc_skb(uint32_t size) {
|
|
if (size > SKB_MAX_DATA) return NULL;
|
|
|
|
for (int i = 0; i < SKB_POOL_SIZE; i++) {
|
|
if (!s_skb_pool[i].allocated) {
|
|
sk_buff_t* skb = &s_skb_pool[i];
|
|
kmemset(skb, 0, sizeof(sk_buff_t));
|
|
skb->allocated = true;
|
|
skb->head = skb->raw_storage;
|
|
skb->data = skb->raw_storage;
|
|
skb->tail = skb->raw_storage;
|
|
skb->end = skb->raw_storage + sizeof(skb->raw_storage);
|
|
skb->len = 0;
|
|
return skb;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void kfree_skb(sk_buff_t* skb) {
|
|
if (!skb) return;
|
|
skb->allocated = false;
|
|
skb->len = 0;
|
|
}
|
|
|
|
uint8_t* skb_put(sk_buff_t* skb, uint32_t len) {
|
|
if (!skb || skb->tail + len > skb->end) return NULL;
|
|
uint8_t* prev_tail = skb->tail;
|
|
skb->tail += len;
|
|
skb->len += len;
|
|
return prev_tail;
|
|
}
|
|
|
|
uint8_t* skb_push(sk_buff_t* skb, uint32_t len) {
|
|
if (!skb || skb->data - len < skb->head) return NULL;
|
|
skb->data -= len;
|
|
skb->len += len;
|
|
return skb->data;
|
|
}
|
|
|
|
uint8_t* skb_pull(sk_buff_t* skb, uint32_t len) {
|
|
if (!skb || len > skb->len) return NULL;
|
|
skb->data += len;
|
|
skb->len -= len;
|
|
return skb->data;
|
|
}
|
|
|
|
void skb_reserve(sk_buff_t* skb, uint32_t len) {
|
|
if (!skb || skb->data + len > skb->end) return;
|
|
skb->data += len;
|
|
skb->tail += len;
|
|
}
|