Module Name: src Committed By: christos Date: Wed Dec 10 01:10:38 UTC 2014
Modified Files: src/sys/netinet6: scope6.c scope6_var.h Log Message: printable version of the scope. remove stray breaks. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/netinet6/scope6.c cvs rdiff -u -r1.2 -r1.3 src/sys/netinet6/scope6_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet6/scope6.c diff -u src/sys/netinet6/scope6.c:1.10 src/sys/netinet6/scope6.c:1.11 --- src/sys/netinet6/scope6.c:1.10 Sat Nov 15 19:04:06 2014 +++ src/sys/netinet6/scope6.c Tue Dec 9 20:10:37 2014 @@ -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 @@ in6_addrscope(const struct in6_addr *add 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 @@ in6_addrscope(const struct in6_addr *add 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 @@ in6_setscope(struct in6_addr *in6, const 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. Index: src/sys/netinet6/scope6_var.h diff -u src/sys/netinet6/scope6_var.h:1.2 src/sys/netinet6/scope6_var.h:1.3 --- src/sys/netinet6/scope6_var.h:1.2 Wed Oct 24 02:37:22 2007 +++ src/sys/netinet6/scope6_var.h Tue Dec 9 20:10:37 2014 @@ -57,6 +57,7 @@ int sa6_recoverscope(struct sockaddr_in6 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_ */