FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
cli.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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 
16 #include <vlib/vlib.h>
17 #include <vnet/vnet.h>
18 #include <vppinfra/error.h>
19 #include <vnet/ethernet/ethernet.h>
20 #include <vnet/feature/feature.h>
21 #include <vnet/gso/gso.h>
22 
23 static clib_error_t *
25  unformat_input_t * input,
26  vlib_cli_command_t * cmd)
27 {
28  vnet_main_t *vnm = vnet_get_main ();
29  unformat_input_t _line_input, *line_input = &_line_input;
30  clib_error_t *error = 0;
31 
32  u32 sw_if_index = ~0;
33  u8 enable = 0;
34 
35  /* Get a line of input. */
36  if (!unformat_user (input, unformat_line_input, line_input))
37  return 0;
38 
39  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
40  {
41  if (unformat
42  (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
43  ;
44  else if (unformat (line_input, "enable"))
45  enable = 1;
46  else if (unformat (line_input, "disable"))
47  enable = 0;
48  else
49  {
50  error = unformat_parse_error (line_input);
51  goto done;
52  }
53  }
54 
55  if (sw_if_index == ~0)
56  {
57  error = clib_error_return (0, "Interface not specified...");
58  goto done;
59  }
61 
62  switch (rv)
63  {
64  case VNET_API_ERROR_INVALID_VALUE:
65  error = clib_error_return (0, "interface type is not hardware");
66  break;
67  case VNET_API_ERROR_FEATURE_DISABLED:
68  error = clib_error_return (0, "interface should be ethernet interface");
69  break;
70  default:
71  ;
72  }
73 
74 done:
75  unformat_free (line_input);
76  return error;
77 }
78 
79 /* *INDENT-OFF* */
81  .path = "set interface feature gso",
82  .short_help = "set interface feature gso <intfc> [enable | disable]",
84 };
85 /* *INDENT-ON* */
86 
87 /*
88  * fd.io coding-style-patch-verification: ON
89  *
90  * Local Variables:
91  * eval: (c-set-style "gnu")
92  * End:
93  */
vlib.h
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
unformat_line_input
unformat_function_t unformat_line_input
Definition: format.h:275
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
unformat_parse_error
#define unformat_parse_error(input)
Definition: format.h:261
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
unformat_input_t
struct _unformat_input_t unformat_input_t
ethernet.h
error
Definition: cJSON.c:88
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
error.h
feature.h
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vnet_sw_interface_gso_enable_disable
int vnet_sw_interface_gso_enable_disable(u32 sw_if_index, u8 enable)
Definition: gso.c:27
gso.h
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
vnet_main_t
Definition: vnet.h:76
set_interface_feature_gso_command
static vlib_cli_command_t set_interface_feature_gso_command
(constructor) VLIB_CLI_COMMAND (set_interface_feature_gso_command)
Definition: cli.c:80
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:462
u32
unsigned int u32
Definition: types.h:88
vlib_main_t
Definition: main.h:102
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
rv
int __clib_unused rv
Definition: application.c:491
vnet.h
vlib_cli_command_t
Definition: cli.h:92
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
set_interface_feature_gso_command_fn
static clib_error_t * set_interface_feature_gso_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:24