diff options
-rw-r--r-- | slirp/libslirp.h | 2 | ||||
-rw-r--r-- | slirp/misc.c | 20 | ||||
-rw-r--r-- | slirp/slirp.c | 22 | ||||
-rw-r--r-- | slirp/tcp_input.c | 6 | ||||
-rw-r--r-- | slirp/tcp_subr.c | 9 |
5 files changed, 46 insertions, 13 deletions
diff --git a/slirp/libslirp.h b/slirp/libslirp.h index 772427d..6a54eb1 100644 --- a/slirp/libslirp.h +++ b/slirp/libslirp.h @@ -24,6 +24,8 @@ void slirp_output(const uint8_t *pkt, int pkt_len); 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 char *args, int addr_low_byte, + int guest_port); extern const char *tftp_prefix; diff --git a/slirp/misc.c b/slirp/misc.c index 64bd9ee..26f8eb5 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -212,7 +212,20 @@ strerror(error) #endif -#if 0 +#ifdef _WIN32 + +int +fork_exec(so, ex, do_pty) + struct socket *so; + char *ex; + int do_pty; +{ + /* not implemented */ + return 0; +} + +#else + int openpty(amaster, aslave) int *amaster, *aslave; @@ -301,7 +314,9 @@ fork_exec(so, ex, do_pty) int opt; int master; char *argv[256]; +#if 0 char buff[256]; +#endif /* don't want to clobber the original */ char *bptr; char *curarg; @@ -360,6 +375,7 @@ fork_exec(so, ex, do_pty) connect(s, (struct sockaddr *)&addr, addrlen); } +#if 0 if (x_port >= 0) { #ifdef HAVE_SETENV sprintf(buff, "%s:%d.%d", inet_ntoa(our_addr), x_port, x_screen); @@ -369,7 +385,7 @@ fork_exec(so, ex, do_pty) putenv(buff); #endif } - +#endif dup2(s, 0); dup2(s, 1); dup2(s, 2); diff --git a/slirp/slirp.c b/slirp/slirp.c index bc2b155..99f1687 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -20,6 +20,7 @@ int do_slowtimo; int link_up; struct timeval tt; FILE *lfd; +struct ex_list *exec_list; /* XXX: suppress those select globals */ fd_set *global_readfds, *global_writefds, *global_xfds; @@ -538,13 +539,20 @@ void arp_input(const uint8_t *pkt, int pkt_len) struct ethhdr *reh = (struct ethhdr *)arp_reply; struct arphdr *rah = (struct arphdr *)(arp_reply + ETH_HLEN); int ar_op; + struct ex_list *ex_ptr; ar_op = ntohs(ah->ar_op); switch(ar_op) { case ARPOP_REQUEST: - if (!memcmp(ah->ar_tip, &special_addr, 3) && - (ah->ar_tip[3] == CTL_DNS || ah->ar_tip[3] == CTL_ALIAS)) { - + if (!memcmp(ah->ar_tip, &special_addr, 3)) { + if (ah->ar_tip[3] == CTL_DNS || ah->ar_tip[3] == CTL_ALIAS) + goto arp_ok; + for (ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { + if (ex_ptr->ex_addr == ah->ar_tip[3]) + goto arp_ok; + } + return; + arp_ok: /* XXX: make an ARP request to have the client address */ memcpy(client_ethaddr, eh->h_source, ETH_ALEN); @@ -612,6 +620,7 @@ void if_encap(const uint8_t *ip_data, int ip_data_len) memcpy(eh->h_dest, client_ethaddr, ETH_ALEN); memcpy(eh->h_source, special_ethaddr, ETH_ALEN - 1); + /* XXX: not correct */ eh->h_source[5] = CTL_ALIAS; eh->h_proto = htons(ETH_P_IP); memcpy(buf + sizeof(struct ethhdr), ip_data, ip_data_len); @@ -632,3 +641,10 @@ int slirp_redir(int is_udp, int host_port, } return 0; } + +int slirp_add_exec(int do_pty, const char *args, int addr_low_byte, + int guest_port) +{ + return add_exec(&exec_list, do_pty, (char *)args, + addr_low_byte, htons(guest_port)); +} diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c index 4f74d0c..42f02b3 100644 --- a/slirp/tcp_input.c +++ b/slirp/tcp_input.c @@ -658,10 +658,11 @@ findso: if(lastbyte==CTL_CMD || lastbyte==CTL_EXEC) { /* Command or exec adress */ so->so_state |= SS_CTL; - } else { + } else +#endif + { /* May be an add exec */ struct ex_list *ex_ptr; - for(ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if(ex_ptr->ex_fport == so->so_fport && lastbyte == ex_ptr->ex_addr) { @@ -671,7 +672,6 @@ findso: } } if(so->so_state & SS_CTL) goto cont_input; -#endif } /* CTL_ALIAS: Do nothing, tcp_fconnect will be called on it */ } diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index c29dc60..b6fbbfa 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -1249,7 +1249,6 @@ int tcp_ctl(so) struct socket *so; { -#if 0 struct sbuf *sb = &so->so_snd; int command; struct ex_list *ex_ptr; @@ -1259,6 +1258,7 @@ tcp_ctl(so) DEBUG_CALL("tcp_ctl"); DEBUG_ARG("so = %lx", (long )so); +#if 0 /* * Check if they're authorised */ @@ -1267,7 +1267,7 @@ tcp_ctl(so) sb->sb_wptr += sb->sb_cc; return 0; } - +#endif command = (ntohl(so->so_faddr.s_addr) & 0xff); switch(command) { @@ -1300,6 +1300,7 @@ tcp_ctl(so) DEBUG_MISC((dfd, " executing %s \n",ex_ptr->ex_exec)); return(fork_exec(so, ex_ptr->ex_exec, do_pty)); +#if 0 case CTL_CMD: for (tmpso = tcb.so_next; tmpso != &tcb; tmpso = tmpso->so_next) { if (tmpso->so_emu == EMU_CTL && @@ -1318,8 +1319,6 @@ tcp_ctl(so) sb->sb_wptr += sb->sb_cc; do_echo=-1; return(2); - } -#else - return 0; #endif + } } |