ripngd: Replace redistribution strings with route_types.h defines.

This commit is contained in:
Matthieu Boutier 2012-02-09 20:58:07 +01:00 committed by Paul Jakma
parent d70ab9dcd8
commit 93079db65c

View File

@ -217,7 +217,8 @@ static struct {
{ZEBRA_ROUTE_CONNECT, 1, "connected"}, {ZEBRA_ROUTE_CONNECT, 1, "connected"},
{ZEBRA_ROUTE_STATIC, 1, "static"}, {ZEBRA_ROUTE_STATIC, 1, "static"},
{ZEBRA_ROUTE_OSPF6, 1, "ospf6"}, {ZEBRA_ROUTE_OSPF6, 1, "ospf6"},
{ZEBRA_ROUTE_BGP, 1, "bgp"}, {ZEBRA_ROUTE_BGP, 2, "bgp"},
{ZEBRA_ROUTE_BABEL, 2, "babel"},
{0, 0, NULL} {0, 0, NULL}
}; };
@ -289,198 +290,147 @@ DEFUN (no_ripng_redistribute_ripng,
DEFUN (ripng_redistribute_type, DEFUN (ripng_redistribute_type,
ripng_redistribute_type_cmd, ripng_redistribute_type_cmd,
"redistribute (kernel|connected|static|ospf6|bgp)", "redistribute " QUAGGA_REDIST_STR_RIPNGD,
"Redistribute information from another routing protocol\n" "Redistribute\n"
"Kernel routes\n" QUAGGA_REDIST_HELP_STR_RIPNGD)
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPFv3)\n"
"Border Gateway Protocol (BGP)\n")
{ {
int i; int type;
for(i = 0; redist_type[i].str; i++) type = proto_redistnum(AFI_IP6, argv[0]);
if (type < 0)
{ {
if (strncmp (redist_type[i].str, argv[0], vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
redist_type[i].str_min_len) == 0) return CMD_WARNING;
{
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
return CMD_SUCCESS;
}
} }
vty_out(vty, "Invalid type %s%s", argv[0], zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
VTY_NEWLINE); return CMD_SUCCESS;
return CMD_WARNING;
} }
DEFUN (no_ripng_redistribute_type, DEFUN (no_ripng_redistribute_type,
no_ripng_redistribute_type_cmd, no_ripng_redistribute_type_cmd,
"no redistribute (kernel|connected|static|ospf6|bgp)", "no redistribute " QUAGGA_REDIST_STR_RIPNGD,
NO_STR NO_STR
"Redistribute information from another routing protocol\n" "Redistribute\n"
"Kernel routes\n" QUAGGA_REDIST_HELP_STR_RIPNGD)
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPFv3)\n"
"Border Gateway Protocol (BGP)\n")
{ {
int i; int type;
for (i = 0; redist_type[i].str; i++) type = proto_redistnum(AFI_IP6, argv[0]);
if (type < 0)
{ {
if (strncmp(redist_type[i].str, argv[0], vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
redist_type[i].str_min_len) == 0) return CMD_WARNING;
{
ripng_redistribute_metric_unset (redist_type[i].type);
ripng_redistribute_routemap_unset (redist_type[i].type);
return ripng_redistribute_unset (redist_type[i].type);
}
} }
vty_out(vty, "Invalid type %s%s", argv[0], ripng_redistribute_metric_unset (type);
VTY_NEWLINE); ripng_redistribute_routemap_unset (type);
return ripng_redistribute_unset (type);
return CMD_WARNING;
} }
DEFUN (ripng_redistribute_type_metric, DEFUN (ripng_redistribute_type_metric,
ripng_redistribute_type_metric_cmd, ripng_redistribute_type_metric_cmd,
"redistribute (kernel|connected|static|ospf6|bgp) metric <0-16>", "redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16>",
"Redistribute information from another routing protocol\n" "Redistribute\n"
"Kernel routes\n" QUAGGA_REDIST_HELP_STR_RIPNGD
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPFv3)\n"
"Border Gateway Protocol (BGP)\n"
"Metric\n" "Metric\n"
"Metric value\n") "Metric value\n")
{ {
int i; int type;
int metric; int metric;
metric = atoi (argv[1]); metric = atoi (argv[1]);
type = proto_redistnum(AFI_IP6, argv[0]);
for (i = 0; redist_type[i].str; i++) { if (type < 0)
if (strncmp(redist_type[i].str, argv[0], {
redist_type[i].str_min_len) == 0) vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
{ return CMD_WARNING;
ripng_redistribute_metric_set (redist_type[i].type, metric); }
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0], ripng_redistribute_metric_set (type, metric);
VTY_NEWLINE); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
return CMD_SUCCESS;
return CMD_WARNING;
} }
ALIAS (no_ripng_redistribute_type, ALIAS (no_ripng_redistribute_type,
no_ripng_redistribute_type_metric_cmd, no_ripng_redistribute_type_metric_cmd,
"no redistribute (kernel|connected|static|ospf6|bgp) metric <0-16>", "no redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16>",
NO_STR NO_STR
"Redistribute information from another routing protocol\n" "Redistribute\n"
"Kernel routes\n" QUAGGA_REDIST_HELP_STR_RIPNGD
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPFv3)\n"
"Border Gateway Protocol (BGP)\n"
"Metric\n" "Metric\n"
"Metric value\n") "Metric value\n")
DEFUN (ripng_redistribute_type_routemap, DEFUN (ripng_redistribute_type_routemap,
ripng_redistribute_type_routemap_cmd, ripng_redistribute_type_routemap_cmd,
"redistribute (kernel|connected|static|ospf6|bgp) route-map WORD", "redistribute " QUAGGA_REDIST_STR_RIPNGD " route-map WORD",
"Redistribute information from another routing protocol\n" "Redistribute\n"
"Kernel routes\n" QUAGGA_REDIST_HELP_STR_RIPNGD
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPFv3)\n"
"Border Gateway Protocol (BGP)\n"
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int i; int type;
for (i = 0; redist_type[i].str; i++) { type = proto_redistnum(AFI_IP6, argv[0]);
if (strncmp(redist_type[i].str, argv[0],
redist_type[i].str_min_len) == 0)
{
ripng_redistribute_routemap_set (redist_type[i].type, argv[1]);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0], if (type < 0)
VTY_NEWLINE); {
vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_WARNING; ripng_redistribute_routemap_set (type, argv[1]);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
return CMD_SUCCESS;
} }
ALIAS (no_ripng_redistribute_type, ALIAS (no_ripng_redistribute_type,
no_ripng_redistribute_type_routemap_cmd, no_ripng_redistribute_type_routemap_cmd,
"no redistribute (kernel|connected|static|ospf6|bgp) route-map WORD", "no redistribute " QUAGGA_REDIST_STR_RIPNGD " route-map WORD",
NO_STR NO_STR
"Redistribute information from another routing protocol\n" "Redistribute\n"
"Kernel routes\n" QUAGGA_REDIST_HELP_STR_RIPNGD
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPFv3)\n"
"Border Gateway Protocol (BGP)\n"
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
DEFUN (ripng_redistribute_type_metric_routemap, DEFUN (ripng_redistribute_type_metric_routemap,
ripng_redistribute_type_metric_routemap_cmd, ripng_redistribute_type_metric_routemap_cmd,
"redistribute (kernel|connected|static|ospf6|bgp) metric <0-16> route-map WORD", "redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16> route-map WORD",
"Redistribute information from another routing protocol\n" "Redistribute\n"
"Kernel routes\n" QUAGGA_REDIST_HELP_STR_RIPNGD
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPFv3)\n"
"Border Gateway Protocol (BGP)\n"
"Metric\n" "Metric\n"
"Metric value\n" "Metric value\n"
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")
{ {
int i; int type;
int metric; int metric;
type = proto_redistnum(AFI_IP6, argv[0]);
metric = atoi (argv[1]); metric = atoi (argv[1]);
for (i = 0; redist_type[i].str; i++) { if (type < 0)
if (strncmp(redist_type[i].str, argv[0], {
redist_type[i].str_min_len) == 0) vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
{ return CMD_WARNING;
ripng_redistribute_metric_set (redist_type[i].type, metric); }
ripng_redistribute_routemap_set (redist_type[i].type, argv[2]);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0], ripng_redistribute_metric_set (type, metric);
VTY_NEWLINE); ripng_redistribute_routemap_set (type, argv[2]);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
return CMD_WARNING; return CMD_SUCCESS;
} }
ALIAS (no_ripng_redistribute_type, ALIAS (no_ripng_redistribute_type,
no_ripng_redistribute_type_metric_routemap_cmd, no_ripng_redistribute_type_metric_routemap_cmd,
"no redistribute (kernel|connected|static|ospf6|bgp) metric <0-16> route-map WORD", "no redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16> route-map WORD",
NO_STR NO_STR
"Redistribute information from another routing protocol\n" "Redistribute\n"
"Kernel routes\n" QUAGGA_REDIST_HELP_STR_RIPNGD
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPFv3)\n"
"Border Gateway Protocol (BGP)\n"
"Route map reference\n" "Route map reference\n"
"Pointer to route-map entries\n") "Pointer to route-map entries\n")