From bf6d91dc4edf3d08f0de41f71503159b1713fc9a Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Sat, 24 Sep 2011 11:06:42 +0200 Subject: Use undefined scope for undefined IPv6 addresses. --- lib/ip.c | 4 ++-- lib/ip.h | 1 + lib/ipv6.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/ip.c b/lib/ip.c index 791a601..aa61553 100644 --- a/lib/ip.c +++ b/lib/ip.c @@ -27,9 +27,9 @@ char * ip_scope_text(unsigned scope) { - static char *scope_table[] = { "host", "link", "site", "org", "univ" }; + static char *scope_table[] = { "host", "link", "site", "org", "univ", "undef" }; - if (scope > SCOPE_UNIVERSE) + if (scope > SCOPE_UNDEFINED) return "?"; else return scope_table[scope]; diff --git a/lib/ip.h b/lib/ip.h index e9923e2..5d74d21 100644 --- a/lib/ip.h +++ b/lib/ip.h @@ -37,6 +37,7 @@ #define SCOPE_SITE 2 #define SCOPE_ORGANIZATION 3 #define SCOPE_UNIVERSE 4 +#define SCOPE_UNDEFINED 5 char *ip_scope_text(unsigned); diff --git a/lib/ipv6.c b/lib/ipv6.c index 7c28c48..623f632 100644 --- a/lib/ipv6.c +++ b/lib/ipv6.c @@ -85,6 +85,7 @@ ipv6_classify(ip_addr *a) case 5: return IADDR_MULTICAST | SCOPE_SITE; case 8: return IADDR_MULTICAST | SCOPE_ORGANIZATION; case 14: return IADDR_MULTICAST | SCOPE_UNIVERSE; + default: return IADDR_MULTICAST | SCOPE_UNDEFINED; } } if (!x && !a->addr[1] && !a->addr[2]) @@ -102,7 +103,7 @@ ipv6_classify(ip_addr *a) if (y >= 0x01000000 && y < 0xe0000000) return IADDR_HOST | SCOPE_UNIVERSE; } - return IADDR_INVALID; + return IADDR_HOST | SCOPE_UNDEFINED; } void -- cgit v1.2.3