+
+static clib_error_t *
+memif_socket_filename_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;
+ int r;
+ u32 socket_id;
+ u8 *socket_filename;
+
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ socket_id = ~0;
+ socket_filename = 0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "id %u", &socket_id))
+ ;
+ else if (unformat (line_input, "filename %s", &socket_filename))
+ ;
+ else
+ {
+ vec_free (socket_filename);
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
+ }
+
+ unformat_free (line_input);
+
+ if (socket_id == 0 || socket_id == ~0)
+ {
+ vec_free (socket_filename);
+ return clib_error_return (0, "Invalid socket id");
+ }
+
+ if (!socket_filename || *socket_filename == 0)
+ {
+ vec_free (socket_filename);
+ return clib_error_return (0, "Invalid socket filename");
+ }
+
+ r = memif_socket_filename_add_del (1, socket_id, socket_filename);
+
+ vec_free (socket_filename);
+
+ if (r < 0)
+ {
+ switch (r)
+ {
+ case VNET_API_ERROR_INVALID_ARGUMENT:
+ return clib_error_return (0, "Invalid argument");
+ case VNET_API_ERROR_SYSCALL_ERROR_1:
+ return clib_error_return (0, "Syscall error 1");
+ case VNET_API_ERROR_ENTRY_ALREADY_EXISTS:
+ return clib_error_return (0, "Already exists");
+ case VNET_API_ERROR_UNEXPECTED_INTF_STATE:
+ return clib_error_return (0, "Interface still in use");
+ default:
+ return clib_error_return (0, "Unknown error");
+ }
+ }
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (memif_socket_filename_create_command, static) = {
+ .path = "create memif socket",
+ .short_help = "create memif socket [id <id>] [filename <path>]",
+ .function = memif_socket_filename_create_command_fn,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+memif_socket_filename_delete_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ unformat_input_t _line_input, *line_input = &_line_input;
+ int r;
+ u32 socket_id;
+
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ socket_id = ~0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "id %u", &socket_id))
+ ;
+ else
+ {
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
+ }
+
+ unformat_free (line_input);
+
+ if (socket_id == 0 || socket_id == ~0)
+ {
+ return clib_error_return (0, "Invalid socket id");
+ }
+
+ r = memif_socket_filename_add_del (0, socket_id, 0);
+
+ if (r < 0)
+ {
+ switch (r)
+ {
+ case VNET_API_ERROR_INVALID_ARGUMENT:
+ return clib_error_return (0, "Invalid argument");
+ case VNET_API_ERROR_SYSCALL_ERROR_1:
+ return clib_error_return (0, "Syscall error 1");
+ case VNET_API_ERROR_ENTRY_ALREADY_EXISTS:
+ return clib_error_return (0, "Already exists");
+ case VNET_API_ERROR_UNEXPECTED_INTF_STATE:
+ return clib_error_return (0, "Interface still in use");
+ default:
+ return clib_error_return (0, "Unknown error");
+ }
+ }
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (memif_socket_filename_delete_command, static) = {
+ .path = "delete memif socket",
+ .short_help = "delete memif socket [id <id>]",
+ .function = memif_socket_filename_delete_command_fn,
+};
+/* *INDENT-ON* */
+