19 int main (
int argc,
char * argv[])
47 static u8 * format_my_node_frame (
u8 * s, va_list * va)
53 s =
format (s,
"scalar %d, vector { ", g->scalar);
55 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;
112 .scalar_size =
sizeof (my_frame_t),
123 .scalar_size =
sizeof (my_frame_t),
134 } my_process_completion_type_t;
139 } my_process_event_data_t;
141 static u8 * format_my_process_event_data (
u8 * s, va_list * va)
143 my_process_event_data_t * d = va_arg (*va, my_process_event_data_t *);
144 return format (s,
"{ a %d b %.6f}", d->a, d->b);
159 for (i = 0; i < 5; i++)
171 for (n_events_seen = 0; n_events_seen < 2;)
175 n_events_seen +=
vec_len (data);
178 node->
name, i, type, data[0]);
187 my_process_event_data_t * data;
188 for (n_events_seen = 0; n_events_seen < 2;)
195 type, format_my_process_event_data, data);
197 n_events_seen +=
vec_len (data);
222 i == 1 ? MY_EVENT_TYPE1 : MY_EVENT_TYPE2,
226 my_process_event_data_t * d;
231 i == 1 ? MY_EVENT_TYPE1 : MY_EVENT_TYPE2,
245 .function = my_proc_input,
247 .name =
"my-proc-input",
252 u32 prec = va_arg (*args,
u32);
253 f64 * result = va_arg (*args,
f64 *);
258 "+%U",
"-%U",
"/%U",
"*%U",
"^%U",
265 for (p = prec; p <
ARRAY_LEN (binops); p++)
268 _unformat_farith, prec + 0, &tmp[1]))
270 switch (binops[p][0])
272 case '+': result[0] = tmp[0] + tmp[1];
break;
273 case '-': result[0] = tmp[0] - tmp[1];
break;
274 case '/': result[0] = tmp[0] / tmp[1];
break;
275 case '*': result[0] = tmp[0] * tmp[1];
break;
276 case '^': result[0] = pow (tmp[0], tmp[1]);
break;
287 _unformat_farith, prec + 0, &tmp[0]))
294 _unformat_farith, 0, &tmp[0]))
310 f64 * result = va_arg (*args,
f64 *);
317 u32 * data = va_arg (*args,
u32 *);
322 .name =
"decimal_integer",
323 .short_help =
"a decimal integer",
325 .data_size =
sizeof (
u32),
329 .name =
"float_expression",
330 .short_help =
"floating point expression",
331 .unformat_function = unformat_farith,
332 .data_size =
sizeof (
f64),
366 .path =
"bar %decimal_integer",
367 .short_help =
"bar1 command",
368 .function = bar_command,
372 .path =
"bar %decimal_integer %decimal_integer",
373 .short_help =
"bar2 command",
374 .function = bar_command,
378 .path =
"zap %float_expression",
379 .short_help =
"bar3 command",
380 .function = bar_command,
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
#define vec_foreach_index(var, v)
Iterate over vector indices.
sll srl srl sll sra u16x4 i
#define VLIB_CLI_PARSE_RULE(x)
always_inline uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
always_inline vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
always_inline void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
add_epi add_epi sub_epi sub_epi adds_epu subs_epu i16x8 y
always_inline uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
int main(int argc, char *argv[])
static clib_error_t * unix_cli_init(vlib_main_t *vm)
#define VLIB_INIT_FUNCTION(x)
always_inline void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
#define vlib_call_init_function(vm, x)
always_inline uword * vlib_process_wait_for_event(vlib_main_t *vm)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
always_inline void * vlib_frame_args(vlib_frame_t *f)
#define vec_free(V)
Free vector's memory (no header).
always_inline void vlib_process_put_event_data(vlib_main_t *vm, void *event_data)
#define VLIB_CLI_COMMAND(x,...)
always_inline 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)
clib_error_t * unix_physmem_init(vlib_main_t *vm, int physical_memory_required)
int vlib_unix_main(int argc, char *argv[])
#define VLIB_REGISTER_NODE(x,...)
#define STRUCT_SIZE_OF(t, f)
always_inline f64 vlib_time_now(vlib_main_t *vm)
always_inline 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)
static clib_error_t * main_stub_init(vlib_main_t *vm)
always_inline void * vlib_cli_get_parse_rule_result(vlib_main_t *vm, uword index)