Subject: Re: Raw socket functionality
To: None <netbsd-help@NetBSD.ORG>
From: None <tooleym@douglas.bc.ca>
List: netbsd-help
Date: 03/13/1998 13:01:14
You must do a call to tell the kernel that you are including your own IP
header in the packet--note that you must now ensure that the header is
correct or it will not be accepted properly and you may risk it simply
being ignored by some routers along the way to the destination.

The way you tell the kernel that you are including the header is via the
following call:

return=setsockopt(socket, IPPROTO_IP, IP_HDRINCL, &flags);

where flags is an integer. (the IPPROTO_IP is a bit fuzzy--i'm going off
memory here)

see the man page for setsockopt. you don't actually have to run out and
buy an entire book--all the relevant information is in the programmer's
online manuals.

Good luck!

Marc Tooley
tooleym@douglas.bc.ca

> Hi,
> 
> 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?
> 
> Can I listen to all tcp packets that my machine receives if I use
> SOCK_RAW and IPPROTO_TCP?
> 
> This is on vanilla 1.3.
> 
> Thanks,
> Geir Inge.