summaryrefslogtreecommitdiffstats
path: root/lib/zebra.h
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2017-08-01 02:22:20 +0200
committerRenato Westphal <renato@opensourcerouting.org>2017-08-01 04:45:03 +0200
commit085347cfadbca04a7dfee175971c23e266becc6b (patch)
tree2985709e4844ba19230b8189d128c3b048bbea6d /lib/zebra.h
parentlib/bgpd: introduce the iana_safi_t enum (diff)
downloadfrr-085347cfadbca04a7dfee175971c23e266becc6b.tar.xz
frr-085347cfadbca04a7dfee175971c23e266becc6b.zip
lib: use switch statements in the AFI/SAFI conversion functions
Switch statements are more elegant (and potentially faster... but that's not the main motivation). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/zebra.h')
-rw-r--r--lib/zebra.h56
1 files changed, 34 insertions, 22 deletions
diff --git a/lib/zebra.h b/lib/zebra.h
index 1924675a1..c31fe0809 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -486,58 +486,70 @@ typedef uint32_t route_tag_t;
static inline afi_t afi_iana2int(iana_afi_t afi)
{
- if (afi == IANA_AFI_IPV4)
+ switch (afi) {
+ case IANA_AFI_IPV4:
return AFI_IP;
- if (afi == IANA_AFI_IPV6)
+ case IANA_AFI_IPV6:
return AFI_IP6;
- if (afi == IANA_AFI_L2VPN)
+ case IANA_AFI_L2VPN:
return AFI_L2VPN;
- return AFI_MAX;
+ default:
+ return AFI_MAX;
+ }
}
static inline iana_afi_t afi_int2iana(afi_t afi)
{
- if (afi == AFI_IP)
+ switch (afi) {
+ case AFI_IP:
return IANA_AFI_IPV4;
- if (afi == AFI_IP6)
+ case AFI_IP6:
return IANA_AFI_IPV6;
- if (afi == AFI_L2VPN)
+ case AFI_L2VPN:
return IANA_AFI_L2VPN;
- return IANA_AFI_RESERVED;
+ default:
+ return IANA_AFI_RESERVED;
+ }
}
static inline safi_t safi_iana2int(iana_safi_t safi)
{
- if (safi == IANA_SAFI_UNICAST)
+ switch (safi) {
+ case IANA_SAFI_UNICAST:
return SAFI_UNICAST;
- if (safi == IANA_SAFI_MULTICAST)
+ case IANA_SAFI_MULTICAST:
return SAFI_MULTICAST;
- if (safi == IANA_SAFI_MPLS_VPN)
+ case IANA_SAFI_MPLS_VPN:
return SAFI_MPLS_VPN;
- if (safi == IANA_SAFI_ENCAP)
+ case IANA_SAFI_ENCAP:
return SAFI_ENCAP;
- if (safi == IANA_SAFI_EVPN)
+ case IANA_SAFI_EVPN:
return SAFI_EVPN;
- if (safi == IANA_SAFI_LABELED_UNICAST)
+ case IANA_SAFI_LABELED_UNICAST:
return SAFI_LABELED_UNICAST;
- return SAFI_MAX;
+ default:
+ return SAFI_MAX;
+ }
}
static inline iana_safi_t safi_int2iana(safi_t safi)
{
- if (safi == SAFI_UNICAST)
+ switch (safi) {
+ case SAFI_UNICAST:
return IANA_SAFI_UNICAST;
- if (safi == SAFI_MULTICAST)
+ case SAFI_MULTICAST:
return IANA_SAFI_MULTICAST;
- if (safi == SAFI_MPLS_VPN)
+ case SAFI_MPLS_VPN:
return IANA_SAFI_MPLS_VPN;
- if (safi == SAFI_ENCAP)
+ case SAFI_ENCAP:
return IANA_SAFI_ENCAP;
- if (safi == SAFI_EVPN)
+ case SAFI_EVPN:
return IANA_SAFI_EVPN;
- if (safi == SAFI_LABELED_UNICAST)
+ case SAFI_LABELED_UNICAST:
return IANA_SAFI_LABELED_UNICAST;
- return IANA_SAFI_RESERVED;
+ default:
+ return IANA_SAFI_RESERVED;
+ }
}
#endif /* _ZEBRA_H */