Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

babeld: implement show babel route ADDR.

This is just an alternate syntax for host routes, but it's
convenient when working with pure meshes.
  • Loading branch information...
commit 323aa13c3f05db3c2b19df83d22ad84cb3331fa9 1 parent 776d929
@jech jech authored
Showing with 77 additions and 1 deletion.
  1. +75 −1 babeld/babel_interface.c
  2. +2 −0  doc/babeld.texi
View
76 babeld/babel_interface.c
@@ -1066,7 +1066,77 @@ ALIAS (show_babel_route_prefix,
SHOW_STR
"Babel information\n"
"IPv6 prefix <network>/<length>\n")
-
+
+DEFUN (show_babel_route_addr,
+ show_babel_route_addr_cmd,
+ "show babel route A.B.C.D",
+ SHOW_STR
+ "Babel information\n"
+ "IPv4 address <network>/<length>\n")
+{
+ struct show_babel_routes_closure c = {vty, NULL};
+ struct in_addr addr;
+ char buf[INET_ADDRSTRLEN + 8];
+ struct prefix prefix;
+ int ret;
+
+ ret = inet_aton (argv[0], &addr);
+ if (ret <= 0) {
+ vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ /* Quagga has no convenient prefix constructors. */
+ snprintf(buf, sizeof(buf), "%s/%d", inet_ntoa(addr), 32);
+
+ ret = str2prefix(buf, &prefix);
+ if (ret == 0) {
+ vty_out (vty, "%% Parse error -- this shouldn't happen%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ c.prefix = &prefix;
+ for_all_routes(show_babel_routes_sub, &c);
+ for_all_xroutes(show_babel_xroutes_sub, &c);
+ return CMD_SUCCESS;
+}
+
+DEFUN (show_babel_route_addr6,
+ show_babel_route_addr6_cmd,
+ "show babel route X:X::X:X",
+ SHOW_STR
+ "Babel information\n"
+ "IPv6 address <network>/<length>\n")
+{
+ struct show_babel_routes_closure c = {vty, NULL};
+ struct in6_addr addr;
+ char buf1[INET6_ADDRSTRLEN];
+ char buf[INET6_ADDRSTRLEN + 8];
+ struct prefix prefix;
+ int ret;
+
+ ret = inet_pton (AF_INET6, argv[0], &addr);
+ if (ret <= 0) {
+ vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ /* Quagga has no convenient prefix constructors. */
+ snprintf(buf, sizeof(buf), "%s/%d",
+ inet_ntop(AF_INET6, &addr, buf1, sizeof(buf1)), 128);
+
+ ret = str2prefix(buf, &prefix);
+ if (ret == 0) {
+ vty_out (vty, "%% Parse error -- this shouldn't happen%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ c.prefix = &prefix;
+ for_all_routes(show_babel_routes_sub, &c);
+ for_all_xroutes(show_babel_xroutes_sub, &c);
+ return CMD_SUCCESS;
+}
+
DEFUN (show_babel_parameters,
show_babel_parameters_cmd,
"show babel parameters",
@@ -1131,6 +1201,10 @@ babel_if_init ()
install_element(ENABLE_NODE, &show_babel_route_prefix_cmd);
install_element(VIEW_NODE, &show_babel_route_prefix6_cmd);
install_element(ENABLE_NODE, &show_babel_route_prefix6_cmd);
+ install_element(VIEW_NODE, &show_babel_route_addr_cmd);
+ install_element(ENABLE_NODE, &show_babel_route_addr_cmd);
+ install_element(VIEW_NODE, &show_babel_route_addr6_cmd);
+ install_element(ENABLE_NODE, &show_babel_route_addr6_cmd);
install_element(VIEW_NODE, &show_babel_parameters_cmd);
install_element(ENABLE_NODE, &show_babel_parameters_cmd);
}
View
2  doc/babeld.texi
@@ -165,6 +165,8 @@ Specify which kind of routes should be redistributed into Babel.
@section Show Babel information
@deffn {Command} {show babel route} {}
+@deffnx {Command} {show babel route A.B.C.D}
+@deffnx {Command} {show babel route X:X::X:X}
@deffnx {Command} {show babel route A.B.C.D/M}
@deffnx {Command} {show babel route X:X::X:X/M}
@deffnx {Command} {show babel interface} {}
Please sign in to comment.
Something went wrong with that request. Please try again.