Datagrams Outside the Kernel

Abhijit Khale akhale at chamomile.uucp
Tue Jul 3 06:20:40 AEST 1990


In article <414 at minya.UUCP> jc at minya.UUCP (John Chambers) writes:
>In article <8009 at inco.UUCP>, mack at inco.UUCP (Dave Mack) writes:
>> 
>> I have question which may (or may not) be worthy of this august
>> assemblage.
>> 
>> I have a program running in user context which has a datagram (IP,
>> for example) in a buffer. I need to hand this datagram over to
>> the kernel in such a way that it gets transmitted to whatever
>> Internet address lurks in the IP header.
>> 
>> I also need to solve the inverse problem: getting a datagram in
>> its raw form from the kernel when it arrives at my machine.

I missed the original article, but .. 

Use raw IP sockets. These allow you to get a datagram in its raw
form when it arrives at the machine [ Actually when
all fragments of that datagram arrive. ]. You will also get the header.

Raw IP sockets can also be used to send out IP packets with a 
particular header. Not all fields in the IP header can be manipulated,
though. You cannot set the src addr to an addr not that of the
machine. Also, the TTL and the checksum ( obviously ) are filled in 
by the system. 

>
>I'll second this request.  I've been asked whether I can build an
>application which, in effect, "volunteers" to handle any IP address
>that the kernel doesn't know what to do with.  In perusing TFM, I
>haven't found any hint that this is possible.  Does any extant IP
>implementation supply a hook that allows this?

A  raw socket would enable you to do that. [ I think so anyway,
since I am not sure I understand your question fully ]. 

man 4 ip will tell you more about how to open a raw socket. 

Abhijit 
akhale at parc.xerox.com 



More information about the Comp.unix.wizards mailing list