windows - Why does OnLinkPrefixLength differ to adapter PrefixLength? -


if take msdn example inside ip_adapter_addresses structure on windows 7 sp1 expand out enumeration of unicast addresses:

char s[1024]; (i = 0; punicast != null; i++) {   inet_ntop (punicast->address.lpsockaddr->sa_family,       punicast->address.lpsockaddr->sa_family == af_inet ?       (pvoid)&((struct sockaddr_in*)punicast->address.lpsockaddr)->sin_addr :       (pvoid)&((struct sockaddr_in6*)punicast->address.lpsockaddr)->sin6_addr,       s, sizeof (s));   printf ("\t#%lu %s/%u\n",       i, s, (unsigned)punicast->onlinkprefixlength);   punicast = punicast->next; } 

and prefix details:

char s[1024]; (i = 0; pprefix != null; i++) {   inet_ntop (pprefix->address.lpsockaddr->sa_family,       pprefix->address.lpsockaddr->sa_family == af_inet ?       (pvoid)&((struct sockaddr_in*)pprefix->address.lpsockaddr)->sin_addr :       (pvoid)&((struct sockaddr_in6*)pprefix->address.lpsockaddr)->sin6_addr,       s, sizeof (s));   printf ("\t#%lu %s/%u\n",       i, s, pprefix->prefixlength);   pprefix = pprefix->next; } 

but 1 adapter shows following output:

length of ip_adapter_address struct: 376 ifindex (ipv4 interface): 15 adapter name: {84c25ec1-7abb-4d6e-b8c7-8dee08961ee2} #0 2001:0:4137:9e76:2443:d6:ba87:1a2a/64 #1 fe80::2443:d6:ba87:1a2a/64 number of unicast addresses: 2 ... #0 ::/0 #1 2001::/32 #2 2001:0:4137:9e76:2443:d6:ba87:1a2a/128 #3 fe80::/64 #4 fe80::2443:d6:ba87:1a2a/128 #5 ff00::/8 number of ip adapter prefix entries: 6 

the prefix list correct, albeit expanded on msdn's description of 3 addresses:

on windows vista , later, linked ip_adapter_prefix structures pointed firstprefix member include 3 ip adapter prefixes each ip address assigned adapter. these include host ip address prefix, subnet ip address prefix, , subnet broadcast ip address prefix. in addition, each adapter there multicast address prefix , broadcast address prefix.

i determine list correct comparing output of netstat -r:

ipv6 route table ================================================== active routes:  if metric network destination      gateway  15     58 ::/0                     on-link   1    306 ::1/128                  on-link  15     58 2001::/32                on-link  15    306 2001:0:4137:9e76:2443:d6:ba87:1a2a/128                                     on-link  14    281 fe80::/64                on-link  15    306 fe80::/64                on-link  15    306 fe80::2443:d6:ba87:1a2a/128                                     on-link  14    281 fe80::6153:a573:f691:8167/128                                     on-link   1    306 ff00::/8                 on-link  15    306 ff00::/8                 on-link  14    281 ff00::/8                 on-link ================================================== 

however interpretation of api onlinkprefixlength should return 32 global-scope unicast address vista+ api returning 64, why?

a bit of background information: there few default prefix lengths ipv6. lan has prefix length of 64. link local addresses see (fe80::/64) examples of that. addresses of own system show single addresses in routing table (/128). multicast addresses special (ff00::/8) don't correspond 1 address of 1 host group of multiple hosts on potentially multiple networks.

the /32 seeing teredo address block (2001:0000::/32 == 2001::/32). teredo ipv6-in-ipv4 tunneling protocol windows automatically configures. routing table shows default ipv6 route (::/0) through teredo adapter. system doesn't seem have 'normal' ipv6 global unicast.

summary: on-link-prefix-length /64. teredo special case , uses fixed 'special' /32. own ipv6 addresses complete , have prefix length of /128.

you right in 2001:0:4137:9e76:2443:d6:ba87:1a2a/64 doesn't make sense. teredo should have network prefix length of /32. if single ipv6 address should have prefix length of /128. /64 not make sense teredo , seems bug.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -