Changeset 7992 for trunk/src/wsock32/wsock32.cpp
- Timestamp:
- Feb 23, 2002, 5:39:10 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wsock32/wsock32.cpp
r7979 r7992 1 /* $Id: wsock32.cpp,v 1.4 8 2002-02-20 16:08:03sandervl Exp $ */1 /* $Id: wsock32.cpp,v 1.49 2002-02-23 16:39:10 sandervl Exp $ */ 2 2 3 3 /* … … 65 65 #include "dbglocal.h" 66 66 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 71 69 72 70 ODINDEBUGCHANNEL(WSOCK32-WSOCK32) 73 74 71 75 72 /***************************************************************************** … … 209 206 strcpy(msg, "WSAHOST_NOT_FOUND"); 210 207 break; 208 case WSAENOPROTOOPT: 209 strcpy(msg, "WSAENOPROTOOPT"); 210 break; 211 case WSAEHOSTUNREACH: 212 strcpy(msg, "WSAEHOSTUNREACH"); 213 break; 211 214 default: 212 215 strcpy(msg, "unknown"); … … 326 329 return SOCKET_ERROR; 327 330 } 331 dprintf(("connect to %s", inet_ntoa(((sockaddr_in*)name)->sin_addr))); 332 328 333 ret = connect(s, (sockaddr *)name, namelen); 329 334 // map BSD error codes … … 550 555 //with the same parameters for the new socket (see docs) 551 556 if(QueryAsyncEvent(s, &mode, ¬ifyHandle, ¬ifyData, &lEvent) == TRUE) { 557 dprintf(("Setting async select for socket %x, mode %d, %x %x %x", ret, mode, notifyHandle, notifyData, lEvent)); 552 558 if(WSAAsyncSelectWorker(ret, mode, notifyHandle, notifyData, lEvent) == SOCKET_ERROR) { 553 559 ret = SOCKET_ERROR; … … 584 590 return SOCKET_ERROR; 585 591 } 592 dprintf(("bind to %s", inet_ntoa(((sockaddr_in*)addr)->sin_addr))); 586 593 ret = bind(s, (struct sockaddr *)addr, namelen); 587 594 … … 682 689 } 683 690 } 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 } 685 700 686 701 //Reset FD_READ event flagfor WSAAsyncSelect thread if one was created for this socket … … 714 729 return SOCKET_ERROR; 715 730 } 731 dprintf(("recvfrom to %s", inet_ntoa(((sockaddr_in*)from)->sin_addr))); 732 716 733 ret = recvfrom(s, buf, len, flags, from, fromlen); 717 734 … … 719 736 WSASetLastError(wsaErrno()); 720 737 } 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 } 722 747 723 748 //Reset FD_READ event flagfor WSAAsyncSelect thread if one was created for this socket … … 734 759 { 735 760 int ret; 761 int optlen; 762 int option; 736 763 737 764 if(!fWSAInitialized) { … … 744 771 return SOCKET_ERROR; 745 772 } 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 746 790 ret = send(s, (char *)buf, len, flags); 747 791 … … 785 829 // check if the socket is a raw socket and has the IP_HDRINCL switch 786 830 // if this is the case, we overwrite the IP header length field with 787 // the actual length because some apps tend to put ingarbage in there788 // and rely on Windows correctingthis831 // the actual length because some apps tend to put garbage in there 832 // and rely on Windows to correct this 789 833 optlen = sizeof(option); 790 834 option = 0; … … 794 838 } 795 839 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 796 846 ret = sendto(s, (char *)buf, len, flags, (struct sockaddr *)to, tolen); 797 847 … … 1052 1102 return SOCKET_ERROR; 1053 1103 } 1104 dprintf(("IPPROTO_TCP, TCP_NODELAY 0x%x", *optval)); 1054 1105 ret = setsockopt(s, level, optname, (char *)optval, optlen); 1055 1106 }
Note:
See TracChangeset
for help on using the changeset viewer.