Last active
August 29, 2015 14:14
-
-
Save vstakhov/0b1a7075d4b91256435b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: af_inet6.c | |
=================================================================== | |
--- af_inet6.c (revision 277757) | |
+++ af_inet6.c (working copy) | |
@@ -167,6 +167,34 @@ | |
} | |
static void | |
+in6_print_scope(uint8_t *a) | |
+{ | |
+ const char *sname = NULL; | |
+ uint16_t val; | |
+ | |
+ val = (a[0] << 4) + ((a[1] & 0xc0) >> 4); | |
+ | |
+ if ((val & 0xff0) == 0xff0) { | |
+ sname = "Multicast"; | |
+ } | |
+ else { | |
+ switch(val) { | |
+ case 0xfe8: | |
+ sname = "Link"; | |
+ break; | |
+ case 0xfec: | |
+ sname = "Site"; | |
+ break; | |
+ default: | |
+ sname = "Global"; | |
+ break; | |
+ } | |
+ } | |
+ | |
+ printf("scope: %s ", sname); | |
+} | |
+ | |
+static void | |
in6_status(int s __unused, const struct ifaddrs *ifa) | |
{ | |
struct sockaddr_in6 *sin, null_sin; | |
@@ -257,9 +285,7 @@ | |
if ((flags6 & IN6_IFF_PREFER_SOURCE) != 0) | |
printf("prefer_source "); | |
- if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) | |
- printf("scopeid 0x%x ", | |
- ((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id); | |
+ in6_print_scope((uint8_t *)&((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_addr); | |
if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) { | |
printf("pltime "); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment