This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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 Developer                                mailto:cygwin@cygwin.com
>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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]