34 if (id->
type == IKEV2_ID_TYPE_ID_FQDN ||
35 id->
type == IKEV2_ID_TYPE_ID_RFC822_ADDR)
66 vlib_cli_output(vm,
" iip %U ispi %lx rip %U rspi %lx",
67 format_ip4_address, &sa->iaddr, sa->ispi,
68 format_ip4_address, &sa->raddr, sa->rspi);
70 tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_ENCR);
71 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
73 tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_PRF);
74 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
76 tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_INTEG);
77 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
79 tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_DH);
80 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
82 vlib_cli_output(vm,
" %v", s);
85 vlib_cli_output(vm,
" nonce i:%U\n r:%U",
86 format_hex_bytes, sa->i_nonce, vec_len(sa->i_nonce),
87 format_hex_bytes, sa->r_nonce, vec_len(sa->r_nonce));
89 vlib_cli_output(vm,
" SK_d %U",
90 format_hex_bytes, sa->sk_d, vec_len(sa->sk_d));
91 vlib_cli_output(vm,
" SK_a i:%U\n r:%U",
92 format_hex_bytes, sa->sk_ai, vec_len(sa->sk_ai),
93 format_hex_bytes, sa->sk_ar, vec_len(sa->sk_ar));
94 vlib_cli_output(vm,
" SK_e i:%U\n r:%U",
95 format_hex_bytes, sa->sk_ei, vec_len(sa->sk_ei),
96 format_hex_bytes, sa->sk_er, vec_len(sa->sk_er));
97 vlib_cli_output(vm,
" SK_p i:%U\n r:%U",
98 format_hex_bytes, sa->sk_pi, vec_len(sa->sk_pi),
99 format_hex_bytes, sa->sk_pr, vec_len(sa->sk_pr));
101 vlib_cli_output(vm,
" identifier (i) %U",
102 format_ikev2_id_type_and_data, &sa->i_id);
103 vlib_cli_output(vm,
" identifier (r) %U",
104 format_ikev2_id_type_and_data, &sa->r_id);
106 vec_foreach(child, sa->childs)
108 vlib_cli_output(vm,
" child sa %u:", child - sa->childs);
110 tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_ENCR);
111 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
113 tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_INTEG);
114 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
116 tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_ESN);
117 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
119 vlib_cli_output(vm,
" %v", s);
122 vlib_cli_output(vm,
" spi(i) %lx spi(r) %lx",
123 child->i_proposals ? child->i_proposals[0].spi : 0,
124 child->r_proposals ? child->r_proposals[0].spi : 0);
126 vlib_cli_output(vm,
" SK_e i:%U\n r:%U",
127 format_hex_bytes, child->sk_ei, vec_len(child->sk_ei),
128 format_hex_bytes, child->sk_er, vec_len(child->sk_er));
131 vlib_cli_output(vm,
" SK_a i:%U\n r:%U",
132 format_hex_bytes, child->sk_ai, vec_len(child->sk_ai),
133 format_hex_bytes, child->sk_ar, vec_len(child->sk_ar));
134 vlib_cli_output(vm,
" traffic selectors (i):");
136 vec_foreach(ts, child->tsi)
138 vlib_cli_output(vm,
" %u type %u protocol_id %u addr " 139 "%U - %U port %u - %u",
141 ts->ts_type, ts->protocol_id,
142 format_ip4_address, &ts->start_addr,
143 format_ip4_address, &ts->end_addr,
144 clib_net_to_host_u16( ts->start_port),
145 clib_net_to_host_u16( ts->end_port));
147 vlib_cli_output(vm,
" traffic selectors (r):");
148 vec_foreach(ts, child->tsr)
150 vlib_cli_output(vm,
" %u type %u protocol_id %u addr " 151 "%U - %U port %u - %u",
153 ts->ts_type, ts->protocol_id,
154 format_ip4_address, &ts->start_addr,
155 format_ip4_address, &ts->end_addr,
156 clib_net_to_host_u16( ts->start_port),
157 clib_net_to_host_u16( ts->end_port));
169 .path =
"show ikev2 sa",
170 .short_help =
"show ikev2 sa",
186 u32 tmp1, tmp2, tmp3;
190 u32 responder_sw_if_index = (
u32) ~ 0;
191 u32 tun_sw_if_index = (
u32) ~ 0;
197 const char *valid_chars =
"a-zA-Z0-9_";
216 else if (
unformat (line_input,
"set %U auth shared-key-mic string %v",
221 IKEV2_AUTH_METHOD_SHARED_KEY_MIC, data,
225 else if (
unformat (line_input,
"set %U auth shared-key-mic hex %U",
231 IKEV2_AUTH_METHOD_SHARED_KEY_MIC, data,
235 else if (
unformat (line_input,
"set %U auth rsa-sig cert-file %v",
243 else if (
unformat (line_input,
"set %U id local %U %U",
254 else if (
unformat (line_input,
"set %U id local %U 0x%U",
263 else if (
unformat (line_input,
"set %U id local %U %v",
271 else if (
unformat (line_input,
"set %U id remote %U %U",
282 else if (
unformat (line_input,
"set %U id remote %U 0x%U",
291 else if (
unformat (line_input,
"set %U id remote %U %v",
299 else if (
unformat (line_input,
"set %U traffic-selector local " 300 "ip-range %U - %U port-range %u - %u protocol %u",
304 &tmp1, &tmp2, &tmp3))
311 else if (
unformat (line_input,
"set %U traffic-selector remote " 312 "ip-range %U - %U port-range %u - %u protocol %u",
316 &tmp1, &tmp2, &tmp3))
323 else if (
unformat (line_input,
"set %U responder %U %U",
334 else if (
unformat (line_input,
"set %U tunnel %U",
344 "set %U ike-crypto-alg %U %u ike-integ-alg %U ike-dh %U",
358 "set %U esp-crypto-alg %U %u esp-integ-alg %U esp-dh %U",
371 "set %U esp-crypto-alg %U %u esp-dh %U",
381 else if (
unformat (line_input,
"set %U sa-lifetime %lu %u %u %lu",
383 &tmp4, &tmp1, &tmp2, &tmp5))
389 else if (
unformat (line_input,
"set %U udp-encap",
395 else if (
unformat (line_input,
"set %U ipsec-over-udp port %u",
419 .path =
"ikev2 profile",
421 "ikev2 profile [add|del] <id>\n" 422 "ikev2 profile set <id> auth [rsa-sig|shared-key-mic] [cert-file|string|hex]" 424 "ikev2 profile set <id> id <local|remote> <type> <data>\n" 425 "ikev2 profile set <id> tunnel <interface>\n" 426 "ikev2 profile set <id> udp-encap\n" 427 "ikev2 profile set <id> traffic-selector <local|remote> ip-range " 428 "<start-addr> - <end-addr> port-range <start-port> - <end-port> " 429 "protocol <protocol-number>\n" 430 "ikev2 profile set <id> responder <interface> <addr>\n" 431 "ikev2 profile set <id> ike-crypto-alg <crypto alg> <key size> ike-integ-alg <integ alg> ike-dh <dh type>\n" 432 "ikev2 profile set <id> esp-crypto-alg <crypto alg> <key size> " 433 "[esp-integ-alg <integ alg>] esp-dh <dh type>\n" 434 "ikev2 profile set <id> sa-lifetime <seconds> <jitter> <handover> <max bytes>",
449 vlib_cli_output(vm,
"profile %v", p->name);
454 vlib_cli_output(vm,
" auth-method %U auth data 0x%U",
455 format_ikev2_auth_method, p->auth.method,
456 format_hex_bytes, p->auth.data, vec_len(p->auth.data));
458 vlib_cli_output(vm,
" auth-method %U auth data %v",
459 format_ikev2_auth_method, p->auth.method, p->auth.data);
464 if (p->loc_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
465 vlib_cli_output(vm,
" local id-type %U data %U",
466 format_ikev2_id_type, p->loc_id.type,
467 format_ip4_address, p->loc_id.data);
468 else if (p->loc_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
469 vlib_cli_output(vm,
" local id-type %U data 0x%U",
470 format_ikev2_id_type, p->loc_id.type,
471 format_hex_bytes, p->loc_id.data,
472 vec_len(p->loc_id.data));
474 vlib_cli_output(vm,
" local id-type %U data %v",
475 format_ikev2_id_type, p->loc_id.type, p->loc_id.data);
480 if (p->rem_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
481 vlib_cli_output(vm,
" remote id-type %U data %U",
482 format_ikev2_id_type, p->rem_id.type,
483 format_ip4_address, p->rem_id.data);
484 else if (p->rem_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
485 vlib_cli_output(vm,
" remote id-type %U data 0x%U",
486 format_ikev2_id_type, p->rem_id.type,
487 format_hex_bytes, p->rem_id.data,
488 vec_len(p->rem_id.data));
490 vlib_cli_output(vm,
" remote id-type %U data %v",
491 format_ikev2_id_type, p->rem_id.type, p->rem_id.data);
495 vlib_cli_output(vm,
" local traffic-selector addr %U - %U port %u - %u" 503 vlib_cli_output(vm,
" remote traffic-selector addr %U - %U port %u - %u" 525 .path =
"show ikev2 profile",
526 .short_help =
"show ikev2 profile",
538 u32 period = 0, max_retries = 0;
545 if (
unformat (line_input,
"%d %d", &period, &max_retries))
564 .path =
"ikev2 set liveness",
565 .short_help =
"ikev2 set liveness <period> <max-retires>",
584 if (
unformat (line_input,
"%s", &data))
604 .path =
"set ikev2 local key",
606 "set ikev2 local key <file>",
622 const char *valid_chars =
"a-zA-Z0-9_";
635 else if (
unformat (line_input,
"del-child-sa %x", &tmp1))
640 else if (
unformat (line_input,
"del-sa %lx", &tmp2))
645 else if (
unformat (line_input,
"rekey-child-sa %x", &tmp1))
665 .path =
"ikev2 initiate",
667 "ikev2 initiate sa-init <profile id>\n" 668 "ikev2 initiate del-child-sa <child sa ispi>\n" 669 "ikev2 initiate del-sa <sa ispi>\n" 670 "ikev2 initiate rekey-child-sa <profile id> <child sa ispi>\n",
693 if (!
unformat (line_input,
"%d", &log_level))
710 .path =
"ikev2 set logging level",
712 .short_help =
"ikev2 set logging level <0-5>",
ikev2_main_per_thread_data_t * per_thread_data
u8 * format_ikev2_id_type_and_data(u8 *s, va_list *args)
clib_error_t * ikev2_set_profile_responder(vlib_main_t *vm, u8 *name, u32 sw_if_index, ip4_address_t ip4)
ikev2_transform_integ_type_t
clib_error_t * ikev2_add_del_profile(vlib_main_t *vm, u8 *name, int is_add)
vnet_main_t * vnet_get_main(void)
clib_error_t * ikev2_set_profile_udp_encap(vlib_main_t *vm, u8 *name)
uword unformat_ikev2_transform_encr_type(unformat_input_t *input, va_list *args)
ikev2_profile_t * profiles
clib_error_t * ikev2_initiate_delete_ike_sa(vlib_main_t *vm, u64 ispi)
uword unformat_ikev2_id_type(unformat_input_t *input, va_list *args)
clib_error_t * ikev2_set_profile_tunnel_interface(vlib_main_t *vm, u8 *name, u32 sw_if_index)
static clib_error_t * set_ikev2_liveness_period_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * ikev2_set_profile_sa_lifetime(vlib_main_t *vm, u8 *name, u64 lifetime, u32 jitter, u32 handover, u64 maxdata)
unformat_function_t unformat_vnet_sw_interface
clib_error_t * ikev2_set_liveness_params(u32 period, u32 max_retries)
format_function_t format_vnet_sw_if_index_name
vnet_api_error_t ikev2_set_profile_ipsec_udp_port(vlib_main_t *vm, u8 *name, u16 port, u8 is_set)
#define clib_memcpy(d, s, n)
ikev2_transform_dh_type_t
static clib_error_t * show_ikev2_sa_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
clib_error_t * ikev2_initiate_sa_init(vlib_main_t *vm, u8 *name)
uword unformat_ikev2_transform_dh_type(unformat_input_t *input, va_list *args)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
clib_error_t * ikev2_set_profile_auth(vlib_main_t *vm, u8 *name, u8 auth_method, u8 *auth_data, u8 data_hex_format)
#define clib_error_return(e, args...)
clib_error_t * ikev2_set_profile_esp_transforms(vlib_main_t *vm, u8 *name, ikev2_transform_encr_type_t crypto_alg, ikev2_transform_integ_type_t integ_alg, ikev2_transform_dh_type_t dh_type, u32 crypto_key_size)
int ikev2_set_log_level(ikev2_log_level_t log_level)
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
clib_error_t * ikev2_initiate_delete_child_sa(vlib_main_t *vm, u32 ispi)
static u8 * format_vnet_api_errno(u8 *s, va_list *args)
clib_error_t * ikev2_set_local_key(vlib_main_t *vm, u8 *file)
clib_error_t * ikev2_set_profile_ts(vlib_main_t *vm, u8 *name, u8 protocol_id, u16 start_port, u16 end_port, ip4_address_t start_addr, ip4_address_t end_addr, int is_local)
clib_error_t * ikev2_initiate_rekey_child_sa(vlib_main_t *vm, u32 ispi)
ikev2_transform_encr_type_t
#define vec_free(V)
Free vector's memory (no header).
#define VLIB_CLI_COMMAND(x,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
uword unformat_ikev2_transform_integ_type(unformat_input_t *input, va_list *args)
static clib_error_t * show_ikev2_profile_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * ikev2_set_profile_ike_transforms(vlib_main_t *vm, u8 *name, ikev2_transform_encr_type_t crypto_alg, ikev2_transform_integ_type_t integ_alg, ikev2_transform_dh_type_t dh_type, u32 crypto_key_size)
static clib_error_t * set_ikev2_local_key_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_foreach(var, vec)
Vector iterator.
void ikev2_cli_reference(void)
static clib_error_t * ikev2_set_log_level_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * ikev2_profile_add_del_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define IPSEC_UDP_PORT_NONE
static clib_error_t * ikev2_initiate_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_ikev2_id_type(u8 *s, va_list *args)