return 0;
}
-static void net_slirp_hostfwd_remove(Monitor *mon, const char *port_str)
+void net_slirp_hostfwd_remove(Monitor *mon, const char *port_str)
{
int host_port;
char buf[256] = "";
int is_udp = 0;
int n;
- if (!mon)
+ if (!slirp_inited) {
+ monitor_printf(mon, "user mode network stack not in use\n");
return;
+ }
if (!port_str || !port_str[0])
goto fail_syntax;
config_error(mon, "invalid host forwarding rule '%s'\n", redir_str);
}
-void net_slirp_redir(Monitor *mon, const char *redir_str, const char *redir_opt2)
+void net_slirp_hostfwd_add(Monitor *mon, const char *redir_str)
{
- struct slirp_config_str *config;
-
if (!slirp_inited) {
- if (mon) {
- monitor_printf(mon, "user mode network stack not in use\n");
- } else {
- config = qemu_malloc(sizeof(*config));
- pstrcpy(config->str, sizeof(config->str), redir_str);
- config->flags = SLIRP_CFG_HOSTFWD;
- config->next = slirp_configs;
- slirp_configs = config;
- }
+ monitor_printf(mon, "user mode network stack not in use\n");
return;
}
- if (!strcmp(redir_str, "remove")) {
- net_slirp_hostfwd_remove(mon, redir_opt2);
+ slirp_hostfwd(mon, redir_str);
+}
+
+void net_slirp_redir(const char *redir_str)
+{
+ struct slirp_config_str *config;
+
+ if (!slirp_inited) {
+ config = qemu_malloc(sizeof(*config));
+ pstrcpy(config->str, sizeof(config->str), redir_str);
+ config->flags = SLIRP_CFG_HOSTFWD;
+ config->next = slirp_configs;
+ slirp_configs = config;
return;
}
- slirp_hostfwd(mon, redir_str);
+ slirp_hostfwd(NULL, redir_str);
}
#ifndef _WIN32
void net_client_uninit(NICInfo *nd);
int net_client_parse(const char *str);
void net_slirp_smb(const char *exported_dir);
-void net_slirp_redir(Monitor *mon, const char *redir_str, const char *redir_opt2);
+void net_slirp_hostfwd_add(Monitor *mon, const char *redir_str);
+void net_slirp_hostfwd_remove(Monitor *mon, const char *port_str);
+void net_slirp_redir(const char *redir_str);
void net_cleanup(void);
int slirp_is_inited(void);
void net_client_check(void);
ETEXI
#ifdef CONFIG_SLIRP
- { "host_net_redir", "ss?", net_slirp_redir,
- "[tcp|udp]:host-port:[guest-host]:guest-port", "redirect TCP or UDP connections from host to guest (requires -net user)\n"
- "host_net_redir remove [tcp:|udp:]host-port -- remove redirection" },
+ { "hostfwd_add", "s", net_slirp_hostfwd_add,
+ "[tcp|udp]:hostport:[guestaddr]:guestport",
+ "redirect TCP or UDP connections from host to guest (requires -net user)" },
+ { "hostfwd_remove", "s", net_slirp_hostfwd_remove,
+ "[tcp|udp]:hostport", "remove host-to-guest TCP or UDP redirection" },
#endif
STEXI
@item host_net_redir