Subject: Re: strangeness while using SOCK_RAW
To: <>
From: Ignatios Souvatzis <is@netbsd.org>
List: tech-kern
Date: 02/09/2007 11:48:54
--azLHFNyN32YCQGCU
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);
> [...]
>=20
> I don't understand this behavior and comment.
>=20
> What "programs" using SOCK_RAW, IPPROTO_RAW (the behavior for undefined p=
rotos
> 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 =
ripping
> 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).
Regards,
-is
--azLHFNyN32YCQGCU
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (NetBSD)
iD8DBQFFzFFuN4tiz3B8hB0RAhCKAJ99TalRyDDr4JwrRc0ABQLcvbAyeQCdEoEe
2/u5ax+tIn3v9AikyjkTSxA=
=oEoK
-----END PGP SIGNATURE-----
--azLHFNyN32YCQGCU--