Line data Source code
1 : /* 2 : * Copyright (c) 2023 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 <tracenode/tracenode.h> 18 : 19 : static clib_error_t * 20 0 : tracenode_feature_cmd_fn (vlib_main_t *vm, unformat_input_t *input, 21 : vlib_cli_command_t *cmd) 22 : { 23 0 : unformat_input_t _line_input, *line_input = &_line_input; 24 0 : u32 sw_if_index = ~0; 25 0 : int enable = 1, is_pcap = 0; 26 : int rv; 27 : 28 : /* Get a line of input. */ 29 0 : if (!unformat_user (input, unformat_line_input, line_input)) 30 0 : return 0; 31 : 32 0 : while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) 33 : { 34 0 : if (unformat (line_input, "disable")) 35 0 : enable = 0; 36 0 : else if (unformat (line_input, "pcap")) 37 0 : is_pcap = 1; 38 0 : else if (unformat (line_input, "%U", unformat_vnet_sw_interface, 39 : vnet_get_main (), &sw_if_index)) 40 : { 41 0 : if (sw_if_index == 0) 42 0 : return clib_error_return (0, "Local interface not supported..."); 43 : } 44 : 45 : else 46 0 : break; 47 : } 48 : 49 0 : if (sw_if_index == ~0) 50 0 : return clib_error_return (0, "Software interface required"); 51 : 52 0 : if ((rv = tracenode_feature_enable_disable (sw_if_index, is_pcap, enable)) != 53 : 0) 54 0 : return clib_error_return ( 55 : 0, "vnet_enable_disable_tracenode_feature returned %d", rv); 56 : 57 0 : return 0; 58 : } 59 : 60 36863 : VLIB_CLI_COMMAND (tracenode_feature, static) = { 61 : .path = "tracenode feature", 62 : .short_help = "tracenode feature <intfc> [disable] [pcap]", 63 : .function = tracenode_feature_cmd_fn, 64 : }; 65 : 66 : /* 67 : * fd.io coding-style-patch-verification: ON 68 : * 69 : * Local Variables: 70 : * eval: (c-set-style "gnu") 71 : * End: 72 : */