--------------------- PatchSet 5895 Date: 2007/10/07 21:24:23 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Fix more compile errors in Win32 build Members: src/win32.cc:1.8.6.1->1.8.6.2 Index: squid3/src/win32.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/win32.cc,v retrieving revision 1.8.6.1 retrieving revision 1.8.6.2 diff -u -r1.8.6.1 -r1.8.6.2 --- squid3/src/win32.cc 5 Jan 2007 16:59:44 -0000 1.8.6.1 +++ squid3/src/win32.cc 7 Oct 2007 21:24:23 -0000 1.8.6.2 @@ -1,6 +1,5 @@ - /* - * $Id: win32.cc,v 1.8.6.1 2007/01/05 16:59:44 hno Exp $ + * $Id: win32.cc,v 1.8.6.2 2007/10/07 21:24:23 amosjeffries Exp $ * * Windows support * AUTHOR: Guido Serassio @@ -56,36 +55,34 @@ int new_socket; fde *F = NULL; - struct sockaddr_in serv_addr; - int len = sizeof(serv_addr); - u_short handle1_port; + IPAddress handle0 = default_localhost_addr; + IPAddress handle1; + struct addrinfo *AI = NULL; handles[0] = handles[1] = -1; statCounter.syscalls.sock.sockets++; - if ((new_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) - return -1; - - memset((void *) &serv_addr, 0, sizeof(serv_addr)); - - serv_addr.sin_family = AF_INET; + handle0.SetPort(0); + handle0.GetAddrInfo(AI); - serv_addr.sin_port = htons(0); - - serv_addr.sin_addr = local_addr; + if ((new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol)) < 0) + return -1; - if (bind(new_socket, (SOCKADDR *) & serv_addr, len) < 0 || - listen(new_socket, 1) < 0 || getsockname(new_socket, (SOCKADDR *) & serv_addr, &len) < 0 || - (handles[1] = socket(PF_INET, SOCK_STREAM, 0)) < 0) { + if (bind(new_socket, AI->ai_addr, AI->ai_addrlen) < 0 || + listen(new_socket, 1) < 0 || getsockname(new_socket, AI->ai_addr, &(AI->ai_addrlen) ) < 0 || + (handles[1] = socket(AI->ai_family, AI->ai_socktype, 0)) < 0) { closesocket(new_socket); return -1; } - handle1_port = ntohs(serv_addr.sin_port); + handle0 = *AI; // retrieve the new details returned by connect() + + handle1.Setport(handle1.GetPort()); + handle1.GetAddrInfo(AI); - if (connect(handles[1], (SOCKADDR *) & serv_addr, len) < 0 || - (handles[0] = accept(new_socket, (SOCKADDR *) & serv_addr, &len)) < 0) { + if (connect(handles[1], AI->ai_addr, AI->ai_addrlen) < 0 || + (handles[0] = accept(new_socket, AI->ai_addr, &(AI->ai_addrlen)) ) < 0) { closesocket(handles[1]); handles[1] = -1; closesocket(new_socket); @@ -95,13 +92,12 @@ closesocket(new_socket); F = &fd_table[handles[0]]; - F->local_addr = local_addr; - F->local_port = ntohs(serv_addr.sin_port); + F->local_addr = handle0; F = &fd_table[handles[1]]; - F->local_addr = local_addr; - xstrncpy(F->ipaddr, inet_ntoa(local_addr), 16); - F->remote_port = handle1_port; + F->local_addr = default_localhost_addr; + handle1.NtoA(F->ipaddr, MAX_IPSTRLEN); + F->remote_port = handle1; return 0; } @@ -160,8 +156,7 @@ fde *F = &fd_table[fd]; SOCKET s = F->win32.handle; - return __WSAFDIsSet(s, set - ); + return __WSAFDIsSet(s, set); } LONG CALLBACK WIN32_ExceptionHandler(EXCEPTION_POINTERS* ep)