lib: add SAFI_ENCAP type, safi2str prefix utility
Signed-off-by: Lou Berger <lberger@labn.net>
diff --git a/lib/prefix.c b/lib/prefix.c
index 936e9fc..3e4ca16 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -223,6 +223,22 @@
return 0;
}
+const char *
+safi2str(safi_t safi)
+{
+ switch (safi) {
+ case SAFI_UNICAST:
+ return "unicast";
+ case SAFI_MULTICAST:
+ return "multicast";
+ case SAFI_ENCAP:
+ return "encap";
+ case SAFI_MPLS_VPN:
+ return "vpn";
+ }
+ return NULL;
+}
+
/* If n includes p prefix then return 1 else return 0. */
int
prefix_match (const struct prefix *n, const struct prefix *p)
diff --git a/lib/prefix.h b/lib/prefix.h
index a517d79..4a31750 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -173,6 +173,7 @@
extern int str2family(const char *);
extern int afi2family (afi_t);
extern afi_t family2afi (int);
+extern const char *safi2str(safi_t safi);
/* Check bit of the prefix. */
extern unsigned int prefix_bit (const u_char *prefix, const u_char prefixlen);
diff --git a/lib/zebra.h b/lib/zebra.h
index 5f45a3a..644729b 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -489,7 +489,8 @@
#define SAFI_MULTICAST 2
#define SAFI_RESERVED_3 3
#define SAFI_MPLS_VPN 4
-#define SAFI_MAX 5
+#define SAFI_ENCAP 7 /* per IANA */
+#define SAFI_MAX 8
/* Default Administrative Distance of each protocol. */
#define ZEBRA_KERNEL_DISTANCE_DEFAULT 0