20 main (
int argc,
char *argv[])
36 .runs_after =
VLIB_INITS(
"unix_physmem_init",
"unix_cli_init"),
49 format_my_node_frame (
u8 * s, va_list * va)
55 s =
format (s,
"scalar %d, vector { ", g->scalar);
57 s =
format (s,
"%d, ", g->vector[i]);
78 f, format_my_node_frame, f);
90 for (i = 0; i < 5; i++)
96 y->vector[
i] = y->scalar +
i;
113 .scalar_size =
sizeof (my_frame_t),
126 .scalar_size =
sizeof (my_frame_t),
139 } my_process_completion_type_t;
145 } my_process_event_data_t;
148 format_my_process_event_data (
u8 * s, va_list * va)
150 my_process_event_data_t *d = va_arg (*va, my_process_event_data_t *);
151 return format (s,
"{ a %d b %.6f}", d->a, d->b);
164 for (i = 0; i < 5; i++)
176 for (n_events_seen = 0; n_events_seen < 2;)
180 n_events_seen +=
vec_len (data);
192 my_process_event_data_t *
data;
193 for (n_events_seen = 0; n_events_seen < 2;)
202 format_my_process_event_data, data);
204 n_events_seen +=
vec_len (data);
229 i == 1 ? MY_EVENT_TYPE1 : MY_EVENT_TYPE2,
233 my_process_event_data_t *d;
255 .function = my_proc_input,
257 .name =
"my-proc-input",
264 u32 prec = va_arg (*args,
u32);
265 f64 *result = va_arg (*args,
f64 *);
270 "+%U",
"-%U",
"/%U",
"*%U",
"^%U",
277 for (p = prec; p <
ARRAY_LEN (binops); p++)
279 if (
unformat (
i, binops[p], _unformat_farith, prec + 0, &tmp[1]))
281 switch (binops[p][0])
284 result[0] = tmp[0] + tmp[1];
287 result[0] = tmp[0] - tmp[1];
290 result[0] = tmp[0] / tmp[1];
293 result[0] = tmp[0] * tmp[1];
296 result[0] = pow (tmp[0], tmp[1]);
308 else if (
unformat (
i,
"-%U", _unformat_farith, prec + 0, &tmp[0]))
314 else if (
unformat (
i,
"(%U)", _unformat_farith, 0, &tmp[0]))
331 f64 *result = va_arg (*args,
f64 *);
345 .name =
"decimal_integer",.short_help =
351 .name =
"float_expression",.short_help =
352 "floating point expression",.unformat_function =
353 unformat_farith,.data_size =
sizeof (
f64),};
364 d = vlib_cli_get_parse_rule_result (vm, 0);
365 e = vlib_cli_get_parse_rule_result (vm, 1);
372 u32 *d = vlib_cli_get_parse_rule_result (vm, 0);
379 f64 *d = vlib_cli_get_parse_rule_result (vm, 0);
389 .path =
"bar %decimal_integer",
390 .short_help =
"bar1 command",
391 .function = bar_command,
395 .path =
"bar %decimal_integer %decimal_integer",
396 .short_help =
"bar2 command",
397 .function = bar_command,
401 .path =
"zap %float_expression",
402 .short_help =
"bar3 command",
403 .function = bar_command,
int vlib_unix_main(int argc, char *argv[])
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define VLIB_CLI_PARSE_RULE(x)
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
static f64 vlib_time_now(vlib_main_t *vm)
int main(int argc, char *argv[])
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
#define VLIB_INIT_FUNCTION(x)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
vl_api_fib_path_type_t type
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
u32 node_index
Node index.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
#define VLIB_REGISTER_NODE(x,...)
static void * vlib_process_signal_event_at_time(vlib_main_t *vm, f64 dt, uword node_index, uword type_opaque, uword n_data_elts, uword n_data_elt_bytes)
#define vec_free(V)
Free vector's memory (no header).
static void * vlib_frame_scalar_args(vlib_frame_t *f)
Get pointer to frame scalar data.
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
vlib_main_t vlib_node_runtime_t * node
#define VLIB_CLI_COMMAND(x,...)
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
static void * vlib_process_get_event_data(vlib_main_t *vm, uword *return_event_type_opaque)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void vlib_process_put_event_data(vlib_main_t *vm, void *event_data)
#define STRUCT_SIZE_OF(t, f)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static clib_error_t * main_stub_init(vlib_main_t *vm)