|
|
|
|
@ -24,8 +24,10 @@
|
|
|
|
|
#include <arpa/inet.h> |
|
|
|
|
#include <ifaddrs.h> |
|
|
|
|
#include <net/if.h> |
|
|
|
|
#ifdef __linux__ |
|
|
|
|
#include <linux/netlink.h> |
|
|
|
|
#include <linux/rtnetlink.h> |
|
|
|
|
#endif |
|
|
|
|
#ifndef IFA_F_TEMPORARY |
|
|
|
|
#define IFA_F_TEMPORARY 0x01 |
|
|
|
|
#endif |
|
|
|
|
@ -114,6 +116,7 @@ int get_interface_ipv6_by_index(uint32_t netif_index, int temporary, uint8_t* ad
|
|
|
|
|
return found ? 0 : -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef __linux__ |
|
|
|
|
/* get_interface_ipv6_addr_nl — netlink-based IPv6 address lookup with proper IFA_F_* flags
|
|
|
|
|
* |
|
|
|
|
* getifaddrs() ifa_flags contains interface flags (IFF_UP etc.), NOT address flags |
|
|
|
|
@ -194,6 +197,13 @@ int get_interface_ipv6_addr_nl(uint32_t netif_index, int prefer_stable, uint8_t*
|
|
|
|
|
if (has_fallback) { memcpy(addr_out, fallback, 16); return 0; } |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
int get_interface_ipv6_addr_nl(uint32_t netif_index, int prefer_stable, uint8_t* addr_out) { |
|
|
|
|
(void)netif_index; (void)prefer_stable; |
|
|
|
|
if (addr_out) memset(addr_out, 0, 16); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
uint32_t get_default_route_netif_index(int family) { |
|
|
|
|
if (family != AF_INET && family != AF_INET6) return 0; |
|
|
|
|
|