`ifconfig` patch to resolve IPv6 scope names
raichoo
raichoo at googlemail.com
Wed Aug 9 20:18:09 UTC 2017
Hi,
I've made a trivial patch that resolves IPv6 scope names (according to
rfc4291).
I thought this might be handy, so one does not have to memorize what id
refers
to which scope. And it's a nice opportunity to get my feet wet I guess :)
This is my first patch and I have no idea what's the best way to contribute
to the
project (probably I didn't look hard enough or in the wrong places).
Feedback and pointers appreciated.
Kind regards,
raichoo
diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c
index e93d94355e..165b2cc90a 100644
--- a/sbin/ifconfig/af_inet6.c
+++ b/sbin/ifconfig/af_inet6.c
@@ -268,10 +268,32 @@ in6_status(int s __unused, const struct ifaddrs *ifa)
if ((flags6 & IN6_IFF_PREFER_SOURCE) != 0)
printf("prefer_source ");
- if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id)
+ if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) {
printf("scopeid 0x%x ",
((struct sockaddr_in6
*)(ifa->ifa_addr))->sin6_scope_id);
+ switch (((struct sockaddr_in6
*)(ifa->ifa_addr))->sin6_scope_id) {
+ case 0x1:
+ printf("interface-local ");
+ break;
+ case 0x2:
+ printf("link-local ");
+ break;
+ case 0x4:
+ printf("admin-local ");
+ break;
+ case 0x5:
+ printf("site-local ");
+ break;
+ case 0x8:
+ printf("organization-local ");
+ break;
+ case 0xe:
+ printf("global ");
+ break;
+ }
+ }
+
if (ip6lifetime && (lifetime.ia6t_preferred ||
lifetime.ia6t_expire)) {
printf("pltime ");
if (lifetime.ia6t_preferred) {
More information about the freebsd-hackers
mailing list