summaryrefslogtreecommitdiffstats
path: root/lib/ipaddr.h
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2022-01-19 21:06:45 +0100
committerIgor Ryzhov <iryzhov@nfware.com>2022-01-19 21:13:04 +0100
commit860e740b3634ca480cb14cd71a988adf9e481ff8 (patch)
tree54fc677e2c9294208d690c06dd3fd426913f1e1d /lib/ipaddr.h
parentbgpd: fix populating the attribute (diff)
downloadfrr-860e740b3634ca480cb14cd71a988adf9e481ff8.tar.xz
frr-860e740b3634ca480cb14cd71a988adf9e481ff8.zip
bgpd: replace custom union gw_addr with struct ipaddr
BGP EVPN custom `union gw_addr` is basically the same thing as a common `struct ipaddr` but it lacks the address family which is needed in some cases. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/ipaddr.h')
-rw-r--r--lib/ipaddr.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/ipaddr.h b/lib/ipaddr.h
index 730c7ce13..a334ea969 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