]> git.proxmox.com Git - mirror_frr.git/commitdiff
babeld: add command: "show_babel_database".
authorMatthieu Boutier <boutier@pps.jussieu.fr>
Wed, 18 Jan 2012 19:01:31 +0000 (20:01 +0100)
committerPaul Jakma <paul@quagga.net>
Sun, 25 Mar 2012 16:06:52 +0000 (17:06 +0100)
babeld/babel_interface.c
babeld/route.h

index bd32d263281cc663bb968e50d5542a28da53bf8a..d4c84b353206ce032eaf1234bed037ff94d172a7 100644 (file)
@@ -52,6 +52,8 @@ THE SOFTWARE.
 #include "route.h"
 #include "babel_zebra.h"
 #include "neighbour.h"
+#include "route.h"
+#include "xroute.h"
 
 
 static int babel_enable_if_lookup (const char *ifname);
@@ -773,6 +775,60 @@ DEFUN (show_babel_neighbour,
     return CMD_SUCCESS;
 }
 
+static void
+show_babel_routes_sub (struct vty *vty, struct babel_route *route)
+{
+    const unsigned char *nexthop =
+        memcmp(route->nexthop, route->neigh->address, 16) == 0 ?
+        NULL : route->nexthop;
+
+    vty_out(vty,
+            "%s metric %d refmetric %d id %s seqno %d age %d "
+            "via %s neigh %s%s%s%s%s",
+            format_prefix(route->src->prefix, route->src->plen),
+            route_metric(route), route->refmetric,
+            format_eui64(route->src->id),
+            (int)route->seqno,
+            (int)(babel_now.tv_sec - route->time),
+            route->neigh->ifp->name,
+            format_address(route->neigh->address),
+            nexthop ? " nexthop " : "",
+            nexthop ? format_address(nexthop) : "",
+            route->installed ? " (installed)" :
+            route_feasible(route) ? " (feasible)" : "",
+            VTY_NEWLINE);
+}
+
+static void
+show_babel_xroutes_sub (struct vty *vty, struct xroute *xroute)
+{
+    vty_out(vty, "%s metric %d (exported)%s",
+            format_prefix(xroutes->prefix, xroute->plen),
+            xroutes->metric,
+            VTY_NEWLINE);
+}
+
+DEFUN (show_babel_database,
+       show_babel_database_cmd,
+       "show babel database",
+       SHOW_STR
+       IP_STR
+       "Babel information\n"
+       "Database information\n"
+       "No attributes\n")
+{
+    int i;
+
+    for(i = 0; i < numroutes; i++) {
+        show_babel_routes_sub(vty, &routes[i]);
+    }
+    for(i = 0; i < numxroutes; i++) {
+        show_babel_xroutes_sub(vty, &xroutes[i]);
+    }
+
+    return CMD_SUCCESS;
+}
+
 void
 babel_if_init ()
 {
@@ -806,6 +862,8 @@ babel_if_init ()
   install_element (ENABLE_NODE, &show_babel_interface_cmd);
     install_element(VIEW_NODE, &show_babel_neighbour_cmd);
     install_element(ENABLE_NODE, &show_babel_neighbour_cmd);
+    install_element(VIEW_NODE, &show_babel_database_cmd);
+    install_element(ENABLE_NODE, &show_babel_database_cmd);
 }
 
 /* hooks: functions called respectively when struct interface is
index e38f157729b57fa3402e7ab75509793d5dce19ea..c08332a6d99767a10fde8d40b2766b1d748a08f8 100644 (file)
@@ -37,6 +37,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */
 
+#ifndef BABEL_ROUTE_H
+#define BABEL_ROUTE_H
+
 #include "babel_interface.h"
 #include "source.h"
 
@@ -102,3 +105,5 @@ void expire_routes(void);
 
 void babel_uninstall_all_routes(void);
 struct babel_route *babel_route_get_by_source(struct source *src);
+
+#endif