Subject: Re: strangeness while using SOCK_RAW
To: <>
From: Ignatios Souvatzis <>
List: tech-net
Date: 02/09/2007 11:48:54
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi Eric,

On Thu, Feb 08, 2007 at 03:59:30PM +0100, Eric Auge wrote:

> /usr/src/sys/netinet/raw_ip.c :
> [...]
> /*
>  * XXX Compatibility: programs using raw IP expect ip_len
>  * XXX to have the header length subtracted, and in host order.
>  * XXX ip_off is also expected to be host order.
>  */
>  ip->ip_len =3D ntohs(ip->ip_len) - (ip->ip_hl << 2);
>  NTOHS(ip->ip_off);
> [...]
> I don't understand this behavior and comment.
> What "programs" using SOCK_RAW, IPPROTO_RAW (the behavior for undefined p=
> seems to be similar to the IPPROTO_RAW one) expect the RAW IP header
> len(ip->ip_len) to be substracted from the size of the IP header without =
> off the header itself ...?

I think I read a comment somewhere (Stevens Vol. 2 ?) that programs get=20
the same environment they would get in the kernel at a some calling point.

Sounds reasonable - you can test basic stuff, before you start building
and booting kernels.

For serious work, you'd socket(PF_INET, SOCK_DGRAM, PROTO_OSPF) (and
write the code to support that in the kernel).


Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.4.5 (NetBSD)