Commit a3d4af03bbedccb5c777562284c1098b9df7fe8a
1 parent
9d728e8c
allow inetd like program exec
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1060 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
5 changed files
with
46 additions
and
13 deletions
slirp/libslirp.h
... | ... | @@ -24,6 +24,8 @@ void slirp_output(const uint8_t *pkt, int pkt_len); |
24 | 24 | |
25 | 25 | int slirp_redir(int is_udp, int host_port, |
26 | 26 | struct in_addr guest_addr, int guest_port); |
27 | +int slirp_add_exec(int do_pty, const char *args, int addr_low_byte, | |
28 | + int guest_port); | |
27 | 29 | |
28 | 30 | extern const char *tftp_prefix; |
29 | 31 | ... | ... |
slirp/misc.c
... | ... | @@ -212,7 +212,20 @@ strerror(error) |
212 | 212 | #endif |
213 | 213 | |
214 | 214 | |
215 | -#if 0 | |
215 | +#ifdef _WIN32 | |
216 | + | |
217 | +int | |
218 | +fork_exec(so, ex, do_pty) | |
219 | + struct socket *so; | |
220 | + char *ex; | |
221 | + int do_pty; | |
222 | +{ | |
223 | + /* not implemented */ | |
224 | + return 0; | |
225 | +} | |
226 | + | |
227 | +#else | |
228 | + | |
216 | 229 | int |
217 | 230 | openpty(amaster, aslave) |
218 | 231 | int *amaster, *aslave; |
... | ... | @@ -301,7 +314,9 @@ fork_exec(so, ex, do_pty) |
301 | 314 | int opt; |
302 | 315 | int master; |
303 | 316 | char *argv[256]; |
317 | +#if 0 | |
304 | 318 | char buff[256]; |
319 | +#endif | |
305 | 320 | /* don't want to clobber the original */ |
306 | 321 | char *bptr; |
307 | 322 | char *curarg; |
... | ... | @@ -360,6 +375,7 @@ fork_exec(so, ex, do_pty) |
360 | 375 | connect(s, (struct sockaddr *)&addr, addrlen); |
361 | 376 | } |
362 | 377 | |
378 | +#if 0 | |
363 | 379 | if (x_port >= 0) { |
364 | 380 | #ifdef HAVE_SETENV |
365 | 381 | sprintf(buff, "%s:%d.%d", inet_ntoa(our_addr), x_port, x_screen); |
... | ... | @@ -369,7 +385,7 @@ fork_exec(so, ex, do_pty) |
369 | 385 | putenv(buff); |
370 | 386 | #endif |
371 | 387 | } |
372 | - | |
388 | +#endif | |
373 | 389 | dup2(s, 0); |
374 | 390 | dup2(s, 1); |
375 | 391 | dup2(s, 2); | ... | ... |
slirp/slirp.c
... | ... | @@ -20,6 +20,7 @@ int do_slowtimo; |
20 | 20 | int link_up; |
21 | 21 | struct timeval tt; |
22 | 22 | FILE *lfd; |
23 | +struct ex_list *exec_list; | |
23 | 24 | |
24 | 25 | /* XXX: suppress those select globals */ |
25 | 26 | fd_set *global_readfds, *global_writefds, *global_xfds; |
... | ... | @@ -538,13 +539,20 @@ void arp_input(const uint8_t *pkt, int pkt_len) |
538 | 539 | struct ethhdr *reh = (struct ethhdr *)arp_reply; |
539 | 540 | struct arphdr *rah = (struct arphdr *)(arp_reply + ETH_HLEN); |
540 | 541 | int ar_op; |
542 | + struct ex_list *ex_ptr; | |
541 | 543 | |
542 | 544 | ar_op = ntohs(ah->ar_op); |
543 | 545 | switch(ar_op) { |
544 | 546 | case ARPOP_REQUEST: |
545 | - if (!memcmp(ah->ar_tip, &special_addr, 3) && | |
546 | - (ah->ar_tip[3] == CTL_DNS || ah->ar_tip[3] == CTL_ALIAS)) { | |
547 | - | |
547 | + if (!memcmp(ah->ar_tip, &special_addr, 3)) { | |
548 | + if (ah->ar_tip[3] == CTL_DNS || ah->ar_tip[3] == CTL_ALIAS) | |
549 | + goto arp_ok; | |
550 | + for (ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { | |
551 | + if (ex_ptr->ex_addr == ah->ar_tip[3]) | |
552 | + goto arp_ok; | |
553 | + } | |
554 | + return; | |
555 | + arp_ok: | |
548 | 556 | /* XXX: make an ARP request to have the client address */ |
549 | 557 | memcpy(client_ethaddr, eh->h_source, ETH_ALEN); |
550 | 558 | |
... | ... | @@ -612,6 +620,7 @@ void if_encap(const uint8_t *ip_data, int ip_data_len) |
612 | 620 | |
613 | 621 | memcpy(eh->h_dest, client_ethaddr, ETH_ALEN); |
614 | 622 | memcpy(eh->h_source, special_ethaddr, ETH_ALEN - 1); |
623 | + /* XXX: not correct */ | |
615 | 624 | eh->h_source[5] = CTL_ALIAS; |
616 | 625 | eh->h_proto = htons(ETH_P_IP); |
617 | 626 | memcpy(buf + sizeof(struct ethhdr), ip_data, ip_data_len); |
... | ... | @@ -632,3 +641,10 @@ int slirp_redir(int is_udp, int host_port, |
632 | 641 | } |
633 | 642 | return 0; |
634 | 643 | } |
644 | + | |
645 | +int slirp_add_exec(int do_pty, const char *args, int addr_low_byte, | |
646 | + int guest_port) | |
647 | +{ | |
648 | + return add_exec(&exec_list, do_pty, (char *)args, | |
649 | + addr_low_byte, htons(guest_port)); | |
650 | +} | ... | ... |
slirp/tcp_input.c
... | ... | @@ -658,10 +658,11 @@ findso: |
658 | 658 | if(lastbyte==CTL_CMD || lastbyte==CTL_EXEC) { |
659 | 659 | /* Command or exec adress */ |
660 | 660 | so->so_state |= SS_CTL; |
661 | - } else { | |
661 | + } else | |
662 | +#endif | |
663 | + { | |
662 | 664 | /* May be an add exec */ |
663 | 665 | struct ex_list *ex_ptr; |
664 | - | |
665 | 666 | for(ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { |
666 | 667 | if(ex_ptr->ex_fport == so->so_fport && |
667 | 668 | lastbyte == ex_ptr->ex_addr) { |
... | ... | @@ -671,7 +672,6 @@ findso: |
671 | 672 | } |
672 | 673 | } |
673 | 674 | if(so->so_state & SS_CTL) goto cont_input; |
674 | -#endif | |
675 | 675 | } |
676 | 676 | /* CTL_ALIAS: Do nothing, tcp_fconnect will be called on it */ |
677 | 677 | } | ... | ... |
slirp/tcp_subr.c
... | ... | @@ -1249,7 +1249,6 @@ int |
1249 | 1249 | tcp_ctl(so) |
1250 | 1250 | struct socket *so; |
1251 | 1251 | { |
1252 | -#if 0 | |
1253 | 1252 | struct sbuf *sb = &so->so_snd; |
1254 | 1253 | int command; |
1255 | 1254 | struct ex_list *ex_ptr; |
... | ... | @@ -1259,6 +1258,7 @@ tcp_ctl(so) |
1259 | 1258 | DEBUG_CALL("tcp_ctl"); |
1260 | 1259 | DEBUG_ARG("so = %lx", (long )so); |
1261 | 1260 | |
1261 | +#if 0 | |
1262 | 1262 | /* |
1263 | 1263 | * Check if they're authorised |
1264 | 1264 | */ |
... | ... | @@ -1267,7 +1267,7 @@ tcp_ctl(so) |
1267 | 1267 | sb->sb_wptr += sb->sb_cc; |
1268 | 1268 | return 0; |
1269 | 1269 | } |
1270 | - | |
1270 | +#endif | |
1271 | 1271 | command = (ntohl(so->so_faddr.s_addr) & 0xff); |
1272 | 1272 | |
1273 | 1273 | switch(command) { |
... | ... | @@ -1300,6 +1300,7 @@ tcp_ctl(so) |
1300 | 1300 | DEBUG_MISC((dfd, " executing %s \n",ex_ptr->ex_exec)); |
1301 | 1301 | return(fork_exec(so, ex_ptr->ex_exec, do_pty)); |
1302 | 1302 | |
1303 | +#if 0 | |
1303 | 1304 | case CTL_CMD: |
1304 | 1305 | for (tmpso = tcb.so_next; tmpso != &tcb; tmpso = tmpso->so_next) { |
1305 | 1306 | if (tmpso->so_emu == EMU_CTL && |
... | ... | @@ -1318,8 +1319,6 @@ tcp_ctl(so) |
1318 | 1319 | sb->sb_wptr += sb->sb_cc; |
1319 | 1320 | do_echo=-1; |
1320 | 1321 | return(2); |
1321 | - } | |
1322 | -#else | |
1323 | - return 0; | |
1324 | 1322 | #endif |
1323 | + } | |
1325 | 1324 | } | ... | ... |