-static u8 *
-format_lisp_status (u8 * s, va_list * args)
-{
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
- return format (s, "%s", lcm->is_enabled ? "enabled" : "disabled");
-}
-
-static clib_error_t *
-lisp_show_status_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- u8 *msg = 0;
- msg = format (msg, "feature: %U\ngpe: %U\n",
- format_lisp_status, format_vnet_lisp_gpe_status);
- vlib_cli_output (vm, "%v", msg);
- vec_free (msg);
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_show_status_command) = {
- .path = "show lisp status",
- .short_help = "show lisp status",
- .function = lisp_show_status_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_show_eid_table_map_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- hash_pair_t *p;
- unformat_input_t _line_input, *line_input = &_line_input;
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
- uword *vni_table = 0;
- u8 is_l2 = 0;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "l2"))
- {
- vni_table = lcm->bd_id_by_vni;
- is_l2 = 1;
- }
- else if (unformat (line_input, "l3"))
- {
- vni_table = lcm->table_id_by_vni;
- is_l2 = 0;
- }
- else
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
- }
-
- if (!vni_table)
- {
- vlib_cli_output (vm, "Error: expected l2|l3 param!\n");
- return 0;
- }
-
- vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
-
- /* *INDENT-OFF* */
- hash_foreach_pair (p, vni_table,
- ({
- vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
- }));
- /* *INDENT-ON* */
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_show_eid_table_map_command) = {
- .path = "show lisp eid-table map",
- .short_help = "show lisp eid-table l2|l3",
- .function = lisp_show_eid_table_map_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_add_del_locator_set_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
- vnet_main_t *vnm = lgm->vnet_main;
- unformat_input_t _line_input, *line_input = &_line_input;
- u8 is_add = 1;
- clib_error_t *error = 0;
- u8 *locator_set_name = 0;
- locator_t locator, *locators = 0;
- vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
- u32 ls_index = 0;
- int rv = 0;
-
- memset (&locator, 0, sizeof (locator));
- memset (a, 0, sizeof (a[0]));
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "add %_%v%_", &locator_set_name))
- is_add = 1;
- else if (unformat (line_input, "del %_%v%_", &locator_set_name))
- is_add = 0;
- else if (unformat (line_input, "iface %U p %d w %d",
- unformat_vnet_sw_interface, vnm,
- &locator.sw_if_index, &locator.priority,
- &locator.weight))
- {
- locator.local = 1;
- vec_add1 (locators, locator);
- }
- else
- {
- error = unformat_parse_error (line_input);
- goto done;
- }
- }
-
- a->name = locator_set_name;
- a->locators = locators;
- a->is_add = is_add;
- a->local = 1;
-
- rv = vnet_lisp_add_del_locator_set (a, &ls_index);
- if (0 != rv)
- {
- error = clib_error_return (0, "failed to %s locator-set!",
- is_add ? "add" : "delete");
- }
-
-done:
- vec_free (locators);
- if (locator_set_name)
- vec_free (locator_set_name);
- return error;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_cp_add_del_locator_set_command) = {
- .path = "lisp locator-set",
- .short_help = "lisp locator-set add/del <name> [iface <iface-name> "
- "p <priority> w <weight>]",
- .function = lisp_add_del_locator_set_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_add_del_locator_in_set_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
- vnet_main_t *vnm = lgm->vnet_main;
- unformat_input_t _line_input, *line_input = &_line_input;
- u8 is_add = 1;
- clib_error_t *error = 0;
- u8 *locator_set_name = 0;
- u8 locator_set_name_set = 0;
- locator_t locator, *locators = 0;
- vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
- u32 ls_index = 0;
-
- memset (&locator, 0, sizeof (locator));
- memset (a, 0, sizeof (a[0]));
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "add"))
- is_add = 1;
- else if (unformat (line_input, "del"))
- is_add = 0;
- else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
- locator_set_name_set = 1;
- else if (unformat (line_input, "iface %U p %d w %d",
- unformat_vnet_sw_interface, vnm,
- &locator.sw_if_index, &locator.priority,
- &locator.weight))
- {
- locator.local = 1;
- vec_add1 (locators, locator);
- }
- else
- {
- error = unformat_parse_error (line_input);
- goto done;
- }
- }
-
- if (!locator_set_name_set)
- {
- error = clib_error_return (0, "locator_set name not set!");
- goto done;
- }
-
- a->name = locator_set_name;
- a->locators = locators;
- a->is_add = is_add;
- a->local = 1;
-
- vnet_lisp_add_del_locator (a, 0, &ls_index);
-
-done:
- vec_free (locators);
- vec_free (locator_set_name);
- return error;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_cp_add_del_locator_in_set_command) = {
- .path = "lisp locator",
- .short_help = "lisp locator add/del locator-set <name> iface <iface-name> "
- "p <priority> w <weight>",
- .function = lisp_add_del_locator_in_set_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_cp_show_locator_sets_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- locator_set_t *lsit;
- locator_t *loc;
- u32 *locit;
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
-
- vlib_cli_output (vm, "%s%=16s%=16s%=16s", "Locator-set", "Locator",
- "Priority", "Weight");
-
- /* *INDENT-OFF* */
- pool_foreach (lsit, lcm->locator_set_pool,
- ({
- u8 * msg = 0;
- int next_line = 0;
- if (lsit->local)
- {
- msg = format (msg, "%v", lsit->name);
- }
- else
- {
- msg = format (msg, "<%s-%d>", "remote", lsit - lcm->locator_set_pool);
- }
- vec_foreach (locit, lsit->locator_indices)
- {
- if (next_line)
- {
- msg = format (msg, "%16s", " ");
- }
- loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
- if (loc->local)
- msg = format (msg, "%16d%16d%16d\n", loc->sw_if_index, loc->priority,
- loc->weight);
- else
- msg = format (msg, "%16U%16d%16d\n", format_ip_address,
- &gid_address_ip(&loc->address), loc->priority,
- loc->weight);
- next_line = 1;
- }
- vlib_cli_output (vm, "%v", msg);
- vec_free (msg);
- }));
- /* *INDENT-ON* */
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_cp_show_locator_sets_command) = {
- .path = "show lisp locator-set",
- .short_help = "Shows locator-sets",
- .function = lisp_cp_show_locator_sets_command_fn,
-};
-/* *INDENT-ON* */
-