summaryrefslogtreecommitdiffstats
path: root/lib/prefix.h
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2016-03-30 13:44:03 +0300
committerTimo Teräs <timo.teras@iki.fi>2016-03-30 14:29:40 +0300
commit8cb40c91cdfb00ddf04e88d3ecd40403890d90f7 (patch)
tree6d6a3de27525820abb740f1fa8347b6f03986bad /lib/prefix.h
parent86c5d2ee68f7b9c00ae4aeb5c8b3c5d82c5ebffc (diff)
downloadquagga-8cb40c91cdfb00ddf04e88d3ecd40403890d90f7.tar.bz2
quagga-8cb40c91cdfb00ddf04e88d3ecd40403890d90f7.tar.xz
cumulus take-3cumulus-take-3
Diffstat (limited to 'lib/prefix.h')
-rw-r--r--lib/prefix.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/prefix.h b/lib/prefix.h
index 4a317507..d4f0eb92 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -235,13 +235,26 @@ extern void masklen2ip6 (const int, struct in6_addr *);
extern void str2in6_addr (const char *, struct in6_addr *);
extern const char *inet6_ntoa (struct in6_addr);
+static inline int ipv6_martian (struct in6_addr *addr)
+{
+ struct in6_addr localhost_addr;
+
+ inet_pton (AF_INET6, "::1", &localhost_addr);
+
+ if (IPV6_ADDR_SAME(&localhost_addr, addr))
+ return 1;
+
+ return 0;
+}
+
#endif /* HAVE_IPV6 */
extern int all_digit (const char *);
+/* NOTE: This routine expects the address argument in network byte order. */
static inline int ipv4_martian (struct in_addr *addr)
{
- in_addr_t ip = addr->s_addr;
+ in_addr_t ip = ntohl(addr->s_addr);
if (IPV4_NET0(ip) || IPV4_NET127(ip) || IPV4_CLASS_DE(ip)) {
return 1;