45 .short_help =
"Show commands",
51 .short_help =
"Clear commands",
57 .short_help =
"Set commands",
63 .short_help =
"Test commands",
89 case ' ':
case '\t':
case '\r':
case '\n':
98 match = clib_bitmap_andnot (match, p->
bitmaps[n]);
125 match = clib_bitmap_and (match, p->
bitmaps[n]);
148 case '\n':
case '\r':
158 if (c ==
'{' &&
unformat (i,
"%v", &s))
182 uword * match_bitmap, is_unique, index;
194 d[0] = _vec_resize (d[0],
223 int is_long = va_arg (*args,
int);
241 u8 * path = va_arg (*args,
u8 *);
244 for (i = 0; i <
vec_len (path); i++)
321 uword parent_command_index)
330 if (is_main_dispatch &&
unformat (input,
"help"))
332 uword help_at_end_of_line,
i;
350 if (! help_at_end_of_line)
374 for (i = 0; i <
vec_len (subs); i++)
398 else if (is_main_dispatch && (
unformat (input,
"choices") ||
unformat (input,
"?")))
402 subs =
all_subs (cm, 0, parent_command_index);
411 else if (
unformat (input,
"comment %v", &
string))
416 else if (
unformat (input,
"uncomment %U",
432 if (has_sub_commands)
435 if (has_sub_commands && ! error)
499 __attribute__ ((weak));
513 uword save_function_arg;
590 .path =
"show memory",
591 .short_help =
"Show current memory usage",
616 .path =
"memory-trace",
617 .short_help =
"Enable/disable memory allocation trace",
639 }
else if (
unformat(input,
"off")) {
647 }
else if (
unformat(input,
"now")) {
664 .path =
"test heap-validate",
665 .short_help =
"<on/off/now> validate heap on future allocs/frees or right now",
695 .path =
"test sleep",
696 .function = sleep_ten_seconds,
697 .short_help =
"Sleep for 10 seconds",
706 uword index_of_last_space = ~0;
718 if (l > 0 && s[l-1] !=
' ')
726 if (l > 0 && s[l-1] ==
' ')
727 index_of_last_space =
vec_len (s);
735 if (l > 0 && s[l-1] ==
' ')
739 return index_of_last_space;
746 for (i =
vec_len (path) - 1; i >= 0; i--)
776 if (sub_name[0] ==
'%')
787 sizeof (sub_name[0]),
799 clib_error (
"reference to unknown rule `%%%v' in path `%v'",
824 sub_c->
index = child_index;
825 sub_c->
name = sub_name;
855 uword p_len, pi, * p;
882 parent->
path = p_path;
912 char * normalized_path;
952 error =
clib_error_return (0,
"duplicate command name with path %v", normalized_path);
974 c->
path = normalized_path;
1011 r->
name = (
char *) r_name;
1024 __attribute__((unused))
1031 if (! r->
name || strlen (r->
name) == 0)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
uword output_function_arg
static void add_sub_command(vlib_cli_main_t *cm, uword parent_index, uword child_index)
unformat_function_t * unformat_function
static clib_error_t * vlib_cli_init(vlib_main_t *vm)
static vlib_cli_command_t * all_subs(vlib_cli_main_t *cm, vlib_cli_command_t *subs, u32 command_index)
static int vlib_cli_cmp_command(void *a1, void *a2)
sll srl srl sll sra u16x4 i
void * clib_per_cpu_mheaps[CLIB_MAX_MHEAPS]
#define foreach_vlib_main(body)
always_inline uword clib_bitmap_count_set_bits(uword *ai)
static uword vlib_cli_normalize_path(char *input, char **result)
static vlib_cli_command_t * get_sub_command(vlib_cli_main_t *cm, vlib_cli_command_t *parent, u32 si)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
clib_error_t * vlib_cli_register_parse_rule(vlib_main_t *vm, vlib_cli_parse_rule_t *r_reg)
vlib_cli_command_t * commands
#define clib_error(format, args...)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
uword * sub_rule_index_by_name
#define hash_set_mem(h, key, value)
always_inline uword vlib_cli_command_is_empty(vlib_cli_command_t *c)
u8 * format_mheap(u8 *s, va_list *va)
#define clib_bitmap_dup(v)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
static clib_error_t * test_heap_validate(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_INIT_FUNCTION(x)
always_inline uword parent_path_len(char *path)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
always_inline uword clib_bitmap_first_set(uword *ai)
uword * command_index_by_path
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
#define vlib_call_init_function(vm, x)
always_inline mheap_t * mheap_header(u8 *v)
static void vlib_cli_make_parent(vlib_cli_main_t *cm, uword ci)
vlib_cli_parse_rule_t * parse_rules
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header...
vlib_cli_command_function_t * function
clib_error_t * vlib_cli_register(vlib_main_t *vm, vlib_cli_command_t *c)
vlib_cli_sub_rule_t * sub_rules
#define vec_dup(V)
Return copy of vector (no header, no alignment)
always_inline f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_cli_sub_command_t * sub_commands
#define vec_free(V)
Free vector's memory (no header).
#define clib_error_free(e)
static uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
static u8 * format_vlib_cli_command_help(u8 *s, va_list *args)
#define VLIB_CLI_COMMAND(x,...)
vlib_worker_thread_t * vlib_worker_threads
#define clib_elf_section_data_next(a, extra)
static uword * vlib_cli_sub_command_match(vlib_cli_command_t *c, unformat_input_t *input)
void vlib_worker_thread_barrier_sync(vlib_main_t *vm)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
uword * parse_rule_index_by_name
void( vlib_cli_output_function_t)(uword arg, u8 *buffer, uword buffer_bytes)
#define MHEAP_FLAG_VALIDATE
#define clib_bitmap_free(v)
uword * sub_command_index_by_name
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
always_inline uword clib_bitmap_is_zero(uword *ai)
#define MHEAP_FLAG_SMALL_OBJECT_CACHE
static u8 * format_vlib_cli_parse_rule_name(u8 *s, va_list *args)
struct vlib_cli_command_t * next_cli_command
#define hash_create_vec(elts, key_bytes, value_bytes)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static u8 * format_vlib_cli_path(u8 *s, va_list *args)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
static clib_error_t * vlib_cli_dispatch_sub_commands(vlib_main_t *vm, vlib_cli_main_t *cm, unformat_input_t *input, uword parent_command_index)
#define hash_get_mem(h, key)
vlib_cli_command_t * cli_command_registrations
void mheap_validate(void *v)
always_inline vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
#define vec_foreach(var, vec)
Vector iterator.
vlib_cli_parse_position_t * sub_command_positions
static clib_error_t * enable_disable_memory_trace(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_error_return(e, args...)
vlib_cli_output_function_t * output_function
static clib_error_t * show_memory_usage(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void clib_mem_trace(int enable)
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
static uword unformat_vlib_cli_sub_command(unformat_input_t *i, va_list *args)
static int vlib_cli_cmp_rule(void *a1, void *a2)
void vlib_unix_error_report(vlib_main_t *, clib_error_t *)