2 * flowprobe.c - skeleton vpp-api-test plug-in
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <vlibapi/api.h>
19 #include <vlibmemory/api.h>
20 #include <vppinfra/error.h>
21 #include <flowprobe/flowprobe.h>
23 #define __plugin_msg_base flowprobe_test_main.msg_id_base
24 #include <vlibapi/vat_helper_macros.h>
27 * @file vpp_api_test plugin
30 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
32 /* Declare message IDs */
33 #include <flowprobe/flowprobe.api_enum.h>
34 #include <flowprobe/flowprobe.api_types.h>
38 /** API message ID base */
40 /** vat_main_t pointer */
42 } flowprobe_test_main_t;
44 flowprobe_test_main_t flowprobe_test_main;
47 api_flowprobe_tx_interface_add_del (vat_main_t * vam)
49 unformat_input_t *i = vam->input;
50 int enable_disable = 1;
51 u8 which = FLOW_VARIANT_IP4;
53 vl_api_flowprobe_tx_interface_add_del_t *mp;
56 /* Parse args required to build the message */
57 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
59 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
61 else if (unformat (i, "sw_if_index %d", &sw_if_index))
63 else if (unformat (i, "disable"))
65 else if (unformat (i, "ip4"))
66 which = FLOW_VARIANT_IP4;
67 else if (unformat (i, "ip6"))
68 which = FLOW_VARIANT_IP6;
69 else if (unformat (i, "l2"))
70 which = FLOW_VARIANT_L2;
75 if (sw_if_index == ~0)
77 errmsg ("missing interface name / explicit sw_if_index number \n");
81 /* Construct the API message */
82 M (FLOWPROBE_TX_INTERFACE_ADD_DEL, mp);
83 mp->sw_if_index = ntohl (sw_if_index);
84 mp->is_add = enable_disable;
90 /* Wait for a reply... */
96 api_flowprobe_params (vat_main_t * vam)
98 unformat_input_t *i = vam->input;
99 u32 active_timer = ~0;
100 u32 passive_timer = ~0;
101 vl_api_flowprobe_params_t *mp;
105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
107 if (unformat (i, "active %d", &active_timer))
109 else if (unformat (i, "passive %d", &passive_timer))
111 else if (unformat (i, "record"))
112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
114 if (unformat (i, "l2"))
115 record_flags |= FLOWPROBE_RECORD_FLAG_L2;
116 else if (unformat (i, "l3"))
117 record_flags |= FLOWPROBE_RECORD_FLAG_L3;
118 else if (unformat (i, "l4"))
119 record_flags |= FLOWPROBE_RECORD_FLAG_L4;
127 if (passive_timer > 0 && active_timer > passive_timer)
129 errmsg ("Passive timer has to be greater than active one...\n");
133 /* Construct the API message */
134 M (FLOWPROBE_PARAMS, mp);
135 mp->record_flags = record_flags;
136 mp->active_timer = ntohl (active_timer);
137 mp->passive_timer = ntohl (passive_timer);
142 /* Wait for a reply... */
149 * List of messages that the api test plugin sends,
150 * and that the data plane plugin processes
152 #include <flowprobe/flowprobe.api_test.c>
155 * fd.io coding-style-patch-verification: ON
158 * eval: (c-set-style "gnu")