-
- // look up the interface index by LUID
- if((idx = find_ifindex(m, p->Luid)) < 0) {
- catta_log_error("could not allocate index ip_adapter_address");
+ size_t n;
+
+ // we want an index specific to the hardware interface, but Windows
+ // has one for IPv4 and one for IPv6. it seems like these are always the
+ // same unless one of the protocols is not available. let's have a bunch of
+ // checks...
+ if(!p->IfIndex && !p->Ipv6IfIndex) {
+ return; // no usable protocols
+ } else if(!p->IfIndex) {
+ idx = p->Ipv6IfIndex; // IPv6 but no IPv4 (huh!)
+ } else if(!p->Ipv6IfIndex) {
+ idx = p->IfIndex; // IPv4 but no IPv6
+ } else if(p->IfIndex == p->Ipv6IfIndex) {
+ idx = p->IfIndex; // same index for both protocols
+ } else {
+ // both indexes valid but not equal
+ catta_log_error("unsupported interface: %ls (IfIndex and Ipv6IfIndex differ: %u/%u)",
+ p->FriendlyName, (unsigned int)p->IfIndex, (unsigned int)p->Ipv6IfIndex);