summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-01-07 09:33:28 -0500
committerPaul Jakma <paul.jakma@hpe.com>2016-02-26 14:11:40 +0000
commitf3cfc46450cccc5ac035a5a97c5a1a5484205705 (patch)
tree3ae512da65c1b4962363c038b8b2c94e27decf65 /lib
parentd5062d218994885710fe02f516f0c06025b4fc9a (diff)
downloadquagga-f3cfc46450cccc5ac035a5a97c5a1a5484205705.tar.bz2
quagga-f3cfc46450cccc5ac035a5a97c5a1a5484205705.tar.xz
lib, bgpd: Fixup afi_t to be an enum and cleanup zebra.h
This code change does two things: 1) Removes ZEBRA_AFI_XXX #defines since they were redundant information 2) Switches afi_t to an enumerated type so that the compiler can do a bit more compile time checking. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/plist.c11
-rw-r--r--lib/zebra.h15
2 files changed, 10 insertions, 16 deletions
diff --git a/lib/plist.c b/lib/plist.c
index f9e626d8..699c9b13 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -698,8 +698,9 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
}
/* "any" is special token for matching any IPv4 addresses. */
- if (afi == AFI_IP)
+ switch (afi)
{
+ case AFI_IP:
if (strncmp ("any", prefix, strlen (prefix)) == 0)
{
ret = str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4 *) &p);
@@ -715,10 +716,8 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
vty_out (vty, "%% Malformed IPv4 prefix%s", VTY_NEWLINE);
return CMD_WARNING;
}
- }
-#ifdef HAVE_IPV6
- else if (afi == AFI_IP6)
- {
+ break;
+ case AFI_IP6:
if (strncmp ("any", prefix, strlen (prefix)) == 0)
{
ret = str2prefix_ipv6 ("::/0", (struct prefix_ipv6 *) &p);
@@ -734,8 +733,8 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
vty_out (vty, "%% Malformed IPv6 prefix%s", VTY_NEWLINE);
return CMD_WARNING;
}
+ break;
}
-#endif /* HAVE_IPV6 */
/* ge and le check. */
if (genum && (genum <= p.prefixlen))
diff --git a/lib/zebra.h b/lib/zebra.h
index a607437a..a9c76c6a 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -445,11 +445,6 @@ extern int proto_redistnum(int afi, const char *s);
extern const char *zserv_command_string (unsigned int command);
-/* Zebra's family types. */
-#define ZEBRA_FAMILY_IPV4 1
-#define ZEBRA_FAMILY_IPV6 2
-#define ZEBRA_FAMILY_MAX 3
-
/* Error codes of zebra. */
#define ZEBRA_ERR_NOERROR 0
#define ZEBRA_ERR_RTEXIST -1
@@ -483,9 +478,11 @@ extern const char *zserv_command_string (unsigned int command);
#endif
/* Address family numbers from RFC1700. */
-#define AFI_IP 1
-#define AFI_IP6 2
-#define AFI_MAX 3
+typedef enum {
+ AFI_IP = 1,
+ AFI_IP6 = 2,
+#define AFI_MAX 3
+} afi_t;
/* Subsequent Address Family Identifier. */
#define SAFI_UNICAST 1
@@ -516,8 +513,6 @@ extern const char *zserv_command_string (unsigned int command);
#define SET_FLAG(V,F) (V) |= (F)
#define UNSET_FLAG(V,F) (V) &= ~(F)
-/* AFI and SAFI type. */
-typedef u_int16_t afi_t;
typedef u_int8_t safi_t;
/* Zebra types. Used in Zserv message header. */