+static clib_error_t *
+map_if_command_fn (vlib_main_t * vm,
+ unformat_input_t * input, vlib_cli_command_t * cmd)
+{
+ unformat_input_t _line_input, *line_input = &_line_input;
+ clib_error_t *error = NULL;
+ bool is_enable = true, is_translation = false;
+ vnet_main_t *vnm = vnet_get_main ();
+ u32 sw_if_index = ~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, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
+ ;
+ else if (unformat (line_input, "del"))
+ is_enable = false;
+ else if (unformat (line_input, "map-t"))
+ is_translation = true;
+ else
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
+ }
+
+done:
+ unformat_free (line_input);
+
+ if (sw_if_index == ~0)
+ {
+ error = clib_error_return (0, "unknown interface");
+ return error;
+ }
+
+ int rv = map_if_enable_disable (is_enable, sw_if_index, is_translation);
+ if (rv)
+ {
+ error = clib_error_return (0, "failure enabling MAP on interface");
+ }
+
+ return error;
+}
+
+