Skip to content

Commit

Permalink
Fix incorrect IPv6 interface index on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz authored and tguillem committed Aug 21, 2019
1 parent b976b56 commit 3876182
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,18 @@ mdns_list_interfaces(multicast_if** pp_intfs, size_t* p_nb_intf, int ai_family)
for (current = res; current != NULL; current = current->Next) {
if (!mdns_is_interface_valuable(current))
continue;
if (ai_family == AF_INET6)
*intfs = htonl(current->Ipv6IfIndex);
else
if (ai_family == AF_INET6) {
// For IPv6, The input value for setting IPV6_MULTICAST_IF is the
// interface index of the desired outgoing interface in *host byte order*.
// See https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options
*intfs = current->Ipv6IfIndex;
}
else {
// For IPv4, The input value for setting IP_MULTICAST_IF is the
// interface index of the desired outgoing interface in *network byte order*.
// See https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options
*intfs = htonl(current->IfIndex);
}
++intfs;
}
*p_nb_intf = nb_intf;
Expand Down

0 comments on commit 3876182

Please sign in to comment.