]> git.puffer.fish Git - mirror/frr.git/commitdiff
babeld: add command: "show_babel_neighbour".
authorMatthieu Boutier <boutier@pps.jussieu.fr>
Wed, 18 Jan 2012 15:39:29 +0000 (16:39 +0100)
committerPaul Jakma <paul@quagga.net>
Sun, 25 Mar 2012 16:06:52 +0000 (17:06 +0100)
babeld/babel_interface.c

index edfa2b40deb34f0e0de3627eca047e9fd425ea7b..bd32d263281cc663bb968e50d5542a28da53bf8a 100644 (file)
@@ -51,6 +51,7 @@ THE SOFTWARE.
 #include "message.h"
 #include "route.h"
 #include "babel_zebra.h"
+#include "neighbour.h"
 
 
 static int babel_enable_if_lookup (const char *ifname);
@@ -727,6 +728,51 @@ DEFUN (show_babel_interface,
   return CMD_SUCCESS;
 }
 
+static void
+show_babel_neighbour_sub (struct vty *vty, struct neighbour *neigh)
+{
+    vty_out (vty,
+             "Neighbour %s dev %s reach %04x rxcost %d txcost %d %s.%s",
+             format_address(neigh->address),
+             neigh->ifp->name,
+             neigh->reach,
+             neighbour_rxcost(neigh),
+             neigh->txcost,
+             if_up(neigh->ifp) ? "" : " (down)",
+             VTY_NEWLINE);
+}
+
+DEFUN (show_babel_neighbour,
+       show_babel_neighbour_cmd,
+       "show babel neighbour [INTERFACE]",
+       SHOW_STR
+       IP_STR
+       "Babel information\n"
+       "Print neighbours\n"
+       "Interface name\n")
+{
+    struct neighbour *neigh;
+    struct interface *ifp;
+
+    if (argc == 0) {
+        FOR_ALL_NEIGHBOURS(neigh) {
+            show_babel_neighbour_sub(vty, neigh);
+        }
+        return CMD_SUCCESS;
+    }
+    if ((ifp = if_lookup_by_name (argv[0])) == NULL)
+    {
+        vty_out (vty, "No such interface name%s", VTY_NEWLINE);
+        return CMD_WARNING;
+    }
+    FOR_ALL_NEIGHBOURS(neigh) {
+        if(ifp->ifindex == neigh->ifp->ifindex) {
+            show_babel_neighbour_sub(vty, neigh);
+        }
+    }
+    return CMD_SUCCESS;
+}
+
 void
 babel_if_init ()
 {
@@ -758,6 +804,8 @@ babel_if_init ()
   /* "show babel ..." commands */
   install_element (VIEW_NODE, &show_babel_interface_cmd);
   install_element (ENABLE_NODE, &show_babel_interface_cmd);
+    install_element(VIEW_NODE, &show_babel_neighbour_cmd);
+    install_element(ENABLE_NODE, &show_babel_neighbour_cmd);
 }
 
 /* hooks: functions called respectively when struct interface is