Subject: Re: Raw socket functionality
To: Geir Inge Jensen <>
From: Chad Mynhier <>
List: current-users
Date: 03/13/1998 09:50:19
Geir Inge Jensen writes:
>How is IPPROTO_RAW supposed to work? I thought that I could send raw ip
>packets unchanged to the network. I use this:
>  raw = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
>and use this flag in the IP header:
>  ip->ip_p = IPPROTO_TCP;
>However, the packet that finally reaches the network has IPPROTO_RAW in
>its IP-header! Can I change this functionality?

If I'm not mistaken, what you're missing here is a call to setsockopt()
to specify IP_HDRINCL.  When you set this option, you are responsible for
filling in the fields in the IP header.  If you don't set this option,
the fields will be filled in for you.

You might want to look at Stevens' Unix Network Programming, Volume 1,
2nd edition.  Chapter 25 discusses raw IP.  Page 657 discusses the 
IP_HDRINCL option.

Chad Mynhier