2 * Copyright (c) 2015 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef __included_vat_h__
16 #define __included_vat_h__
21 #include <sys/types.h>
22 #include <sys/socket.h>
24 #include <vppinfra/clib.h>
25 #include <vppinfra/format.h>
26 #include <vppinfra/error.h>
27 #include <vppinfra/elog.h>
28 #include <vppinfra/time.h>
29 #include <vppinfra/macros.h>
30 #include <vppinfra/socket.h>
31 #include <vnet/vnet.h>
32 #include <vlib/vlib.h>
33 #include <vlib/unix/unix.h>
34 #include <vlibapi/api.h>
35 #include <vlibmemory/api.h>
37 #include "vat/json_format.h"
39 #include <vlib/vlib.h>
46 * Subinterface ID. A number 0-N to uniquely identify this
47 * subinterface under the super interface
51 /* Number of tags 0-2 */
52 u8 sub_number_of_tags;
53 u16 sub_outer_vlan_id;
54 u16 sub_inner_vlan_id;
64 /* 0 = dot1q, 1=dot1ad */
66 u16 sub_exact_match:1;
68 u16 sub_outer_vlan_id_any:1;
69 u16 sub_inner_vlan_id_any:1;
73 /* vlan tag rewrite */
78 } sw_interface_subif_t;
84 } ip_address_details_t;
89 ip_address_details_t *addr;
96 } interface_counter_t;
100 struct in_addr address;
108 struct in6_addr address;
116 struct in_addr address;
124 struct in6_addr address;
130 struct vat_registered_features_t;
134 /* vpe input queue */
135 svm_queue_t *vl_input_queue;
137 /* interface name table */
138 uword *sw_if_index_by_interface_name;
140 /* subinterface table */
141 sw_interface_subif_t *sw_if_subif_table;
143 /* Graph node table */
144 uword *graph_node_index_by_name;
145 vlib_node_t ***graph_nodes;
148 ip_details_t *ip_details_by_sw_if_index[2];
150 /* sw_if_index of currently processed interface */
151 u32 current_sw_if_index;
153 /* remember that we are dumping ipv6 */
157 uword *function_by_name;
163 clib_macro_main_t macro_main;
165 /* Errors by number */
166 uword *error_string_by_error_number;
168 /* Main thread can spin (w/ timeout) here if needed */
171 volatile u32 result_ready;
173 volatile u32 sw_if_index;
174 volatile u8 *shmem_result;
177 /* our client index */
179 int client_index_invalid;
181 /* Time is of the essence... */
182 clib_time_t clib_time;
184 /* Unwind (so we can quit) */
187 volatile int do_exit;
189 /* temporary parse buffer */
190 unformat_input_t *input;
195 /* stdio input / output FILEs */
198 u32 input_line_number;
200 /* exec mode toggle */
203 /* Regenerate the interface table */
204 volatile int regenerate_interface_table;
206 /* flag for JSON output format */
209 /* flag for interface event display */
210 u8 interface_event_display;
212 /* JSON tree used in composing dump api call results */
213 vat_json_node_t json_tree;
216 u64 **simple_interface_counters;
217 interface_counter_t **combined_interface_counters;
218 ip4_fib_counter_t **ip4_fib_counters;
219 u32 *ip4_fib_counters_vrf_id_by_index;
220 ip6_fib_counter_t **ip6_fib_counters;
221 u32 *ip6_fib_counters_vrf_id_by_index;
222 ip4_nbr_counter_t **ip4_nbr_counters;
223 ip6_nbr_counter_t **ip6_nbr_counters;
225 ssvm_private_t stat_segment;
226 clib_spinlock_t *stat_segment_lockp;
228 socket_client_main_t *socket_client_main;
231 elog_main_t elog_main;
233 struct vat_registered_features_t *feature_function_registrations;
236 vlib_main_t *vlib_main;
239 extern vat_main_t vat_main;
241 void vat_suspend (vlib_main_t * vm, f64 interval);
242 f64 vat_time_now (vat_main_t * vam);
243 void errmsg (char *fmt, ...);
244 void vat_api_hookup (vat_main_t * vam);
245 int api_sw_interface_dump (vat_main_t * vam);
246 void do_one_file (vat_main_t * vam);
247 int exec (vat_main_t * vam);
249 /* Plugin API library functions */
250 extern char *vat_plugin_path;
251 extern char *vat_plugin_name_filter;
252 void vat_plugin_api_reference (void);
253 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
254 uword unformat_ip4_address (unformat_input_t * input, va_list * args);
255 uword unformat_ethernet_address (unformat_input_t * input, va_list * args);
256 uword unformat_ethernet_type_host_byte_order (unformat_input_t * input,
258 uword unformat_ip6_address (unformat_input_t * input, va_list * args);
259 u8 *format_ip4_address (u8 * s, va_list * args);
260 u8 *format_ip6_address (u8 * s, va_list * args);
261 u8 *format_ip46_address (u8 * s, va_list * args);
262 u8 *format_ethernet_address (u8 * s, va_list * args);
264 int vat_socket_connect (vat_main_t * vam);
266 #if VPP_API_TEST_BUILTIN
267 #define print api_cli_output
268 void api_cli_output (void *, const char *fmt, ...);
270 #define print fformat_append_cr
271 void fformat_append_cr (FILE *, const char *fmt, ...);
275 typedef clib_error_t *(vat_feature_function_t) (vat_main_t * vam);
276 typedef struct vat_registered_features_t
278 vat_feature_function_t *function;
279 struct vat_registered_features_t *next;
280 } vat_registered_features_t;
283 #define VAT_REGISTER_FEATURE_FUNCTION(x) \
284 vat_registered_features_t _vat_feature_function_##x; \
285 static void __vlib_add_config_function_##x (void) \
286 __attribute__((__constructor__)) ; \
287 static void __vlib_add_config_function_##x (void) \
289 vat_main_t * vam = &vat_main; \
290 _vat_feature_function_##x.next = vam->feature_function_registrations; \
291 vam->feature_function_registrations = &_vat_feature_function_##x; \
293 vat_registered_features_t _vat_feature_function_##x = \
299 #endif /* __included_vat_h__ */
302 * fd.io coding-style-patch-verification: ON
305 * eval: (c-set-style "gnu")