Re: Wierdness of WSASendTo()??
On Thu, Apr 11, 2002 at 10:33:53AM -0600, Mark Paulus wrote: Ok, I have done some browsing, and now I'm totally confused. According to Microsoft, there are 2 headers and libraries: winsock.h Ws2tcpip.h Since I can seem to use the IP_HDRINCL macro, I am picking ws2tcpip.h file. Don't include winsock.h and friends if you're using Cygwin sockets. Just include sys/socket.h and all these POSIX schtuff. If you don't get IP_HDRINCL included that way, it's a leak in our headers (shouldn't that be in in.h?). For testing, just define IP_HDRINCL as 2 in your source file. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developermailto:[EMAIL PROTECTED] Red Hat, Inc. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Wierdness of WSASendTo()??
Thanks Corinna for that insight. However it didn't work. Further research has shown me this: The program opens one socket in RAW mode, which the developer uses to create an ICMP packet. This packet then get's sent out (He has 2 segments in his packet. An IP segment and an ICMP segment. He sets the protocol of the IP Header to IPPROTO_ICMP). Then he opens a second socket with IPPROTO_ICMP, to listen for the returning events. Because his is using his own header in his packet, he is able to manually send out an ICMP packet. However, under cygwin, I am not able to seemingly set the sending socket to ICMP mode, and so the protocol for these packets is defaulted to 0xFF, which the queried host says, What the heck, and fails the packet. I have gotten around this by ifdef'ing around the code, and by basically creating one socket in IPPROTO_ICMP mode, and using it to send receive the packets. Now I CAN use the setsockopt option to change the ttl, and the ICMP socket takes care of setting the protocol for the IP packet header. IP_HDRINCL does NOT exist when I only use sys/socket.h. Further searches only show it defined in w32api/ws2tcpip.h. And when I manually define it as 2, then I get those packets with an extra 20 bytes, and a protocol of 0xFF. My system is slightly old, but not that old: $ uname -a CYGWIN_NT-5.0 CSP00509 1.3.10(0.51/3/2) 2002-02-25 11:14 i686 unknown Has this socket code updated recently, or do we have a lack? (I would love to be able to dig a bit deeper and provide any patches, but I can't seem to get my company's Legal Eagles off their royal cans to provide/sign a release... :(:(:( ) On Fri, 12 Apr 2002 13:41:38 +0200, Corinna Vinschen wrote: On Thu, Apr 11, 2002 at 10:33:53AM -0600, Mark Paulus wrote: Ok, I have done some browsing, and now I'm totally confused. According to Microsoft, there are 2 headers and libraries: winsock.h Ws2tcpip.h Since I can seem to use the IP_HDRINCL macro, I am picking ws2tcpip.h file. Don't include winsock.h and friends if you're using Cygwin sockets. Just include sys/socket.h and all these POSIX schtuff. If you don't get IP_HDRINCL included that way, it's a leak in our headers (shouldn't that be in in.h?). For testing, just define IP_HDRINCL as 2 in your source file. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developermailto:[EMAIL PROTECTED] Red Hat, Inc. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Wierdness of WSASendTo()??
On Thu, Apr 11, 2002 at 08:20:59AM -0600, Mark Paulus wrote: MTR believes it's sending out a good ICMP packet of 64 bytes (0x40). cygwin_sendto() also thinks it's sending out 64 bytes (as reported by strace). However, tcpdump on my linux box is receiving 84 bytes. What it looks like to me is that somehow WSASendTo is re-formatting the packet that is going out. But, this turns it into an invalid packet, and causes a network unreachable error on the linux box, and the response never comes back. Has anyone seen this behaviour before?? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/wsanxref_8xo2.asp Look for IP_HDRINCL. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developermailto:[EMAIL PROTECTED] Red Hat, Inc. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: Wierdness of WSASendTo()??
Ok, I have done some browsing, and now I'm totally confused. According to Microsoft, there are 2 headers and libraries: winsock.h Ws2tcpip.h Since I can seem to use the IP_HDRINCL macro, I am picking ws2tcpip.h file. However, I can't seem to figure out how to set the option. When I invoke the following code fragment: #ifdef IP_HDRINCL /* FreeBSD wants this to avoid sending out packets with protocol type RAW to the network. */ if(setsockopt(sendsock, SOL_IP, IP_HDRINCL, trueopt, sizeof(trueopt))) { perror(setsockopt(IP_HDRINCL,1)); return -1; } #endif I get the following from strace, which indicates that maybe cygwin doesn't support IP_HDRINCL??? 202 280647 [main] mtr 2576 cygwin_socket: socket (2, 3, 255) 4034 284681 [main] mtr 2576 wsock_init: res 0 210 284891 [main] mtr 2576 wsock_init: wVersion 514 281 285172 [main] mtr 2576 wsock_init: wHighVersion 514 177 285349 [main] mtr 2576 wsock_init: szDescription WinSock 2.0 174 285523 [main] mtr 2576 wsock_init: szSystemStatus Running 171 285694 [main] mtr 2576 wsock_init: iMaxSockets 0 170 285864 [main] mtr 2576 wsock_init: iMaxUdpDg 0 372 286236 [main] mtr 2576 wsock_init: lpVendorInfo 0 64252 350488 [main] mtr 2576 fdsock: not setting socket inheritance since winsock2_active 1 272 350760 [main] mtr 2576 dtable::build_fhandler: fd 3, fh 0x615607C0 169 350929 [main] mtr 2576 fdsock: fd 3, name '/dev/udp', soc 0x27C 168 351097 [main] mtr 2576 cygwin_socket: 3 = socket (2, 3, 255) 5043 356140 [main] mtr 2576 cygwin_setsockopt: setsockopt optval=1 352 356492 [main] mtr 2576 cygwin_setsockopt: 0 = setsockopt (3, 0, 1 (SO_DEBUG), 22FE40, 4) Do I need to maybe restructure my code so that I do not create a header??? On Thu, 11 Apr 2002 17:07:40 +0200, Corinna Vinschen wrote: On Thu, Apr 11, 2002 at 08:20:59AM -0600, Mark Paulus wrote: MTR believes it's sending out a good ICMP packet of 64 bytes (0x40). cygwin_sendto() also thinks it's sending out 64 bytes (as reported by strace). However, tcpdump on my linux box is receiving 84 bytes. What it looks like to me is that somehow WSASendTo is re-formatting the packet that is going out. But, this turns it into an invalid packet, and causes a network unreachable error on the linux box, and the response never comes back. Has anyone seen this behaviour before?? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/wsanxref_8xo2.asp Look for IP_HDRINCL. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developermailto:[EMAIL PROTECTED] Red Hat, Inc. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/