-VLIB_CLI_COMMAND (lisp_add_del_remote_mapping_command) =
-{
-.path = "lisp remote-mapping",.short_help =
- "lisp remote-mapping add|del [del-all] vni <vni> "
- "eid <est-eid> [action <no-action|natively-forward|"
- "send-map-request|drop>] rloc <dst-locator> p <prio> w <weight> "
- "[rloc <dst-locator> ... ]",.function =
- lisp_add_del_remote_mapping_command_fn,};
-
-/**
- * Handler for add/del adjacency CLI.
- */
-static clib_error_t *
-lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- clib_error_t *error = 0;
- unformat_input_t _line_input, *line_input = &_line_input;
- vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
- u8 is_add = 1;
- ip_prefix_t *reid_ippref, *leid_ippref;
- gid_address_t leid, reid;
- u8 *dmac = gid_address_mac (&reid);
- u8 *smac = gid_address_mac (&leid);
- u8 reid_set = 0, leid_set = 0;
- u32 vni;
- int rv;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- memset (&reid, 0, sizeof (reid));
- memset (&leid, 0, sizeof (leid));
-
- leid_ippref = &gid_address_ippref (&leid);
- reid_ippref = &gid_address_ippref (&reid);
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "del"))
- is_add = 0;
- else if (unformat (line_input, "add"))
- ;
- else if (unformat (line_input, "reid %U",
- unformat_ip_prefix, reid_ippref))
- {
- gid_address_type (&reid) = GID_ADDR_IP_PREFIX;
- reid_set = 1;
- }
- else if (unformat (line_input, "reid %U", unformat_mac_address, dmac))
- {
- gid_address_type (&reid) = GID_ADDR_MAC;
- reid_set = 1;
- }
- else if (unformat (line_input, "vni %u", &vni))
- {
- gid_address_vni (&leid) = vni;
- gid_address_vni (&reid) = vni;
- }
- else if (unformat (line_input, "leid %U",
- unformat_ip_prefix, leid_ippref))
- {
- gid_address_type (&leid) = GID_ADDR_IP_PREFIX;
- leid_set = 1;
- }
- else if (unformat (line_input, "leid %U", unformat_mac_address, smac))
- {
- gid_address_type (&leid) = GID_ADDR_MAC;
- leid_set = 1;
- }
- else
- {
- clib_warning ("parse error");
- goto done;
- }
- }
-
- if (!reid_set || !leid_set)
- {
- clib_warning ("missing remote or local eid!");
- goto done;
- }
-
- if ((gid_address_type (&leid) != gid_address_type (&reid))
- || (gid_address_type (&reid) == GID_ADDR_IP_PREFIX
- && ip_prefix_version (reid_ippref)
- != ip_prefix_version (leid_ippref)))
- {
- clib_warning ("remote and local EIDs are of different types!");
- return error;
- }
-
- memset (a, 0, sizeof (a[0]));
- gid_address_copy (&a->leid, &leid);
- gid_address_copy (&a->reid, &reid);
-
- a->is_add = is_add;
- rv = vnet_lisp_add_del_adjacency (a);
-
- if (rv)
- clib_warning ("failed to %s adjacency!", is_add ? "add" : "delete");
-
-done:
- unformat_free (line_input);
- return error;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_add_del_adjacency_command) = {
- .path = "lisp adjacency",
- .short_help = "lisp adjacency add|del vni <vni> reid <remote-eid> "
- "leid <local-eid>",
- .function = lisp_add_del_adjacency_command_fn,
-};
-/* *INDENT-ON* */
-
-int
-vnet_lisp_set_map_request_mode (u8 mode)
-{
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
-
- if (vnet_lisp_enable_disable_status () == 0)
- {
- clib_warning ("LISP is disabled!");
- return VNET_API_ERROR_LISP_DISABLED;
- }
-
- if (mode >= _MR_MODE_MAX)
- {
- clib_warning ("Invalid LISP map request mode %d!", mode);
- return VNET_API_ERROR_INVALID_ARGUMENT;
- }
-
- lcm->map_request_mode = mode;
- return 0;
-}
-
-static clib_error_t *
-lisp_map_request_mode_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- unformat_input_t _i, *i = &_i;
- map_request_mode_t mr_mode = _MR_MODE_MAX;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, i))
- return 0;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "dst-only"))
- mr_mode = MR_MODE_DST_ONLY;
- else if (unformat (i, "src-dst"))
- mr_mode = MR_MODE_SRC_DST;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- goto done;
- }
- }
-
- if (_MR_MODE_MAX == mr_mode)
- {
- clib_warning ("No LISP map request mode entered!");
- return 0;
- }
-
- vnet_lisp_set_map_request_mode (mr_mode);
-done:
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_map_request_mode_command) = {
- .path = "lisp map-request mode",
- .short_help = "lisp map-request mode dst-only|src-dst",
- .function = lisp_map_request_mode_command_fn,
-};
-/* *INDENT-ON* */
-
-static u8 *
-format_lisp_map_request_mode (u8 * s, va_list * args)
-{
- u32 mode = va_arg (*args, u32);
-
- switch (mode)
- {
- case 0:
- return format (0, "dst-only");
- case 1:
- return format (0, "src-dst");
- }
- return 0;
-}
-
-static clib_error_t *
-lisp_show_map_request_mode_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- vlib_cli_output (vm, "map-request mode: %U", format_lisp_map_request_mode,
- vnet_lisp_get_map_request_mode ());
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_show_map_request_mode_command) = {
- .path = "show lisp map-request mode",
- .short_help = "show lisp map-request mode",
- .function = lisp_show_map_request_mode_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-lisp_show_map_resolvers_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- lisp_msmr_t *mr;
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
-
- vec_foreach (mr, lcm->map_resolvers)
- {
- vlib_cli_output (vm, "%U", format_ip_address, &mr->address);
- }
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (lisp_show_map_resolvers_command) = {
- .path = "show lisp map-resolvers",
- .short_help = "show lisp map-resolvers",
- .function = lisp_show_map_resolvers_command_fn,
-};
-/* *INDENT-ON* */
-
-int
-vnet_lisp_pitr_set_locator_set (u8 * locator_set_name, u8 is_add)
-{
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
- u32 locator_set_index = ~0;
- mapping_t *m;
- uword *p;
-
- if (vnet_lisp_enable_disable_status () == 0)
- {
- clib_warning ("LISP is disabled!");
- return VNET_API_ERROR_LISP_DISABLED;
- }
-
- p = hash_get_mem (lcm->locator_set_index_by_name, locator_set_name);
- if (!p)
- {
- clib_warning ("locator-set %v doesn't exist", locator_set_name);
- return -1;
- }
- locator_set_index = p[0];
-
- if (is_add)
- {