diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-06-10 19:58:58 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-06-10 19:58:58 +0000 |
commit | c9227bf8a7a339b12d957d918b536cf876a46ca0 (patch) | |
tree | b3210fca346d487e88071dbcd85a3c855bdbdc6c /winsup | |
parent | bbfcc68ad284e0ae779559e8836f513ad78b4204 (diff) | |
download | cygnal-c9227bf8a7a339b12d957d918b536cf876a46ca0.tar.gz cygnal-c9227bf8a7a339b12d957d918b536cf876a46ca0.tar.bz2 cygnal-c9227bf8a7a339b12d957d918b536cf876a46ca0.zip |
* fhandler_procnet.cc (get_scope): New static function to evaluate
scope.
(dad_to_flags): New static array to convert Windows DAD state to
Linux values.
(format_procnet_ifinet6): Drop asking for IfIndex, just use Ipv6IfIndex.
Use get_scope and dad_to_flags to generate more accurate linux-like
output.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 10 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_procnet.cc | 33 |
2 files changed, 39 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 775c710a1..63eb45d5e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,15 @@ 2008-06-10 Corinna Vinschen <corinna@vinschen.de> + * fhandler_procnet.cc (get_scope): New static function to evaluate + scope. + (dad_to_flags): New static array to convert Windows DAD state to + Linux values. + (format_procnet_ifinet6): Drop asking for IfIndex, just use Ipv6IfIndex. + Use get_scope and dad_to_flags to generate more accurate linux-like + output. + +2008-06-10 Corinna Vinschen <corinna@vinschen.de> + * net.cc (if_nametoindex): Fix typo in call to get_adapters_addresses. (if_indextoname): Prefer IPv6 loopback device name over IPv4 loopback device name on pre-Vista systems. diff --git a/winsup/cygwin/fhandler_procnet.cc b/winsup/cygwin/fhandler_procnet.cc index f9fd94707..7b2423c2a 100644 --- a/winsup/cygwin/fhandler_procnet.cc +++ b/winsup/cygwin/fhandler_procnet.cc @@ -229,6 +229,31 @@ fhandler_procnet::fill_filebuf () return true; } +/* Return the same scope values as Linux. */ +static unsigned int +get_scope (struct in6_addr *addr) +{ + if (IN6_IS_ADDR_LOOPBACK (addr)) + return 0x10; + if (IN6_IS_ADDR_LINKLOCAL (addr)) + return 0x20; + if (IN6_IS_ADDR_SITELOCAL (addr)) + return 0x40; + if (IN6_IS_ADDR_V4COMPAT (addr)) + return 0x80; + return 0x0; +} + +/* Convert DAD state into Linux compatible values. */ +static unsigned int dad_to_flags[] = +{ + 0x02, /* Invalid -> NODAD */ + 0x40, /* Tentative -> TENTATIVE */ + 0xc0, /* Duplicate to PERMANENT | TENTATIVE */ + 0x20, /* Deprecated -> DEPRECATED */ + 0x80 /* Preferred -> PERMANENT */ +}; + static _off64_t format_procnet_ifinet6 (char *&filebuf) { @@ -262,11 +287,11 @@ format_procnet_ifinet6 (char *&filebuf) filebuf[filesize++] = ' '; filesize += sprintf (filebuf + filesize, "%02lx %02x %02x %02x %s\n", - pap->IfIndex ?: pap->Ipv6IfIndex, + pap->Ipv6IfIndex, ip_addr_prefix (pua, pap->FirstPrefix), - ((struct sockaddr_in6 *) - pua->Address.lpSockaddr)->sin6_scope_id, - pua->DadState, + get_scope (&((struct sockaddr_in6 *) + pua->Address.lpSockaddr)->sin6_addr), + dad_to_flags [pua->DadState], pap->AdapterName); } |