summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorG. Paul Ziemba <paulz@labn.net>2018-03-28 18:56:45 +0200
committerG. Paul Ziemba <paulz@labn.net>2018-04-04 18:24:17 +0200
commitdb2fde34d3be4a20eed9e6b5cad92bfea2b471fa (patch)
treeea85fef4555528567d6c67f9e354ce1d5e8c1ac8 /lib
parentMerge pull request #1993 from vivek-cumulus/evpn-fixes (diff)
downloadfrr-db2fde34d3be4a20eed9e6b5cad92bfea2b471fa.tar.xz
frr-db2fde34d3be4a20eed9e6b5cad92bfea2b471fa.zip
lib/prefix.[ch]: add family2str()
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
Diffstat (limited to 'lib')
-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 ed55fac88..b38dd9458 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 4efbc5a95..f01c85b81 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);