Re: Gratuitous ARP/RAW sockets under Linux

Alan Cox (iialan@iifeak.swan.ac.uk)
Mon, 5 Feb 1996 08:49:13 +0000 (GMT)


> b) My second question is -- Is there an example code fragment that
> shows how to generate ethernet encapsulated IP messages from
> user space (with root privileges) in which various ethernet fields
> (dest addr, Type) and IP fields (e.g. TTL) can be controlled by the
> user? RAW sockets should be usbale in this fashion but
> the man pages don't say much about RAW sockets.

A SOCK_RAW IP socket lets you set the core fields, if you open it with
a type of IPPROTO_RAW you can fill in almost anything. I'd recommend reading
the soure to ping (from netkit-B) to see this in use.

You can also send raw frames down to the physical level using the SOCK_PACKET
interface (eg to send gratuitous arp from user space). See the
libpacket.[ch] files from DOSemu for a support library.

Alan