From 860e740b3634ca480cb14cd71a988adf9e481ff8 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Wed, 19 Jan 2022 23:06:45 +0300 Subject: 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 --- lib/ipaddr.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/ipaddr.h') 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 -- cgit v1.2.3