Binding an ipv6 slaac address to windows IP Stack error 10049

346 views Asked by At

Background:

This is the 2nd time a call to bind has stopped my project's dev progress. The first time was Selecting a socket interface for any unknown environment. bind was the perceived fault then, its opaque source code not allowing me to see the spurious Hyper-V interface. I implemented Remy Lebeau's suggestion of using GetAdaptersAddresses to cycle through the adapter interfaces to get the desired entry. Since I am creating an ipv6 slaac ip address, I next implemented RFC7217. This produces an address like this: 2600:8806:2700:115:617e:7efc:2e2a:31cc where the network id, the first 8 bytes, is standard and comes from the Router Advertisement and the 'interface id', the latter 8 bytes, is what RFC7217 tells you how to make. I am able to create the socket object for the created address without a problem.

Problem:

But when I try to bind the address, I get error WSAEADDRNOTAVAIL (10049):

The requested address is not valid in its context. This error is returned if the specified address pointed to by the name parameter is not a valid local IP address on this computer.

Indirectly, this means bind is working. It just means that windows has never seen the address before since it wasn't given out by the ISP. But that is the very nature of SLAAC addresses.

Question:

How should I proceed so that windows can recognize my slaac address without which I cannot make the Listen call? Is there someone else who has worked through this problem, perhaps another way?

Attempt1:

Make a call to CreateUnicastIpAddressEntry. Unfortunately, this call requires the app to have administrator privileges. I suggested this in Microsoft's Developer Community: Call the CreateUnicastIpAddressEntry function as user instead of as administrator.

Edit1:

I have now run the MS sample programs (see Unable to GetUnicastIpAddressEntry after CreateUnicastIpAddressEntry). The functions work, but there is a problem in retrieving the ipv6 addr. bind() still does not work after a successful entry.

Edit2:

Further testing revealed that Bind() is still failing for ethernet connections. See bind() works for ipv6 wireless adapter interface but not for ipv6 ethernet (error 10049). Once again a simple debugging problem becomes practically insurmountable due to Microsoft's black-box call to the undocumented __imp_bind function.

Conclusion:

An ipv6 slaac address's network id comes from the ISP via the router and is therefore not a security threat. Its interface id is un-crackable. The address presents no security risk and therefore should not be subjected to the administrator privilege requirement.

1

There are 1 answers

0
rtischer8277 On BEST ANSWER

In the process of resolving the Unable to GetUnicastIpAddressEntry after CreateUnicastIpAddressEntry posting, it was verified that bind() and listen() can indeed be made to work for RFC7217 IPv6 SLAAC generated addresses. See its Answer.