slirp: rename exec_list
This list is not only used to handle command to execute on guest connection, it can also redirect to an arbitrary object, such as a chardev. Let's rename the struct and the field to "guestfwd". Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
This commit is contained in:
parent
df2ad332da
commit
5d300fc922
@ -36,10 +36,10 @@ remque(void *a)
|
||||
element->qh_rlink = NULL;
|
||||
}
|
||||
|
||||
int add_exec(struct ex_list **ex_ptr, void *chardev, const char *cmdline,
|
||||
int add_exec(struct gfwd_list **ex_ptr, void *chardev, const char *cmdline,
|
||||
struct in_addr addr, int port)
|
||||
{
|
||||
struct ex_list *tmp_ptr;
|
||||
struct gfwd_list *tmp_ptr;
|
||||
|
||||
/* First, check if the port is "bound" */
|
||||
for (tmp_ptr = *ex_ptr; tmp_ptr; tmp_ptr = tmp_ptr->ex_next) {
|
||||
@ -49,7 +49,7 @@ int add_exec(struct ex_list **ex_ptr, void *chardev, const char *cmdline,
|
||||
}
|
||||
|
||||
tmp_ptr = *ex_ptr;
|
||||
*ex_ptr = g_new0(struct ex_list, 1);
|
||||
*ex_ptr = g_new0(struct gfwd_list, 1);
|
||||
(*ex_ptr)->ex_fport = port;
|
||||
(*ex_ptr)->ex_addr = addr;
|
||||
if (chardev) {
|
||||
|
@ -8,12 +8,12 @@
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
struct ex_list {
|
||||
struct gfwd_list {
|
||||
void *ex_chardev;
|
||||
struct in_addr ex_addr; /* Server address */
|
||||
int ex_fport; /* Port to telnet to */
|
||||
char *ex_exec; /* Command line of what to exec */
|
||||
struct ex_list *ex_next;
|
||||
struct gfwd_list *ex_next;
|
||||
};
|
||||
|
||||
#define EMU_NONE 0x0
|
||||
@ -51,7 +51,7 @@ struct slirp_quehead {
|
||||
|
||||
void slirp_insque(void *, void *);
|
||||
void slirp_remque(void *);
|
||||
int add_exec(struct ex_list **, void *, const char *, struct in_addr, int);
|
||||
int add_exec(struct gfwd_list **, void *, const char *, struct in_addr, int);
|
||||
int fork_exec(struct socket *so, const char *ex);
|
||||
|
||||
#endif
|
||||
|
@ -345,9 +345,9 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,
|
||||
|
||||
void slirp_cleanup(Slirp *slirp)
|
||||
{
|
||||
struct ex_list *e, *next;
|
||||
struct gfwd_list *e, *next;
|
||||
|
||||
for (e = slirp->exec_list; e; e = next) {
|
||||
for (e = slirp->guestfwd_list; e; e = next) {
|
||||
next = e->ex_next;
|
||||
g_free(e->ex_exec);
|
||||
g_free(e);
|
||||
@ -760,7 +760,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
|
||||
struct ethhdr *reh = (struct ethhdr *)arp_reply;
|
||||
struct slirp_arphdr *rah = (struct slirp_arphdr *)(arp_reply + ETH_HLEN);
|
||||
int ar_op;
|
||||
struct ex_list *ex_ptr;
|
||||
struct gfwd_list *ex_ptr;
|
||||
|
||||
if (!slirp->in_enabled) {
|
||||
return;
|
||||
@ -780,7 +780,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len)
|
||||
if (ah->ar_tip == slirp->vnameserver_addr.s_addr ||
|
||||
ah->ar_tip == slirp->vhost_addr.s_addr)
|
||||
goto arp_ok;
|
||||
for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||
for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||
if (ex_ptr->ex_addr.s_addr == ah->ar_tip)
|
||||
goto arp_ok;
|
||||
}
|
||||
@ -1052,7 +1052,7 @@ int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline,
|
||||
return -1;
|
||||
}
|
||||
|
||||
return add_exec(&slirp->exec_list, chardev, cmdline, *guest_addr,
|
||||
return add_exec(&slirp->guestfwd_list, chardev, cmdline, *guest_addr,
|
||||
htons(guest_port));
|
||||
}
|
||||
|
||||
@ -1423,9 +1423,9 @@ static const VMStateDescription vmstate_slirp = {
|
||||
static void slirp_state_save(QEMUFile *f, void *opaque)
|
||||
{
|
||||
Slirp *slirp = opaque;
|
||||
struct ex_list *ex_ptr;
|
||||
struct gfwd_list *ex_ptr;
|
||||
|
||||
for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next)
|
||||
for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next)
|
||||
if (ex_ptr->ex_chardev) {
|
||||
struct socket *so;
|
||||
so = slirp_find_ctl_socket(slirp, ex_ptr->ex_addr,
|
||||
@ -1445,7 +1445,7 @@ static void slirp_state_save(QEMUFile *f, void *opaque)
|
||||
static int slirp_state_load(QEMUFile *f, void *opaque, int version_id)
|
||||
{
|
||||
Slirp *slirp = opaque;
|
||||
struct ex_list *ex_ptr;
|
||||
struct gfwd_list *ex_ptr;
|
||||
|
||||
while (qemu_get_byte(f)) {
|
||||
int ret;
|
||||
@ -1460,7 +1460,7 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id)
|
||||
slirp->vnetwork_addr.s_addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||
for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||
if (ex_ptr->ex_chardev &&
|
||||
so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr &&
|
||||
so->so_fport == ex_ptr->ex_fport) {
|
||||
|
@ -147,7 +147,7 @@ struct Slirp {
|
||||
char client_hostname[33];
|
||||
|
||||
int restricted;
|
||||
struct ex_list *exec_list;
|
||||
struct gfwd_list *guestfwd_list;
|
||||
|
||||
/* mbuf states */
|
||||
struct quehead m_freelist;
|
||||
|
@ -211,7 +211,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af)
|
||||
struct sockaddr_storage lhost, fhost;
|
||||
struct sockaddr_in *lhost4, *fhost4;
|
||||
struct sockaddr_in6 *lhost6, *fhost6;
|
||||
struct ex_list *ex_ptr;
|
||||
struct gfwd_list *ex_ptr;
|
||||
Slirp *slirp;
|
||||
|
||||
DEBUG_CALL("tcp_input");
|
||||
@ -394,7 +394,7 @@ findso:
|
||||
* for non-hostfwd connections. These should be dropped, unless it
|
||||
* happens to be a guestfwd.
|
||||
*/
|
||||
for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||
for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||
if (ex_ptr->ex_fport == ti->ti_dport &&
|
||||
ti->ti_dst.s_addr == ex_ptr->ex_addr.s_addr) {
|
||||
break;
|
||||
@ -616,7 +616,7 @@ findso:
|
||||
if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr &&
|
||||
so->so_faddr.s_addr != slirp->vnameserver_addr.s_addr) {
|
||||
/* May be an add exec */
|
||||
for (ex_ptr = slirp->exec_list; ex_ptr;
|
||||
for (ex_ptr = slirp->guestfwd_list; ex_ptr;
|
||||
ex_ptr = ex_ptr->ex_next) {
|
||||
if(ex_ptr->ex_fport == so->so_fport &&
|
||||
so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) {
|
||||
|
@ -949,14 +949,14 @@ int tcp_ctl(struct socket *so)
|
||||
{
|
||||
Slirp *slirp = so->slirp;
|
||||
struct sbuf *sb = &so->so_snd;
|
||||
struct ex_list *ex_ptr;
|
||||
struct gfwd_list *ex_ptr;
|
||||
|
||||
DEBUG_CALL("tcp_ctl");
|
||||
DEBUG_ARG("so = %p", so);
|
||||
|
||||
if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr) {
|
||||
/* Check if it's pty_exec */
|
||||
for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||
for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||
if (ex_ptr->ex_fport == so->so_fport &&
|
||||
so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) {
|
||||
if (ex_ptr->ex_chardev) {
|
||||
|
Loading…
Reference in New Issue
Block a user