diff options
author | Pavel Kotucek <pkotucek@cisco.com> | 2017-08-16 15:45:37 +0200 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2017-08-18 12:34:43 +0000 |
commit | f77e913549bbe08c09431e2f7d4bea61e4027fea (patch) | |
tree | b6c4b89f1ffa75b6847f4f2e7ccc6983aaf1f5ed /src/plugins/acl | |
parent | 71bb05454c97cc18e3c95127b54385c52e4c57c2 (diff) |
Fix small issues in ACL api
Enable IP address without prefix length, if not given use max (32/128)
Parse correctly type of acl (ipv4).
Change-Id: I3d5d6b45037c9e0f95d2d112ae584f006c6cb4d1
Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
Diffstat (limited to 'src/plugins/acl')
-rw-r--r-- | src/plugins/acl/acl_test.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 704906a9..2b517585 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -886,7 +886,7 @@ static int api_macip_acl_add (vat_main_t * vam) else if (unformat (i, "ipv4")) { vec_validate_macip_acl_rules(rules, rule_idx); - rules[rule_idx].is_ipv6 = 1; + rules[rule_idx].is_ipv6 = 0; } else if (unformat (i, "permit")) { @@ -908,8 +908,12 @@ static int api_macip_acl_add (vat_main_t * vam) rules[rule_idx].is_permit = action; } else if (unformat (i, "ip %U/%d", - unformat_ip4_address, &src_v4address, &src_prefix_length)) + unformat_ip4_address, &src_v4address, &src_prefix_length) || + unformat (i, "ip %U", + unformat_ip4_address, &src_v4address)) { + if (src_prefix_length == 0) + src_prefix_length = 32; vec_validate_macip_acl_rules(rules, rule_idx); memcpy (rules[rule_idx].src_ip_addr, &src_v4address, 4); rules[rule_idx].src_ip_prefix_len = src_prefix_length; @@ -920,8 +924,12 @@ static int api_macip_acl_add (vat_main_t * vam) /* Everything in MACIP is "source" but allow this verbosity */ } else if (unformat (i, "ip %U/%d", - unformat_ip6_address, &src_v6address, &src_prefix_length)) + unformat_ip6_address, &src_v6address, &src_prefix_length) || + unformat (i, "ip %U", + unformat_ip6_address, &src_v6address)) { + if (src_prefix_length == 0) + src_prefix_length = 128; vec_validate_macip_acl_rules(rules, rule_idx); memcpy (rules[rule_idx].src_ip_addr, &src_v6address, 16); rules[rule_idx].src_ip_prefix_len = src_prefix_length; |