aboutsummaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2009-06-24 14:42:28 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-29 08:52:45 -0500
commitf3546deb079fd9e069870b9fd2f22bb48d5c8254 (patch)
tree40f742ab62041f18c8c5cd42f7b282616fb8fd4b /net.c
parent2ad82cf9e2c2adad874fbecabd48e1cf699b7c84 (diff)
downloadqemu-f3546deb079fd9e069870b9fd2f22bb48d5c8254.zip
qemu-f3546deb079fd9e069870b9fd2f22bb48d5c8254.tar.gz
qemu-f3546deb079fd9e069870b9fd2f22bb48d5c8254.tar.bz2
slirp: Rework monitor commands for host forwarding
Improve the monitor interface for adding and removing host forwarding rules by splitting it up in two commands and rename them to hostfwd_add and hostfwd_remove. Also split up the paths taken for legacy -redir support and the monitor add command as the latter will be extended later on. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'net.c')
-rw-r--r--net.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/net.c b/net.c
index f26c3f8..883a236 100644
--- a/net.c
+++ b/net.c
@@ -871,7 +871,7 @@ static int net_slirp_init(Monitor *mon, VLANState *vlan, const char *model,
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] = "";
@@ -879,8 +879,10 @@ static void net_slirp_hostfwd_remove(Monitor *mon, const char *port_str)
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;
@@ -958,29 +960,30 @@ static void slirp_hostfwd(Monitor *mon, const char *redir_str)
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