1 // Copyright (c) 2018 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_stat_client_wrapper_h
16 #define included_stat_client_wrapper_h
21 #include <arpa/inet.h>
23 #include <vpp-api/client/stat_client.h> // VPP has to be installed!
25 // The stat_client.h defines its version using two macros:
26 // STAT_VERSION_MAJOR - for major version
27 // STAT_VERSION_MINOR - for minor version
28 // both were introduced in VPP 19.04 (not on release, later on stable/1904)
29 // https://github.com/FDio/vpp/commit/1cb333cdf5ce26557233c5bdb5a18738cb6e1e2c
31 // Name vector directory type was introduced in VPP 19.04
32 #if STAT_VERSION_MAJOR >= 1 && STAT_VERSION_MINOR >= 1
33 #define SUPPORTS_NAME_VECTOR // VPP 19.04 is required!
37 govpp_stat_connect(char *socket_name)
39 return stat_segment_connect(socket_name);
43 govpp_stat_disconnect()
45 stat_segment_disconnect();
49 govpp_stat_segment_ls(uint8_t **pattern)
51 return stat_segment_ls(pattern);
55 govpp_stat_segment_vec_len(void *vec)
57 return stat_segment_vec_len(vec);
61 govpp_stat_segment_vec_free(void *vec)
63 stat_segment_vec_free(vec);
67 govpp_stat_segment_dir_index_to_name(uint32_t *dir, uint32_t index)
69 return stat_segment_index_to_name(dir[index]);
72 static stat_segment_data_t*
73 govpp_stat_segment_dump(uint32_t *counter_vec)
75 return stat_segment_dump(counter_vec);
78 static stat_segment_data_t
79 govpp_stat_segment_dump_index(stat_segment_data_t *data, int index)
85 govpp_stat_segment_data_type(stat_segment_data_t *data)
91 govpp_stat_segment_data_get_scalar_value(stat_segment_data_t *data)
93 return data->scalar_value;
97 govpp_stat_segment_data_get_error_value(stat_segment_data_t *data)
99 return data->error_value;
103 govpp_stat_segment_data_get_simple_counter(stat_segment_data_t *data)
105 return data->simple_counter_vec;
109 govpp_stat_segment_data_get_simple_counter_index(stat_segment_data_t *data, int index)
111 return data->simple_counter_vec[index];
115 govpp_stat_segment_data_get_simple_counter_index_value(stat_segment_data_t *data, int index, int index2)
117 return data->simple_counter_vec[index][index2];
120 static vlib_counter_t**
121 govpp_stat_segment_data_get_combined_counter(stat_segment_data_t *data)
123 return data->combined_counter_vec;
126 static vlib_counter_t*
127 govpp_stat_segment_data_get_combined_counter_index(stat_segment_data_t *data, int index)
129 return data->combined_counter_vec[index];
133 govpp_stat_segment_data_get_combined_counter_index_packets(stat_segment_data_t *data, int index, int index2)
135 return data->combined_counter_vec[index][index2].packets;
139 govpp_stat_segment_data_get_combined_counter_index_bytes(stat_segment_data_t *data, int index, int index2)
141 return data->combined_counter_vec[index][index2].bytes;
145 govpp_stat_segment_data_get_name_vector(stat_segment_data_t *data)
147 #ifdef SUPPORTS_NAME_VECTOR
148 return data->name_vector; // VPP 19.04 is required!
155 govpp_stat_segment_data_get_name_vector_index(stat_segment_data_t *data, int index)
157 #ifdef SUPPORTS_NAME_VECTOR
158 return data->name_vector[index]; // VPP 19.04 is required!
165 govpp_stat_segment_data_free(stat_segment_data_t *data)
167 stat_segment_data_free(data);
171 govpp_stat_segment_string_vector(uint8_t ** string_vector, char *string)
173 return stat_segment_string_vector(string_vector, string);
176 #endif /* included_stat_client_wrapper_h */