2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #include <vlib/vlib.h>
16 #include <vnet/vnet.h>
17 #include <vnet/pg/pg.h>
18 #include <vppinfra/error.h>
19 #include <vnet/udp/udp.h>
20 #include <vnet/ipsec/ipsec_sa.h>
21 #include <plugins/ikev2/ikev2.h>
22 #include <plugins/ikev2/ikev2_priv.h>
25 format_ikev2_id_type_and_data (u8 * s, va_list * args)
27 ikev2_id_t *id = va_arg (*args, ikev2_id_t *);
29 if (id->type == 0 || vec_len (id->data) == 0)
30 return format (s, "none");
32 s = format (s, "%U", format_ikev2_id_type, id->type);
34 if (id->type == IKEV2_ID_TYPE_ID_FQDN ||
35 id->type == IKEV2_ID_TYPE_ID_RFC822_ADDR)
37 s = format (s, " %v", id->data);
42 format (s, " %U", format_hex_bytes, &id->data,
43 (uword) (vec_len (id->data)));
51 show_ikev2_sa_command_fn (vlib_main_t * vm,
52 unformat_input_t * input, vlib_cli_command_t * cmd)
54 ikev2_main_t *km = &ikev2_main;
55 ikev2_main_per_thread_data_t *tkm;
58 ikev2_child_sa_t *child;
59 ikev2_sa_transform_t *tr;
61 vec_foreach (tkm, km->per_thread_data)
64 pool_foreach (sa, tkm->sas, ({
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));
93 vlib_cli_output(vm, " SK_a i:%U\n r:%U",
94 format_hex_bytes, sa->sk_ai, vec_len(sa->sk_ai),
95 format_hex_bytes, sa->sk_ar, vec_len(sa->sk_ar));
97 vlib_cli_output(vm, " SK_e i:%U\n r:%U",
98 format_hex_bytes, sa->sk_ei, vec_len(sa->sk_ei),
99 format_hex_bytes, sa->sk_er, vec_len(sa->sk_er));
100 vlib_cli_output(vm, " SK_p i:%U\n r:%U",
101 format_hex_bytes, sa->sk_pi, vec_len(sa->sk_pi),
102 format_hex_bytes, sa->sk_pr, vec_len(sa->sk_pr));
104 vlib_cli_output(vm, " identifier (i) %U",
105 format_ikev2_id_type_and_data, &sa->i_id);
106 vlib_cli_output(vm, " identifier (r) %U",
107 format_ikev2_id_type_and_data, &sa->r_id);
109 vec_foreach(child, sa->childs)
111 vlib_cli_output(vm, " child sa %u:", child - sa->childs);
113 tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_ENCR);
114 s = format(s, "%U ", format_ikev2_sa_transform, tr);
116 tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_INTEG);
117 s = format(s, "%U ", format_ikev2_sa_transform, tr);
119 tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_ESN);
120 s = format(s, "%U ", format_ikev2_sa_transform, tr);
122 vlib_cli_output(vm, " %v", s);
125 vlib_cli_output(vm, " spi(i) %lx spi(r) %lx",
126 child->i_proposals ? child->i_proposals[0].spi : 0,
127 child->r_proposals ? child->r_proposals[0].spi : 0);
129 vlib_cli_output(vm, " SK_e i:%U\n r:%U",
130 format_hex_bytes, child->sk_ei, vec_len(child->sk_ei),
131 format_hex_bytes, child->sk_er, vec_len(child->sk_er));
134 vlib_cli_output(vm, " SK_a i:%U\n r:%U",
135 format_hex_bytes, child->sk_ai, vec_len(child->sk_ai),
136 format_hex_bytes, child->sk_ar, vec_len(child->sk_ar));
137 vlib_cli_output(vm, " traffic selectors (i):");
139 vec_foreach(ts, child->tsi)
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));
150 vlib_cli_output(vm, " traffic selectors (r):");
151 vec_foreach(ts, child->tsr)
153 vlib_cli_output(vm, " %u type %u protocol_id %u addr "
154 "%U - %U port %u - %u",
156 ts->ts_type, ts->protocol_id,
157 format_ip4_address, &ts->start_addr,
158 format_ip4_address, &ts->end_addr,
159 clib_net_to_host_u16( ts->start_port),
160 clib_net_to_host_u16( ts->end_port));
163 vlib_cli_output(vm, "");
171 VLIB_CLI_COMMAND (show_ikev2_sa_command, static) = {
172 .path = "show ikev2 sa",
173 .short_help = "show ikev2 sa",
174 .function = show_ikev2_sa_command_fn,
178 static clib_error_t *
179 ikev2_profile_add_del_command_fn (vlib_main_t * vm,
180 unformat_input_t * input,
181 vlib_cli_command_t * cmd)
183 vnet_main_t *vnm = vnet_get_main ();
184 unformat_input_t _line_input, *line_input = &_line_input;
189 u32 tmp1, tmp2, tmp3;
192 ip4_address_t end_addr;
193 u32 responder_sw_if_index = (u32) ~ 0;
194 u32 tun_sw_if_index = (u32) ~ 0;
195 ip4_address_t responder_ip4;
196 ikev2_transform_encr_type_t crypto_alg;
197 ikev2_transform_integ_type_t integ_alg;
198 ikev2_transform_dh_type_t dh_type;
200 const char *valid_chars = "a-zA-Z0-9_";
202 if (!unformat_user (input, unformat_line_input, line_input))
205 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
207 if (unformat (line_input, "add %U", unformat_token, valid_chars, &name))
209 r = ikev2_add_del_profile (vm, name, 1);
214 (line_input, "del %U", unformat_token, valid_chars, &name))
216 r = ikev2_add_del_profile (vm, name, 0);
219 else if (unformat (line_input, "set %U auth shared-key-mic string %v",
220 unformat_token, valid_chars, &name, &data))
223 ikev2_set_profile_auth (vm, name,
224 IKEV2_AUTH_METHOD_SHARED_KEY_MIC, data,
228 else if (unformat (line_input, "set %U auth shared-key-mic hex %U",
229 unformat_token, valid_chars, &name,
230 unformat_hex_string, &data))
233 ikev2_set_profile_auth (vm, name,
234 IKEV2_AUTH_METHOD_SHARED_KEY_MIC, data,
238 else if (unformat (line_input, "set %U auth rsa-sig cert-file %v",
239 unformat_token, valid_chars, &name, &data))
242 ikev2_set_profile_auth (vm, name, IKEV2_AUTH_METHOD_RSA_SIG, data,
246 else if (unformat (line_input, "set %U id local %U %U",
247 unformat_token, valid_chars, &name,
248 unformat_ikev2_id_type, &id_type,
249 unformat_ip4_address, &ip4))
251 data = vec_new (u8, 4);
252 clib_memcpy (data, ip4.as_u8, 4);
254 ikev2_set_profile_id (vm, name, (u8) id_type, data, /*local */ 1);
257 else if (unformat (line_input, "set %U id local %U 0x%U",
258 unformat_token, valid_chars, &name,
259 unformat_ikev2_id_type, &id_type,
260 unformat_hex_string, &data))
263 ikev2_set_profile_id (vm, name, (u8) id_type, data, /*local */ 1);
266 else if (unformat (line_input, "set %U id local %U %v",
267 unformat_token, valid_chars, &name,
268 unformat_ikev2_id_type, &id_type, &data))
271 ikev2_set_profile_id (vm, name, (u8) id_type, data, /*local */ 1);
274 else if (unformat (line_input, "set %U id remote %U %U",
275 unformat_token, valid_chars, &name,
276 unformat_ikev2_id_type, &id_type,
277 unformat_ip4_address, &ip4))
279 data = vec_new (u8, 4);
280 clib_memcpy (data, ip4.as_u8, 4);
281 r = ikev2_set_profile_id (vm, name, (u8) id_type, data, /*remote */
285 else if (unformat (line_input, "set %U id remote %U 0x%U",
286 unformat_token, valid_chars, &name,
287 unformat_ikev2_id_type, &id_type,
288 unformat_hex_string, &data))
290 r = ikev2_set_profile_id (vm, name, (u8) id_type, data, /*remote */
294 else if (unformat (line_input, "set %U id remote %U %v",
295 unformat_token, valid_chars, &name,
296 unformat_ikev2_id_type, &id_type, &data))
298 r = ikev2_set_profile_id (vm, name, (u8) id_type, data, /*remote */
302 else if (unformat (line_input, "set %U traffic-selector local "
303 "ip-range %U - %U port-range %u - %u protocol %u",
304 unformat_token, valid_chars, &name,
305 unformat_ip4_address, &ip4,
306 unformat_ip4_address, &end_addr,
307 &tmp1, &tmp2, &tmp3))
310 ikev2_set_profile_ts (vm, name, (u8) tmp3, (u16) tmp1, (u16) tmp2,
311 ip4, end_addr, /*local */ 1);
314 else if (unformat (line_input, "set %U traffic-selector remote "
315 "ip-range %U - %U port-range %u - %u protocol %u",
316 unformat_token, valid_chars, &name,
317 unformat_ip4_address, &ip4,
318 unformat_ip4_address, &end_addr,
319 &tmp1, &tmp2, &tmp3))
322 ikev2_set_profile_ts (vm, name, (u8) tmp3, (u16) tmp1, (u16) tmp2,
323 ip4, end_addr, /*remote */ 0);
326 else if (unformat (line_input, "set %U responder %U %U",
327 unformat_token, valid_chars, &name,
328 unformat_vnet_sw_interface, vnm,
329 &responder_sw_if_index, unformat_ip4_address,
333 ikev2_set_profile_responder (vm, name, responder_sw_if_index,
337 else if (unformat (line_input, "set %U tunnel %U",
338 unformat_token, valid_chars, &name,
339 unformat_vnet_sw_interface, vnm, &tun_sw_if_index))
341 r = ikev2_set_profile_tunnel_interface (vm, name, tun_sw_if_index);
347 "set %U ike-crypto-alg %U %u ike-integ-alg %U ike-dh %U",
348 unformat_token, valid_chars, &name,
349 unformat_ikev2_transform_encr_type, &crypto_alg, &tmp1,
350 unformat_ikev2_transform_integ_type, &integ_alg,
351 unformat_ikev2_transform_dh_type, &dh_type))
354 ikev2_set_profile_ike_transforms (vm, name, crypto_alg, integ_alg,
361 "set %U ike-crypto-alg %U %u ike-dh %U",
362 unformat_token, valid_chars, &name,
363 unformat_ikev2_transform_encr_type, &crypto_alg, &tmp1,
364 unformat_ikev2_transform_dh_type, &dh_type))
367 ikev2_set_profile_ike_transforms (vm, name, crypto_alg,
368 IKEV2_TRANSFORM_INTEG_TYPE_NONE,
375 "set %U esp-crypto-alg %U %u esp-integ-alg %U",
376 unformat_token, valid_chars, &name,
377 unformat_ikev2_transform_encr_type, &crypto_alg, &tmp1,
378 unformat_ikev2_transform_integ_type, &integ_alg))
381 ikev2_set_profile_esp_transforms (vm, name, crypto_alg, integ_alg,
382 IKEV2_TRANSFORM_DH_TYPE_NONE,
388 "set %U esp-crypto-alg %U %u",
389 unformat_token, valid_chars, &name,
390 unformat_ikev2_transform_encr_type, &crypto_alg, &tmp1))
393 ikev2_set_profile_esp_transforms (vm, name, crypto_alg, 0,
394 IKEV2_TRANSFORM_DH_TYPE_NONE,
398 else if (unformat (line_input, "set %U sa-lifetime %lu %u %u %lu",
399 unformat_token, valid_chars, &name,
400 &tmp4, &tmp1, &tmp2, &tmp5))
403 ikev2_set_profile_sa_lifetime (vm, name, tmp4, tmp1, tmp2, tmp5);
406 else if (unformat (line_input, "set %U udp-encap",
407 unformat_token, valid_chars, &name))
409 r = ikev2_set_profile_udp_encap (vm, name);
412 else if (unformat (line_input, "set %U ipsec-over-udp port %u",
413 unformat_token, valid_chars, &name, &tmp1))
415 int rv = ikev2_set_profile_ipsec_udp_port (vm, name, tmp1, 1);
417 r = clib_error_return (0, "Error: %U", format_vnet_api_errno, rv);
424 r = clib_error_return (0, "parse error: '%U'",
425 format_unformat_error, line_input);
430 unformat_free (line_input);
435 VLIB_CLI_COMMAND (ikev2_profile_add_del_command, static) = {
436 .path = "ikev2 profile",
438 "ikev2 profile [add|del] <id>\n"
439 "ikev2 profile set <id> auth [rsa-sig|shared-key-mic] [cert-file|string|hex]"
441 "ikev2 profile set <id> id <local|remote> <type> <data>\n"
442 "ikev2 profile set <id> tunnel <interface>\n"
443 "ikev2 profile set <id> udp-encap\n"
444 "ikev2 profile set <id> traffic-selector <local|remote> ip-range "
445 "<start-addr> - <end-addr> port-range <start-port> - <end-port> "
446 "protocol <protocol-number>\n"
447 "ikev2 profile set <id> responder <interface> <addr>\n"
448 "ikev2 profile set <id> ike-crypto-alg <crypto alg> <key size> ike-integ-alg <integ alg> ike-dh <dh type>\n"
449 "ikev2 profile set <id> esp-crypto-alg <crypto alg> <key size> "
450 "[esp-integ-alg <integ alg>]\n"
451 "ikev2 profile set <id> sa-lifetime <seconds> <jitter> <handover> <max bytes>",
452 .function = ikev2_profile_add_del_command_fn,
456 static clib_error_t *
457 show_ikev2_profile_command_fn (vlib_main_t * vm,
458 unformat_input_t * input,
459 vlib_cli_command_t * cmd)
461 ikev2_main_t *km = &ikev2_main;
465 pool_foreach (p, km->profiles, ({
466 vlib_cli_output(vm, "profile %v", p->name);
471 vlib_cli_output(vm, " auth-method %U auth data 0x%U",
472 format_ikev2_auth_method, p->auth.method,
473 format_hex_bytes, p->auth.data, vec_len(p->auth.data));
475 vlib_cli_output(vm, " auth-method %U auth data %v",
476 format_ikev2_auth_method, p->auth.method, p->auth.data);
481 if (p->loc_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
482 vlib_cli_output(vm, " local id-type %U data %U",
483 format_ikev2_id_type, p->loc_id.type,
484 format_ip4_address, p->loc_id.data);
485 else if (p->loc_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
486 vlib_cli_output(vm, " local id-type %U data 0x%U",
487 format_ikev2_id_type, p->loc_id.type,
488 format_hex_bytes, p->loc_id.data,
489 vec_len(p->loc_id.data));
491 vlib_cli_output(vm, " local id-type %U data %v",
492 format_ikev2_id_type, p->loc_id.type, p->loc_id.data);
497 if (p->rem_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
498 vlib_cli_output(vm, " remote id-type %U data %U",
499 format_ikev2_id_type, p->rem_id.type,
500 format_ip4_address, p->rem_id.data);
501 else if (p->rem_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
502 vlib_cli_output(vm, " remote id-type %U data 0x%U",
503 format_ikev2_id_type, p->rem_id.type,
504 format_hex_bytes, p->rem_id.data,
505 vec_len(p->rem_id.data));
507 vlib_cli_output(vm, " remote id-type %U data %v",
508 format_ikev2_id_type, p->rem_id.type, p->rem_id.data);
511 if (p->loc_ts.end_addr.as_u32)
512 vlib_cli_output(vm, " local traffic-selector addr %U - %U port %u - %u"
514 format_ip4_address, &p->loc_ts.start_addr,
515 format_ip4_address, &p->loc_ts.end_addr,
516 p->loc_ts.start_port, p->loc_ts.end_port,
517 p->loc_ts.protocol_id);
519 if (p->rem_ts.end_addr.as_u32)
520 vlib_cli_output(vm, " remote traffic-selector addr %U - %U port %u - %u"
522 format_ip4_address, &p->rem_ts.start_addr,
523 format_ip4_address, &p->rem_ts.end_addr,
524 p->rem_ts.start_port, p->rem_ts.end_port,
525 p->rem_ts.protocol_id);
526 if (~0 != p->tun_itf)
527 vlib_cli_output(vm, " protected tunnel %U",
528 format_vnet_sw_if_index_name, vnet_get_main(), p->tun_itf);
529 if (~0 != p->responder.sw_if_index)
530 vlib_cli_output(vm, " responder %U %U",
531 format_vnet_sw_if_index_name, vnet_get_main(), p->responder.sw_if_index,
532 format_ip4_address, &p->responder.ip4);
534 vlib_cli_output(vm, " udp-encap");
536 if (p->ipsec_over_udp_port != IPSEC_UDP_PORT_NONE)
537 vlib_cli_output(vm, " ipsec-over-udp port %d", p->ipsec_over_udp_port);
539 if (p->ike_ts.crypto_alg || p->ike_ts.integ_alg || p->ike_ts.dh_type || p->ike_ts.crypto_key_size)
540 vlib_cli_output(vm, " ike-crypto-alg %U %u ike-integ-alg %U ike-dh %U",
541 format_ikev2_transform_encr_type, p->ike_ts.crypto_alg, p->ike_ts.crypto_key_size,
542 format_ikev2_transform_integ_type, p->ike_ts.integ_alg,
543 format_ikev2_transform_dh_type, p->ike_ts.dh_type);
545 if (p->esp_ts.crypto_alg || p->esp_ts.integ_alg || p->esp_ts.dh_type)
546 vlib_cli_output(vm, " esp-crypto-alg %U %u esp-integ-alg %U",
547 format_ikev2_transform_encr_type, p->esp_ts.crypto_alg, p->esp_ts.crypto_key_size,
548 format_ikev2_transform_integ_type, p->esp_ts.integ_alg);
550 vlib_cli_output(vm, " lifetime %d jitter %d handover %d maxdata %d",
551 p->lifetime, p->lifetime_jitter, p->handover, p->lifetime_maxdata);
559 VLIB_CLI_COMMAND (show_ikev2_profile_command, static) = {
560 .path = "show ikev2 profile",
561 .short_help = "show ikev2 profile",
562 .function = show_ikev2_profile_command_fn,
566 static clib_error_t *
567 set_ikev2_liveness_period_fn (vlib_main_t * vm,
568 unformat_input_t * input,
569 vlib_cli_command_t * cmd)
571 unformat_input_t _line_input, *line_input = &_line_input;
573 u32 period = 0, max_retries = 0;
575 if (!unformat_user (input, unformat_line_input, line_input))
578 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
580 if (unformat (line_input, "%d %d", &period, &max_retries))
582 r = ikev2_set_liveness_params (period, max_retries);
589 r = clib_error_return (0, "parse error: '%U'",
590 format_unformat_error, line_input);
593 unformat_free (line_input);
598 VLIB_CLI_COMMAND (set_ikev2_liveness_command, static) = {
599 .path = "ikev2 set liveness",
600 .short_help = "ikev2 set liveness <period> <max-retires>",
601 .function = set_ikev2_liveness_period_fn,
605 static clib_error_t *
606 set_ikev2_local_key_command_fn (vlib_main_t * vm,
607 unformat_input_t * input,
608 vlib_cli_command_t * cmd)
610 unformat_input_t _line_input, *line_input = &_line_input;
614 if (!unformat_user (input, unformat_line_input, line_input))
617 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
619 if (unformat (line_input, "%s", &data))
621 r = ikev2_set_local_key (vm, data);
628 r = clib_error_return (0, "parse error: '%U'",
629 format_unformat_error, line_input);
633 unformat_free (line_input);
638 VLIB_CLI_COMMAND (set_ikev2_local_key_command, static) = {
639 .path = "set ikev2 local key",
641 "set ikev2 local key <file>",
642 .function = set_ikev2_local_key_command_fn,
647 static clib_error_t *
648 ikev2_initiate_command_fn (vlib_main_t * vm,
649 unformat_input_t * input, vlib_cli_command_t * cmd)
651 unformat_input_t _line_input, *line_input = &_line_input;
657 const char *valid_chars = "a-zA-Z0-9_";
659 if (!unformat_user (input, unformat_line_input, line_input))
662 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
665 (line_input, "sa-init %U", unformat_token, valid_chars, &name))
667 r = ikev2_initiate_sa_init (vm, name);
670 else if (unformat (line_input, "del-child-sa %x", &tmp1))
672 r = ikev2_initiate_delete_child_sa (vm, tmp1);
675 else if (unformat (line_input, "del-sa %lx", &tmp2))
677 r = ikev2_initiate_delete_ike_sa (vm, tmp2);
680 else if (unformat (line_input, "rekey-child-sa %x", &tmp1))
682 r = ikev2_initiate_rekey_child_sa (vm, tmp1);
689 r = clib_error_return (0, "parse error: '%U'",
690 format_unformat_error, line_input);
694 unformat_free (line_input);
699 VLIB_CLI_COMMAND (ikev2_initiate_command, static) = {
700 .path = "ikev2 initiate",
702 "ikev2 initiate sa-init <profile id>\n"
703 "ikev2 initiate del-child-sa <child sa ispi>\n"
704 "ikev2 initiate del-sa <sa ispi>\n"
705 "ikev2 initiate rekey-child-sa <profile id> <child sa ispi>\n",
706 .function = ikev2_initiate_command_fn,
711 ikev2_cli_reference (void)
715 static clib_error_t *
716 ikev2_set_log_level_command_fn (vlib_main_t * vm,
717 unformat_input_t * input,
718 vlib_cli_command_t * cmd)
720 unformat_input_t _line_input, *line_input = &_line_input;
721 u32 log_level = IKEV2_LOG_NONE;
722 clib_error_t *error = 0;
724 /* Get a line of input. */
725 if (!unformat_user (input, unformat_line_input, line_input))
728 if (!unformat (line_input, "%d", &log_level))
730 error = clib_error_return (0, "unknown input '%U'",
731 format_unformat_error, line_input);
734 int rc = ikev2_set_log_level (log_level);
736 error = clib_error_return (0, "setting log level failed!");
739 unformat_free (line_input);
744 VLIB_CLI_COMMAND (ikev2_set_log_level_command, static) = {
745 .path = "ikev2 set logging level",
746 .function = ikev2_set_log_level_command_fn,
747 .short_help = "ikev2 set logging level <0-5>",
752 * fd.io coding-style-patch-verification: ON
755 * eval: (c-set-style "gnu")