summaryrefslogtreecommitdiff
path: root/babeld/babel_interface.c
diff options
context:
space:
mode:
authorDenis Ovsienko <infrastation@yandex.ru>2012-01-17 19:25:03 +0400
committerPaul Jakma <paul@quagga.net>2012-03-25 17:06:52 +0100
commitd4e46e681434e768b870679b998eb1ac7635fdfc (patch)
tree9c37d25a9f90c1546e325811678b861b25a14c8e /babeld/babel_interface.c
parent8f3607f84eb5d21d4732a51b39775b7edf8796c2 (diff)
babeld: implement "show babel interface" command
* babel_interface.c * show_babel_interface_sub(): new function to process one ifp * show_babel_interface(): new function, VTY wrapper * babel_if_init(): update respectively
Diffstat (limited to 'babeld/babel_interface.c')
-rw-r--r--babeld/babel_interface.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c
index 4bd4499a..df68afba 100644
--- a/babeld/babel_interface.c
+++ b/babeld/babel_interface.c
@@ -660,6 +660,62 @@ is_interface_ll_address(struct interface *ifp, const unsigned char *address)
return 0;
}
+static void
+show_babel_interface_sub (struct vty *vty, struct interface *ifp)
+{
+ int is_up;
+ babel_interface_nfo *babel_ifp;
+
+ vty_out (vty, "%s is %s%s", ifp->name,
+ ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
+ vty_out (vty, " ifindex %u, MTU %u bytes %s%s",
+ ifp->ifindex, ifp->mtu, if_flag_dump(ifp->flags), VTY_NEWLINE);
+
+ if (babel_enable_if_lookup (ifp->name) < 0)
+ {
+ vty_out (vty, " Babel protocol is not enabled on this interface%s", VTY_NEWLINE);
+ return;
+ }
+ if (!is_up)
+ {
+ vty_out (vty, " Babel protocol is enabled, but not running on this interface%s", VTY_NEWLINE);
+ return;
+ }
+ babel_ifp = babel_get_if_nfo (ifp);
+ vty_out (vty, " Babel protocol is running on this interface%s", VTY_NEWLINE);
+ vty_out (vty, " Operating mode is \"%s\"%s",
+ CHECK_FLAG (babel_ifp->flags, BABEL_IF_WIRED) ? "wired" : "wireless", VTY_NEWLINE);
+ vty_out (vty, " Split horizon mode is %s%s",
+ CHECK_FLAG (babel_ifp->flags, BABEL_IF_SPLIT_HORIZON) ? "On" : "Off", VTY_NEWLINE);
+ vty_out (vty, " Hello interval is %u ms%s", babel_ifp->hello_interval, VTY_NEWLINE);
+}
+
+DEFUN (show_babel_interface,
+ show_babel_interface_cmd,
+ "show babel interface [INTERFACE]",
+ SHOW_STR
+ IP_STR
+ "Babel information\n"
+ "Interface information\n"
+ "Interface name\n")
+{
+ struct interface *ifp;
+ struct listnode *node;
+
+ if (argc == 0)
+ {
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
+ show_babel_interface_sub (vty, ifp);
+ 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;
+ }
+ show_babel_interface_sub (vty, ifp);
+ return CMD_SUCCESS;
+}
void
babel_if_init ()
@@ -688,6 +744,10 @@ babel_if_init ()
install_element(INTERFACE_NODE, &babel_set_hello_interval_cmd);
install_element(INTERFACE_NODE, &babel_passive_interface_cmd);
install_element(INTERFACE_NODE, &no_babel_passive_interface_cmd);
+
+ /* "show babel ..." commands */
+ install_element (VIEW_NODE, &show_babel_interface_cmd);
+ install_element (ENABLE_NODE, &show_babel_interface_cmd);
}
/* hooks: functions called respectively when struct interface is