33 if (id->
type == IKEV2_ID_TYPE_ID_FQDN ||
34 id->
type == IKEV2_ID_TYPE_ID_RFC822_ADDR)
60 vlib_cli_output(vm,
" iip %U ispi %lx rip %U rspi %lx",
61 format_ip4_address, &sa->iaddr, sa->ispi,
62 format_ip4_address, &sa->raddr, sa->rspi);
64 tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_ENCR);
65 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
67 tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_PRF);
68 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
70 tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_INTEG);
71 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
73 tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_DH);
74 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
76 vlib_cli_output(vm,
" %v", s);
79 vlib_cli_output(vm,
" nonce i:%U\n r:%U",
80 format_hex_bytes, sa->i_nonce, vec_len(sa->i_nonce),
81 format_hex_bytes, sa->r_nonce, vec_len(sa->r_nonce));
83 vlib_cli_output(vm,
" SK_d %U",
84 format_hex_bytes, sa->sk_d, vec_len(sa->sk_d));
85 vlib_cli_output(vm,
" SK_a i:%U\n r:%U",
86 format_hex_bytes, sa->sk_ai, vec_len(sa->sk_ai),
87 format_hex_bytes, sa->sk_ar, vec_len(sa->sk_ar));
88 vlib_cli_output(vm,
" SK_e i:%U\n r:%U",
89 format_hex_bytes, sa->sk_ei, vec_len(sa->sk_ei),
90 format_hex_bytes, sa->sk_er, vec_len(sa->sk_er));
91 vlib_cli_output(vm,
" SK_p i:%U\n r:%U",
92 format_hex_bytes, sa->sk_pi, vec_len(sa->sk_pi),
93 format_hex_bytes, sa->sk_pr, vec_len(sa->sk_pr));
95 vlib_cli_output(vm,
" identifier (i) %U",
96 format_ikev2_id_type_and_data, &sa->i_id);
97 vlib_cli_output(vm,
" identifier (r) %U",
98 format_ikev2_id_type_and_data, &sa->r_id);
100 vec_foreach(child, sa->childs)
102 vlib_cli_output(vm,
" child sa %u:", child - sa->childs);
104 tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_ENCR);
105 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
107 tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_INTEG);
108 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
110 tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_ESN);
111 s = format(s,
"%U ", format_ikev2_sa_transform, tr);
113 vlib_cli_output(vm,
" %v", s);
116 vlib_cli_output(vm,
" spi(i) %lx spi(r) %lx",
117 child->i_proposals ? child->i_proposals[0].spi : 0,
118 child->r_proposals ? child->r_proposals[0].spi : 0);
120 vlib_cli_output(vm,
" SK_e i:%U\n r:%U",
121 format_hex_bytes, child->sk_ei, vec_len(child->sk_ei),
122 format_hex_bytes, child->sk_er, vec_len(child->sk_er));
123 vlib_cli_output(vm,
" SK_a i:%U\n r:%U",
124 format_hex_bytes, child->sk_ai, vec_len(child->sk_ai),
125 format_hex_bytes, child->sk_ar, vec_len(child->sk_ar));
126 vlib_cli_output(vm,
" traffic selectors (i):");
127 vec_foreach(ts, child->tsi)
129 vlib_cli_output(vm,
" %u type %u protocol_id %u addr " 130 "%U - %U port %u - %u",
132 ts->ts_type, ts->protocol_id,
133 format_ip4_address, &ts->start_addr,
134 format_ip4_address, &ts->end_addr,
135 clib_net_to_host_u16( ts->start_port),
136 clib_net_to_host_u16( ts->end_port));
138 vlib_cli_output(vm,
" traffic selectors (r):");
139 vec_foreach(ts, child->tsr)
141 vlib_cli_output(vm,
" %u type %u protocol_id %u addr " 142 "%U - %U port %u - %u",
144 ts->ts_type, ts->protocol_id,
145 format_ip4_address, &ts->start_addr,
146 format_ip4_address, &ts->end_addr,
147 clib_net_to_host_u16( ts->start_port),
148 clib_net_to_host_u16( ts->end_port));
157 .path =
"show ikev2 sa",
158 .short_help =
"show ikev2 sa",
172 u32 tmp1, tmp2, tmp3;
176 const char * valid_chars =
"a-zA-Z0-9_";
192 else if (
unformat (line_input,
"set %U auth shared-key-mic string %v",
199 else if (
unformat (line_input,
"set %U auth shared-key-mic hex %U",
207 else if (
unformat (line_input,
"set %U auth rsa-sig cert-file %v",
214 else if (
unformat (line_input,
"set %U id local %U %U",
224 else if (
unformat (line_input,
"set %U id local %U 0x%U",
232 else if (
unformat (line_input,
"set %U id local %U %v",
239 else if (
unformat (line_input,
"set %U id remote %U %U",
249 else if (
unformat (line_input,
"set %U id remote %U 0x%U",
257 else if (
unformat (line_input,
"set %U id remote %U %v",
264 else if (
unformat (line_input,
"set %U traffic-selector local " 265 "ip-range %U - %U port-range %u - %u protocol %u",
269 &tmp1, &tmp2, &tmp3))
275 else if (
unformat (line_input,
"set %U traffic-selector remote " 276 "ip-range %U - %U port-range %u - %u protocol %u",
280 &tmp1, &tmp2, &tmp3))
301 .path =
"ikev2 profile",
303 "ikev2 profile [add|del] <id>\n" 304 "ikev2 profile set <id> auth [rsa-sig|shared-key-mic] [cert-file|string|hex]" 306 "ikev2 profile set <id> id <local|remote> <type> <data>\n" 307 "ikev2 profile set <id> traffic-selector <local|remote> ip-range " 308 "<start-addr> - <end-addr> port-range <start-port> - <end-port> " 309 "protocol <protocol-number>",
322 vlib_cli_output(vm,
"profile %v", p->name);
327 vlib_cli_output(vm,
" auth-method %U auth data 0x%U",
328 format_ikev2_auth_method, p->auth.method,
329 format_hex_bytes, p->auth.data, vec_len(p->auth.data));
331 vlib_cli_output(vm,
" auth-method %U auth data %v",
332 format_ikev2_auth_method, p->auth.method, p->auth.data);
337 if (p->loc_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
338 vlib_cli_output(vm,
" local id-type %U data %U",
339 format_ikev2_id_type, p->loc_id.type,
340 format_ip4_address, p->loc_id.data);
341 else if (p->loc_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
342 vlib_cli_output(vm,
" local id-type %U data 0x%U",
343 format_ikev2_id_type, p->loc_id.type,
344 format_hex_bytes, p->loc_id.data,
345 vec_len(p->loc_id.data));
347 vlib_cli_output(vm,
" local id-type %U data %v",
348 format_ikev2_id_type, p->loc_id.type, p->loc_id.data);
353 if (p->rem_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
354 vlib_cli_output(vm,
" remote id-type %U data %U",
355 format_ikev2_id_type, p->rem_id.type,
356 format_ip4_address, p->rem_id.data);
357 else if (p->rem_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
358 vlib_cli_output(vm,
" remote id-type %U data 0x%U",
359 format_ikev2_id_type, p->rem_id.type,
360 format_hex_bytes, p->rem_id.data,
361 vec_len(p->rem_id.data));
363 vlib_cli_output(vm,
" remote id-type %U data %v",
364 format_ikev2_id_type, p->rem_id.type, p->rem_id.data);
368 vlib_cli_output(vm,
" local traffic-selector addr %U - %U port %u - %u" 376 vlib_cli_output(vm,
" remote traffic-selector addr %U - %U port %u - %u" 388 .path =
"show ikev2 profile",
389 .short_help =
"show ikev2 profile",
406 if (
unformat (line_input,
"%v", &data))
425 .path =
"set ikev2 local key",
427 "set ikev2 local key <file>",
u8 * format_ikev2_id_type_and_data(u8 *s, va_list *args)
clib_error_t * ikev2_add_del_profile(vlib_main_t *vm, u8 *name, int is_add)
ikev2_profile_t * profiles
uword unformat_ikev2_id_type(unformat_input_t *input, va_list *args)
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)
#define VLIB_INIT_FUNCTION(x)
#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)
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
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)
#define vec_free(V)
Free vector's memory (no header).
#define clib_memcpy(a, b, c)
#define VLIB_CLI_COMMAND(x,...)
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)
static clib_error_t * set_ikev2_local_key_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * ikev2_cli_init(vlib_main_t *vm)
#define clib_error_return(e, args...)
static clib_error_t * ikev2_profile_add_del_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)