Subject: Re: Raw socket functionality
To: Geir Inge Jensen <Geir.I.Jensen@runit.sintef.no>
From: Jeremy Cooper <email@example.com>
Date: 03/13/1998 13:44:22
On Fri, 13 Mar 1998, Geir Inge Jensen wrote:
> How is IPPROTO_RAW supposed to work? I thought that I could send raw ip
> packets unchanged to the network. [ ... ]
> However, the packet that finally reaches the network has IPPROTO_RAW in
> its IP-header! Can I change this functionality?
IPPROTO_RAW notifies the IP protocol stack that to send IP packets with a
protocol field of ``RAW'' (as opposed to TCP, UDP, or ICMP), instead of
``RAW IP Packets'' as you are assuming. Note this distinction carefully.
If you truly want to manufacture your own IP packets with headers
included, you must make a call to setsockopt() to toggle the IP_HDRINCL
flag on the socket before you use it.
int state = 1;
setsockopt(sockfd, 0, IP_HDRINCL, &state, sizeof(state))