/** * Copyright (c) 2026 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "dusk.h" #define NETWORK_INFO_IPV4_DNS_COUNT_MAX 2 #define NETWORK_INFO_IPV4_OCTET_COUNT 4 #define NETWORK_INFO_IPV6_OCTET_COUNT 16 #define NETWORK_INFO_IPV6_DNS_COUNT_MAX 2 #define NETWORK_INFO_FORMAT_IPV4 "%u.%u.%u.%u" #define NETWORK_INFO_FORMAT_IPV6 \ "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x" typedef enum { NETWORK_TYPE_IPV4, #ifdef DUSK_NETWORK_IPV6 NETWORK_TYPE_IPV6, #endif } networktype_t; typedef struct { uint8_t ip[NETWORK_INFO_IPV4_OCTET_COUNT]; } networkinfoipv4_t; #ifdef DUSK_NETWORK_IPV6 typedef struct { uint8_t ip[NETWORK_INFO_IPV6_OCTET_COUNT]; } networkinfoipv6_t; #endif typedef struct { networktype_t type; union { networkinfoipv4_t ipv4; #ifdef DUSK_NETWORK_IPV6 networkinfoipv6_t ipv6; #endif }; } networkinfo_t; /** * Returns the network information for the currently active network connection. * * @return Network information for the currently active network connection. */ networkinfo_t networkGetInfo();