aboutsummaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2009-05-26 13:03:27 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-05-28 02:14:56 -0500
commit1c6ed9f3379faac83da0ed3e95cbd49003ac0dd1 (patch)
treea00f486a54b46a346b25c73d217bfde0704a5df4 /net.c
parentc1261d8d1617d8cf5722039a59ebb66c310f3aea (diff)
User networking: Show active connections
In case you're wondering what connections exactly you have open or maybe redir'ed in the past, you can't really find out from qemu right now. This patch enables you to see all current connections the host only networking holds open, so you can kill them using the previous patch. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'net.c')
-rw-r--r--net.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/net.c b/net.c
index 9f5b79bc49..2d24a7ce5f 100644
--- a/net.c
+++ b/net.c
@@ -568,6 +568,45 @@ static int net_slirp_init(VLANState *vlan, const char *model, const char *name)
return 0;
}
+static void net_slirp_redir_print(void *opaque, int is_udp,
+ struct in_addr *laddr, u_int lport,
+ struct in_addr *faddr, u_int fport)
+{
+ Monitor *mon = (Monitor *)opaque;
+ uint32_t h_addr;
+ uint32_t g_addr;
+ char buf[16];
+
+ h_addr = ntohl(faddr->s_addr);
+ g_addr = ntohl(laddr->s_addr);
+
+ monitor_printf(mon, " %s |", is_udp ? "udp" : "tcp" );
+ snprintf(buf, 15, "%d.%d.%d.%d", (h_addr >> 24) & 0xff,
+ (h_addr >> 16) & 0xff,
+ (h_addr >> 8) & 0xff,
+ (h_addr) & 0xff);
+ monitor_printf(mon, " %15s |", buf);
+ monitor_printf(mon, " %5d |", fport);
+
+ snprintf(buf, 15, "%d.%d.%d.%d", (g_addr >> 24) & 0xff,
+ (g_addr >> 16) & 0xff,
+ (g_addr >> 8) & 0xff,
+ (g_addr) & 0xff);
+ monitor_printf(mon, " %15s |", buf);
+ monitor_printf(mon, " %5d\n", lport);
+
+}
+
+static void net_slirp_redir_list(Monitor *mon)
+{
+ if (!mon)
+ return;
+
+ monitor_printf(mon, " Prot | Host Addr | HPort | Guest Addr | GPort\n");
+ monitor_printf(mon, " | | | | \n");
+ slirp_redir_loop(net_slirp_redir_print, mon);
+}
+
static void net_slirp_redir_rm(Monitor *mon, const char *port_str)
{
int host_port;
@@ -622,6 +661,11 @@ void net_slirp_redir(Monitor *mon, const char *redir_str, const char *redir_opt2
return;
}
+ if (!strcmp(redir_str, "list")) {
+ net_slirp_redir_list(mon);
+ return;
+ }
+
p = redir_str;
if (get_str_sep(buf, sizeof(buf), &p, ':') < 0)
goto fail_syntax;