aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2020-12-14 17:32:01 +0100
committerDamjan Marion <dmarion@me.com>2020-12-14 21:51:06 +0000
commit1474ab355f3f22eefcbc0d66d493557fd15d3dfc (patch)
tree8aa6c4784e347233f02dd901fce43b7df6129512
parent506aa3c93c26c41a343d19d13c4b9c3810ab489e (diff)
ikev2: fix show ikev2 profile
format_ip_address() to display {local,remote}_id does not work because we do not store ip_address_t but ip{4,6}_address_t, hence we lack the ip_address_family_t version field. Update format_ikev2_id_type_and_data() to support all types and use it instead. Type: fix Change-Id: I7a81beb0b22fcf1c5d1bf03a32a6cc4f030f4361 Signed-off-by: Benoît Ganne <bganne@cisco.com>
-rw-r--r--src/plugins/ikev2/ikev2_cli.c56
1 files changed, 18 insertions, 38 deletions
diff --git a/src/plugins/ikev2/ikev2_cli.c b/src/plugins/ikev2/ikev2_cli.c
index 1bb2dd91a88..efd0a209ebc 100644
--- a/src/plugins/ikev2/ikev2_cli.c
+++ b/src/plugins/ikev2/ikev2_cli.c
@@ -27,18 +27,24 @@ format_ikev2_id_type_and_data (u8 * s, va_list * args)
if (id->type == 0 || vec_len (id->data) == 0)
return format (s, "none");
- s = format (s, "%U", format_ikev2_id_type, id->type);
+ s = format (s, "id-type %U data ", format_ikev2_id_type, id->type);
- if (id->type == IKEV2_ID_TYPE_ID_FQDN ||
- id->type == IKEV2_ID_TYPE_ID_RFC822_ADDR)
+ switch (id->type)
{
- s = format (s, " %v", id->data);
- }
- else
- {
- s =
- format (s, " %U", format_hex_bytes, &id->data,
- (uword) (vec_len (id->data)));
+ case IKEV2_ID_TYPE_ID_IPV4_ADDR:
+ s = format (s, "%U", format_ip4_address, id->data);
+ break;
+ case IKEV2_ID_TYPE_ID_IPV6_ADDR:
+ s = format (s, "%U", format_ip6_address, id->data);
+ break;
+ case IKEV2_ID_TYPE_ID_FQDN: /* fallthrough */
+ case IKEV2_ID_TYPE_ID_RFC822_ADDR:
+ s = format (s, "%v", id->data);
+ break;
+ default:
+ s = format (s, "0x%U", format_hex_bytes, &id->data,
+ (uword) (vec_len (id->data)));
+ break;
}
return s;
@@ -577,36 +583,10 @@ show_ikev2_profile_command_fn (vlib_main_t * vm,
}
if (p->loc_id.data)
- {
- if (p->loc_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
- vlib_cli_output(vm, " local id-type %U data %U",
- format_ikev2_id_type, p->loc_id.type,
- format_ip_address, p->loc_id.data);
- else if (p->loc_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
- vlib_cli_output(vm, " local id-type %U data 0x%U",
- format_ikev2_id_type, p->loc_id.type,
- format_hex_bytes, p->loc_id.data,
- vec_len(p->loc_id.data));
- else
- vlib_cli_output(vm, " local id-type %U data %v",
- format_ikev2_id_type, p->loc_id.type, p->loc_id.data);
- }
+ vlib_cli_output(vm, " local %U", format_ikev2_id_type_and_data, &p->loc_id);
if (p->rem_id.data)
- {
- if (p->rem_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
- vlib_cli_output(vm, " remote id-type %U data %U",
- format_ikev2_id_type, p->rem_id.type,
- format_ip_address, p->rem_id.data);
- else if (p->rem_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
- vlib_cli_output(vm, " remote id-type %U data 0x%U",
- format_ikev2_id_type, p->rem_id.type,
- format_hex_bytes, p->rem_id.data,
- vec_len(p->rem_id.data));
- else
- vlib_cli_output(vm, " remote id-type %U data %v",
- format_ikev2_id_type, p->rem_id.type, p->rem_id.data);
- }
+ vlib_cli_output(vm, " remote %U", format_ikev2_id_type_and_data, &p->rem_id);
if (!ip_address_is_zero (&p->loc_ts.start_addr))
vlib_cli_output(vm, " local traffic-selector addr %U - %U port %u - %u"