diff options
Diffstat (limited to 'lib/prefix.h')
| -rw-r--r-- | lib/prefix.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/prefix.h b/lib/prefix.h index a27f46ba0a..0732cf1290 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -315,7 +315,9 @@ extern void prefix_ipv4_free(struct prefix_ipv4 *); extern int str2prefix_ipv4(const char *, struct prefix_ipv4 *); extern void apply_mask_ipv4(struct prefix_ipv4 *); -#define PREFIX_COPY_IPV4(DST, SRC) \ +#define PREFIX_COPY(DST, SRC) \ + *((struct prefix *)(DST)) = *((const struct prefix *)(SRC)) +#define PREFIX_COPY_IPV4(DST, SRC) \ *((struct prefix_ipv4 *)(DST)) = *((const struct prefix_ipv4 *)(SRC)); extern int prefix_ipv4_any(const struct prefix_ipv4 *); @@ -377,15 +379,20 @@ static inline int ipv4_martian(struct in_addr *addr) return 0; } -static inline int is_default_prefix(struct prefix *p) +static inline int is_default_prefix(const struct prefix *p) { if (!p) return 0; - if (((p->family == AF_INET) && (p->u.prefix4.s_addr == INADDR_ANY)) - || ((p->family == AF_INET6) - && !memcmp(&p->u.prefix6, &in6addr_any, - sizeof(struct in6_addr)))) + if ((p->family == AF_INET) && + (p->u.prefix4.s_addr == INADDR_ANY) && + (p->prefixlen == 0)) + return 1; + + if ((p->family == AF_INET6) && + (p->prefixlen == 0) && + (!memcmp(&p->u.prefix6, &in6addr_any, + sizeof(struct in6_addr)))) return 1; return 0; |
