Skip to content

Commit

Permalink
slirp: Adding family argument to tcp_fconnect()
Browse files Browse the repository at this point in the history
This patch simply adds a unsigned short family argument to remove the hardcoded
"AF_INET" in the call of qemu_socket().

This prepares for IPv6 support.

Signed-off-by: Guillaume Subiron <maethor@subiron.org>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
  • Loading branch information
Guillaume Subiron authored and jasowang committed Feb 4, 2016
1 parent 9b5a30d commit cc573a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion slirp/slirp.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void tcp_respond(struct tcpcb *, register struct tcpiphdr *, register struct mbu
struct tcpcb * tcp_newtcpcb(struct socket *);
struct tcpcb * tcp_close(register struct tcpcb *);
void tcp_sockclosed(struct tcpcb *);
int tcp_fconnect(struct socket *);
int tcp_fconnect(struct socket *, unsigned short af);
void tcp_connect(struct socket *);
int tcp_attach(struct socket *);
uint8_t tcp_tos(struct socket *);
Expand Down
2 changes: 1 addition & 1 deletion slirp/tcp_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
goto cont_input;
}

if ((tcp_fconnect(so) == -1) &&
if ((tcp_fconnect(so, so->so_ffamily) == -1) &&
#if defined(_WIN32)
socket_error() != WSAEWOULDBLOCK
#else
Expand Down
5 changes: 3 additions & 2 deletions slirp/tcp_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,15 @@ tcp_sockclosed(struct tcpcb *tp)
* nonblocking. Connect returns after the SYN is sent, and does
* not wait for ACK+SYN.
*/
int tcp_fconnect(struct socket *so)
int tcp_fconnect(struct socket *so, unsigned short af)
{
int ret=0;

DEBUG_CALL("tcp_fconnect");
DEBUG_ARG("so = %p", so);

if( (ret = so->s = qemu_socket(AF_INET,SOCK_STREAM,0)) >= 0) {
ret = so->s = qemu_socket(af, SOCK_STREAM, 0);
if (ret >= 0) {
int opt, s=so->s;
struct sockaddr_storage addr;

Expand Down

0 comments on commit cc573a6

Please sign in to comment.