summaryrefslogtreecommitdiff
path: root/lib/prefix.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prefix.c')
-rw-r--r--lib/prefix.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/lib/prefix.c b/lib/prefix.c
index 1d098f78c5..a6aae08a6a 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -1,22 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Prefix related functions.
* Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
@@ -138,6 +123,23 @@ afi_t family2afi(int family)
return 0;
}
+const char *afi2str_lower(afi_t afi)
+{
+ switch (afi) {
+ case AFI_IP:
+ return "ipv4";
+ case AFI_IP6:
+ return "ipv6";
+ case AFI_L2VPN:
+ return "l2vpn";
+ case AFI_MAX:
+ case AFI_UNSPEC:
+ return "bad-value";
+ }
+
+ assert(!"Reached end of function we should never reach");
+}
+
const char *afi2str(afi_t afi)
{
switch (afi) {
@@ -148,11 +150,11 @@ const char *afi2str(afi_t afi)
case AFI_L2VPN:
return "l2vpn";
case AFI_MAX:
+ case AFI_UNSPEC:
return "bad-value";
- default:
- break;
}
- return NULL;
+
+ assert(!"Reached end of function we should never reach");
}
const char *safi2str(safi_t safi)
@@ -172,9 +174,12 @@ const char *safi2str(safi_t safi)
return "labeled-unicast";
case SAFI_FLOWSPEC:
return "flowspec";
- default:
+ case SAFI_UNSPEC:
+ case SAFI_MAX:
return "unknown";
}
+
+ assert(!"Reached end of function we should never reach");
}
/* If n includes p prefix then return 1 else return 0. */
@@ -1443,9 +1448,11 @@ int evpn_prefix2prefix(const struct prefix *evpn, struct prefix *to)
switch (addr->route_type) {
case BGP_EVPN_MAC_IP_ROUTE:
if (IS_IPADDR_V4(&addr->macip_addr.ip))
- ipaddr2prefix(&addr->macip_addr.ip, 32, to);
+ ipaddr2prefix(&addr->macip_addr.ip, IPV4_MAX_BITLEN,
+ to);
else if (IS_IPADDR_V6(&addr->macip_addr.ip))
- ipaddr2prefix(&addr->macip_addr.ip, 128, to);
+ ipaddr2prefix(&addr->macip_addr.ip, IPV6_MAX_BITLEN,
+ to);
else
return -1; /* mac only? */
@@ -1507,7 +1514,7 @@ static ssize_t printfrr_ia(struct fbuf *buf, struct printfrr_eargs *ea,
return bputch(buf, '*');
break;
- default:
+ case IPADDR_NONE:
break;
}
}