diff options
Diffstat (limited to 'src/plugins/ikev2/ikev2_test.c')
-rw-r--r-- | src/plugins/ikev2/ikev2_test.c | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/src/plugins/ikev2/ikev2_test.c b/src/plugins/ikev2/ikev2_test.c index 222f01ad123..81a222c0971 100644 --- a/src/plugins/ikev2/ikev2_test.c +++ b/src/plugins/ikev2/ikev2_test.c @@ -135,7 +135,7 @@ MACRO_FORMAT (auth_method) s = format (s, " %s", id->data); break; case IKEV2_ID_TYPE_ID_IPV4_ADDR: - s = format (s, " %U", format_ip4_address, id->data); + s = format (s, " %U", format_ip_address, id->data); break; case IKEV2_ID_TYPE_ID_KEY_ID: s = format (s, " 0x%U", format_hex_bytes, id->data, id->data_len); @@ -225,7 +225,6 @@ static void vl_api_ikev2_profile_details_t_handler { vat_main_t *vam = ikev2_test_main.vat_main; vl_api_ikev2_profile_t *p = &mp->profile; - ip4_address_t start_addr, end_addr; fformat (vam->ofp, "profile %s\n", p->name); @@ -256,21 +255,17 @@ static void vl_api_ikev2_profile_details_t_handler format_ikev2_id_type_and_data, &p->rem_id); } - ip4_address_decode (p->loc_ts.start_addr, &start_addr); - ip4_address_decode (p->loc_ts.end_addr, &end_addr); fformat (vam->ofp, " local traffic-selector addr %U - %U port %u - %u" " protocol %u\n", - format_ip4_address, &start_addr, - format_ip4_address, &end_addr, + format_ip_address, &p->loc_ts.start_addr, + format_ip_address, &p->loc_ts.end_addr, clib_net_to_host_u16 (p->loc_ts.start_port), clib_net_to_host_u16 (p->loc_ts.end_port), p->loc_ts.protocol_id); - ip4_address_decode (p->rem_ts.start_addr, &start_addr); - ip4_address_decode (p->rem_ts.end_addr, &end_addr); fformat (vam->ofp, " remote traffic-selector addr %U - %U port %u - %u" " protocol %u\n", - format_ip4_address, &start_addr, - format_ip4_address, &end_addr, + format_ip_address, &p->rem_ts.start_addr, + format_ip_address, &p->rem_ts.end_addr, clib_net_to_host_u16 (p->rem_ts.start_port), clib_net_to_host_u16 (p->rem_ts.end_port), p->rem_ts.protocol_id); u32 tun_itf = clib_net_to_host_u32 (p->tun_itf); @@ -280,7 +275,7 @@ static void vl_api_ikev2_profile_details_t_handler u32 sw_if_index = clib_net_to_host_u32 (p->responder.sw_if_index); if (~0 != sw_if_index) fformat (vam->ofp, " responder idx %d %U\n", - sw_if_index, format_ip4_address, &p->responder.ip4); + sw_if_index, format_ip_address, &p->responder.addr); if (p->udp_encap) fformat (vam->ofp, " udp-encap\n"); @@ -348,18 +343,18 @@ vl_api_ikev2_sa_details_t_handler (vl_api_ikev2_sa_details_t * mp) { vat_main_t *vam = ikev2_test_main.vat_main; vl_api_ikev2_sa_t *sa = &mp->sa; - ip4_address_t iaddr; - ip4_address_t raddr; + ip_address_t iaddr; + ip_address_t raddr; vl_api_ikev2_keys_t *k = &sa->keys; vl_api_ikev2_sa_t_endian (sa); - ip4_address_decode (sa->iaddr, &iaddr); - ip4_address_decode (sa->raddr, &raddr); + ip_address_decode2 (&sa->iaddr, &iaddr); + ip_address_decode2 (&sa->raddr, &raddr); fformat (vam->ofp, "profile index %d sa index: %d\n", mp->sa.profile_index, mp->sa.sa_index); - fformat (vam->ofp, " iip %U ispi %lx rip %U rspi %lx\n", format_ip4_address, - &iaddr, sa->ispi, format_ip4_address, &raddr, sa->rspi); + fformat (vam->ofp, " iip %U ispi %lx rip %U rspi %lx\n", format_ip_address, + &iaddr, sa->ispi, format_ip_address, &raddr, sa->rspi); fformat (vam->ofp, " %U ", format_ikev2_sa_transform, &sa->encryption); fformat (vam->ofp, "%U ", format_ikev2_sa_transform, &sa->prf); fformat (vam->ofp, "%U ", format_ikev2_sa_transform, &sa->integrity); @@ -526,18 +521,17 @@ static void { vat_main_t *vam = ikev2_test_main.vat_main; vl_api_ikev2_ts_t *ts = &mp->ts; - ip4_address_t start_addr; - ip4_address_t end_addr; + ip_address_t start_addr, end_addr; vl_api_ikev2_ts_t_endian (ts); - ip4_address_decode (ts->start_addr, &start_addr); - ip4_address_decode (ts->end_addr, &end_addr); + ip_address_decode2 (&ts->start_addr, &start_addr); + ip_address_decode2 (&ts->end_addr, &end_addr); fformat (vam->ofp, " %s protocol_id %u addr " "%U - %U port %u - %u\n", ts->is_local, ts->protocol_id, - format_ip4_address, &start_addr, - format_ip4_address, &end_addr, ts->start_port, ts->end_port); + format_ip_address, &start_addr, + format_ip_address, &end_addr, ts->start_port, ts->end_port); vam->result_ready = 1; } @@ -797,7 +791,7 @@ api_ikev2_profile_set_id (vat_main_t * vam) u8 *data = 0; u8 is_local = 0; u32 id_type = 0; - ip4_address_t ip4; + ip_address_t ip; int ret; const char *valid_chars = "a-zA-Z0-9_"; @@ -808,10 +802,10 @@ api_ikev2_profile_set_id (vat_main_t * vam) vec_add1 (name, 0); else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type)) ; - else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4)) + else if (unformat (i, "id_data %U", unformat_ip_address, &ip)) { - data = vec_new (u8, 4); - clib_memcpy (data, ip4.as_u8, 4); + data = vec_new (u8, ip_address_size (&ip)); + clib_memcpy (data, ip_addr_bytes (&ip), ip_address_size (&ip)); } else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data)) ; @@ -875,14 +869,12 @@ api_ikev2_profile_set_ts (vat_main_t * vam) u8 *name = 0; u8 is_local = 0; u32 proto = 0, start_port = 0, end_port = (u32) ~ 0; - ip4_address_t start_addr, end_addr; + ip_address_t start_addr, end_addr; + u8 start_addr_set = 0, end_addr_set = 0; const char *valid_chars = "a-zA-Z0-9_"; int ret; - start_addr.as_u32 = 0; - end_addr.as_u32 = (u32) ~ 0; - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { if (unformat (i, "name %U", unformat_token, valid_chars, &name)) @@ -894,10 +886,10 @@ api_ikev2_profile_set_ts (vat_main_t * vam) else if (unformat (i, "end_port %d", &end_port)) ; else - if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr)) - ; - else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr)) - ; + if (unformat (i, "start_addr %U", unformat_ip_address, &start_addr)) + start_addr_set = 1; + else if (unformat (i, "end_addr %U", unformat_ip_address, &end_addr)) + end_addr_set = 1; else if (unformat (i, "local")) is_local = 1; else if (unformat (i, "remote")) @@ -909,6 +901,12 @@ api_ikev2_profile_set_ts (vat_main_t * vam) } } + if (!start_addr_set || !end_addr_set) + { + errmsg ("missing start or end address"); + return -99; + } + if (!vec_len (name)) { errmsg ("profile name must be specified"); @@ -927,8 +925,8 @@ api_ikev2_profile_set_ts (vat_main_t * vam) mp->ts.protocol_id = (u8) proto; mp->ts.start_port = clib_host_to_net_u16 ((u16) start_port); mp->ts.end_port = clib_host_to_net_u16 ((u16) end_port); - ip4_address_encode (&start_addr, mp->ts.start_addr); - ip4_address_encode (&end_addr, mp->ts.end_addr); + ip_address_encode2 (&start_addr, &mp->ts.start_addr); + ip_address_encode2 (&end_addr, &mp->ts.end_addr); clib_memcpy (mp->name, name, vec_len (name)); vec_free (name); @@ -1035,7 +1033,7 @@ api_ikev2_set_responder (vat_main_t * vam) int ret; u8 *name = 0; u32 sw_if_index = ~0; - ip4_address_t address; + ip_address_t address; const char *valid_chars = "a-zA-Z0-9_"; @@ -1043,7 +1041,7 @@ api_ikev2_set_responder (vat_main_t * vam) { if (unformat (i, "%U interface %d address %U", unformat_token, valid_chars, - &name, &sw_if_index, unformat_ip4_address, &address)) + &name, &sw_if_index, unformat_ip_address, &address)) vec_add1 (name, 0); else { @@ -1070,7 +1068,7 @@ api_ikev2_set_responder (vat_main_t * vam) vec_free (name); mp->responder.sw_if_index = clib_host_to_net_u32 (sw_if_index); - ip4_address_encode (&address, mp->responder.ip4); + ip_address_encode2 (&address, &mp->responder.addr); S (mp); W (ret); |