diff options
-rw-r--r-- | babeld/babel_interface.c | 58 | ||||
-rw-r--r-- | babeld/route.h | 5 |
2 files changed, 63 insertions, 0 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index bd32d263..d4c84b35 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -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 diff --git a/babeld/route.h b/babeld/route.h index e38f1577..c08332a6 100644 --- a/babeld/route.h +++ b/babeld/route.h @@ -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 |