Background
At the beginning of my program I build a linked list of adapter interface addresses using GetAdaptersAddresses. Later, after creating an ipv6 slaac
address, calling Socket()
, Bind()
and Listen()
all succeed where the IfType
is Wireless, that is, IfType
71 (IF_TYPE_IEEE80211
). My filter parameters are family
and ifType
. I test by connecting and disconnecting the ethernet cable. For each case my software finds the active interface with said parameters: connected it finds ethernet first, disconnected it doesn't find ethernet, then looks further for a wireless interface. See SO Unable to GetUnicastIpAddressEntry after CreateUnicastIpAddressEntry for relevant code snippets.
Problem
However, if the interface's IfType
is 6 (IF_TYPE_ETHERNET_CSMACD
), Socket()
succeeds, but Bind()
and of course Listen()
then fails.
Question
Are there any other factors or interface parameters I have left out that can determine the outcome?
Attempt1
Cycle through all ipv6 interfaces just to empirically determine if any would succeed. None did on two machines.
Attempt2
Looked for scope id
and append that to address, however, I didn't see the scope id
parameter in the interface linked list.
Attempt3
Bind()
will fail to enter the ip address into the internal table ifipRow.DadState
is not set toIpDadStatePreferred
after the call to InitializeUnicastIpAddressEntry and before the call to CreateUnicastIpAddressEntry:This results in a binding to a
preferred
socket upon whichListen()
can be successfully called.Here are the incorrect doc snippets in
CreateUnicastIpAddressEntry
:If the returned
DadState
isIpDadStateTentative
, the address is not useable either.Also, there is this:
DadState
is not ignored, and as stated before will result in a non-preferred, non-useable address if not set to preferred.