summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/prefix.c15
-rw-r--r--lib/prefix.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/prefix.c b/lib/prefix.c
index ed55fac883..b38dd94589 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -467,6 +467,21 @@ int str2family(const char *string)
return -1;
}
+const char *family2str(int family)
+{
+ switch (family) {
+ case AF_INET:
+ return "IPv4";
+ case AF_INET6:
+ return "IPv6";
+ case AF_ETHERNET:
+ return "Ethernet";
+ case AF_EVPN:
+ return "Evpn";
+ }
+ return "?";
+}
+
/* Address Famiy Identifier to Address Family converter. */
int afi2family(afi_t afi)
{
diff --git a/lib/prefix.h b/lib/prefix.h
index 4efbc5a95c..f01c85b811 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -290,6 +290,7 @@ static inline void ipv4_addr_copy(struct in_addr *dst,
extern int str2family(const char *);
extern int afi2family(afi_t);
extern afi_t family2afi(int);
+extern const char *family2str(int family);
extern const char *safi2str(safi_t safi);
extern const char *afi2str(afi_t afi);