subunit is required on centos as well as fedora
[vpp.git] / src / plugins / pppoe / pppoe_cp.c
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2017 Intel and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17
18 #include <pppoe/pppoe.h>
19
20 static clib_error_t *
21 pppoe_add_del_cp_command_fn (vlib_main_t * vm,
22                              unformat_input_t * input,
23                              vlib_cli_command_t * cmd)
24 {
25   unformat_input_t _line_input, *line_input = &_line_input;
26   pppoe_main_t *pem = &pppoe_main;
27   u8 is_add = 1;
28   u8 cp_if_index_set = 0;
29   u32 cp_if_index = 0;
30   clib_error_t *error = NULL;
31
32   /* Get a line of input. */
33   if (!unformat_user (input, unformat_line_input, line_input))
34     return 0;
35
36   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
37     {
38       if (unformat (line_input, "del"))
39         {
40           is_add = 0;
41         }
42       else if (unformat (line_input, "cp-if-index %d", &cp_if_index))
43         cp_if_index_set = 1;
44       else
45         {
46           error = clib_error_return (0, "parse error: '%U'",
47                                      format_unformat_error, line_input);
48           goto done;
49         }
50     }
51
52   if (cp_if_index_set == 0)
53     {
54       error = clib_error_return (0, "cp if index not specified");
55       goto done;
56     }
57
58   if (is_add)
59     {
60       pem->cp_if_index = cp_if_index;
61     }
62   else
63     {
64       pem->cp_if_index = ~0;
65     }
66
67 done:
68   unformat_free (line_input);
69
70   return error;
71 }
72
73 /* *INDENT-OFF* */
74 VLIB_CLI_COMMAND (create_pppoe_cp_cmd, static) =
75 {
76     .path = "create pppoe cp",
77     .short_help = "create pppoe cp if-name <intfc> [del]",
78     .function = pppoe_add_del_cp_command_fn,
79 };
80 /* *INDENT-ON* */
81
82 /*
83  * fd.io coding-style-patch-verification: ON
84  *
85  * Local Variables:
86  * eval: (c-set-style "gnu")
87  * End:
88  */