Learning VPP: CLI



VPP preferred interface is a binary API that is used by Northbound control plane applications like Honeycomb.

But for debugging and other related purposes VPP includes very convenient CLI engine from both user and developer perspectives.

To add a new command it is required to register its name, help string and handler routine.


1. A registration.

VLIB_CLI_COMMAND (test_create_command, static) =
.path = "create test",
.short_help = "create test name <string>",
.function = test_create_command_fn,

2. A handler.

static clib_error_t *
test_create_command_fn (vlib_main_t * vm,
                        unformat_input_t * input,
                        vlib_cli_command_t * cmd)
  unformat_input_t _line_input, *line_input = &_line_input;
  u8 *name = NULL;
  if (unformat_user (input, unformat_line_input, line_input))
    while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
      if (unformat (line_input, "name %s", &name));
        unformat_free (line_input);
        return clib_error_return (0, "unknown input `%U'",
        format_unformat_error, input);
    unformat_free (line_input);

  return NULL;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s