mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
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>
This commit is contained in:
parent
c1261d8d16
commit
1c6ed9f337
4 changed files with 74 additions and 1 deletions
|
@ -18,6 +18,10 @@ 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);
|
||||
|
||||
void slirp_redir_loop(void (*func)(void *opaque, int is_udp,
|
||||
struct in_addr *laddr, u_int lport,
|
||||
struct in_addr *faddr, u_int fport),
|
||||
void *opaque);
|
||||
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);
|
||||
|
|
|
@ -734,6 +734,30 @@ void if_encap(const uint8_t *ip_data, int ip_data_len)
|
|||
}
|
||||
}
|
||||
|
||||
static void _slirp_redir_loop(void (*func)(void *opaque, int is_udp,
|
||||
struct in_addr *laddr, u_int lport,
|
||||
struct in_addr *faddr, u_int fport),
|
||||
void *opaque, int is_udp)
|
||||
{
|
||||
struct socket *head = (is_udp ? &udb : &tcb);
|
||||
struct socket *so;
|
||||
|
||||
for (so = head->so_next; so != head; so = so->so_next) {
|
||||
func(opaque, is_udp,
|
||||
&so->so_laddr, ntohs(so->so_lport),
|
||||
&so->so_faddr, ntohs(so->so_fport));
|
||||
}
|
||||
}
|
||||
|
||||
void slirp_redir_loop(void (*func)(void *opaque, int is_udp,
|
||||
struct in_addr *laddr, u_int lport,
|
||||
struct in_addr *faddr, u_int fport),
|
||||
void *opaque)
|
||||
{
|
||||
_slirp_redir_loop(func, opaque, 0);
|
||||
_slirp_redir_loop(func, opaque, 1);
|
||||
}
|
||||
|
||||
/* Unlistens a redirection
|
||||
*
|
||||
* Return value: number of redirs removed */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue