Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet6 printable version of the scope.



details:   https://anonhg.NetBSD.org/src/rev/a260281f8e10
branches:  trunk
changeset: 334840:a260281f8e10
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Dec 10 01:10:37 2014 +0000

description:
printable version of the scope.
remove stray breaks.

diffstat:

 sys/netinet6/scope6.c     |  27 ++++++++++++++++++---------
 sys/netinet6/scope6_var.h |   1 +
 2 files changed, 19 insertions(+), 9 deletions(-)

diffs (83 lines):

diff -r 240b5c9f2ffd -r a260281f8e10 sys/netinet6/scope6.c
--- a/sys/netinet6/scope6.c     Wed Dec 10 01:10:14 2014 +0000
+++ b/sys/netinet6/scope6.c     Wed Dec 10 01:10:37 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scope6.c,v 1.10 2014/11/16 00:04:06 joerg Exp $        */
+/*     $NetBSD: scope6.c,v 1.11 2014/12/10 01:10:37 christos Exp $     */
 /*     $KAME$  */
 
 /*-
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scope6.c,v 1.10 2014/11/16 00:04:06 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scope6.c,v 1.11 2014/12/10 01:10:37 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -181,13 +181,10 @@
                switch (scope) {
                case 0x80:
                        return IPV6_ADDR_SCOPE_LINKLOCAL;
-                       break;
                case 0xc0:
                        return IPV6_ADDR_SCOPE_SITELOCAL;
-                       break;
                default:
                        return IPV6_ADDR_SCOPE_GLOBAL; /* just in case */
-                       break;
                }
        }
 
@@ -202,16 +199,12 @@
                switch (scope) {
                case IPV6_ADDR_SCOPE_INTFACELOCAL:
                        return IPV6_ADDR_SCOPE_INTFACELOCAL;
-                       break;
                case IPV6_ADDR_SCOPE_LINKLOCAL:
                        return IPV6_ADDR_SCOPE_LINKLOCAL;
-                       break;
                case IPV6_ADDR_SCOPE_SITELOCAL:
                        return IPV6_ADDR_SCOPE_SITELOCAL;
-                       break;
                default:
                        return IPV6_ADDR_SCOPE_GLOBAL;
-                       break;
                }
        }
 
@@ -439,6 +432,22 @@
        return in6_setzoneid(in6, zoneid);
 }
 
+const char *
+in6_getscopename(const struct in6_addr *addr)
+{
+       switch (in6_addrscope(addr)) {
+       case IPV6_ADDR_SCOPE_INTFACELOCAL:      return "interface";
+#if IPV6_ADDR_SCOPE_INTFACELOCAL != IPV6_ADDR_SCOPE_NODELOCAL
+       case IPV6_ADDR_SCOPE_NODELOCAL:         return "node";
+#endif
+       case IPV6_ADDR_SCOPE_LINKLOCAL:         return "link";
+       case IPV6_ADDR_SCOPE_SITELOCAL:         return "site";
+       case IPV6_ADDR_SCOPE_ORGLOCAL:          return "organization";
+       case IPV6_ADDR_SCOPE_GLOBAL:            return "global";
+       default:                                return "unknown";
+       }
+}
+
 /*
  * Just clear the embedded scope identifier.  Return 0 if the original address
  * is intact; return non 0 if the address is modified.
diff -r 240b5c9f2ffd -r a260281f8e10 sys/netinet6/scope6_var.h
--- a/sys/netinet6/scope6_var.h Wed Dec 10 01:10:14 2014 +0000
+++ b/sys/netinet6/scope6_var.h Wed Dec 10 01:10:37 2014 +0000
@@ -57,6 +57,7 @@
 int    in6_setzoneid(struct in6_addr *, uint32_t);
 int    in6_setscope(struct in6_addr *, const struct ifnet *, u_int32_t *);
 int    in6_clearscope(struct in6_addr *);
+const char *in6_getscopename(const struct in6_addr *);
 #endif /* _KERNEL */
 
 #endif /* _NETINET6_SCOPE6_VAR_H_ */



Home | Main Index | Thread Index | Old Index