Real-Time Embedded Network Stack
| 1 | # RTNet Stack – API Reference |
| 2 | |
| 3 | ## Initialization |
| 4 | - `RTNET_Error_t RTNET_Initialize(const RTNET_IPv6Addr_t* local_ipv6, const RTNET_MACAddr_t* local_mac);` |
| 5 | Initializes stack context and seeds timers/ports. |
| 6 | |
| 7 | - `RTNET_Error_t RTNET_AddRoute(const RTNET_IPv6Addr_t* destination, uint8_t prefix_len, const RTNET_IPv6Addr_t* next_hop, uint16_t metric);` |
| 8 | Adds static route; `next_hop == NULL` means directly connected. |
| 9 | |
| 10 | - `void RTNET_PeriodicTask(void);` |
| 11 | Maintenance (timeouts, cache aging). Call ~every 100 ms. |
| 12 | |
| 13 | ## RX/TX |
| 14 | - `RTNET_Error_t RTNET_ProcessRxPacket(const uint8_t* data, uint16_t length);` |
| 15 | Feed a received Ethernet frame (IPv6). |
| 16 | |
| 17 | - `RTNET_Error_t RTNET_UDP_Send(const RTNET_IPv6Addr_t* dest_addr, uint16_t dest_port, uint16_t src_port, const uint8_t* payload, uint16_t payload_len, uint8_t qos_priority);` |
| 18 | Sends UDP datagram. `src_port=0` auto-assigns an ephemeral port. QoS values: `RTNET_QOS_{CRITICAL,HIGH,NORMAL,LOW}`. |
| 19 | |
| 20 | ## TCP-Lite |
| 21 | - `RTNET_Error_t RTNET_TCP_Connect(const RTNET_IPv6Addr_t* dest_addr, uint16_t dest_port, uint8_t* connection_id);` |
| 22 | - `RTNET_Error_t RTNET_TCP_Send(uint8_t connection_id, const uint8_t* data, uint16_t length);` |
| 23 | - `RTNET_Error_t RTNET_TCP_Close(uint8_t connection_id);` |
| 24 | |
| 25 | Connections are limited by `RTNET_MAX_TCP_CONNECTIONS`. States are simplified for embedded timing. |
| 26 | |
| 27 | ## mDNS |
| 28 | - `RTNET_Error_t RTNET_mDNS_Query(const char* service_name, RTNET_mDNSRecord_t* result);` |
| 29 | - `RTNET_Error_t RTNET_mDNS_Announce(const char* service_name, uint16_t port, uint32_t ttl_sec);` |
| 30 | |
| 31 | Cache size: `RTNET_MAX_MDNS_CACHE`. Names are limited to 63 chars (plus terminator). |
| 32 | |
| 33 | ## Statistics |
| 34 | - `RTNET_Error_t RTNET_GetStatistics(RTNET_Statistics_t* stats);` |
| 35 | Returns RX/TX counters, drops, checksum and routing errors. |
| 36 | |
| 37 | ## Platform Hooks (BSP) |
| 38 | - `void RTNET_CriticalSectionEnter/Exit(void);` |
| 39 | - `uint32_t RTNET_GetTimeMs(void);` |
| 40 | - `void RTNET_HardwareTransmit(const uint8_t* data, uint16_t length);` |
| 41 | |
| 42 | Provide these in production; host builds use stubs. |
| 43 |