diff options
Diffstat (limited to 'ripd/rip_zebra.c')
| -rw-r--r-- | ripd/rip_zebra.c | 176 |
1 files changed, 66 insertions, 110 deletions
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 44fc1cd8f9..7fa3baea7e 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -263,46 +263,6 @@ static struct { {0, 0, NULL} }; -DEFUN (router_zebra, - router_zebra_cmd, - "router zebra", - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - vty->node = ZEBRA_NODE; - zclient->enable = 1; - zclient_start (zclient); - return CMD_SUCCESS; -} - -DEFUN (no_router_zebra, - no_router_zebra_cmd, - "no router zebra", - NO_STR - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - zclient->enable = 0; - zclient_stop (zclient); - return CMD_SUCCESS; -} - -#if 0 -static int -rip_redistribute_set (int type) -{ - if (vrf_bitmap_check (zclient->redist[AFI_IP][type], VRF_DEFAULT)) - return CMD_SUCCESS; - - vrf_bitmap_set (zclient->redist[AFI_IP][type], VRF_DEFAULT); - - if (zclient->sock > 0) - zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, API_IP, type); - - return CMD_SUCCESS; -} -#endif - static int rip_redistribute_unset (int type) { @@ -379,7 +339,7 @@ DEFUN (rip_redistribute_type, for(i = 0; redist_type[i].str; i++) { - if (strncmp (redist_type[i].str, argv[0], + if (strncmp (redist_type[i].str, argv[2]->arg, redist_type[i].str_min_len) == 0) { zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, @@ -388,7 +348,7 @@ DEFUN (rip_redistribute_type, } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[2]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -405,7 +365,7 @@ DEFUN (no_rip_redistribute_type, for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], + if (strncmp(redist_type[i].str, argv[3]->arg, redist_type[i].str_min_len) == 0) { rip_metric_unset (redist_type[i].type, DONT_CARE_METRIC_RIP); @@ -415,7 +375,7 @@ DEFUN (no_rip_redistribute_type, } } - vty_out(vty, "Invalid type %s%s", argv[0], + vty_out(vty, "Invalid type %s%s", argv[3]->arg, VTY_NEWLINE); return CMD_WARNING; @@ -429,21 +389,21 @@ DEFUN (rip_redistribute_type_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_word = 3; 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) + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) { - rip_routemap_set (redist_type[i].type, argv[1]); + rip_routemap_set (redist_type[i].type, argv[idx_word]->arg); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, redist_type[i].type, 0, VRF_DEFAULT); return CMD_SUCCESS; } } - vty_out(vty, "Invalid type %s%s", argv[0], - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -457,42 +417,42 @@ DEFUN (no_rip_redistribute_type_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 2; + int idx_word = 4; 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) - { - if (rip_routemap_unset (redist_type[i].type,argv[1])) - return CMD_WARNING; - rip_redistribute_unset (redist_type[i].type); - return CMD_SUCCESS; - } - } + for (i = 0; redist_type[i].str; i++) { + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) + { + if (rip_routemap_unset (redist_type[i].type,argv[idx_word]->arg)) + return CMD_WARNING; + rip_redistribute_unset (redist_type[i].type); + return CMD_SUCCESS; + } + } - vty_out(vty, "Invalid type %s%s", argv[0], - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } DEFUN (rip_redistribute_type_metric, rip_redistribute_type_metric_cmd, - "redistribute " FRR_REDIST_STR_RIPD " metric <0-16>", + "redistribute " FRR_REDIST_STR_RIPD " metric (0-16)", REDIST_STR FRR_REDIST_HELP_STR_RIPD "Metric\n" "Metric value\n") { + int idx_protocol = 1; + int idx_number = 3; int i; int metric; - metric = atoi (argv[1]); + metric = atoi (argv[idx_number]->arg); for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], - redist_type[i].str_min_len) == 0) + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) { rip_redistribute_metric_set (redist_type[i].type, metric); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, @@ -501,44 +461,42 @@ DEFUN (rip_redistribute_type_metric, } } - vty_out(vty, "Invalid type %s%s", argv[0], - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } DEFUN (no_rip_redistribute_type_metric, no_rip_redistribute_type_metric_cmd, - "no redistribute " FRR_REDIST_STR_RIPD " metric <0-16>", + "no redistribute " FRR_REDIST_STR_RIPD " metric (0-16)", NO_STR REDIST_STR FRR_REDIST_HELP_STR_RIPD "Metric\n" "Metric value\n") { + int idx_protocol = 2; + int idx_number = 4; 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) - { - if (rip_metric_unset (redist_type[i].type, atoi(argv[1]))) - return CMD_WARNING; - rip_redistribute_unset (redist_type[i].type); - return CMD_SUCCESS; - } - } + for (i = 0; redist_type[i].str; i++) { + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) + { + if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) + return CMD_WARNING; + rip_redistribute_unset (redist_type[i].type); + return CMD_SUCCESS; + } + } - vty_out(vty, "Invalid type %s%s", argv[0], - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } DEFUN (rip_redistribute_type_metric_routemap, rip_redistribute_type_metric_routemap_cmd, - "redistribute " FRR_REDIST_STR_RIPD " metric <0-16> route-map WORD", + "redistribute " FRR_REDIST_STR_RIPD " metric (0-16) route-map WORD", REDIST_STR FRR_REDIST_HELP_STR_RIPD "Metric\n" @@ -546,25 +504,26 @@ DEFUN (rip_redistribute_type_metric_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 1; + int idx_number = 3; + int idx_word = 5; int i; int metric; - metric = atoi (argv[1]); + metric = atoi (argv[idx_number]->arg); for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[0], - redist_type[i].str_min_len) == 0) + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) { rip_redistribute_metric_set (redist_type[i].type, metric); - rip_routemap_set (redist_type[i].type, argv[2]); + rip_routemap_set (redist_type[i].type, argv[idx_word]->arg); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, redist_type[i].type, 0, VRF_DEFAULT); return CMD_SUCCESS; } } - vty_out(vty, "Invalid type %s%s", argv[0], - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -572,8 +531,7 @@ DEFUN (rip_redistribute_type_metric_routemap, DEFUN (no_rip_redistribute_type_metric_routemap, no_rip_redistribute_type_metric_routemap_cmd, - "no redistribute " FRR_REDIST_STR_RIPD - " metric <0-16> route-map WORD", + "no redistribute " FRR_REDIST_STR_RIPD " metric (0-16) route-map WORD", NO_STR REDIST_STR FRR_REDIST_HELP_STR_RIPD @@ -582,27 +540,27 @@ DEFUN (no_rip_redistribute_type_metric_routemap, "Route map reference\n" "Pointer to route-map entries\n") { + int idx_protocol = 2; + int idx_number = 4; + int idx_word = 6; 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) - { - if (rip_metric_unset (redist_type[i].type, atoi(argv[1]))) - return CMD_WARNING; - if (rip_routemap_unset (redist_type[i].type, argv[2])) - { - rip_redistribute_metric_set(redist_type[i].type, atoi(argv[1])); - return CMD_WARNING; - } - rip_redistribute_unset (redist_type[i].type); - return CMD_SUCCESS; - } + for (i = 0; redist_type[i].str; i++) { + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) + { + if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) + return CMD_WARNING; + if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg)) + { + rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg)); + return CMD_WARNING; + } + rip_redistribute_unset (redist_type[i].type); + return CMD_SUCCESS; + } } - vty_out(vty, "Invalid type %s%s", argv[0], - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -744,8 +702,6 @@ rip_zclient_init (struct thread_master *master) install_node (&zebra_node, config_write_zebra); /* Install command elements to zebra node. */ - install_element (CONFIG_NODE, &router_zebra_cmd); - install_element (CONFIG_NODE, &no_router_zebra_cmd); install_default (ZEBRA_NODE); install_element (ZEBRA_NODE, &rip_redistribute_rip_cmd); install_element (ZEBRA_NODE, &no_rip_redistribute_rip_cmd); |
