summaryrefslogtreecommitdiffstats
path: root/isisd
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2016-09-30 01:24:52 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2016-09-30 01:24:52 +0200
commitd8bd2affd3ccc2ab05c71af19beae39cb9c4ce9f (patch)
tree54faed23c238ee38d186a60a4005b1a5f7ac4d40 /isisd
parentall: scrubbed some argc CHECK MEs (diff)
downloadfrr-d8bd2affd3ccc2ab05c71af19beae39cb9c4ce9f.tar.xz
frr-d8bd2affd3ccc2ab05c71af19beae39cb9c4ce9f.zip
isisd: scrub argc CHECK ME's, refactor general
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'isisd')
-rw-r--r--isisd/isis_redist.c60
-rw-r--r--isisd/isis_routemap.c10
-rw-r--r--isisd/isis_vty.c38
3 files changed, 57 insertions, 51 deletions
diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c
index 7cd3027f1..e330a1017 100644
--- a/isisd/isis_redist.c
+++ b/isisd/isis_redist.c
@@ -635,16 +635,11 @@ DEFUN (no_isis_redistribute,
if (!afi)
return CMD_WARNING;
- type = proto_redistnum(afi, argv[idx_protocol]->arg);
+ type = proto_redistnum(afi, argv[idx_protocol]->text);
if (type < 0 || type == ZEBRA_ROUTE_ISIS)
return CMD_WARNING;
- if (!strcmp("level-1", argv[idx_level]->arg))
- level = 1;
- else if (!strcmp("level-2", argv[idx_level]->arg))
- level = 2;
- else
- return CMD_WARNING;
+ level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2;
isis_redist_unset(area, level, family, type);
return 0;
@@ -652,7 +647,7 @@ DEFUN (no_isis_redistribute,
DEFUN (isis_default_originate,
isis_default_originate_cmd,
- "default-information originate <ipv4|ipv6> <level-1|level-2> [always|metric (0-16777215)|route-map WORD]",
+ "default-information originate <ipv4|ipv6> <level-1|level-2> [<always|metric (0-16777215)|route-map WORD>]",
"Control distribution of default information\n"
"Distribute a default route\n"
"Distribute default route for IPv4\n"
@@ -670,21 +665,16 @@ DEFUN (isis_default_originate,
int idx_metric_rmap = 4;
struct isis_area *area = vty->index;
int family;
- int originate_type;
+ int originate_type = DEFAULT_ORIGINATE;
int level;
- unsigned long metric;
- const char *routemap;
+ unsigned long metric = 0xffffffff;
+ const char *routemap = NULL;
- family = str2family(argv[idx_afi]->arg);
+ family = str2family(argv[idx_afi]->text);
if (family < 0)
return CMD_WARNING;
- if (!strcmp("level-1", argv[idx_level]->arg))
- level = 1;
- else if (!strcmp("level-2", argv[idx_level]->arg))
- level = 2;
- else
- return CMD_WARNING;
+ level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2;
if ((area->is_type & level) != level)
{
@@ -692,10 +682,15 @@ DEFUN (isis_default_originate,
return CMD_WARNING;
}
- if (argv[idx_metric_rmap]->arg && *argv[idx_metric_rmap]->arg != '\0')
- originate_type = DEFAULT_ORIGINATE_ALWAYS;
- else
- originate_type = DEFAULT_ORIGINATE;
+ if (argc > 4)
+ {
+ if (strmatch (argv[idx_metric_rmap]->text, "always"))
+ originate_type = DEFAULT_ORIGINATE_ALWAYS;
+ else if (strmatch(argv[idx_metric_rmap]->text, "metric"))
+ metric = strtoul(argv[idx_metric_rmap + 1]->arg, NULL, 10);
+ else
+ routemap = argv[idx_metric_rmap + 1]->arg;
+ }
if (family == AF_INET6 && originate_type != DEFAULT_ORIGINATE_ALWAYS)
{
@@ -703,21 +698,6 @@ DEFUN (isis_default_originate,
vty_out(vty, "so use with care or use default-originate always.%s", VTY_NEWLINE);
}
- if (strmatch(argv[idx_metric_rmap]->text, "metric"))
- {
- char *endp;
- metric = strtoul(argv[idx_metric_rmap + 1]->arg, &endp, 10);
- routemap = NULL;
-
- if (argv[idx_metric_rmap]->arg[0] == '\0' || *endp != '\0')
- return CMD_WARNING;
- }
- else
- {
- routemap = argv[idx_metric_rmap + 1]->arg;
- metric = 0xffffffff;
- }
-
isis_redist_set(area, level, family, DEFAULT_ROUTE, metric, routemap, originate_type);
return 0;
}
@@ -740,13 +720,13 @@ DEFUN (no_isis_default_originate,
int family;
int level;
- family = str2family(argv[idx_afi]->arg);
+ family = str2family(argv[idx_afi]->text);
if (family < 0)
return CMD_WARNING;
- if (!strcmp("level-1", argv[idx_level]->arg))
+ if (strmatch ("level-1", argv[idx_level]->text))
level = 1;
- else if (!strcmp("level-2", argv[idx_level]->arg))
+ else if (strmatch ("level-2", argv[idx_level]->text))
level = 2;
else
return CMD_WARNING;
diff --git a/isisd/isis_routemap.c b/isisd/isis_routemap.c
index a1f087548..72caa5a09 100644
--- a/isisd/isis_routemap.c
+++ b/isisd/isis_routemap.c
@@ -371,7 +371,7 @@ DEFUN (no_match_ip_address,
"IP Access-list name\n")
{
int idx_acl = 4;
- if (argc <= idx_acl)
+ if (argc == 4)
return isis_route_match_delete(vty, vty->index, "ip address", NULL);
return isis_route_match_delete(vty, vty->index, "ip address", argv[idx_acl]->arg);
}
@@ -404,7 +404,7 @@ DEFUN (no_match_ip_address_prefix_list,
"IP prefix-list name\n")
{
int idx_word = 5;
- if (argc <= idx_word)
+ if (argc == 5)
return isis_route_match_delete (vty, vty->index, "ip address prefix-list", NULL);
return isis_route_match_delete (vty, vty->index, "ip address prefix-list", argv[idx_word]->arg);
}
@@ -435,7 +435,7 @@ DEFUN (no_match_ipv6_address,
"IPv6 access-list name\n")
{
int idx_word = 4;
- if (argc <= idx_word)
+ if (argc == 4)
return isis_route_match_delete(vty, vty->index, "ipv6 address", NULL);
return isis_route_match_delete(vty, vty->index, "ipv6 address", argv[idx_word]->arg);
}
@@ -467,7 +467,7 @@ DEFUN (no_match_ipv6_address_prefix_list,
"IP prefix-list name\n")
{
int idx_word = 5;
- if (argc <= idx_word)
+ if (argc == 5)
return isis_route_match_delete (vty, vty->index, "ipv6 address prefix-list", NULL);
return isis_route_match_delete (vty, vty->index, "ipv6 address prefix-list", argv[idx_word]->arg);
}
@@ -498,7 +498,7 @@ DEFUN (no_set_metric,
"Metric value\n")
{
int idx_number = 3;
- if (argc <= idx_number)
+ if (argc == 3)
return isis_route_set_delete(vty, vty->index, "metric", NULL);
return isis_route_set_delete(vty, vty->index, "metric", argv[idx_number]->arg);
}
diff --git a/isisd/isis_vty.c b/isisd/isis_vty.c
index a1970a901..93c547260 100644
--- a/isisd/isis_vty.c
+++ b/isisd/isis_vty.c
@@ -2057,9 +2057,8 @@ area_passwd_set(struct vty *vty, int level,
DEFUN (area_passwd_md5,
area_passwd_md5_cmd,
- "<area-password|domain-password> md5 WORD [authenticate snp <send-only|validate>]",
+ "area-password md5 WORD [authenticate snp <send-only|validate>]",
"Configure the authentication password for an area\n"
- "Set the authentication password for a routing domain\n"
"Authentication type\n"
"Level-wide password\n"
"Authentication\n"
@@ -2084,12 +2083,24 @@ DEFUN (area_passwd_md5,
argv[idx_word]->arg, snp_auth);
}
+DEFUN (domain_passwd_md5,
+ domain_passwd_md5_cmd,
+ "domain-password md5 WORD [authenticate snp <send-only|validate>]",
+ "Set the authentication password for a routing domain\n"
+ "Authentication type\n"
+ "Level-wide password\n"
+ "Authentication\n"
+ "SNP PDUs\n"
+ "Send but do not check PDUs on receiving\n"
+ "Send and check PDUs on receiving\n")
+{
+ return area_passwd_md5 (self, vty, argc, argv);
+}
DEFUN (area_passwd_clear,
area_passwd_clear_cmd,
- "<area-password|domain-password> clear WORD [authenticate snp <send-only|validate>]",
+ "area-password clear WORD [authenticate snp <send-only|validate>]",
"Configure the authentication password for an area\n"
- "Set the authentication password for a routing domain\n"
"Authentication type\n"
"Area password\n"
"Authentication\n"
@@ -2106,7 +2117,7 @@ DEFUN (area_passwd_clear,
if (argc > 3)
{
snp_auth = SNP_AUTH_SEND;
- if (strmatch(argv[idx_type]->arg, "validate"))
+ if (strmatch (argv[idx_type]->text, "validate"))
snp_auth |= SNP_AUTH_RECV;
}
@@ -2114,6 +2125,19 @@ DEFUN (area_passwd_clear,
argv[idx_word]->arg, snp_auth);
}
+DEFUN (domain_passwd_clear,
+ domain_passwd_clear_cmd,
+ "domain-password clear WORD [authenticate snp <send-only|validate>]",
+ "Set the authentication password for a routing domain\n"
+ "Authentication type\n"
+ "Area password\n"
+ "Authentication\n"
+ "SNP PDUs\n"
+ "Send but do not check PDUs on receiving\n"
+ "Send and check PDUs on receiving\n")
+{
+ return area_passwd_clear (self, vty, argc, argv);
+}
DEFUN (no_area_passwd,
no_area_passwd_cmd,
@@ -2123,7 +2147,7 @@ DEFUN (no_area_passwd,
"Set the authentication password for a routing domain\n")
{
int idx_password = 1;
- int level = (argv[idx_password]->arg[0] == 'd') ? IS_LEVEL_2 : IS_LEVEL_1;
+ int level = strmatch (argv[idx_password]->text, "domain-password") ? IS_LEVEL_2 : IS_LEVEL_1;
struct isis_area *area = vty->index;
if (!area)
@@ -2246,5 +2270,7 @@ isis_vty_init (void)
install_element (ISIS_NODE, &area_passwd_md5_cmd);
install_element (ISIS_NODE, &area_passwd_clear_cmd);
+ install_element (ISIS_NODE, &domain_passwd_md5_cmd);
+ install_element (ISIS_NODE, &domain_passwd_clear_cmd);
install_element (ISIS_NODE, &no_area_passwd_cmd);
}