diff --git a/slirp/libslirp.h b/slirp/libslirp.h index 772427d110f562496d375cf77de101f0d0d62213..6a54eb14f69a71fa68f71f5c3b5c04b1e191d58e 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 64bd9ee2f5837248e8402aa2a52a6b4617fc2f7f..26f8eb578d221c02094569d61af04e15c7b8e71b 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 bc2b15509aea8a347ef98a3ba4834ea40c8c741c..99f1687400640214df60bea8af1f2d76a8578a09 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 4f74d0cdbc51c51d01498f96ffa2cb2eb11550c5..42f02b3e654c8c23688be6c37087e7925509eef8 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 c29dc604ff2e73ff0a00ee7224a4cad9983865c7..b6fbbfaf0975b88d2df6261ce8d2d10ab66e60cc 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 + } }