2010-01-03 20:36:32 +01:00
|
|
|
diff -rc --exclude '*~' qemu-kvm-0.12.1.2-orig/slirp/socket.c qemu-kvm-0.12.1.2/slirp/socket.c
|
|
|
|
*** qemu-kvm-0.12.1.2-orig/slirp/socket.c 2009-12-29 21:46:34.000000000 +0100
|
|
|
|
--- qemu-kvm-0.12.1.2/slirp/socket.c 2010-01-03 20:24:11.000000000 +0100
|
2009-08-05 19:26:39 +02:00
|
|
|
***************
|
2010-01-03 20:36:32 +01:00
|
|
|
*** 588,593 ****
|
|
|
|
--- 588,594 ----
|
2009-08-05 19:26:39 +02:00
|
|
|
u_int lport, int flags)
|
|
|
|
{
|
|
|
|
struct sockaddr_in addr;
|
|
|
|
+ struct sockaddr_un addr_un;
|
|
|
|
struct socket *so;
|
|
|
|
int s, opt = 1;
|
|
|
|
socklen_t addrlen = sizeof(addr);
|
|
|
|
***************
|
2010-01-03 20:36:32 +01:00
|
|
|
*** 622,634 ****
|
2009-08-05 19:26:39 +02:00
|
|
|
so->so_lport = lport; /* Kept in network format */
|
|
|
|
so->so_laddr.s_addr = laddr; /* Ditto */
|
|
|
|
|
|
|
|
! addr.sin_family = AF_INET;
|
|
|
|
! addr.sin_addr.s_addr = haddr;
|
|
|
|
! addr.sin_port = hport;
|
|
|
|
|
2010-01-03 20:36:32 +01:00
|
|
|
! if (((s = qemu_socket(AF_INET,SOCK_STREAM,0)) < 0) ||
|
2009-08-05 19:26:39 +02:00
|
|
|
(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) ||
|
|
|
|
! (bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
|
|
|
|
(listen(s,1) < 0)) {
|
|
|
|
int tmperrno = errno; /* Don't clobber the real reason we failed */
|
|
|
|
|
2010-01-03 20:36:32 +01:00
|
|
|
--- 623,644 ----
|
2009-08-05 19:26:39 +02:00
|
|
|
so->so_lport = lport; /* Kept in network format */
|
|
|
|
so->so_laddr.s_addr = laddr; /* Ditto */
|
|
|
|
|
2010-01-03 20:36:32 +01:00
|
|
|
! so->so_uds = ntohs(hport) >= 0xff00;
|
|
|
|
!
|
|
|
|
! if (so->so_uds) {
|
|
|
|
! addr_un.sun_family = AF_UNIX;
|
|
|
|
! sprintf(addr_un.sun_path, "./%d.socket", ntohs(hport));
|
|
|
|
! unlink(addr_un.sun_path);
|
|
|
|
! } else {
|
|
|
|
! addr.sin_family = AF_INET;
|
|
|
|
! addr.sin_addr.s_addr = haddr;
|
|
|
|
! addr.sin_port = hport;
|
|
|
|
! }
|
|
|
|
|
|
|
|
! if (((s = qemu_socket(so->so_uds ? PF_UNIX : AF_INET, SOCK_STREAM, 0)) < 0) ||
|
2009-08-05 19:26:39 +02:00
|
|
|
(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) ||
|
2010-01-03 20:36:32 +01:00
|
|
|
! (bind(s, so->so_uds ? (struct sockaddr *) &addr_un : (struct sockaddr *) &addr,
|
|
|
|
! so->so_uds ? sizeof(addr_un) : sizeof(addr)) < 0) ||
|
2009-08-05 19:26:39 +02:00
|
|
|
(listen(s,1) < 0)) {
|
|
|
|
int tmperrno = errno; /* Don't clobber the real reason we failed */
|
|
|
|
|
|
|
|
***************
|
2010-01-03 20:36:32 +01:00
|
|
|
*** 644,655 ****
|
2009-08-05 19:26:39 +02:00
|
|
|
}
|
|
|
|
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
|
|
|
|
|
|
|
|
! getsockname(s,(struct sockaddr *)&addr,&addrlen);
|
|
|
|
! so->so_fport = addr.sin_port;
|
|
|
|
! if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
|
|
|
|
! so->so_faddr = slirp->vhost_addr;
|
|
|
|
! else
|
|
|
|
! so->so_faddr = addr.sin_addr;
|
|
|
|
|
|
|
|
so->s = s;
|
|
|
|
return so;
|
2010-01-03 20:36:32 +01:00
|
|
|
--- 654,670 ----
|
2009-08-05 19:26:39 +02:00
|
|
|
}
|
|
|
|
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
|
|
|
|
|
2009-08-21 17:40:32 +02:00
|
|
|
! if (so->so_uds) {
|
2009-08-21 16:26:46 +02:00
|
|
|
! so->so_fport = hport;
|
2009-08-05 19:26:39 +02:00
|
|
|
! so->so_faddr = slirp->vhost_addr;
|
|
|
|
! } else {
|
|
|
|
! getsockname(s,(struct sockaddr *)&addr,&addrlen);
|
|
|
|
! so->so_fport = addr.sin_port;
|
|
|
|
! if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
|
|
|
|
! so->so_faddr = slirp->vhost_addr;
|
|
|
|
! else
|
|
|
|
! so->so_faddr = addr.sin_addr;
|
|
|
|
! }
|
|
|
|
|
|
|
|
so->s = s;
|
|
|
|
return so;
|
2010-01-03 20:36:32 +01:00
|
|
|
diff -rc --exclude '*~' qemu-kvm-0.12.1.2-orig/slirp/socket.h qemu-kvm-0.12.1.2/slirp/socket.h
|
|
|
|
*** qemu-kvm-0.12.1.2-orig/slirp/socket.h 2009-12-29 21:46:34.000000000 +0100
|
|
|
|
--- qemu-kvm-0.12.1.2/slirp/socket.h 2010-01-03 20:20:50.000000000 +0100
|
2009-08-21 17:40:32 +02:00
|
|
|
***************
|
|
|
|
*** 33,39 ****
|
|
|
|
struct in_addr so_laddr; /* local host table entry */
|
|
|
|
u_int16_t so_fport; /* foreign port */
|
|
|
|
u_int16_t so_lport; /* local port */
|
|
|
|
!
|
|
|
|
u_int8_t so_iptos; /* Type of service */
|
|
|
|
u_int8_t so_emu; /* Is the socket emulated? */
|
|
|
|
|
|
|
|
--- 33,40 ----
|
|
|
|
struct in_addr so_laddr; /* local host table entry */
|
|
|
|
u_int16_t so_fport; /* foreign port */
|
|
|
|
u_int16_t so_lport; /* local port */
|
|
|
|
! int so_uds; /* foreign "port" is a unix domain socket */
|
|
|
|
!
|
|
|
|
u_int8_t so_iptos; /* Type of service */
|
|
|
|
u_int8_t so_emu; /* Is the socket emulated? */
|
|
|
|
|
2010-01-03 20:36:32 +01:00
|
|
|
diff -rc --exclude '*~' qemu-kvm-0.12.1.2-orig/slirp/tcp_subr.c qemu-kvm-0.12.1.2/slirp/tcp_subr.c
|
|
|
|
*** qemu-kvm-0.12.1.2-orig/slirp/tcp_subr.c 2009-12-29 21:46:34.000000000 +0100
|
|
|
|
--- qemu-kvm-0.12.1.2/slirp/tcp_subr.c 2010-01-03 20:20:50.000000000 +0100
|
2009-08-21 17:40:32 +02:00
|
|
|
***************
|
2010-01-03 20:36:32 +01:00
|
|
|
*** 383,389 ****
|
2009-08-21 17:40:32 +02:00
|
|
|
Slirp *slirp = inso->slirp;
|
|
|
|
struct socket *so;
|
|
|
|
struct sockaddr_in addr;
|
|
|
|
! socklen_t addrlen = sizeof(struct sockaddr_in);
|
|
|
|
struct tcpcb *tp;
|
|
|
|
int s, opt;
|
|
|
|
|
2010-01-03 20:36:32 +01:00
|
|
|
--- 383,390 ----
|
2009-08-21 17:40:32 +02:00
|
|
|
Slirp *slirp = inso->slirp;
|
|
|
|
struct socket *so;
|
|
|
|
struct sockaddr_in addr;
|
|
|
|
! struct sockaddr_un addr_un;
|
|
|
|
! socklen_t addrlen;
|
|
|
|
struct tcpcb *tp;
|
|
|
|
int s, opt;
|
|
|
|
|
|
|
|
***************
|
2010-01-03 20:36:32 +01:00
|
|
|
*** 413,419 ****
|
2009-08-21 17:40:32 +02:00
|
|
|
|
|
|
|
(void) tcp_mss(sototcpcb(so), 0);
|
|
|
|
|
|
|
|
! if ((s = accept(inso->s,(struct sockaddr *)&addr,&addrlen)) < 0) {
|
|
|
|
tcp_close(sototcpcb(so)); /* This will sofree() as well */
|
|
|
|
return;
|
|
|
|
}
|
2010-01-03 20:36:32 +01:00
|
|
|
--- 414,423 ----
|
2009-08-21 17:40:32 +02:00
|
|
|
|
|
|
|
(void) tcp_mss(sototcpcb(so), 0);
|
|
|
|
|
|
|
|
! addrlen = inso->so_uds ? sizeof(struct sockaddr_un) : sizeof(struct sockaddr_in);
|
|
|
|
!
|
|
|
|
! if ((inso->so_uds && (s = accept(inso->s, (struct sockaddr *) &addr_un, &addrlen)) < 0) ||
|
|
|
|
! (!inso->so_uds && (s = accept(inso->s, (struct sockaddr *) &addr, &addrlen)) < 0)) {
|
|
|
|
tcp_close(sototcpcb(so)); /* This will sofree() as well */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
***************
|
2010-01-03 20:36:32 +01:00
|
|
|
*** 425,435 ****
|
2009-08-21 17:40:32 +02:00
|
|
|
opt = 1;
|
|
|
|
setsockopt(s,IPPROTO_TCP,TCP_NODELAY,(char *)&opt,sizeof(int));
|
|
|
|
|
|
|
|
! so->so_fport = addr.sin_port;
|
|
|
|
! so->so_faddr = addr.sin_addr;
|
|
|
|
! /* Translate connections from localhost to the real hostname */
|
|
|
|
! if (so->so_faddr.s_addr == 0 || so->so_faddr.s_addr == loopback_addr.s_addr)
|
|
|
|
! so->so_faddr = slirp->vhost_addr;
|
|
|
|
|
|
|
|
/* Close the accept() socket, set right state */
|
|
|
|
if (inso->so_state & SS_FACCEPTONCE) {
|
2010-01-03 20:36:32 +01:00
|
|
|
--- 429,444 ----
|
2009-08-21 17:40:32 +02:00
|
|
|
opt = 1;
|
|
|
|
setsockopt(s,IPPROTO_TCP,TCP_NODELAY,(char *)&opt,sizeof(int));
|
|
|
|
|
|
|
|
! if (inso->so_uds) {
|
|
|
|
! so->so_fport = htons(s); /* use the fd number as the foreign port */
|
|
|
|
! so->so_faddr = slirp->vhost_addr;
|
|
|
|
! } else {
|
|
|
|
! so->so_fport = addr.sin_port;
|
|
|
|
! so->so_faddr = addr.sin_addr;
|
|
|
|
! /* Translate connections from localhost to the real hostname */
|
|
|
|
! if (so->so_faddr.s_addr == 0 || so->so_faddr.s_addr == loopback_addr.s_addr)
|
|
|
|
! so->so_faddr = slirp->vhost_addr;
|
|
|
|
! }
|
|
|
|
|
|
|
|
/* Close the accept() socket, set right state */
|
|
|
|
if (inso->so_state & SS_FACCEPTONCE) {
|