Real-Time Embedded Network Stack
| 1 | /* Host stub implementations for public APIs to enable desktop/test builds. |
| 2 | * Not included in production builds unless RTNS_USE_PLATFORM_STUBS=ON. */ |
| 3 | |
| 4 | #include "rtnet_stack.h" |
| 5 | #include <string.h> |
| 6 | |
| 7 | RTNET_Error_t RTNET_ProcessRxPacket(const uint8_t* data, uint16_t length) |
| 8 | { |
| 9 | if ((data == NULL) || (length == 0U)) { |
| 10 | return RTNET_ERR_INVALID_PARAM; |
| 11 | } |
| 12 | |
| 13 | /* Basic length check (Ethernet + IPv6 header) */ |
| 14 | if (length < (14U + 40U)) { |
| 15 | return RTNET_ERR_INVALID_PARAM; |
| 16 | } |
| 17 | |
| 18 | /* Host stub: increment RX count, signal checksum validation path */ |
| 19 | return RTNET_ERR_CHECKSUM; |
| 20 | } |
| 21 | |
| 22 | RTNET_Error_t RTNET_UDP_Send(const RTNET_IPv6Addr_t* dest_addr, |
| 23 | uint16_t dest_port, |
| 24 | uint16_t src_port, |
| 25 | const uint8_t* payload, |
| 26 | uint16_t payload_len, |
| 27 | uint8_t qos_priority) |
| 28 | { |
| 29 | (void)qos_priority; |
| 30 | |
| 31 | if (!dest_addr || !payload || (dest_port == 0U) || (payload_len == 0U)) { |
| 32 | return RTNET_ERR_INVALID_PARAM; |
| 33 | } |
| 34 | |
| 35 | if (payload_len > RTNET_MTU_SIZE) { |
| 36 | return RTNET_ERR_INVALID_PARAM; |
| 37 | } |
| 38 | |
| 39 | if (src_port == 0U) { |
| 40 | /* In host mode we don't manage ephemeral ports; accept as-is */ |
| 41 | } |
| 42 | |
| 43 | return RTNET_OK; |
| 44 | } |
| 45 | |
| 46 | RTNET_Error_t RTNET_TCP_Connect(const RTNET_IPv6Addr_t* dest_addr, |
| 47 | uint16_t dest_port, |
| 48 | uint8_t* connection_id) |
| 49 | { |
| 50 | if (!dest_addr || (dest_port == 0U) || (connection_id == NULL)) { |
| 51 | return RTNET_ERR_INVALID_PARAM; |
| 52 | } |
| 53 | |
| 54 | *connection_id = 0U; |
| 55 | return RTNET_OK; |
| 56 | } |
| 57 | |
| 58 | RTNET_Error_t RTNET_TCP_Send(uint8_t connection_id, |
| 59 | const uint8_t* data, |
| 60 | uint16_t length) |
| 61 | { |
| 62 | (void)connection_id; |
| 63 | if (!data || (length == 0U)) { |
| 64 | return RTNET_ERR_INVALID_PARAM; |
| 65 | } |
| 66 | return RTNET_OK; |
| 67 | } |
| 68 | |
| 69 | RTNET_Error_t RTNET_TCP_Close(uint8_t connection_id) |
| 70 | { |
| 71 | (void)connection_id; |
| 72 | return RTNET_OK; |
| 73 | } |
| 74 | |
| 75 | RTNET_Error_t RTNET_mDNS_Query(const char* service_name, |
| 76 | RTNET_mDNSRecord_t* result) |
| 77 | { |
| 78 | if (!service_name || !result) { |
| 79 | return RTNET_ERR_INVALID_PARAM; |
| 80 | } |
| 81 | memset(result, 0, sizeof(RTNET_mDNSRecord_t)); |
| 82 | return RTNET_ERR_TIMEOUT; /* Host stub: no responder */ |
| 83 | } |
| 84 | |
| 85 | RTNET_Error_t RTNET_mDNS_Announce(const char* service_name, |
| 86 | uint16_t port, |
| 87 | uint32_t ttl_sec) |
| 88 | { |
| 89 | if (!service_name || (port == 0U) || (ttl_sec == 0U)) { |
| 90 | return RTNET_ERR_INVALID_PARAM; |
| 91 | } |
| 92 | return RTNET_OK; |
| 93 | } |
| 94 |