Skip to contentSkip to conversation

[6240] Redirect slirp traffic to/from qemu character device (Gleb Natapov)

Qemu-devel Anthony Liguori 1 participant 1 message Jan 8, 2009

lore
Share & tools
lore
#0 lore raw

Revision: 6240

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6240
Author:   aliguori
Date:     2009-01-08 19:18:21 +0000 (Thu, 08 Jan 2009)

Log Message:
-----------
Redirect slirp traffic to/from qemu character device (Gleb Natapov)

Modified Paths:
--------------
trunk/slirp/libslirp.h
trunk/slirp/main.h
trunk/slirp/misc.c
trunk/slirp/sbuf.c
trunk/slirp/slirp.c
trunk/slirp/socket.c
trunk/slirp/socket.h
trunk/slirp/tcp_subr.c

Modified: trunk/slirp/libslirp.h
===================================================================

slirp/libslirp.h +4 -1
@@ -20,13 +20,16 @@
 
 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 slirp_add_exec(int do_pty, const void *args, int addr_low_byte,
                    int guest_port);
 
 extern const char *tftp_prefix;
 extern char slirp_hostname[33];
 
 void slirp_stats(void);
+void slirp_socket_recv(int addr_low_byte, int guest_port, const uint8_t *buf,
+		int size);
+size_t slirp_socket_can_recv(int addr_low_byte, int guest_port);
 
 #ifdef __cplusplus
 }

Modified: trunk/slirp/main.h
===================================================================

slirp/main.h +1 -0
@@ -51,3 +51,4 @@
 #endif
 
 void if_encap(const uint8_t *ip_data, int ip_data_len);
+ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags);

Modified: trunk/slirp/misc.c
===================================================================

slirp/misc.c +1 -1
@@ -169,7 +169,7 @@
 	(*ex_ptr)->ex_fport = port;
 	(*ex_ptr)->ex_addr = addr;
 	(*ex_ptr)->ex_pty = do_pty;
-	(*ex_ptr)->ex_exec = strdup(exec);
+	(*ex_ptr)->ex_exec = (do_pty == 3) ? exec : strdup(exec);
 	(*ex_ptr)->ex_next = tmp_ptr;
 	return 0;
 }

Modified: trunk/slirp/sbuf.c
===================================================================

slirp/sbuf.c +1 -1
@@ -108,7 +108,7 @@
 	 * ottherwise it'll arrive out of order, and hence corrupt
 	 */
 	if (!so->so_rcv.sb_cc)
-	   ret = send(so->s, m->m_data, m->m_len, 0);
+	   ret = slirp_send(so, m->m_data, m->m_len, 0);
 
 	if (ret <= 0) {
 		/*

Modified: trunk/slirp/slirp.c
===================================================================

slirp/slirp.c +62 -1

77 lines not on this page · raw message

Modified: trunk/slirp/socket.c
===================================================================

slirp/socket.c +80 -21

165 lines not on this page · raw message

Modified: trunk/slirp/socket.h
===================================================================

slirp/socket.h +2 -0
@@ -87,5 +87,7 @@
 void soisfconnected _P((register struct socket *));
 void soisfdisconnected _P((struct socket *));
 void sofwdrain _P((struct socket *));
+size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np);
+int soreadbuf(struct socket *so, const char *buf, int size);
 
 #endif /* _SOCKET_H_ */

Modified: trunk/slirp/tcp_subr.c
===================================================================

slirp/tcp_subr.c +5 -0
@@ -1281,6 +1281,11 @@
 		for (ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
 			if (ex_ptr->ex_fport == so->so_fport &&
 			    command == ex_ptr->ex_addr) {
+				if (ex_ptr->ex_pty == 3) {
+					so->s = -1;
+					so->extra = ex_ptr->ex_exec;
+					return 1;
+				}
 				do_pty = ex_ptr->ex_pty;
 				goto do_exec;
 			}