diff options
author | Alexander Graf <agraf@suse.de> | 2009-05-26 13:03:26 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-05-27 09:46:12 -0500 |
commit | 16bc4ff8e55aef49817e7528bf8e38c218ca0448 (patch) | |
tree | e01ad0d19941237f1b6fd6ea192454b5328ca5aa /slirp.c | |
parent | d41c451bbc4aae98e51bebe44274b30c7c2511b4 (diff) | |
download | slirp-16bc4ff8e55aef49817e7528bf8e38c218ca0448.zip slirp-16bc4ff8e55aef49817e7528bf8e38c218ca0448.tar.gz slirp-16bc4ff8e55aef49817e7528bf8e38c218ca0448.tar.bz2 |
User Networking: Enable removal of redirections
Using the new host_net_redir command you can easily create redirections
on the fly while your VM is running.
While that's great, it's missing the removal of redirections, in case you
want to have a port closed again at a later point in time.
This patch adds support for removal of redirections.
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'slirp.c')
-rw-r--r-- | slirp.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -736,6 +736,29 @@ void if_encap(const uint8_t *ip_data, int ip_data_len) } } +/* Unlistens a redirection + * + * Return value: number of redirs removed */ +int slirp_redir_rm(int is_udp, int host_port) +{ + struct socket *so; + struct socket *head = (is_udp ? &udb : &tcb); + int fport = htons(host_port); + int n = 0; + +loop_again: + for (so = head->so_next; so != head; so = so->so_next) { + if (so->so_fport == fport) { + close(so->s); + sofree(so); + n++; + goto loop_again; + } + } + + return n; +} + int slirp_redir(int is_udp, int host_port, struct in_addr guest_addr, int guest_port) { |