Ignore:
Timestamp:
Feb 23, 2002, 5:39:10 PM (24 years ago)
Author:
sandervl
Message:

Don't send FD_CONNECT for sockets that are returned by accept

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wsock32/wsock32.cpp

    r7979 r7992  
    1 /* $Id: wsock32.cpp,v 1.48 2002-02-20 16:08:03 sandervl Exp $ */
     1/* $Id: wsock32.cpp,v 1.49 2002-02-23 16:39:10 sandervl Exp $ */
    22
    33/*
     
    6565#include "dbglocal.h"
    6666
    67 //kso: dirty fix to make this compile! not permanent!
    68 BOOL WINAPI QueryPerformanceCounter(LARGE_INTEGER *p);
    69 #define LowPart u.LowPart
    70 
     67//
     68#define DUMP_PACKETS
    7169
    7270ODINDEBUGCHANNEL(WSOCK32-WSOCK32)
    73 
    7471
    7572/*****************************************************************************
     
    209206            strcpy(msg, "WSAHOST_NOT_FOUND");
    210207            break;
     208        case WSAENOPROTOOPT:
     209            strcpy(msg, "WSAENOPROTOOPT");
     210            break;
     211        case WSAEHOSTUNREACH:
     212            strcpy(msg, "WSAEHOSTUNREACH");
     213            break;
    211214        default:
    212215            strcpy(msg, "unknown");
     
    326329        return SOCKET_ERROR;
    327330   }
     331   dprintf(("connect to %s", inet_ntoa(((sockaddr_in*)name)->sin_addr)));
     332
    328333   ret = connect(s, (sockaddr *)name, namelen);
    329334   // map BSD error codes
     
    550555        //with the same parameters for the new socket (see docs)
    551556        if(QueryAsyncEvent(s, &mode, &notifyHandle, &notifyData, &lEvent) == TRUE) {
     557                dprintf(("Setting async select for socket %x, mode %d, %x %x %x", ret, mode, notifyHandle, notifyData, lEvent));
    552558                if(WSAAsyncSelectWorker(ret, mode, notifyHandle, notifyData, lEvent) == SOCKET_ERROR) {
    553559                        ret = SOCKET_ERROR;
     
    584590        return SOCKET_ERROR;
    585591   }
     592   dprintf(("bind to %s", inet_ntoa(((sockaddr_in*)addr)->sin_addr)));
    586593   ret = bind(s, (struct sockaddr *)addr, namelen);
    587594
     
    682689        }
    683690   }
    684    else WSASetLastError(NO_ERROR);
     691   else {
     692#ifdef DUMP_PACKETS
     693       dprintf(("Packet length %d", ret));
     694       for(int i=0;i<(ret+7)/8;i++) {
     695           dprintf(("%02x %02x %02x %02x %02x %02x %02x %02x %c %c %c %c %c %c %c %c", buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7], buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7]));
     696       }
     697#endif
     698       WSASetLastError(NO_ERROR);
     699   }
    685700
    686701   //Reset FD_READ event flagfor  WSAAsyncSelect thread if one was created for this socket
     
    714729        return SOCKET_ERROR;
    715730   }
     731   dprintf(("recvfrom to %s", inet_ntoa(((sockaddr_in*)from)->sin_addr)));
     732
    716733   ret = recvfrom(s, buf, len, flags, from, fromlen);
    717734
     
    719736        WSASetLastError(wsaErrno());
    720737   }
    721    else WSASetLastError(NO_ERROR);
     738   else {
     739#ifdef DUMP_PACKETS
     740       dprintf(("Packet length %d", ret));
     741       for(int i=0;i<(ret+7)/8;i++) {
     742           dprintf(("%02x %02x %02x %02x %02x %02x %02x %02x %c %c %c %c %c %c %c %c", buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7], buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7]));
     743       }
     744#endif
     745       WSASetLastError(NO_ERROR);
     746   }
    722747
    723748   //Reset FD_READ event flagfor  WSAAsyncSelect thread if one was created for this socket
     
    734759{
    735760   int ret;
     761   int optlen;
     762   int option;
    736763
    737764   if(!fWSAInitialized) {
     
    744771        return SOCKET_ERROR;
    745772   }
     773   // check if the socket is a raw socket and has the IP_HDRINCL switch
     774   // if this is the case, we overwrite the IP header length field with
     775   // the actual length because some apps tend to put garbage in there
     776   // and rely on Windows to correct this
     777   optlen = sizeof(option);
     778   option = 0;
     779   ret = getsockopt(s, IPPROTO_IP, IP_HDRINCL_OS2, (char *)&option, &optlen);
     780   if(ret == 0 && option != FALSE) {
     781       *(u_short *)&buf[2] = len;
     782   }
     783
     784#ifdef DUMP_PACKETS
     785   dprintf(("Packet length %d", len));
     786   for(int i=0;i<(len+7)/8;i++) {
     787           dprintf(("%02x %02x %02x %02x %02x %02x %02x %02x %c %c %c %c %c %c %c %c", buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7], buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7]));
     788   }
     789#endif
    746790   ret = send(s, (char *)buf, len, flags);
    747791
     
    785829   // check if the socket is a raw socket and has the IP_HDRINCL switch
    786830   // if this is the case, we overwrite the IP header length field with
    787    // the actual length because some apps tend to put in garbage in there
    788    // and rely on Windows correcting this
     831   // the actual length because some apps tend to put garbage in there
     832   // and rely on Windows to correct this
    789833   optlen = sizeof(option);
    790834   option = 0;
     
    794838   }
    795839   dprintf(("sending to %s", inet_ntoa(((sockaddr_in*)to)->sin_addr)));
     840#ifdef DUMP_PACKETS
     841   dprintf(("Packet length %d", len));
     842   for(int i=0;i<(len+7)/8;i++) {
     843           dprintf(("%02x %02x %02x %02x %02x %02x %02x %02x %c %c %c %c %c %c %c %c", buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7], buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7]));
     844   }
     845#endif
    796846   ret = sendto(s, (char *)buf, len, flags, (struct sockaddr *)to, tolen);
    797847
     
    10521102                        return SOCKET_ERROR;
    10531103                }
     1104                dprintf(("IPPROTO_TCP, TCP_NODELAY 0x%x", *optval));
    10541105                ret = setsockopt(s, level, optname, (char *)optval, optlen);
    10551106        }
Note: See TracChangeset for help on using the changeset viewer.