diff options
Diffstat (limited to 'slirp')
-rw-r--r-- | slirp/libslirp.h | 1 | ||||
-rw-r--r-- | slirp/slirp.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/slirp/libslirp.h b/slirp/libslirp.h index a1cd70e978..6fc2c329ad 100644 --- a/slirp/libslirp.h +++ b/slirp/libslirp.h @@ -18,6 +18,7 @@ void slirp_input(const uint8_t *pkt, int pkt_len); int slirp_can_output(void); void slirp_output(const uint8_t *pkt, int pkt_len); +int slirp_redir_rm(int is_udp, int host_port); int slirp_redir(int is_udp, int host_port, struct in_addr guest_addr, int guest_port); int slirp_add_exec(int do_pty, const void *args, int addr_low_byte, diff --git a/slirp/slirp.c b/slirp/slirp.c index 04d3dede23..33397c07dc 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -734,6 +734,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) { |