From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E42F9BB84 for ; Fri, 19 May 2006 08:12:43 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k4J6ChFD014450 for ; Fri, 19 May 2006 08:12:43 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA15720 for ; Fri, 19 May 2006 08:12:43 +0200 (MET DST) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k4J6CgQP014447 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 19 May 2006 08:12:42 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first.in-berlin.de (e178025247.adsl.alicedsl.de [85.178.25.247]) (authenticated bits=0) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id k4J6CbKr009189 for ; Fri, 19 May 2006 08:12:38 +0200 Received: by first.in-berlin.de (Postfix, from userid 501) id 9413A286D1C; Fri, 19 May 2006 08:12:41 +0200 (CEST) Date: Fri, 19 May 2006 08:12:41 +0200 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] RAW-sockets Message-ID: <20060519061241.GC393@first.in-berlin.de> References: <20060518152745.GA6163@first.in-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at concorde with ID 446D61DB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 446D61DA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; bandel:01 in-berlin:01 byte:01 ocaml:01 int's:01 sockets:01 int's:01 ocaml:01 icmp:01 2006:98 wrote:01 caml-list:01 oliver:01 oliver:01 ints:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 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