* RAW-sockets
@ 2006-05-18 15:27 Oliver Bandel
2006-05-18 15:50 ` [Caml-list] RAW-sockets Oliver Bandel
[not found] ` <ad8cfe7e0605181709y6de7fd24w7e7d51a0cfa8212c@mail.gmail.com>
0 siblings, 2 replies; 9+ messages in thread
From: Oliver Bandel @ 2006-05-18 15:27 UTC (permalink / raw)
To: caml-list
Hello,
how to use Eaw sockets from OCaml?
As in raw sockets I have to create the IP-header by myself
I'm wondering how.
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?
TIA,
Oliver
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] RAW-sockets
2006-05-18 15:27 RAW-sockets Oliver Bandel
@ 2006-05-18 15:50 ` Oliver Bandel
2006-05-18 16:08 ` Oliver Bandel
[not found] ` <Pine.LNX.4.62.0605181027060.414@camaross.cs.unm.edu>
[not found] ` <ad8cfe7e0605181709y6de7fd24w7e7d51a0cfa8212c@mail.gmail.com>
1 sibling, 2 replies; 9+ messages in thread
From: Oliver Bandel @ 2006-05-18 15:50 UTC (permalink / raw)
To: caml-list
On Thu, May 18, 2006 at 05:27:45PM +0200, Oliver Bandel wrote:
> Hello,
>
>
> how to use Eaw sockets from OCaml?
>
> As in raw sockets I have to create the IP-header by myself
> I'm wondering how.
>
> 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.
[...]
I have not found in the Unix-module an option for the sockets,
that is eaquivalent to the IP_HDRINCL option, as described
by Stevens in the Networking Programming Vol. I.
Isn't it possible in OCaml to create own IP-headers?
So, do I have to go back to C to e.g. write ICMP packets?
TIA,
Oliver
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] RAW-sockets
2006-05-18 15:50 ` [Caml-list] RAW-sockets Oliver Bandel
@ 2006-05-18 16:08 ` Oliver Bandel
[not found] ` <Pine.LNX.4.62.0605181027060.414@camaross.cs.unm.edu>
1 sibling, 0 replies; 9+ messages in thread
From: Oliver Bandel @ 2006-05-18 16:08 UTC (permalink / raw)
To: caml-list
On Thu, May 18, 2006 at 05:50:07PM +0200, Oliver Bandel wrote:
> On Thu, May 18, 2006 at 05:27:45PM +0200, Oliver Bandel wrote:
> > Hello,
> >
> >
> > how to use Eaw sockets from OCaml?
> >
> > As in raw sockets I have to create the IP-header by myself
> > I'm wondering how.
> >
> > 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.
> [...]
>
> I have not found in the Unix-module an option for the sockets,
> that is eaquivalent to the IP_HDRINCL option, as described
> by Stevens in the Networking Programming Vol. I.
>
> Isn't it possible in OCaml to create own IP-headers?
> So, do I have to go back to C to e.g. write ICMP packets?
Or will protocol = 1 (ICMP) automagically set up all IP-specific
stuff?
(But if so: how RAW can one work with that?)
TIA,
Oliver
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <Pine.LNX.4.62.0605181027060.414@camaross.cs.unm.edu>]
* Re: [Caml-list] RAW-sockets
[not found] ` <Pine.LNX.4.62.0605181027060.414@camaross.cs.unm.edu>
@ 2006-05-18 21:14 ` Oliver Bandel
2006-05-19 6:14 ` Oliver Bandel
1 sibling, 0 replies; 9+ messages in thread
From: Oliver Bandel @ 2006-05-18 21:14 UTC (permalink / raw)
To: caml-list
On Thu, May 18, 2006 at 10:36:25AM -0600, William D. Neumann wrote:
> On Thu, 18 May 2006, Oliver Bandel wrote:
>
> >>how to use Eaw sockets from OCaml?
> >>
> >>As in raw sockets I have to create the IP-header by myself
> >>I'm wondering how.
> >>
> >>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.
> >[...]
> >
> >I have not found in the Unix-module an option for the sockets,
> >that is eaquivalent to the IP_HDRINCL option, as described
> >by Stevens in the Networking Programming Vol. I.
> >
> >Isn't it possible in OCaml to create own IP-headers?
> >So, do I have to go back to C to e.g. write ICMP packets?
>
> No. Just create a string in OCaml and use that. Here's a (possibly
> awful) hunk of code I wrote for creating ICMP packets. Take a look at it
> and see how I did things.
[...]
OK, thanks for that impression...
...but soooo much code for this?
Seems that it's easier to do it in C. :(
I will look at your code in more detail later,
but at first look, it was a little shock. :(
Maybe you have implemented more functionality than I need
and so what I was looking for is some lines of code only.
But nevertheless it's god to have his, so I can reason
about how to do some ICMP-based stuff.
Best Regards,
Oliver
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] RAW-sockets
[not found] ` <Pine.LNX.4.62.0605181027060.414@camaross.cs.unm.edu>
2006-05-18 21:14 ` Oliver Bandel
@ 2006-05-19 6:14 ` Oliver Bandel
2006-05-19 14:51 ` William D. Neumann
1 sibling, 1 reply; 9+ messages in thread
From: Oliver Bandel @ 2006-05-19 6:14 UTC (permalink / raw)
To: caml-list
Hi,
On Thu, May 18, 2006 at 10:36:25AM -0600, William D. Neumann wrote:
> On Thu, 18 May 2006, Oliver Bandel wrote:
>
> >>how to use Eaw sockets from OCaml?
> >>
> >>As in raw sockets I have to create the IP-header by myself
> >>I'm wondering how.
> >>
> >>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.
> >[...]
> >
> >I have not found in the Unix-module an option for the sockets,
> >that is eaquivalent to the IP_HDRINCL option, as described
> >by Stevens in the Networking Programming Vol. I.
> >
> >Isn't it possible in OCaml to create own IP-headers?
> >So, do I have to go back to C to e.g. write ICMP packets?
>
> No. Just create a string in OCaml and use that. Here's a (possibly
> awful) hunk of code I wrote for creating ICMP packets. Take a look at it
> and see how I did things.
>
> (************************************************************************
> *
> * icmp.ml
> *
> *
> * Created by William D. Neumann on 10 Mar 2006.
> * Copyright (c) 2006 William D. Neumann. All rights reserved.
> *
> ************************************************************************)
>
>
> (*p
> \setlength{\parindent}{0pt}
> \usepackage{amsmath,amsthm}
> \usepackage{amsfonts}
> *)
>
> (*
> This is [icmp.ml]\footnote{Copyright (c) 2006 William D. Neumann. All
> rights reserved.}, an OCaml program that implements a simple library for
> working with ICMP packets.
> *)
[...]
It's nice that you have embedded LaTeX-code in your comments.
With which tool do you generate your documentation?
If there is such a LP-tool I also would use it, if freely available.
Ciao,
Oliver
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] RAW-sockets
2006-05-19 6:14 ` Oliver Bandel
@ 2006-05-19 14:51 ` William D. Neumann
0 siblings, 0 replies; 9+ messages in thread
From: William D. Neumann @ 2006-05-19 14:51 UTC (permalink / raw)
To: Oliver Bandel; +Cc: caml-list
On Fri, 19 May 2006, Oliver Bandel wrote:
> It's nice that you have embedded LaTeX-code in your comments.
> With which tool do you generate your documentation?
> If there is such a LP-tool I also would use it, if freely available.
I use ocamlweb <http://www.lri.fr/~filliatr/ocamlweb/>.
William D. Neumann
---
"There's just so many extra children, we could just feed the
children to these tigers. We don't need them, we're not doing
anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Life is unfair. Kill yourself or get over it.
-- Black Box Recorder
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <ad8cfe7e0605181709y6de7fd24w7e7d51a0cfa8212c@mail.gmail.com>]
* Re: [Caml-list] RAW-sockets
[not found] ` <ad8cfe7e0605181709y6de7fd24w7e7d51a0cfa8212c@mail.gmail.com>
@ 2006-05-19 6:12 ` Oliver Bandel
[not found] ` <ad8cfe7e0605182316l85124c9s5dd588aa89f9c285@mail.gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Oliver Bandel @ 2006-05-19 6:12 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-05-20 20:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-18 15:27 RAW-sockets Oliver Bandel
2006-05-18 15:50 ` [Caml-list] RAW-sockets Oliver Bandel
2006-05-18 16:08 ` Oliver Bandel
[not found] ` <Pine.LNX.4.62.0605181027060.414@camaross.cs.unm.edu>
2006-05-18 21:14 ` Oliver Bandel
2006-05-19 6:14 ` Oliver Bandel
2006-05-19 14:51 ` William D. Neumann
[not found] ` <ad8cfe7e0605181709y6de7fd24w7e7d51a0cfa8212c@mail.gmail.com>
2006-05-19 6:12 ` Oliver Bandel
[not found] ` <ad8cfe7e0605182316l85124c9s5dd588aa89f9c285@mail.gmail.com>
2006-05-19 6:24 ` Oliver Bandel
[not found] ` <ad8cfe7e0605182327p3a0d16c4ub43326343347c60c@mail.gmail.com>
2006-05-20 20:57 ` Oliver Bandel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox