summaryrefslogtreecommitdiffstats
path: root/lib/nexthop.c
diff options
context:
space:
mode:
authorvivek <vivek@cumulusnetworks.com>2016-09-08 18:38:53 +0200
committervivek <vivek@cumulusnetworks.com>2016-09-08 18:53:26 +0200
commit80c2442a9b959afce944d75c62565a9659bf84f9 (patch)
treed9acd69caa90f5391dff07a461844416f5f0889b /lib/nexthop.c
parentbgpd: Enhance path selection logs (diff)
downloadfrr-80c2442a9b959afce944d75c62565a9659bf84f9.tar.xz
frr-80c2442a9b959afce944d75c62565a9659bf84f9.zip
lib, bgpd: Log next hops
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com> Ticket: CM-12390 Reviewed By: CCR-5156 Testing Done: Manual
Diffstat (limited to 'lib/nexthop.c')
-rw-r--r--lib/nexthop.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c
index 585388421..14486ea15 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -153,3 +153,36 @@ nexthops_free (struct nexthop *nexthop)
nexthop_free (nh);
}
}
+
+const char *
+nexthop2str (struct nexthop *nexthop, char *str, int size)
+{
+ switch (nexthop->type)
+ {
+ case NEXTHOP_TYPE_IFINDEX:
+ snprintf (str, size, "if %u", nexthop->ifindex);
+ break;
+ case NEXTHOP_TYPE_IPV4:
+ snprintf (str, size, "%s", inet_ntoa (nexthop->gate.ipv4));
+ break;
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
+ snprintf (str, size, "%s if %u",
+ inet_ntoa (nexthop->gate.ipv4), nexthop->ifindex);
+ break;
+ case NEXTHOP_TYPE_IPV6:
+ snprintf (str, size, "%s", inet6_ntoa (nexthop->gate.ipv6));
+ break;
+ case NEXTHOP_TYPE_IPV6_IFINDEX:
+ snprintf (str, size, "%s if %u",
+ inet6_ntoa (nexthop->gate.ipv6), nexthop->ifindex);
+ break;
+ case NEXTHOP_TYPE_BLACKHOLE:
+ snprintf (str, size, "blackhole");
+ break;
+ default:
+ snprintf (str, size, "unknown");
+ break;
+ }
+
+ return str;
+}