summaryrefslogtreecommitdiff
path: root/babeld
diff options
context:
space:
mode:
authorMatthieu Boutier <boutier@pps.jussieu.fr>2012-01-26 22:15:34 +0100
committerPaul Jakma <paul@quagga.net>2012-03-25 17:06:53 +0100
commit05c943ac43087750ebc81b916b7dccfe4ae074ff (patch)
tree479fdbb7567e4c01656f9cbf5d19d712e73d2ae4 /babeld
parentc35fafdf887aa32c5be6ad738d3a3b0140cea6e8 (diff)
babeld: Replace redistribution strings with route_types.h defines.
Diffstat (limited to 'babeld')
-rw-r--r--babeld/babel_zebra.c74
1 files changed, 27 insertions, 47 deletions
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