Version française
Home     About     Download     Resources     Contact us    
Browse thread
RAW-sockets
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] RAW-sockets
On Fri, May 19, 2006 at 12:09:31PM +1200, Jonathan Roewen wrote:
> >IP normally uses 32Bit words, and the parts of it are not
> >necessarily byte or nibble oriented.
> >So I have to be able to set some bits directly.
> >But the OCaml int's is not complete 32 Bits.
> >
> >How to use the raw sockets then?
> >
> >Do I have to make a string (for highlevel socket functions)
> >or int's (read/write) and write that string or int-buffer
> >into the socket?
> >So that I write all bytes of the header as if it would be
> >normal data that I would write to a tcp-socket otherwise?
> 
> There are various approaches :-) Extlib has a nice IO module which has
> functions for writing  32-bit ints (using a 31-bit int when that extra
> bit isn't needed or a proper int32). I found that module quite useful
> for writing code that's a bit shorter/simpler for network packet
> generation.
> 
> You can use some other interesting approaches like representing your
> packet to be constructed as a list. I did that for DST's netstack :-)
> Can't say whether it's better or worse -- just different.

Well, I also could use C-functions (externals).

But I don't know HOW OCaml handle's the IP-stuff.

I don't know if - when using protocoll 1 (ICMP) for example,
if the IP-header will be generated automatically by OCaml.
It seems that it will be handled this way, but I have not seen
anything about this in the reference manual.

Do I have to write the IP-header by myself or not?

No documentation about if IP_HDRINCL is used internally or not.

Some more verbosity of the refman could help here.

Ciao,
   Oliver