15 #include <mactime/mactime.api_enum.h> 16 #include <mactime/mactime.api_types.h> 56 #define foreach_mactime_api_msg \ 57 _(MACTIME_DUMP_REPLY, mactime_dump_reply) \ 58 _(MACTIME_DETAILS, mactime_details) 64 i32 retval = clib_net_to_host_u32 (mp->
retval);
89 memset (dev, 0,
sizeof (*dev));
102 for (i = 0; i < clib_net_to_host_u32 (mp->
nranges); i++)
110 #define vl_print(handle, ...) fformat(handle, __VA_ARGS__) 114 #define vl_api_version(n,v) static u32 api_version = v; 115 #include <mactime/mactime.api.h> 116 #undef vl_api_version 125 u8 *msg_base_lookup_name;
133 msg_base_lookup_name =
format (0,
"mactime_%08x%c", api_version, 0);
136 ((
char *) msg_base_lookup_name);
144 vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base), \ 146 vl_api_##n##_t_handler, \ 148 vl_api_##n##_t_endian, \ 149 vl_api_##n##_t_print, \ 150 sizeof(vl_api_##n##_t), 1); 161 u32 deadman_counter = 1000;
165 memset (mp, 0,
sizeof (*mp));
167 clib_host_to_net_u16 (VL_API_MACTIME_DUMP + mm->
msg_id_base);
176 if (mm->
retval && (mm->
retval != VNET_API_ERROR_NO_CHANGE))
191 int need_update2 = 0;
192 static u32 *pool_indices;
199 vec_add1 (pool_indices, dev->pool_index);
204 if (
vec_len (pool_indices) == 0)
223 for (i = 0; i <
vec_len (pool_indices); i++)
225 u32 index = pool_indices[
i];
231 for (j = 0; j <
vec_len (counters_by_thread); j++)
258 for (i = 0; i <
vec_len (pool_indices); i++)
260 u32 index = pool_indices[
i];
266 for (j = 0; j <
vec_len (counters_by_thread); j++)
282 u8 *
a = va_arg (*args,
u8 *);
284 return format (s,
"%02x:%02x:%02x:%02x:%02x:%02x",
285 a[0], a[1], a[2], a[3], a[4], a[5]);
292 int width = va_arg (*va,
int);
298 fmt =
format (0,
"%%%d.3f%%s%c", width, 0);
300 fmt =
format (0,
"%%.3f%%s%c", 0);
302 if (nbytes > (1024ULL * 1024ULL * 1024ULL))
304 nbytes_f64 = ((
f64) nbytes) / (1024.0 * 1024.0 * 1024.0);
307 else if (nbytes > (1024ULL * 1024ULL))
309 nbytes_f64 = ((
f64) nbytes) / (1024.0 * 1024.0);
312 else if (nbytes > 1024ULL)
314 nbytes_f64 = ((
f64) nbytes) / (1024.0);
319 nbytes_f64 = (
f64) nbytes;
323 s =
format (s, (
char *) fmt, nbytes_f64, suffix);
333 int verbose = va_arg (*args,
int);
334 int current_status = 99;
342 s =
format (s,
"%-15s %5s %18s %14s %10s %11s %13s",
343 "Device Name",
"Index",
"Addresses",
"Status",
344 "AllowPkt",
"AllowByte",
"DropPkt");
363 s =
format (s,
" Range %d: %U - %U\n", j,
367 if (now >= start0 && now <= end0)
377 s =
format (s,
" Time in range %d:", j);
378 s =
format (s,
" %U - %U\n",
386 s =
format (s,
" No range match.\n");
400 switch (current_status)
403 status_string =
"static drop";
406 status_string =
"static allow";
409 status_string =
"dynamic drop";
412 status_string =
"dynamic allow";
415 status_string =
"d-quota inact";
418 status_string =
"d-quota activ";
421 status_string =
"code bug!";
425 s =
format (s,
"%-15s %5d %18s %14s %10lld %U %13lld\n",
435 s =
format (s,
"%-59s %s%U %s%U",
" ",
"Quota ",
452 fformat (stdout,
"%U", format_device, dev, 0 );
467 fformat (stderr,
"vpp api client connect error\n");
473 fformat (stderr,
"stat segment connect error");
#define MACTIME_DEVICE_FLAG_DYNAMIC_ALLOW_QUOTA
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void stat_segment_access_start(stat_segment_access_t *sa, stat_client_main_t *sm)
int vl_client_connect_to_vlib(const char *svm_name, const char *client_name, int rx_queue_size)
int stat_segment_connect(const char *socket_name)
static void print_device_table(mt_main_t *mm)
stat_segment_directory_entry_t * directory_vector
Fixed length block allocator.
int my_client_index
All VLIB-side message handlers use my_client_index to identify the queue / client.
#define clib_memcpy_fast(a, b, c)
stat_client_main_t stat_client_main
#define MACTIME_DEVICE_FLAG_DYNAMIC_ALLOW
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Combined counter to hold both packets and byte differences.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
mactime table entry details
#define hash_set_mem(h, key, value)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
void * vl_msg_api_alloc(int nbytes)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
svm_queue_t * vl_input_queue
stat_segment_shared_header_t * shared_header
static void unix_sleep(f64 dt)
static void scrape_stats_segment(mt_main_t *mm)
clib_timebase_range_t * ranges
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vlib_counter_t * drop_counters
static void * stat_segment_pointer(void *start, uint64_t offset)
static f64 clib_timebase_now(clib_timebase_t *tb)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static int connect_to_vpp(char *name)
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
format_function_t format_clib_timebase_time
#define MACTIME_DEVICE_FLAG_STATIC_ALLOW
#define hash_create_string(elts, value_bytes)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
counter_t packets
packet counter
u32 client_index
client index, from api_main
static u8 * format_mac_address(u8 *s, va_list *args)
int main(int argc, char **argv)
vl_api_mac_address_t mac_address
vl_api_mactime_time_range_t ranges[nranges]
u32 my_table_epoch
to suppress dump if no changes
#define MACTIME_DEVICE_FLAG_DYNAMIC_DROP
static u8 * format_bytes_with_width(u8 *s, va_list *va)
u16 vl_client_get_first_plugin_msg_id(const char *plugin_name)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
stat_client_main_t * stat_client_main
#define foreach_mactime_api_msg
uword * device_by_device_name
void clib_time_init(clib_time_t *c)
API main structure, used by both vpp and binary API clients.
void * clib_mem_init(void *heap, uword size)
dump mactime table reply Includes the vpp table epoch, needed to optimize API traffic ...
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
static u8 * format_device(u8 *s, va_list *args)
f64 clib_timebase_find_sunday_midnight(f64 start_time)
static void vl_api_mactime_details_t_handler(vl_api_mactime_details_t *mp)
svm_queue_t * vl_input_queue
vlib_counter_t * allow_counters
uint32_t * stat_segment_ls(uint8_t **patterns)
void clib_timebase_init(clib_timebase_t *tb, i32 timezone_offset_in_hours, clib_timebase_daylight_time_t daylight_type, clib_time_t *clib_time)
#define MACTIME_DEVICE_FLAG_STATIC_DROP
Always drop packets from this device.
static void dump_mactime_table(mt_main_t *mm)
counter_t bytes
byte counter
static bool stat_segment_access_end(stat_segment_access_t *sa, stat_client_main_t *sm)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
mactime_device_t * devices
struct _svm_queue svm_queue_t
#define hash_get_mem(h, key)
static api_main_t * vlibapi_get_main(void)
API common definitions See api_doc.md for more info.
volatile u32 result_ready
static void vl_api_mactime_dump_reply_t_handler(vl_api_mactime_dump_reply_t *mp)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".