Real-Time Embedded Network Stack
| 1 | #include "rtnet_stack.h" |
| 2 | #include <string.h> |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | static const RTNET_IPv6Addr_t LOCAL_IP = { .addr = {0xFE,0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,3} }; |
| 6 | static const RTNET_MACAddr_t LOCAL_MAC = { .addr = {0x00,0x10,0x20,0x30,0x40,0x50} }; |
| 7 | |
| 8 | int main(void) |
| 9 | { |
| 10 | RTNET_Initialize(&LOCAL_IP, &LOCAL_MAC); |
| 11 | |
| 12 | RTNET_mDNSRecord_t record; |
| 13 | RTNET_Error_t err = RTNET_mDNS_Query("_http._tcp.local", &record); |
| 14 | |
| 15 | if (err == RTNET_OK) { |
| 16 | printf("Found service at port %u\n", record.port); |
| 17 | } else { |
| 18 | printf("mDNS query returned %d (expected on host stub)\n", err); |
| 19 | } |
| 20 | |
| 21 | /* Periodic upkeep */ |
| 22 | for (;;) { |
| 23 | RTNET_PeriodicTask(); |
| 24 | } |
| 25 | } |
| 26 |