Getting prefix length for IPv6 interface address?

From: bbmsdn (bbmsdn_at_discussions.microsoft.com)
Date: 02/21/05


Date: Sun, 20 Feb 2005 20:45:01 -0800

What is the correct way to get the prefix length for an IPv6 interface? I'm
using GetAdaptersAddresses to get the interface addresses and I thought I
could use the same relative position in the FirstPrefix list (e.g. 2nd entry
in FirstUnicastAddresses would map to the 2nd entry in FirstPrefix). This
works most of the time, but there are cases when it fails. For example,
immediately after I get notified of an interface list change
(FD_ADDRESS_LIST_CHANGE), I sometimes get the wrong prefix entry (e.g. 2nd
entry in FirstUnicastAddresses is IPv6, but 2nd entry in FirstPrefix is
IPv4). If I delay for a few seconds after FD_ADDRESS_LIST_CHANGE and before
calling GetAdaptersAddresses, it seems to work, but that's a little hack-ish.

Is my general approach correct? If so, is there something better than Sleep(
3000 ) to workaround the FirstUnicastAddress and FirstPrefix lists being
out-of-sync?

BTW...The way I'm reproducing this to manually set my IP to 169.254.x.x then
switch it back to DHCP. When I do this and immediately call
GetAdaptersAddresses after the FD_ADDRESS_LIST_CHANGE event is signaled, I
see the out-of-sync FirstPrefix list.



Relevant Pages

  • Re: Unchecked_Conversion and task pointer.
    ... you should definitely use an interface. ... > entry call, and they will work as an entry in that case. ... > with such a procedure that you can do with an entry (other than requeue it; ... similarly to class-wide subroutines there could be class-wide entries. ...
    (comp.lang.ada)
  • Re: Unchecked_Conversion and task pointer.
    ... >> You can declare a task interface in Ada 200Y: ... be called as an entry. ... >> no one can figure out how a dispatching requeue could work - it couldn't ...
    (comp.lang.ada)
  • [PATCH] Add a non-blocking I2C interface
    ... Here's the code that I have so far for adding a non-blocking interface ... But this mostly is using the queue entry for data, ... of the IPMI SMB driver. ...
    (Linux-Kernel)
  • VB6 Application Overwhelmed by Rapid User Interaction
    ... I have a VB6 app with a somewhat complication user interface screen. ... consists of a grid through which the user can navigate from entry to entry. ...
    (microsoft.public.vb.winapi)