diff options
| author | Pat Ruddy <pat@voltanet.io> | 2020-10-15 14:25:26 +0100 | 
|---|---|---|
| committer | Pat Ruddy <pat@voltanet.io> | 2020-10-16 11:54:30 +0100 | 
| commit | f137734bb4729081573a7496e3e1f257da8690a0 (patch) | |
| tree | 813ee8bcfad28023ff18f308dce401152eba4842 /lib/prefix.c | |
| parent | 8d78eeb54b6094f65577af815971a4d5dc1e6f00 (diff) | |
bgpd: replace bgp_evpn_route2str with prefix2str
Remove bgp_evpn_route2str and replace calls with prefix2str
Signed-off-by: Pat Ruddy <pat@voltanet.io>
Diffstat (limited to 'lib/prefix.c')
| -rw-r--r-- | lib/prefix.c | 37 | 
1 files changed, 25 insertions, 12 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index 78f6646735..24def1bac4 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -909,14 +909,17 @@ int str2prefix(const char *str, struct prefix *p)  static const char *prefixevpn_ead2str(const struct prefix_evpn *p, char *str,  				      int size)  { +	uint8_t family;  	char buf[ESI_STR_LEN]; +	char buf1[INET6_ADDRSTRLEN]; +	family = IS_IPADDR_V4(&p->prefix.ead_addr.ip) ? AF_INET : AF_INET6;  	snprintf(str, size, "[%d]:[%u]:[%s]:[%d]:[%s]", p->prefix.route_type,  		 p->prefix.ead_addr.eth_tag,  		 esi_to_str(&p->prefix.ead_addr.esi, buf, sizeof(buf)), -		 is_evpn_prefix_ipaddr_v4(p) ? IPV4_MAX_BITLEN -					     : IPV6_MAX_BITLEN, -		 inet_ntoa(p->prefix.ead_addr.ip.ipaddr_v4)); +		 (family == AF_INET) ? IPV4_MAX_BITLEN : IPV6_MAX_BITLEN, +		 inet_ntop(family, &p->prefix.ead_addr.ip.ipaddr_v4, buf1, +			   sizeof(buf1)));  	return str;  } @@ -949,11 +952,15 @@ static const char *prefixevpn_macip2str(const struct prefix_evpn *p, char *str,  static const char *prefixevpn_imet2str(const struct prefix_evpn *p, char *str,  				       int size)  { +	uint8_t family; +	char buf[INET6_ADDRSTRLEN]; + +	family = IS_IPADDR_V4(&p->prefix.imet_addr.ip) ? AF_INET : AF_INET6;  	snprintf(str, size, "[%d]:[%d]:[%d]:[%s]", p->prefix.route_type,  		 p->prefix.imet_addr.eth_tag, -		 is_evpn_prefix_ipaddr_v4(p) ? IPV4_MAX_BITLEN -					     : IPV6_MAX_BITLEN, -		 inet_ntoa(p->prefix.imet_addr.ip.ipaddr_v4)); +		 (family == AF_INET) ? IPV4_MAX_BITLEN : IPV6_MAX_BITLEN, +		 inet_ntop(family, &p->prefix.imet_addr.ip.ipaddr_v4, buf, +			   sizeof(buf)));  	return str;  } @@ -961,13 +968,16 @@ static const char *prefixevpn_imet2str(const struct prefix_evpn *p, char *str,  static const char *prefixevpn_es2str(const struct prefix_evpn *p, char *str,  				     int size)  { +	uint8_t family;  	char buf[ESI_STR_LEN]; +	char buf1[INET6_ADDRSTRLEN]; +	family = IS_IPADDR_V4(&p->prefix.es_addr.ip) ? AF_INET : AF_INET6;  	snprintf(str, size, "[%d]:[%s]:[%d]:[%s]", p->prefix.route_type,  		 esi_to_str(&p->prefix.es_addr.esi, buf, sizeof(buf)), -		 is_evpn_prefix_ipaddr_v4(p) ? IPV4_MAX_BITLEN -					     : IPV6_MAX_BITLEN, -		 inet_ntoa(p->prefix.es_addr.ip.ipaddr_v4)); +		 (family == AF_INET) ? IPV4_MAX_BITLEN : IPV6_MAX_BITLEN, +		 inet_ntop(family, &p->prefix.es_addr.ip.ipaddr_v4, buf1, +			   sizeof(buf1)));  	return str;  } @@ -975,12 +985,15 @@ static const char *prefixevpn_es2str(const struct prefix_evpn *p, char *str,  static const char *prefixevpn_prefix2str(const struct prefix_evpn *p, char *str,  					 int size)  { +	uint8_t family; +	char buf[INET6_ADDRSTRLEN]; + +	family = IS_IPADDR_V4(&p->prefix.prefix_addr.ip) ? AF_INET : AF_INET6;  	snprintf(str, size, "[%d]:[%d]:[%d]:[%s]", p->prefix.route_type,  		 p->prefix.prefix_addr.eth_tag,  		 p->prefix.prefix_addr.ip_prefix_length, -		 is_evpn_prefix_ipaddr_v4(p) -			 ? inet_ntoa(p->prefix.prefix_addr.ip.ipaddr_v4) -			 : inet6_ntoa(p->prefix.prefix_addr.ip.ipaddr_v6)); +		 inet_ntop(family, &p->prefix.prefix_addr.ip.ipaddr_v4, buf, +			   sizeof(buf)));  	return str;  }  | 
