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__
20 #include <vppinfra/clib.h>
21 #include <vppinfra/format.h>
22 #include <vppinfra/error.h>
23 #include <vppinfra/time.h>
24 #include <vppinfra/macros.h>
25 #include <vnet/vnet.h>
26 #include <vlib/vlib.h>
27 #include <vlib/unix/unix.h>
28 #include <vlibapi/api.h>
29 #include <vlibmemory/api.h>
31 #include "vat/json_format.h"
33 #include <vlib/vlib.h>
40 * Subinterface ID. A number 0-N to uniquely identify this
41 * subinterface under the super interface
45 /* 0 = dot1q, 1=dot1ad */
48 /* Number of tags 0-2 */
49 u8 sub_number_of_tags;
50 u16 sub_outer_vlan_id;
51 u16 sub_inner_vlan_id;
54 u8 sub_outer_vlan_id_any;
55 u8 sub_inner_vlan_id_any;
57 /* vlan tag rewrite */
62 } sw_interface_subif_t;
68 } ip_address_details_t;
73 ip_address_details_t *addr;
80 } interface_counter_t;
84 struct in_addr address;
92 struct in6_addr address;
100 /* vpe input queue */
101 unix_shared_memory_queue_t *vl_input_queue;
103 /* interface name table */
104 uword *sw_if_index_by_interface_name;
106 /* subinterface table */
107 sw_interface_subif_t *sw_if_subif_table;
109 /* Graph node table */
110 uword *graph_node_index_by_name;
111 vlib_node_t **graph_nodes;
114 ip_details_t *ip_details_by_sw_if_index[2];
116 /* sw_if_index of currently processed interface */
117 u32 current_sw_if_index;
119 /* remember that we are dumping ipv6 */
123 uword *function_by_name;
129 macro_main_t macro_main;
131 /* Errors by number */
132 uword *error_string_by_error_number;
135 /* Main thread can spin (w/ timeout) here if needed */
138 volatile u32 result_ready;
140 volatile u32 sw_if_index;
141 volatile u8 *shmem_result;
142 volatile u8 *cmd_reply;
144 /* our client index */
147 /* Time is of the essence... */
148 clib_time_t clib_time;
150 /* Unwind (so we can quit) */
153 volatile int do_exit;
155 /* temporary parse buffer */
156 unformat_input_t *input;
161 /* stdio input / output FILEs */
164 u32 input_line_number;
166 /* exec mode toggle */
169 /* Regenerate the interface table */
170 volatile int regenerate_interface_table;
172 /* flag for JSON output format */
175 /* flag for interface event display */
176 u8 interface_event_display;
178 /* JSON tree used in composing dump api call results */
179 vat_json_node_t json_tree;
182 u64 **simple_interface_counters;
183 interface_counter_t **combined_interface_counters;
184 ip4_fib_counter_t **ip4_fib_counters;
185 u32 *ip4_fib_counters_vrf_id_by_index;
186 ip6_fib_counter_t **ip6_fib_counters;
187 u32 *ip6_fib_counters_vrf_id_by_index;
190 vlib_main_t *vlib_main;
196 vat_time_now (vat_main_t * vam)
198 #if VPP_API_TEST_BUILTIN
199 return vlib_time_now (vam->vlib_main);
201 return clib_time_now (&vam->clib_time);
205 #if VPP_API_TEST_BUILTIN
206 #define errmsg(fmt,args...) \
208 vat_main_t *__vam = &vat_main; \
209 vlib_cli_output (__vam->vlib_main, fmt, ##args); \
212 #define errmsg(fmt,args...) \
214 vat_main_t *__vam = &vat_main; \
215 if(__vam->ifp != stdin) \
216 fformat(__vam->ofp,"%s(%d): \n", __vam->current_file, \
217 __vam->input_line_number); \
218 fformat(__vam->ofp, fmt "\n", ##args); \
219 fflush(__vam->ofp); \
223 void vat_api_hookup (vat_main_t * vam);
224 int api_sw_interface_dump (vat_main_t * vam);
225 void do_one_file (vat_main_t * vam);
226 int exec (vat_main_t * vam);
228 /* Plugin API library functions */
229 char *vat_plugin_path;
230 char *vat_plugin_name_filter;
231 void vat_plugin_api_reference (void);
232 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
233 uword unformat_ip4_address (unformat_input_t * input, va_list * args);
234 uword unformat_ethernet_address (unformat_input_t * input, va_list * args);
235 uword unformat_ethernet_type_host_byte_order (unformat_input_t * input,
237 uword unformat_ip6_address (unformat_input_t * input, va_list * args);
238 u8 *format_ip4_address (u8 * s, va_list * args);
239 u8 *format_ethernet_address (u8 * s, va_list * args);
241 #if VPP_API_TEST_BUILTIN
242 #define print api_cli_output
243 void api_cli_output (void *, const char *fmt, ...);
245 #define print fformat_append_cr
246 void fformat_append_cr (FILE *, const char *fmt, ...);
249 #endif /* __included_vat_h__ */
252 * fd.io coding-style-patch-verification: ON
255 * eval: (c-set-style "gnu")