allow inetd like program exec
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1060 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
9d728e8c4e
commit
a3d4af03bb
|
@ -24,6 +24,8 @@ void slirp_output(const uint8_t *pkt, int pkt_len);
|
||||||
|
|
||||||
int slirp_redir(int is_udp, int host_port,
|
int slirp_redir(int is_udp, int host_port,
|
||||||
struct in_addr guest_addr, int guest_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;
|
extern const char *tftp_prefix;
|
||||||
|
|
||||||
|
|
20
slirp/misc.c
20
slirp/misc.c
|
@ -212,7 +212,20 @@ strerror(error)
|
||||||
#endif
|
#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
|
int
|
||||||
openpty(amaster, aslave)
|
openpty(amaster, aslave)
|
||||||
int *amaster, *aslave;
|
int *amaster, *aslave;
|
||||||
|
@ -301,7 +314,9 @@ fork_exec(so, ex, do_pty)
|
||||||
int opt;
|
int opt;
|
||||||
int master;
|
int master;
|
||||||
char *argv[256];
|
char *argv[256];
|
||||||
|
#if 0
|
||||||
char buff[256];
|
char buff[256];
|
||||||
|
#endif
|
||||||
/* don't want to clobber the original */
|
/* don't want to clobber the original */
|
||||||
char *bptr;
|
char *bptr;
|
||||||
char *curarg;
|
char *curarg;
|
||||||
|
@ -360,6 +375,7 @@ fork_exec(so, ex, do_pty)
|
||||||
connect(s, (struct sockaddr *)&addr, addrlen);
|
connect(s, (struct sockaddr *)&addr, addrlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (x_port >= 0) {
|
if (x_port >= 0) {
|
||||||
#ifdef HAVE_SETENV
|
#ifdef HAVE_SETENV
|
||||||
sprintf(buff, "%s:%d.%d", inet_ntoa(our_addr), x_port, x_screen);
|
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);
|
putenv(buff);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
dup2(s, 0);
|
dup2(s, 0);
|
||||||
dup2(s, 1);
|
dup2(s, 1);
|
||||||
dup2(s, 2);
|
dup2(s, 2);
|
||||||
|
|
|
@ -20,6 +20,7 @@ int do_slowtimo;
|
||||||
int link_up;
|
int link_up;
|
||||||
struct timeval tt;
|
struct timeval tt;
|
||||||
FILE *lfd;
|
FILE *lfd;
|
||||||
|
struct ex_list *exec_list;
|
||||||
|
|
||||||
/* XXX: suppress those select globals */
|
/* XXX: suppress those select globals */
|
||||||
fd_set *global_readfds, *global_writefds, *global_xfds;
|
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 ethhdr *reh = (struct ethhdr *)arp_reply;
|
||||||
struct arphdr *rah = (struct arphdr *)(arp_reply + ETH_HLEN);
|
struct arphdr *rah = (struct arphdr *)(arp_reply + ETH_HLEN);
|
||||||
int ar_op;
|
int ar_op;
|
||||||
|
struct ex_list *ex_ptr;
|
||||||
|
|
||||||
ar_op = ntohs(ah->ar_op);
|
ar_op = ntohs(ah->ar_op);
|
||||||
switch(ar_op) {
|
switch(ar_op) {
|
||||||
case ARPOP_REQUEST:
|
case ARPOP_REQUEST:
|
||||||
if (!memcmp(ah->ar_tip, &special_addr, 3) &&
|
if (!memcmp(ah->ar_tip, &special_addr, 3)) {
|
||||||
(ah->ar_tip[3] == CTL_DNS || ah->ar_tip[3] == CTL_ALIAS)) {
|
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 */
|
/* XXX: make an ARP request to have the client address */
|
||||||
memcpy(client_ethaddr, eh->h_source, ETH_ALEN);
|
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_dest, client_ethaddr, ETH_ALEN);
|
||||||
memcpy(eh->h_source, special_ethaddr, ETH_ALEN - 1);
|
memcpy(eh->h_source, special_ethaddr, ETH_ALEN - 1);
|
||||||
|
/* XXX: not correct */
|
||||||
eh->h_source[5] = CTL_ALIAS;
|
eh->h_source[5] = CTL_ALIAS;
|
||||||
eh->h_proto = htons(ETH_P_IP);
|
eh->h_proto = htons(ETH_P_IP);
|
||||||
memcpy(buf + sizeof(struct ethhdr), ip_data, ip_data_len);
|
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;
|
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));
|
||||||
|
}
|
||||||
|
|
|
@ -658,10 +658,11 @@ findso:
|
||||||
if(lastbyte==CTL_CMD || lastbyte==CTL_EXEC) {
|
if(lastbyte==CTL_CMD || lastbyte==CTL_EXEC) {
|
||||||
/* Command or exec adress */
|
/* Command or exec adress */
|
||||||
so->so_state |= SS_CTL;
|
so->so_state |= SS_CTL;
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
/* May be an add exec */
|
/* May be an add exec */
|
||||||
struct ex_list *ex_ptr;
|
struct ex_list *ex_ptr;
|
||||||
|
|
||||||
for(ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
for(ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||||
if(ex_ptr->ex_fport == so->so_fport &&
|
if(ex_ptr->ex_fport == so->so_fport &&
|
||||||
lastbyte == ex_ptr->ex_addr) {
|
lastbyte == ex_ptr->ex_addr) {
|
||||||
|
@ -671,7 +672,6 @@ findso:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(so->so_state & SS_CTL) goto cont_input;
|
if(so->so_state & SS_CTL) goto cont_input;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/* CTL_ALIAS: Do nothing, tcp_fconnect will be called on it */
|
/* CTL_ALIAS: Do nothing, tcp_fconnect will be called on it */
|
||||||
}
|
}
|
||||||
|
|
|
@ -1249,7 +1249,6 @@ int
|
||||||
tcp_ctl(so)
|
tcp_ctl(so)
|
||||||
struct socket *so;
|
struct socket *so;
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
struct sbuf *sb = &so->so_snd;
|
struct sbuf *sb = &so->so_snd;
|
||||||
int command;
|
int command;
|
||||||
struct ex_list *ex_ptr;
|
struct ex_list *ex_ptr;
|
||||||
|
@ -1259,6 +1258,7 @@ tcp_ctl(so)
|
||||||
DEBUG_CALL("tcp_ctl");
|
DEBUG_CALL("tcp_ctl");
|
||||||
DEBUG_ARG("so = %lx", (long )so);
|
DEBUG_ARG("so = %lx", (long )so);
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* Check if they're authorised
|
* Check if they're authorised
|
||||||
*/
|
*/
|
||||||
|
@ -1267,7 +1267,7 @@ tcp_ctl(so)
|
||||||
sb->sb_wptr += sb->sb_cc;
|
sb->sb_wptr += sb->sb_cc;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
command = (ntohl(so->so_faddr.s_addr) & 0xff);
|
command = (ntohl(so->so_faddr.s_addr) & 0xff);
|
||||||
|
|
||||||
switch(command) {
|
switch(command) {
|
||||||
|
@ -1300,6 +1300,7 @@ tcp_ctl(so)
|
||||||
DEBUG_MISC((dfd, " executing %s \n",ex_ptr->ex_exec));
|
DEBUG_MISC((dfd, " executing %s \n",ex_ptr->ex_exec));
|
||||||
return(fork_exec(so, ex_ptr->ex_exec, do_pty));
|
return(fork_exec(so, ex_ptr->ex_exec, do_pty));
|
||||||
|
|
||||||
|
#if 0
|
||||||
case CTL_CMD:
|
case CTL_CMD:
|
||||||
for (tmpso = tcb.so_next; tmpso != &tcb; tmpso = tmpso->so_next) {
|
for (tmpso = tcb.so_next; tmpso != &tcb; tmpso = tmpso->so_next) {
|
||||||
if (tmpso->so_emu == EMU_CTL &&
|
if (tmpso->so_emu == EMU_CTL &&
|
||||||
|
@ -1318,8 +1319,6 @@ tcp_ctl(so)
|
||||||
sb->sb_wptr += sb->sb_cc;
|
sb->sb_wptr += sb->sb_cc;
|
||||||
do_echo=-1;
|
do_echo=-1;
|
||||||
return(2);
|
return(2);
|
||||||
}
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue