14 #include <mactime/mactime.api_types.h> 15 #include <mactime/mactime.api_enum.h> 55 #define foreach_mactime_api_msg \ 56 _(MACTIME_DUMP_REPLY, mactime_dump_reply) \ 57 _(MACTIME_DETAILS, mactime_details) 63 i32 retval = clib_net_to_host_u32 (mp->
retval);
88 memset (dev, 0,
sizeof (*dev));
101 for (i = 0; i < clib_net_to_host_u32 (mp->
nranges); i++)
109 #define vl_print(handle, ...) fformat(handle, __VA_ARGS__) 111 #include <mactime/mactime.api.h> 116 #include <mactime/mactime.api.h> 119 #define vl_api_version(n,v) static u32 api_version = v; 120 #include <mactime/mactime.api.h> 121 #undef vl_api_version 128 u8 *msg_base_lookup_name;
136 msg_base_lookup_name =
format (0,
"mactime_%08x%c", api_version, 0);
139 ((
char *) msg_base_lookup_name);
147 vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base), \ 149 vl_api_##n##_t_handler, \ 151 vl_api_##n##_t_endian, \ 152 vl_api_##n##_t_print, \ 153 sizeof(vl_api_##n##_t), 1); 164 u32 deadman_counter = 1000;
168 memset (mp, 0,
sizeof (*mp));
170 clib_host_to_net_u16 (VL_API_MACTIME_DUMP + mm->
msg_id_base);
179 if (mm->
retval && (mm->
retval != VNET_API_ERROR_NO_CHANGE))
193 int need_update2 = 0;
194 static u32 *pool_indices;
206 if (
vec_len (pool_indices) == 0)
224 for (i = 0; i <
vec_len (pool_indices); i++)
232 for (j = 0; j <
vec_len (counters_by_thread); j++)
257 for (i = 0; i <
vec_len (pool_indices); i++)
265 for (j = 0; j <
vec_len (counters_by_thread); j++)
280 u8 *
a = va_arg (*args,
u8 *);
282 return format (s,
"%02x:%02x:%02x:%02x:%02x:%02x",
283 a[0], a[1], a[2], a[3], a[4], a[5]);
290 int width = va_arg (*va,
int);
296 fmt =
format (0,
"%%%d.3f%%s%c", width, 0);
298 fmt =
format (0,
"%%.3f%%s%c", 0);
300 if (nbytes > (1024ULL * 1024ULL * 1024ULL))
302 nbytes_f64 = ((
f64) nbytes) / (1024.0 * 1024.0 * 1024.0);
305 else if (nbytes > (1024ULL * 1024ULL))
307 nbytes_f64 = ((
f64) nbytes) / (1024.0 * 1024.0);
310 else if (nbytes > 1024ULL)
312 nbytes_f64 = ((
f64) nbytes) / (1024.0);
317 nbytes_f64 = (
f64) nbytes;
321 s =
format (s, (
char *) fmt, nbytes_f64, suffix);
331 int verbose = va_arg (*args,
int);
332 int current_status = 99;
340 s =
format (s,
"%-15s %5s %18s %14s %10s %11s %13s",
341 "Device Name",
"Index",
"Addresses",
"Status",
342 "AllowPkt",
"AllowByte",
"DropPkt");
361 s =
format (s,
" Range %d: %U - %U\n", j,
365 if (now >= start0 && now <= end0)
375 s =
format (s,
" Time in range %d:", j);
376 s =
format (s,
" %U - %U\n",
384 s =
format (s,
" No range match.\n");
398 switch (current_status)
401 status_string =
"static drop";
404 status_string =
"static allow";
407 status_string =
"dynamic drop";
410 status_string =
"dynamic allow";
413 status_string =
"d-quota inact";
416 status_string =
"d-quota activ";
419 status_string =
"code bug!";
423 s =
format (s,
"%-15s %5d %18s %14s %10lld %U %13lld\n",
433 s =
format (s,
"%-59s %s%U %s%U",
" ",
"Quota ",
465 fformat (stderr,
"vpp api client connect error\n");
471 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) ...
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
#define pool_foreach(VAR, POOL)
Iterate through pool.
void * clib_mem_init(void *base, uword size)
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
vlib_counter_t * drop_counters
static f64 clib_timebase_now(clib_timebase_t *tb)
description fragment has unexpected format
#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
static void * stat_segment_adjust(stat_client_main_t *sm, void *data)
#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
API main structure, used by both vpp and binary API clients.
__clib_export 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)
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)
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)
__clib_export void clib_time_init(clib_time_t *c)
#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)
static int stat_segment_access_start(stat_segment_access_t *sa, stat_client_main_t *sm)
static unsigned char * print(const cJSON *const item, cJSON_bool format, const internal_hooks *const hooks)
__clib_export f64 clib_timebase_find_sunday_midnight(f64 start_time)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".