Line data Source code
1 : /* 2 : * ct6.c - skeleton vpp-api-test plug-in 3 : * 4 : * Copyright (c) <current-year> <your-organization> 5 : * Licensed under the Apache License, Version 2.0 (the "License"); 6 : * you may not use this file except in compliance with the License. 7 : * You may obtain a copy of the License at: 8 : * 9 : * http://www.apache.org/licenses/LICENSE-2.0 10 : * 11 : * Unless required by applicable law or agreed to in writing, software 12 : * distributed under the License is distributed on an "AS IS" BASIS, 13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 : * See the License for the specific language governing permissions and 15 : * limitations under the License. 16 : */ 17 : #include <vat/vat.h> 18 : #include <vlibapi/api.h> 19 : #include <vlibmemory/api.h> 20 : #include <vppinfra/error.h> 21 : 22 : uword unformat_sw_if_index (unformat_input_t * input, va_list * args); 23 : 24 : /* Declare message IDs */ 25 : #include <ct6/ct6.api_enum.h> 26 : #include <ct6/ct6.api_types.h> 27 : 28 : typedef struct 29 : { 30 : /* API message ID base */ 31 : u16 msg_id_base; 32 : vat_main_t *vat_main; 33 : } ct6_test_main_t; 34 : 35 : ct6_test_main_t ct6_test_main; 36 : 37 : #define __plugin_msg_base ct6_test_main.msg_id_base 38 : #include <vlibapi/vat_helper_macros.h> 39 : 40 : static int 41 0 : api_ct6_enable_disable (vat_main_t * vam) 42 : { 43 0 : unformat_input_t *i = vam->input; 44 0 : int enable_disable = 1; 45 0 : u32 sw_if_index = ~0; 46 : vl_api_ct6_enable_disable_t *mp; 47 0 : u32 inside = ~0; 48 : int ret; 49 : 50 : /* Parse args required to build the message */ 51 0 : while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) 52 : { 53 0 : if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index)) 54 : ; 55 0 : else if (unformat (i, "sw_if_index %d", &sw_if_index)) 56 : ; 57 0 : else if (unformat (i, "disable")) 58 0 : enable_disable = 0; 59 0 : else if (unformat (i, "inside") || unformat (i, "in")) 60 0 : inside = 1; 61 0 : else if (unformat (i, "outside") || unformat (i, "out")) 62 0 : inside = 0; 63 : else 64 : break; 65 : } 66 : 67 0 : if (inside == ~0) 68 : { 69 0 : errmsg ("must specify inside or outside"); 70 0 : return -99; 71 : } 72 : 73 0 : if (sw_if_index == ~0) 74 : { 75 0 : errmsg ("missing interface name / explicit sw_if_index number \n"); 76 0 : return -99; 77 : } 78 : 79 : /* Construct the API message */ 80 0 : M (CT6_ENABLE_DISABLE, mp); 81 0 : mp->sw_if_index = ntohl (sw_if_index); 82 0 : mp->enable_disable = enable_disable; 83 0 : mp->is_inside = (u8) inside; 84 : 85 : /* send it... */ 86 0 : S (mp); 87 : 88 : /* Wait for a reply... */ 89 0 : W (ret); 90 0 : return ret; 91 : } 92 : 93 : #include <ct6/ct6.api_test.c> 94 : 95 : /* 96 : * fd.io coding-style-patch-verification: ON 97 : * 98 : * Local Variables: 99 : * eval: (c-set-style "gnu") 100 : * End: 101 : */