From 5734509c0545ebd95a5b8e3f22a911c1a39ffa1b Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Sun, 25 Dec 2011 17:52:09 +0100 Subject: babeld: Initial import, for Babel routing protocol. * Initial import of the Babel routing protocol, ported to Quagga. * LICENCE: Update the original LICENCE file to include all known potentially applicable copyright claims. Ask that any future contributors to babeld/ grant MIT/X11 licence to their work. * *.{c,h}: Add GPL headers, in according with the SFLC guidance on dealing with potentially mixed GPL/other licensed work, at: https://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html --- babeld/babel_zebra.c | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 babeld/babel_zebra.c (limited to 'babeld/babel_zebra.c') diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c new file mode 100644 index 00000000..6d78ecc6 --- /dev/null +++ b/babeld/babel_zebra.c @@ -0,0 +1,299 @@ +/* + * This file is free software: you may copy, redistribute and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 2 of the License, or (at your + * option) any later version. + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * +Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* quagga's includes */ +#include +#include "command.h" +#include "zclient.h" +#include "stream.h" + +/* babel's includes*/ +#include "babel_zebra.h" +#include "babel_interface.h" +#include "xroute.h" + +void babelz_zebra_init(void); + + +/* we must use a pointer because of zclient.c's functions (new, free). */ +struct zclient *zclient; +static int zebra_config_write (struct vty *vty); +/* Redistribution types */ +static struct { + int type; + int str_min_len; + const char *str; +} redist_type[] = { + {ZEBRA_ROUTE_KERNEL, 1, "kernel"}, + {ZEBRA_ROUTE_CONNECT, 1, "connected"}, + {ZEBRA_ROUTE_STATIC, 1, "static"}, + {ZEBRA_ROUTE_OSPF6, 1, "ospf6"}, + {ZEBRA_ROUTE_BGP, 1, "bgp"}, + {0, 0, NULL} +}; + +/* Zebra node structure. */ +struct cmd_node zebra_node = +{ + ZEBRA_NODE, + "%s(config-router)# ", + 1 /* vtysh? yes */ +}; + + +/* Zebra route add and delete treatment (ipv6). */ +static int +babel_zebra_read_ipv6 (int command, struct zclient *zclient, + zebra_size_t length) +{ + struct stream *s; + struct zapi_ipv6 api; + unsigned long ifindex = -1; + struct in6_addr nexthop; + struct prefix_ipv6 prefix; + + s = zclient->ibuf; + ifindex = 0; + memset (&nexthop, 0, sizeof (struct in6_addr)); + memset (&api, 0, sizeof(struct zapi_ipv6)); + memset (&prefix, 0, sizeof (struct prefix_ipv6)); + + /* Type, flags, message. */ + api.type = stream_getc (s); + api.flags = stream_getc (s); + api.message = stream_getc (s); + + /* IPv6 prefix. */ + prefix.family = AF_INET6; + prefix.prefixlen = stream_getc (s); + stream_get (&prefix.prefix, s, PSIZE (prefix.prefixlen)); + + /* Nexthop, ifindex, distance, metric. */ + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) { + api.nexthop_num = stream_getc (s); + stream_get (&nexthop, s, sizeof(nexthop)); + } + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX)) { + api.ifindex_num = stream_getc (s); + ifindex = stream_getl (s); + } + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE)) + api.distance = stream_getc (s); + else + api.distance = 0; + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC)) + api.metric = stream_getl (s); + else + api.metric = 0; + + if (command == ZEBRA_IPV6_ROUTE_ADD) + babel_ipv6_route_add(&api, &prefix, ifindex, &nexthop); + else + babel_ipv6_route_delete(&api, &prefix, ifindex); + + return 0; +} + +static int +babel_zebra_read_ipv4 (int command, struct zclient *zclient, + zebra_size_t length) +{ + struct stream *s; + struct zapi_ipv4 api; + unsigned long ifindex = -1; + struct in_addr nexthop; + struct prefix_ipv4 prefix; + + s = zclient->ibuf; + ifindex = 0; + memset (&nexthop, 0, sizeof (struct in_addr)); + memset (&api, 0, sizeof(struct zapi_ipv4)); + memset (&prefix, 0, sizeof (struct prefix_ipv4)); + + /* Type, flags, message. */ + api.type = stream_getc (s); + api.flags = stream_getc (s); + api.message = stream_getc (s); + + /* IPv6 prefix. */ + prefix.family = AF_INET; + prefix.prefixlen = stream_getc (s); + stream_get (&prefix.prefix, s, PSIZE (prefix.prefixlen)); + + /* Nexthop, ifindex, distance, metric. */ + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) { + api.nexthop_num = stream_getc (s); + stream_get (&nexthop, s, sizeof(nexthop)); + } + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX)) { + api.ifindex_num = stream_getc (s); + ifindex = stream_getl (s); + } + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE)) + api.distance = stream_getc (s); + else + api.distance = 0; + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC)) + api.metric = stream_getl (s); + else + api.metric = 0; + + if (command == ZEBRA_IPV6_ROUTE_ADD) { + babel_ipv4_route_add(&api, &prefix, ifindex, &nexthop); + } else { + babel_ipv4_route_delete(&api, &prefix, ifindex); + } + + return 0; +} + +static int +babel_redistribute_unset (int type) +{ + if (! zclient->redist[type]) + return CMD_SUCCESS; + + zclient->redist[type] = 0; + + if (zclient->sock > 0) + zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type); + + /* perhaps should we remove xroutes having the same type... */ + + return CMD_SUCCESS; +} + + +/* [Babel Command] */ +DEFUN (babel_redistribute_type, + babel_redistribute_type_cmd, + "redistribute (kernel|connected|static|ospf6|bgp)", + "Redistribute information from another routing protocol\n" + "Kernel routes\n" + "Connected\n" + "Static routes\n" + "Open Shortest Path First (OSPFv3)\n" + "Border Gateway Protocol (BGP)\n") +{ + int i; + + for(i = 0; redist_type[i].str != NULL; i++) { + if (strncmp (redist_type[i].str, argv[0], + redist_type[i].str_min_len) == 0) { + zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, + redist_type[i].type); + return CMD_SUCCESS; + } + } + + vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + + return CMD_WARNING; +} + +/* [Babel Command] */ +DEFUN (no_babel_redistribute_type, + no_babel_redistribute_type_cmd, + "no redistribute (kernel|connected|static|ospf6|bgp)", + NO_STR + "Redistribute information from another routing protocol\n" + "Kernel routes\n" + "Connected\n" + "Static routes\n" + "Open Shortest Path First (OSPFv3)\n" + "Border Gateway Protocol (BGP)\n") +{ + int i; + + for (i = 0; redist_type[i].str; i++) { + if (strncmp(redist_type[i].str, argv[0], + redist_type[i].str_min_len) == 0) { + return babel_redistribute_unset (redist_type[i].type); + } + } + + vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + + return CMD_WARNING; +} + + +void babelz_zebra_init(void) +{ + zclient = zclient_new(); + zclient_init(zclient, ZEBRA_ROUTE_BABEL); + + zclient->interface_add = babel_interface_add; + zclient->interface_delete = babel_interface_delete; + zclient->interface_up = babel_interface_up; + zclient->interface_down = babel_interface_down; + zclient->interface_address_add = babel_interface_address_add; + zclient->interface_address_delete = babel_interface_address_delete; + zclient->ipv4_route_add = babel_zebra_read_ipv4; + zclient->ipv4_route_delete = babel_zebra_read_ipv4; + zclient->ipv6_route_add = babel_zebra_read_ipv6; + zclient->ipv6_route_delete = babel_zebra_read_ipv6; + + install_node (&zebra_node, zebra_config_write); + install_element(BABEL_NODE, &babel_redistribute_type_cmd); + install_element(BABEL_NODE, &no_babel_redistribute_type_cmd); +} + +static int +zebra_config_write (struct vty *vty) +{ + fprintf(stderr, "\tzebra_config_write\n"); + if (! zclient->enable) + { + vty_out (vty, "no router zebra%s", VTY_NEWLINE); + return 1; + } + else if (! zclient->redist[ZEBRA_ROUTE_BABEL]) + { + vty_out (vty, "router zebra%s", VTY_NEWLINE); + vty_out (vty, " no redistribute babel%s", VTY_NEWLINE); + return 1; + } + return 0; +} + +void +babel_zebra_close_connexion(void) +{ + zclient_stop(zclient); +} -- cgit v1.2.1 From 4eedea551290906fc76f3a0c908ae759e78bb68a Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Tue, 17 Jan 2012 22:46:21 +0100 Subject: babeld: change fprintf(stderr) in term of zlog_err. --- babeld/babel_zebra.c | 1 - 1 file changed, 1 deletion(-) (limited to 'babeld/babel_zebra.c') diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c index 6d78ecc6..7ba1adfe 100644 --- a/babeld/babel_zebra.c +++ b/babeld/babel_zebra.c @@ -277,7 +277,6 @@ void babelz_zebra_init(void) static int zebra_config_write (struct vty *vty) { - fprintf(stderr, "\tzebra_config_write\n"); if (! zclient->enable) { vty_out (vty, "no router zebra%s", VTY_NEWLINE); -- cgit v1.2.1 From f1305cbfbed050ed4f389fa282bef49917ffd638 Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Fri, 20 Jan 2012 00:19:35 +0100 Subject: babeld: add command (config) to set debug flags. --- babeld/babel_zebra.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'babeld/babel_zebra.c') diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c index 7ba1adfe..e68c2b70 100644 --- a/babeld/babel_zebra.c +++ b/babeld/babel_zebra.c @@ -46,6 +46,7 @@ THE SOFTWARE. #include "babel_zebra.h" #include "babel_interface.h" #include "xroute.h" +#include "util.h" void babelz_zebra_init(void); @@ -67,6 +68,22 @@ static struct { {0, 0, NULL} }; +/* Debug types */ +static struct { + int type; + int str_min_len; + const char *str; +} debug_type[] = { + {BABEL_DEBUG_COMMON, 1, "common"}, + {BABEL_DEBUG_KERNEL, 1, "kernel"}, + {BABEL_DEBUG_FILTER, 1, "filter"}, + {BABEL_DEBUG_TIMEOUT, 1, "timeout"}, + {BABEL_DEBUG_IF, 1, "interface"}, + {BABEL_DEBUG_ROUTE, 1, "route"}, + {BABEL_DEBUG_ALL, 1, "all"}, + {0, 0, NULL} +}; + /* Zebra node structure. */ struct cmd_node zebra_node = { @@ -252,6 +269,64 @@ DEFUN (no_babel_redistribute_type, return CMD_WARNING; } +#ifndef NO_DEBUG +/* [Babel Command] */ +DEFUN (babel_debug, + babel_debug_cmd, + "debug (common|kernel|filter|timeout|interface|route|all)", + "Enable debug messages for specific or all part.\n" + "Common messages (default)\n" + "Kernel messages\n" + "Filter messages\n" + "Timeout messages\n" + "Interface messages\n" + "Route messages\n" + "All messages\n") +{ + int i; + + for(i = 0; debug_type[i].str != NULL; i++) { + if (strncmp (debug_type[i].str, argv[0], + debug_type[i].str_min_len) == 0) { + debug |= debug_type[i].type; + return CMD_SUCCESS; + } + } + + vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + + return CMD_WARNING; +} + +/* [Babel Command] */ +DEFUN (no_babel_debug, + no_babel_debug_cmd, + "no debug (common|kernel|filter|timeout|interface|route|all)", + NO_STR + "Disable debug messages for specific or all part.\n" + "Common messages (default)\n" + "Kernel messages\n" + "Filter messages\n" + "Timeout messages\n" + "Interface messages\n" + "Route messages\n" + "All messages\n") +{ + int i; + + for (i = 0; debug_type[i].str; i++) { + if (strncmp(debug_type[i].str, argv[0], + debug_type[i].str_min_len) == 0) { + debug &= ~debug_type[i].type; + } + } + + vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + + return CMD_WARNING; +} +#endif /* NO_DEBUG */ + void babelz_zebra_init(void) { @@ -272,6 +347,8 @@ void babelz_zebra_init(void) install_node (&zebra_node, zebra_config_write); install_element(BABEL_NODE, &babel_redistribute_type_cmd); install_element(BABEL_NODE, &no_babel_redistribute_type_cmd); + install_element(BABEL_NODE, &babel_debug_cmd); + install_element(BABEL_NODE, &no_babel_debug_cmd); } static int -- cgit v1.2.1 From 05c943ac43087750ebc81b916b7dccfe4ae074ff Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Thu, 26 Jan 2012 22:15:34 +0100 Subject: babeld: Replace redistribution strings with route_types.h defines. --- babeld/babel_zebra.c | 74 +++++++++++++++++++--------------------------------- 1 file changed, 27 insertions(+), 47 deletions(-) (limited to 'babeld/babel_zebra.c') diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c index e68c2b70..1890291d 100644 --- a/babeld/babel_zebra.c +++ b/babeld/babel_zebra.c @@ -54,19 +54,6 @@ void babelz_zebra_init(void); /* we must use a pointer because of zclient.c's functions (new, free). */ struct zclient *zclient; static int zebra_config_write (struct vty *vty); -/* Redistribution types */ -static struct { - int type; - int str_min_len; - const char *str; -} redist_type[] = { - {ZEBRA_ROUTE_KERNEL, 1, "kernel"}, - {ZEBRA_ROUTE_CONNECT, 1, "connected"}, - {ZEBRA_ROUTE_STATIC, 1, "static"}, - {ZEBRA_ROUTE_OSPF6, 1, "ospf6"}, - {ZEBRA_ROUTE_BGP, 1, "bgp"}, - {0, 0, NULL} -}; /* Debug types */ static struct { @@ -219,54 +206,47 @@ babel_redistribute_unset (int type) /* [Babel Command] */ DEFUN (babel_redistribute_type, babel_redistribute_type_cmd, - "redistribute (kernel|connected|static|ospf6|bgp)", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Open Shortest Path First (OSPFv3)\n" - "Border Gateway Protocol (BGP)\n") + "redistribute " QUAGGA_REDIST_STR_BABELD, + "Redistribute\n" + QUAGGA_REDIST_HELP_STR_BABELD) { - int i; + int type; - for(i = 0; redist_type[i].str != NULL; i++) { - if (strncmp (redist_type[i].str, argv[0], - redist_type[i].str_min_len) == 0) { - zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, - redist_type[i].type); - return CMD_SUCCESS; - } - } + type = proto_redistnum(AFI_IP6, argv[0]); - vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + if (type < 0) + type = proto_redistnum(AFI_IP, argv[0]); - return CMD_WARNING; + if (type < 0) { + vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type); + return CMD_SUCCESS; } /* [Babel Command] */ DEFUN (no_babel_redistribute_type, no_babel_redistribute_type_cmd, - "no redistribute (kernel|connected|static|ospf6|bgp)", + "no redistribute " QUAGGA_REDIST_STR_BABELD, NO_STR - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Open Shortest Path First (OSPFv3)\n" - "Border Gateway Protocol (BGP)\n") + "Redistribute\n" + QUAGGA_REDIST_HELP_STR_BABELD) { - int i; + int type; - for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], - redist_type[i].str_min_len) == 0) { - return babel_redistribute_unset (redist_type[i].type); - } - } + type = proto_redistnum(AFI_IP6, argv[0]); - vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + if (type < 0) + type = proto_redistnum(AFI_IP, argv[0]); - return CMD_WARNING; + if (type < 0) { + vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + return babel_redistribute_unset (type); } #ifndef NO_DEBUG -- cgit v1.2.1 From a0edef1b74bc9785b2aa1ed292a2777b6a75d40e Mon Sep 17 00:00:00 2001 From: Matthieu Boutier Date: Fri, 27 Jan 2012 22:54:11 +0100 Subject: babeld: "return CMD_SUCCESS" was missing for command 'no debug'. --- babeld/babel_zebra.c | 1 + 1 file changed, 1 insertion(+) (limited to 'babeld/babel_zebra.c') diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c index 1890291d..eced995e 100644 --- a/babeld/babel_zebra.c +++ b/babeld/babel_zebra.c @@ -298,6 +298,7 @@ DEFUN (no_babel_debug, if (strncmp(debug_type[i].str, argv[0], debug_type[i].str_min_len) == 0) { debug &= ~debug_type[i].type; + return CMD_SUCCESS; } } -- cgit v1.2.1 From 359be3d0e4db5c931b1ad0dabbac2dea77394de1 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Sat, 11 Feb 2012 15:25:01 +0400 Subject: babeld: dismiss babel_redistribute_unset() The function was effectively duplicating existing zclient_redistribute(). This makes no_babel_redistribute_type() consistent with babel_redistribute_type() --- babeld/babel_zebra.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'babeld/babel_zebra.c') diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c index eced995e..ed6566f7 100644 --- a/babeld/babel_zebra.c +++ b/babeld/babel_zebra.c @@ -186,23 +186,6 @@ babel_zebra_read_ipv4 (int command, struct zclient *zclient, return 0; } -static int -babel_redistribute_unset (int type) -{ - if (! zclient->redist[type]) - return CMD_SUCCESS; - - zclient->redist[type] = 0; - - if (zclient->sock > 0) - zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type); - - /* perhaps should we remove xroutes having the same type... */ - - return CMD_SUCCESS; -} - - /* [Babel Command] */ DEFUN (babel_redistribute_type, babel_redistribute_type_cmd, @@ -246,7 +229,9 @@ DEFUN (no_babel_redistribute_type, return CMD_WARNING; } - return babel_redistribute_unset (type); + zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type); + /* perhaps should we remove xroutes having the same type... */ + return CMD_SUCCESS; } #ifndef NO_DEBUG -- cgit v1.2.1 From a14ef5eeccc8c76c41830475bbe3c31c9e14faa5 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Sat, 11 Feb 2012 21:06:16 +0400 Subject: babeld: justify "running-config" meaning in CLI The primary focus of this commit is to make "show running-config" command display more current configuration, including some of the bits previously seen in the output of "show babel running-config". Besides that, the following commands were renamed for consistency with the syntax of other components: "debug *" to "debug babel *" (and moved to top level) "show babel running-config" to "show babel parameters" * babel_interface.c * show_babel_running_config(): rename to show_babel_parameters(), update syntax pattern, don't call show_babeld_configuration() * babel_if_init(): update respectively * babel_enable_if_config_write(): new VTY helper for static babel_enable_if * babel_interface.h: add extern declaration * babel_main.c: unset all debug options by default * show_babel_main_configuration(): remove debug options decoder * babel_zebra.c * babel_debug(): rename to debug_babel(), update syntax pattern * no_babel_debug(): rename to no_debug_babel(), update syntax pattern * babelz_zebra_init(): update respectively * debug_babel_config_write() new VTY helper for static debug_type * babel_zebra.h: add extern declaration * babeld.c * babel_config_write(): add the code to output "debug babel *", "router babel", "redistribute *" and "network *" statements * show_babeld_configuration(): dismiss * babeld.h: remove extern declaration * babeld.texi: update for renamed commands * babeld.conf.sample: idem, add debug statements block --- babeld/babel_zebra.c | 53 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'babeld/babel_zebra.c') diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c index ed6566f7..75a1e6a8 100644 --- a/babeld/babel_zebra.c +++ b/babeld/babel_zebra.c @@ -236,10 +236,11 @@ DEFUN (no_babel_redistribute_type, #ifndef NO_DEBUG /* [Babel Command] */ -DEFUN (babel_debug, - babel_debug_cmd, - "debug (common|kernel|filter|timeout|interface|route|all)", +DEFUN (debug_babel, + debug_babel_cmd, + "debug babel (common|kernel|filter|timeout|interface|route|all)", "Enable debug messages for specific or all part.\n" + "Babel information\n" "Common messages (default)\n" "Kernel messages\n" "Filter messages\n" @@ -264,11 +265,12 @@ DEFUN (babel_debug, } /* [Babel Command] */ -DEFUN (no_babel_debug, - no_babel_debug_cmd, - "no debug (common|kernel|filter|timeout|interface|route|all)", +DEFUN (no_debug_babel, + no_debug_babel_cmd, + "no debug babel (common|kernel|filter|timeout|interface|route|all)", NO_STR "Disable debug messages for specific or all part.\n" + "Babel information\n" "Common messages (default)\n" "Kernel messages\n" "Filter messages\n" @@ -293,6 +295,39 @@ DEFUN (no_babel_debug, } #endif /* NO_DEBUG */ +/* Output "debug" statement lines, if necessary. */ +int +debug_babel_config_write (struct vty * vty) +{ +#ifdef NO_DEBUG + return 0; +#else + int i, lines = 0; + + if (debug == BABEL_DEBUG_ALL) + { + vty_out (vty, "debug babel all%s", VTY_NEWLINE); + lines++; + } + else + for (i = 0; debug_type[i].str != NULL; i++) + if + ( + debug_type[i].type != BABEL_DEBUG_ALL + && CHECK_FLAG (debug, debug_type[i].type) + ) + { + vty_out (vty, "debug babel %s%s", debug_type[i].str, VTY_NEWLINE); + lines++; + } + if (lines) + { + vty_out (vty, "!%s", VTY_NEWLINE); + lines++; + } + return lines; +#endif /* NO_DEBUG */ +} void babelz_zebra_init(void) { @@ -313,8 +348,10 @@ void babelz_zebra_init(void) install_node (&zebra_node, zebra_config_write); install_element(BABEL_NODE, &babel_redistribute_type_cmd); install_element(BABEL_NODE, &no_babel_redistribute_type_cmd); - install_element(BABEL_NODE, &babel_debug_cmd); - install_element(BABEL_NODE, &no_babel_debug_cmd); + install_element(ENABLE_NODE, &debug_babel_cmd); + install_element(ENABLE_NODE, &no_debug_babel_cmd); + install_element(CONFIG_NODE, &debug_babel_cmd); + install_element(CONFIG_NODE, &no_debug_babel_cmd); } static int -- cgit v1.2.1