On 7/9/06, Peter Philipp <[EMAIL PROTECTED]> wrote:
On Sun, Jul 09, 2006 at 03:32:41PM +0200, Karel Kulhavy wrote:
> Hello
>
> " The types SOCK_RAW, which is available only to the superuser, and SOCK_RDM,
> which is planned, but not yet implemented, are not described here."
> (man socket)
>
> Where is SOCK_RAW described, then? Why is not at least a pointer to the
> description included in the manpage?
Feel free to update the manpage. These features were probably left out because
the designers thought it only suits packet monkeys perhaps?
$ grep -n SOCK_RAW /usr/include/sys/socket.h
52:#define SOCK_RAW 3 /* raw-protocol interface */
$
> I would like to port a program for testing free space optics devices from
> Linux to OpenBSD. It sends raw Ethernet frames, one filled with all 0's
> and another filled with 01 pattern. It's important to fill as large part
> of the packet with these patterns as possible because it's for benchmarking
> the amplifiers.
Uhm, SOCK_RAW only allows you to send layer 3 packets. Perhaps you are
confusing it with SOCK_PACKET which is linux only afaik and does not exist
in BSD. To send layer 2 frames from userland your only option is bpf(4)
injects and tun(4) writes when in layer 2 mode.
> Should I investigate SOCK_RAW or is there a different mechanism under OpenBSD
> how to send a raw Ethernet frame? Or is it not implemented at all?
>
> CL<
What you should do is read the book "Unix Network Programming Volume 1" by
the late W. R. Stevens, he describes most Layer 2 api's for what you want
to do.
I investigated this a little bit a while back. I believe that
AF_INET+SOCK_RAW is IP. AF_INET+SOCK_STREAM is TCP and
AF_INET+SOCK_DGRAM is UDP. So SOCK_RAW lets you construct your own TCP
and UDP headers but if you want to construct your own IP headers you
need to go down a level to bpf(4), as mentioned.
Is this a correct summary?
-Nick