diff options
Diffstat (limited to 'lib/ipaddr.h')
| -rw-r--r-- | lib/ipaddr.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/ipaddr.h b/lib/ipaddr.h index 730c7ce130..a334ea969e 100644 --- a/lib/ipaddr.h +++ b/lib/ipaddr.h @@ -170,6 +170,19 @@ static inline int ipaddr_cmp(const struct ipaddr *a, const struct ipaddr *b) } } +static inline bool ipaddr_is_zero(const struct ipaddr *ip) +{ + switch (ip->ipa_type) { + case IPADDR_NONE: + return true; + case IPADDR_V4: + return ip->ipaddr_v4.s_addr == INADDR_ANY; + case IPADDR_V6: + return IN6_IS_ADDR_UNSPECIFIED(&ip->ipaddr_v6); + } + return true; +} + #ifdef _FRR_ATTRIBUTE_PRINTFRR #pragma FRR printfrr_ext "%pIA" (struct ipaddr *) #endif |
