ikev2: Configure a profile with an existing interface
[vpp.git] / src / plugins / ikev2 / ikev2_cli.c
1 /*
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:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
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 <plugins/ikev2/ikev2.h>
21 #include <plugins/ikev2/ikev2_priv.h>
22
23 u8 *
24 format_ikev2_id_type_and_data (u8 * s, va_list * args)
25 {
26   ikev2_id_t *id = va_arg (*args, ikev2_id_t *);
27
28   if (id->type == 0 || vec_len (id->data) == 0)
29     return format (s, "none");
30
31   s = format (s, "%U", format_ikev2_id_type, id->type);
32
33   if (id->type == IKEV2_ID_TYPE_ID_FQDN ||
34       id->type == IKEV2_ID_TYPE_ID_RFC822_ADDR)
35     {
36       s = format (s, " %v", id->data);
37     }
38   else
39     {
40       s =
41         format (s, " %U", format_hex_bytes, &id->data,
42                 (uword) (vec_len (id->data)));
43     }
44
45   return s;
46 }
47
48
49 static clib_error_t *
50 show_ikev2_sa_command_fn (vlib_main_t * vm,
51                           unformat_input_t * input, vlib_cli_command_t * cmd)
52 {
53   ikev2_main_t *km = &ikev2_main;
54   ikev2_main_per_thread_data_t *tkm;
55   ikev2_sa_t *sa;
56   ikev2_ts_t *ts;
57   ikev2_child_sa_t *child;
58   ikev2_sa_transform_t *tr;
59
60   vec_foreach (tkm, km->per_thread_data)
61   {
62     /* *INDENT-OFF* */
63     pool_foreach (sa, tkm->sas, ({
64       u8 * s = 0;
65       vlib_cli_output(vm, " iip %U ispi %lx rip %U rspi %lx",
66                       format_ip4_address, &sa->iaddr, sa->ispi,
67                       format_ip4_address, &sa->raddr, sa->rspi);
68
69        tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_ENCR);
70        s = format(s, "%U ", format_ikev2_sa_transform, tr);
71
72        tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_PRF);
73        s = format(s, "%U ", format_ikev2_sa_transform, tr);
74
75        tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_INTEG);
76        s = format(s, "%U ", format_ikev2_sa_transform, tr);
77
78        tr = ikev2_sa_get_td_for_type(sa->r_proposals, IKEV2_TRANSFORM_TYPE_DH);
79        s = format(s, "%U ", format_ikev2_sa_transform, tr);
80
81       vlib_cli_output(vm, " %v", s);
82       vec_free(s);
83
84       vlib_cli_output(vm, "  nonce i:%U\n        r:%U",
85                       format_hex_bytes, sa->i_nonce,  vec_len(sa->i_nonce),
86                       format_hex_bytes, sa->r_nonce,  vec_len(sa->r_nonce));
87
88       vlib_cli_output(vm, "  SK_d    %U",
89                       format_hex_bytes, sa->sk_d,  vec_len(sa->sk_d));
90       vlib_cli_output(vm, "  SK_a  i:%U\n        r:%U",
91                       format_hex_bytes, sa->sk_ai, vec_len(sa->sk_ai),
92                       format_hex_bytes, sa->sk_ar, vec_len(sa->sk_ar));
93       vlib_cli_output(vm, "  SK_e  i:%U\n        r:%U",
94                       format_hex_bytes, sa->sk_ei, vec_len(sa->sk_ei),
95                       format_hex_bytes, sa->sk_er, vec_len(sa->sk_er));
96       vlib_cli_output(vm, "  SK_p  i:%U\n        r:%U",
97                       format_hex_bytes, sa->sk_pi, vec_len(sa->sk_pi),
98                       format_hex_bytes, sa->sk_pr, vec_len(sa->sk_pr));
99
100       vlib_cli_output(vm, "  identifier (i) %U",
101                       format_ikev2_id_type_and_data, &sa->i_id);
102       vlib_cli_output(vm, "  identifier (r) %U",
103                       format_ikev2_id_type_and_data, &sa->r_id);
104
105       vec_foreach(child, sa->childs)
106         {
107           vlib_cli_output(vm, "  child sa %u:", child - sa->childs);
108
109           tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_ENCR);
110           s = format(s, "%U ", format_ikev2_sa_transform, tr);
111
112           tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_INTEG);
113           s = format(s, "%U ", format_ikev2_sa_transform, tr);
114
115           tr = ikev2_sa_get_td_for_type(child->r_proposals, IKEV2_TRANSFORM_TYPE_ESN);
116           s = format(s, "%U ", format_ikev2_sa_transform, tr);
117
118           vlib_cli_output(vm, "    %v", s);
119           vec_free(s);
120
121           vlib_cli_output(vm, "    spi(i) %lx spi(r) %lx",
122                           child->i_proposals ? child->i_proposals[0].spi : 0,
123                           child->r_proposals ? child->r_proposals[0].spi : 0);
124
125           vlib_cli_output(vm, "    SK_e  i:%U\n          r:%U",
126                           format_hex_bytes, child->sk_ei, vec_len(child->sk_ei),
127                           format_hex_bytes, child->sk_er, vec_len(child->sk_er));
128           vlib_cli_output(vm, "    SK_a  i:%U\n          r:%U",
129                           format_hex_bytes, child->sk_ai, vec_len(child->sk_ai),
130                           format_hex_bytes, child->sk_ar, vec_len(child->sk_ar));
131           vlib_cli_output(vm, "    traffic selectors (i):");
132           vec_foreach(ts, child->tsi)
133             {
134               vlib_cli_output(vm, "      %u type %u protocol_id %u addr "
135                               "%U - %U port %u - %u",
136                               ts - child->tsi,
137                               ts->ts_type, ts->protocol_id,
138                               format_ip4_address, &ts->start_addr,
139                               format_ip4_address, &ts->end_addr,
140                               clib_net_to_host_u16( ts->start_port),
141                               clib_net_to_host_u16( ts->end_port));
142             }
143           vlib_cli_output(vm, "    traffic selectors (r):");
144           vec_foreach(ts, child->tsr)
145             {
146               vlib_cli_output(vm, "      %u type %u protocol_id %u addr "
147                               "%U - %U port %u - %u",
148                               ts - child->tsr,
149                               ts->ts_type, ts->protocol_id,
150                               format_ip4_address, &ts->start_addr,
151                               format_ip4_address, &ts->end_addr,
152                               clib_net_to_host_u16( ts->start_port),
153                               clib_net_to_host_u16( ts->end_port));
154             }
155         }
156       vlib_cli_output(vm, "");
157     }));
158     /* *INDENT-ON* */
159   }
160   return 0;
161 }
162
163 /* *INDENT-OFF* */
164 VLIB_CLI_COMMAND (show_ikev2_sa_command, static) = {
165     .path = "show ikev2 sa",
166     .short_help = "show ikev2 sa",
167     .function = show_ikev2_sa_command_fn,
168 };
169 /* *INDENT-ON* */
170
171 static clib_error_t *
172 ikev2_profile_add_del_command_fn (vlib_main_t * vm,
173                                   unformat_input_t * input,
174                                   vlib_cli_command_t * cmd)
175 {
176   vnet_main_t *vnm = vnet_get_main ();
177   unformat_input_t _line_input, *line_input = &_line_input;
178   u8 *name = 0;
179   clib_error_t *r = 0;
180   u32 id_type;
181   u8 *data = 0;
182   u32 tmp1, tmp2, tmp3;
183   u64 tmp4, tmp5;
184   ip4_address_t ip4;
185   ip4_address_t end_addr;
186   u32 responder_sw_if_index = (u32) ~ 0;
187   u32 tun_sw_if_index = (u32) ~ 0;
188   ip4_address_t responder_ip4;
189   ikev2_transform_encr_type_t crypto_alg;
190   ikev2_transform_integ_type_t integ_alg;
191   ikev2_transform_dh_type_t dh_type;
192
193   const char *valid_chars = "a-zA-Z0-9_";
194
195   if (!unformat_user (input, unformat_line_input, line_input))
196     return 0;
197
198   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
199     {
200       if (unformat (line_input, "add %U", unformat_token, valid_chars, &name))
201         {
202           r = ikev2_add_del_profile (vm, name, 1);
203           goto done;
204         }
205       else
206         if (unformat
207             (line_input, "del %U", unformat_token, valid_chars, &name))
208         {
209           r = ikev2_add_del_profile (vm, name, 0);
210           goto done;
211         }
212       else if (unformat (line_input, "set %U auth shared-key-mic string %v",
213                          unformat_token, valid_chars, &name, &data))
214         {
215           r =
216             ikev2_set_profile_auth (vm, name,
217                                     IKEV2_AUTH_METHOD_SHARED_KEY_MIC, data,
218                                     0);
219           goto done;
220         }
221       else if (unformat (line_input, "set %U auth shared-key-mic hex %U",
222                          unformat_token, valid_chars, &name,
223                          unformat_hex_string, &data))
224         {
225           r =
226             ikev2_set_profile_auth (vm, name,
227                                     IKEV2_AUTH_METHOD_SHARED_KEY_MIC, data,
228                                     1);
229           goto done;
230         }
231       else if (unformat (line_input, "set %U auth rsa-sig cert-file %v",
232                          unformat_token, valid_chars, &name, &data))
233         {
234           r =
235             ikev2_set_profile_auth (vm, name, IKEV2_AUTH_METHOD_RSA_SIG, data,
236                                     0);
237           goto done;
238         }
239       else if (unformat (line_input, "set %U id local %U %U",
240                          unformat_token, valid_chars, &name,
241                          unformat_ikev2_id_type, &id_type,
242                          unformat_ip4_address, &ip4))
243         {
244           data = vec_new (u8, 4);
245           clib_memcpy (data, ip4.as_u8, 4);
246           r =
247             ikev2_set_profile_id (vm, name, (u8) id_type, data, /*local */ 1);
248           goto done;
249         }
250       else if (unformat (line_input, "set %U id local %U 0x%U",
251                          unformat_token, valid_chars, &name,
252                          unformat_ikev2_id_type, &id_type,
253                          unformat_hex_string, &data))
254         {
255           r =
256             ikev2_set_profile_id (vm, name, (u8) id_type, data, /*local */ 1);
257           goto done;
258         }
259       else if (unformat (line_input, "set %U id local %U %v",
260                          unformat_token, valid_chars, &name,
261                          unformat_ikev2_id_type, &id_type, &data))
262         {
263           r =
264             ikev2_set_profile_id (vm, name, (u8) id_type, data, /*local */ 1);
265           goto done;
266         }
267       else if (unformat (line_input, "set %U id remote %U %U",
268                          unformat_token, valid_chars, &name,
269                          unformat_ikev2_id_type, &id_type,
270                          unformat_ip4_address, &ip4))
271         {
272           data = vec_new (u8, 4);
273           clib_memcpy (data, ip4.as_u8, 4);
274           r = ikev2_set_profile_id (vm, name, (u8) id_type, data,       /*remote */
275                                     0);
276           goto done;
277         }
278       else if (unformat (line_input, "set %U id remote %U 0x%U",
279                          unformat_token, valid_chars, &name,
280                          unformat_ikev2_id_type, &id_type,
281                          unformat_hex_string, &data))
282         {
283           r = ikev2_set_profile_id (vm, name, (u8) id_type, data,       /*remote */
284                                     0);
285           goto done;
286         }
287       else if (unformat (line_input, "set %U id remote %U %v",
288                          unformat_token, valid_chars, &name,
289                          unformat_ikev2_id_type, &id_type, &data))
290         {
291           r = ikev2_set_profile_id (vm, name, (u8) id_type, data,       /*remote */
292                                     0);
293           goto done;
294         }
295       else if (unformat (line_input, "set %U traffic-selector local "
296                          "ip-range %U - %U port-range %u - %u protocol %u",
297                          unformat_token, valid_chars, &name,
298                          unformat_ip4_address, &ip4,
299                          unformat_ip4_address, &end_addr,
300                          &tmp1, &tmp2, &tmp3))
301         {
302           r =
303             ikev2_set_profile_ts (vm, name, (u8) tmp3, (u16) tmp1, (u16) tmp2,
304                                   ip4, end_addr, /*local */ 1);
305           goto done;
306         }
307       else if (unformat (line_input, "set %U traffic-selector remote "
308                          "ip-range %U - %U port-range %u - %u protocol %u",
309                          unformat_token, valid_chars, &name,
310                          unformat_ip4_address, &ip4,
311                          unformat_ip4_address, &end_addr,
312                          &tmp1, &tmp2, &tmp3))
313         {
314           r =
315             ikev2_set_profile_ts (vm, name, (u8) tmp3, (u16) tmp1, (u16) tmp2,
316                                   ip4, end_addr, /*remote */ 0);
317           goto done;
318         }
319       else if (unformat (line_input, "set %U responder %U %U",
320                          unformat_token, valid_chars, &name,
321                          unformat_vnet_sw_interface, vnm,
322                          &responder_sw_if_index, unformat_ip4_address,
323                          &responder_ip4))
324         {
325           r =
326             ikev2_set_profile_responder (vm, name, responder_sw_if_index,
327                                          responder_ip4);
328           goto done;
329         }
330       else if (unformat (line_input, "set %U tunnel %U",
331                          unformat_token, valid_chars, &name,
332                          unformat_vnet_sw_interface, vnm, &tun_sw_if_index))
333         {
334           r = ikev2_set_profile_tunnel_interface (vm, name, tun_sw_if_index);
335           goto done;
336         }
337       else
338         if (unformat
339             (line_input,
340              "set %U ike-crypto-alg %U %u ike-integ-alg %U ike-dh %U",
341              unformat_token, valid_chars, &name,
342              unformat_ikev2_transform_encr_type, &crypto_alg, &tmp1,
343              unformat_ikev2_transform_integ_type, &integ_alg,
344              unformat_ikev2_transform_dh_type, &dh_type))
345         {
346           r =
347             ikev2_set_profile_ike_transforms (vm, name, crypto_alg, integ_alg,
348                                               dh_type, tmp1);
349           goto done;
350         }
351       else
352         if (unformat
353             (line_input,
354              "set %U esp-crypto-alg %U %u esp-integ-alg %U esp-dh %U",
355              unformat_token, valid_chars, &name,
356              unformat_ikev2_transform_encr_type, &crypto_alg, &tmp1,
357              unformat_ikev2_transform_integ_type, &integ_alg,
358              unformat_ikev2_transform_dh_type, &dh_type))
359         {
360           r =
361             ikev2_set_profile_esp_transforms (vm, name, crypto_alg, integ_alg,
362                                               dh_type, tmp1);
363           goto done;
364         }
365       else if (unformat (line_input, "set %U sa-lifetime %lu %u %u %lu",
366                          unformat_token, valid_chars, &name,
367                          &tmp4, &tmp1, &tmp2, &tmp5))
368         {
369           r =
370             ikev2_set_profile_sa_lifetime (vm, name, tmp4, tmp1, tmp2, tmp5);
371           goto done;
372         }
373       else
374         break;
375     }
376
377   r = clib_error_return (0, "parse error: '%U'",
378                          format_unformat_error, line_input);
379
380 done:
381   vec_free (name);
382   vec_free (data);
383   unformat_free (line_input);
384   return r;
385 }
386
387 /* *INDENT-OFF* */
388 VLIB_CLI_COMMAND (ikev2_profile_add_del_command, static) = {
389     .path = "ikev2 profile",
390     .short_help =
391     "ikev2 profile [add|del] <id>\n"
392     "ikev2 profile set <id> auth [rsa-sig|shared-key-mic] [cert-file|string|hex]"
393     " <data>\n"
394     "ikev2 profile set <id> id <local|remote> <type> <data>\n"
395     "ikev2 profile set <id> tunnel <interface>\n"
396     "ikev2 profile set <id> traffic-selector <local|remote> ip-range "
397     "<start-addr> - <end-addr> port-range <start-port> - <end-port> "
398     "protocol <protocol-number>\n"
399     "ikev2 profile set <id> responder <interface> <addr>\n"
400     "ikev2 profile set <id> ike-crypto-alg <crypto alg> <key size> ike-integ-alg <integ alg> ike-dh <dh type>\n"
401     "ikev2 profile set <id> esp-crypto-alg <crypto alg> <key size> esp-integ-alg <integ alg> esp-dh <dh type>\n"
402     "ikev2 profile set <id> sa-lifetime <seconds> <jitter> <handover> <max bytes>",
403     .function = ikev2_profile_add_del_command_fn,
404 };
405 /* *INDENT-ON* */
406
407 static clib_error_t *
408 show_ikev2_profile_command_fn (vlib_main_t * vm,
409                                unformat_input_t * input,
410                                vlib_cli_command_t * cmd)
411 {
412   ikev2_main_t *km = &ikev2_main;
413   ikev2_profile_t *p;
414
415   /* *INDENT-OFF* */
416   pool_foreach (p, km->profiles, ({
417     vlib_cli_output(vm, "profile %v", p->name);
418
419     if (p->auth.data)
420       {
421         if (p->auth.hex)
422           vlib_cli_output(vm, "  auth-method %U auth data 0x%U",
423                           format_ikev2_auth_method, p->auth.method,
424                           format_hex_bytes, p->auth.data, vec_len(p->auth.data));
425         else
426           vlib_cli_output(vm, "  auth-method %U auth data %v",
427                    format_ikev2_auth_method, p->auth.method, p->auth.data);
428       }
429
430     if (p->loc_id.data)
431       {
432         if (p->loc_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
433           vlib_cli_output(vm, "  local id-type %U data %U",
434                           format_ikev2_id_type, p->loc_id.type,
435                           format_ip4_address, p->loc_id.data);
436         else if (p->loc_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
437           vlib_cli_output(vm, "  local id-type %U data 0x%U",
438                           format_ikev2_id_type, p->loc_id.type,
439                           format_hex_bytes, p->loc_id.data,
440                           vec_len(p->loc_id.data));
441         else
442           vlib_cli_output(vm, "  local id-type %U data %v",
443                           format_ikev2_id_type, p->loc_id.type, p->loc_id.data);
444       }
445
446     if (p->rem_id.data)
447       {
448         if (p->rem_id.type == IKEV2_ID_TYPE_ID_IPV4_ADDR)
449           vlib_cli_output(vm, "  remote id-type %U data %U",
450                           format_ikev2_id_type, p->rem_id.type,
451                           format_ip4_address, p->rem_id.data);
452         else if (p->rem_id.type == IKEV2_ID_TYPE_ID_KEY_ID)
453           vlib_cli_output(vm, "  remote id-type %U data 0x%U",
454                           format_ikev2_id_type, p->rem_id.type,
455                           format_hex_bytes, p->rem_id.data,
456                           vec_len(p->rem_id.data));
457         else
458           vlib_cli_output(vm, "  remote id-type %U data %v",
459                           format_ikev2_id_type, p->rem_id.type, p->rem_id.data);
460       }
461
462     if (p->loc_ts.end_addr.as_u32)
463       vlib_cli_output(vm, "  local traffic-selector addr %U - %U port %u - %u"
464                       " protocol %u",
465                       format_ip4_address, &p->loc_ts.start_addr,
466                       format_ip4_address, &p->loc_ts.end_addr,
467                       p->loc_ts.start_port, p->loc_ts.end_port,
468                       p->loc_ts.protocol_id);
469
470     if (p->rem_ts.end_addr.as_u32)
471       vlib_cli_output(vm, "  remote traffic-selector addr %U - %U port %u - %u"
472                       " protocol %u",
473                       format_ip4_address, &p->rem_ts.start_addr,
474                       format_ip4_address, &p->rem_ts.end_addr,
475                       p->rem_ts.start_port, p->rem_ts.end_port,
476                       p->rem_ts.protocol_id);
477   }));
478   /* *INDENT-ON* */
479
480   return 0;
481 }
482
483 /* *INDENT-OFF* */
484 VLIB_CLI_COMMAND (show_ikev2_profile_command, static) = {
485     .path = "show ikev2 profile",
486     .short_help = "show ikev2 profile",
487     .function = show_ikev2_profile_command_fn,
488 };
489 /* *INDENT-ON* */
490
491 static clib_error_t *
492 set_ikev2_local_key_command_fn (vlib_main_t * vm,
493                                 unformat_input_t * input,
494                                 vlib_cli_command_t * cmd)
495 {
496   unformat_input_t _line_input, *line_input = &_line_input;
497   clib_error_t *r = 0;
498   u8 *data = 0;
499
500   if (!unformat_user (input, unformat_line_input, line_input))
501     return 0;
502
503   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
504     {
505       if (unformat (line_input, "%s", &data))
506         {
507           r = ikev2_set_local_key (vm, data);
508           goto done;
509         }
510       else
511         break;
512     }
513
514   r = clib_error_return (0, "parse error: '%U'",
515                          format_unformat_error, line_input);
516
517 done:
518   vec_free (data);
519   unformat_free (line_input);
520   return r;
521 }
522
523 /* *INDENT-OFF* */
524 VLIB_CLI_COMMAND (set_ikev2_local_key_command, static) = {
525     .path = "set ikev2 local key",
526     .short_help =
527     "set ikev2 local key <file>",
528     .function = set_ikev2_local_key_command_fn,
529 };
530 /* *INDENT-ON* */
531
532
533 static clib_error_t *
534 ikev2_initiate_command_fn (vlib_main_t * vm,
535                            unformat_input_t * input, vlib_cli_command_t * cmd)
536 {
537   unformat_input_t _line_input, *line_input = &_line_input;
538   clib_error_t *r = 0;
539   u8 *name = 0;
540   u32 tmp1;
541   u64 tmp2;
542
543   const char *valid_chars = "a-zA-Z0-9_";
544
545   if (!unformat_user (input, unformat_line_input, line_input))
546     return 0;
547
548   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
549     {
550       if (unformat
551           (line_input, "sa-init %U", unformat_token, valid_chars, &name))
552         {
553           r = ikev2_initiate_sa_init (vm, name);
554           goto done;
555         }
556       else if (unformat (line_input, "del-child-sa %x", &tmp1))
557         {
558           r = ikev2_initiate_delete_child_sa (vm, tmp1);
559           goto done;
560         }
561       else if (unformat (line_input, "del-sa %lx", &tmp2))
562         {
563           r = ikev2_initiate_delete_ike_sa (vm, tmp2);
564           goto done;
565         }
566       else if (unformat (line_input, "rekey-child-sa %x", &tmp1))
567         {
568           r = ikev2_initiate_rekey_child_sa (vm, tmp1);
569           goto done;
570         }
571       else
572         break;
573     }
574
575   r = clib_error_return (0, "parse error: '%U'",
576                          format_unformat_error, line_input);
577
578 done:
579   vec_free (name);
580   unformat_free (line_input);
581   return r;
582 }
583
584 /* *INDENT-OFF* */
585 VLIB_CLI_COMMAND (ikev2_initiate_command, static) = {
586     .path = "ikev2 initiate",
587     .short_help =
588         "ikev2 initiate sa-init <profile id>\n"
589         "ikev2 initiate del-child-sa <child sa ispi>\n"
590         "ikev2 initiate del-sa <sa ispi>\n"
591         "ikev2 initiate rekey-child-sa <profile id> <child sa ispi>\n",
592     .function = ikev2_initiate_command_fn,
593 };
594 /* *INDENT-ON* */
595
596 void
597 ikev2_cli_reference (void)
598 {
599 }
600
601 static clib_error_t *
602 ikev2_set_log_level_command_fn (vlib_main_t * vm,
603                                 unformat_input_t * input,
604                                 vlib_cli_command_t * cmd)
605 {
606   unformat_input_t _line_input, *line_input = &_line_input;
607   u8 log_level = IKEV2_LOG_NONE;
608   clib_error_t *error = 0;
609
610   /* Get a line of input. */
611   if (!unformat_user (input, unformat_line_input, line_input))
612     return 0;
613
614   if (!unformat (line_input, "%d", &log_level))
615     {
616       error = clib_error_return (0, "unknown input '%U'",
617                                  format_unformat_error, line_input);
618       goto done;
619     }
620   int rc = ikev2_set_log_level (log_level);
621   if (rc < 0)
622     error = clib_error_return (0, "setting log level failed!");
623
624 done:
625   unformat_free (line_input);
626   return error;
627 }
628
629 /* *INDENT-OFF* */
630 VLIB_CLI_COMMAND (ikev2_set_log_level_command, static) = {
631   .path = "ikev2 set logging level",
632   .function = ikev2_set_log_level_command_fn,
633   .short_help = "ikev2 set logging level <0-5>",
634 };
635 /* *INDENT-ON* */
636
637 /*
638  * fd.io coding-style-patch-verification: ON
639  *
640  * Local Variables:
641  * eval: (c-set-style "gnu")
642  * End:
643  */