forked from joyent/libuv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uv_interface_addresses was using the linked list pointed to by the FirstPrefix member of IP_ADAPTER_ADDRESSES in order to compute the network prefix / network mask. This was flawed in several ways: - FirstPrefix can be NULL, and we would crash. - On Windows Vista and later, the prefix list includes three IP adapter prefixes for each IP address assigned to the adapter. We were assuming a 1:1 mapping with the unicast address list. - Even on Windows versions (i.e. XP) where the prefix list is supposed to have one and only one element for each unicast address, the order of the two lists is not guaranteed to be the same. This fix was inspired and adapted from a commit in the Chromium project: https://codereview.chromium.org/25167002/diff/6001/net/base/net_util_win.cc See MSDN article for reference: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366058(v=vs.85).aspx Excerpt from MSDN below: In addition, the linked IP_ADAPTER_UNICAST_ADDRESS structures pointed to by the FirstUnicastAddress member and the linked IP_ADAPTER_PREFIX structures pointed to by the FirstPrefix member are maintained as separate internal linked lists by the operating system. As a result, the order of linked IP_ADAPTER_UNICAST_ADDRESS structures pointed to by the FirstUnicastAddress member does not have any relationship with the order of linked IP_ADAPTER_PREFIX structures pointed to by the FirstPrefix member. On Windows Vista and later, the linked IP_ADAPTER_PREFIX structures pointed to by the FirstPrefix member include three IP adapter prefixes for each IP address assigned to the adapter. These include the host IP address prefix, the subnet IP address prefix, and the subnet broadcast IP address prefix. In addition, for each adapter there is a multicast address prefix and a broadcast address prefix.
- Loading branch information
1 parent
c18205a
commit 68ac0a6
Showing
1 changed file
with
145 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters