3

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.

Community
  • 1
  • 1
rtischer8277
  • 496
  • 6
  • 27
  • Please show the relevant code and state the exact problem or error. A description alone is not enough. Also see [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – jww Nov 17 '19 at 19:28
  • See SO `Unable to GetUnicastIpAddressEntry after CreateUnicastIpAddressEntry` **Edit1** for the relevant code. – rtischer8277 Nov 19 '19 at 14:14
  • This SO posting, `Bind() Windows Socket works with IPv4 but not with IPv6`, asks basically the same question as this posting, the difference being, the other posting uses `::1` and `getaddrinfo()` to resolve the ip address. Unfortunately, that approach resolves the address using DNS. In contrast, this posting's approach self-creates the ip address using RFC7217. This means the ip address is already resolved since you are the one that created it. DNS has traditionally had security problems although DOH is attempting to fix this. Using RFC7217 eliminates this security hole by design. – rtischer8277 Nov 23 '19 at 18:46

1 Answers1

0

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.

Community
  • 1
  • 1
rtischer8277
  • 496
  • 6
  • 27