Packet sockets: Difference between revisions
| Line 64: | Line 64: | ||
Cooked packets (common, protocol-independent link-layer header in a <tt>sockaddr_ll</tt>). | Cooked packets (common, protocol-independent link-layer header in a <tt>sockaddr_ll</tt>). | ||
==AF_INET/AF_INET6== | ==AF_INET/AF_INET6== | ||
The protocol field restricts the Layer 3 protocols which will be passed to the socket; IPPROTO_RAW can set arbitrary IP protocol values, and thus implies the IP_HDRINCL socket option. | The protocol field restricts the Layer 3 protocols which will be passed to the socket; IPPROTO_RAW can set arbitrary IP protocol values (for transmission, but not reception), and thus implies the IP_HDRINCL socket option. Even if IP_HDRINCL is set, raw sockets might rewrite the following fields: | ||
* Total length | |||
* Checksum | |||
* Packet ID (given a random value if set to 0) | |||
* Source address (selected via routing lookup if set to 0) | |||
===SOCK_RAW=== | ===SOCK_RAW=== | ||
Path MTU is performed on outgoing packets unless disabled via IP_MTU_DISCOVER sockopt, in which case they might be fragmented if they exceed the outgoing device's MTU (unless IP_HDRINCL is used). Fragment reassembly is performed before delivering packets to receiving sockets. | |||
===SOCK_PACKET=== | ===SOCK_PACKET=== | ||
Obsolete since Linux 2.0. | Obsolete since Linux 2.0. | ||