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/time.h>
28 #include <vppinfra/macros.h>
29 #include <vppinfra/socket.h>
30 #include <vnet/vnet.h>
31 #include <vlib/vlib.h>
32 #include <vlib/unix/unix.h>
33 #include <vlibapi/api.h>
34 #include <vlibmemory/api.h>
36 #include "vat/json_format.h"
38 #include <vlib/vlib.h>
45 * Subinterface ID. A number 0-N to uniquely identify this
46 * subinterface under the super interface
50 /* Number of tags 0-2 */
51 u8 sub_number_of_tags;
52 u16 sub_outer_vlan_id;
53 u16 sub_inner_vlan_id;
63 /* 0 = dot1q, 1=dot1ad */
65 u16 sub_exact_match:1;
67 u16 sub_outer_vlan_id_any:1;
68 u16 sub_inner_vlan_id_any:1;
72 /* vlan tag rewrite */
77 } sw_interface_subif_t;
83 } ip_address_details_t;
88 ip_address_details_t *addr;
95 } interface_counter_t;
99 struct in_addr address;
107 struct in6_addr address;
115 struct in_addr address;
123 struct in6_addr address;
131 /* vpe input queue */
132 svm_queue_t *vl_input_queue;
134 /* interface name table */
135 uword *sw_if_index_by_interface_name;
137 /* subinterface table */
138 sw_interface_subif_t *sw_if_subif_table;
140 /* Graph node table */
141 uword *graph_node_index_by_name;
142 vlib_node_t ***graph_nodes;
145 ip_details_t *ip_details_by_sw_if_index[2];
147 /* sw_if_index of currently processed interface */
148 u32 current_sw_if_index;
150 /* remember that we are dumping ipv6 */
154 uword *function_by_name;
160 macro_main_t macro_main;
162 /* Errors by number */
163 uword *error_string_by_error_number;
165 /* Main thread can spin (w/ timeout) here if needed */
168 volatile u32 result_ready;
170 volatile u32 sw_if_index;
171 volatile u8 *shmem_result;
174 /* our client index */
176 int client_index_invalid;
178 /* Time is of the essence... */
179 clib_time_t clib_time;
181 /* Unwind (so we can quit) */
184 volatile int do_exit;
186 /* temporary parse buffer */
187 unformat_input_t *input;
192 /* stdio input / output FILEs */
195 u32 input_line_number;
197 /* exec mode toggle */
200 /* Regenerate the interface table */
201 volatile int regenerate_interface_table;
203 /* flag for JSON output format */
206 /* flag for interface event display */
207 u8 interface_event_display;
209 /* JSON tree used in composing dump api call results */
210 vat_json_node_t json_tree;
213 u64 **simple_interface_counters;
214 interface_counter_t **combined_interface_counters;
215 ip4_fib_counter_t **ip4_fib_counters;
216 u32 *ip4_fib_counters_vrf_id_by_index;
217 ip6_fib_counter_t **ip6_fib_counters;
218 u32 *ip6_fib_counters_vrf_id_by_index;
219 ip4_nbr_counter_t **ip4_nbr_counters;
220 ip6_nbr_counter_t **ip6_nbr_counters;
222 ssvm_private_t stat_segment;
223 clib_spinlock_t *stat_segment_lockp;
225 socket_client_main_t *socket_client_main;
229 vlib_main_t *vlib_main;
232 extern vat_main_t vat_main;
234 void vat_suspend (vlib_main_t * vm, f64 interval);
235 f64 vat_time_now (vat_main_t * vam);
236 void errmsg (char *fmt, ...);
237 void vat_api_hookup (vat_main_t * vam);
238 int api_sw_interface_dump (vat_main_t * vam);
239 void do_one_file (vat_main_t * vam);
240 int exec (vat_main_t * vam);
242 /* Plugin API library functions */
243 char *vat_plugin_path;
244 char *vat_plugin_name_filter;
245 void vat_plugin_api_reference (void);
246 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
247 uword unformat_ip4_address (unformat_input_t * input, va_list * args);
248 uword unformat_ethernet_address (unformat_input_t * input, va_list * args);
249 uword unformat_ethernet_type_host_byte_order (unformat_input_t * input,
251 uword unformat_ip6_address (unformat_input_t * input, va_list * args);
252 u8 *format_ip4_address (u8 * s, va_list * args);
253 u8 *format_ip6_address (u8 * s, va_list * args);
254 u8 *format_ip46_address (u8 * s, va_list * args);
255 u8 *format_ethernet_address (u8 * s, va_list * args);
257 int vat_socket_connect (vat_main_t * vam);
259 #if VPP_API_TEST_BUILTIN
260 #define print api_cli_output
261 void api_cli_output (void *, const char *fmt, ...);
263 #define print fformat_append_cr
264 void fformat_append_cr (FILE *, const char *fmt, ...);
267 #endif /* __included_vat_h__ */
270 * fd.io coding-style-patch-verification: ON
273 * eval: (c-set-style "gnu")