реализация протокола IPv4 в Linux (Linux IPv4 protocol implementation)
Примечание (Note)
IP_FREEBIND
, IP_MSFILTER
, IP_MTU
, IP_MTU_DISCOVER
,
IP_RECVORIGDSTADDR
, IP_PASSSEC
, IP_PKTINFO
, IP_RECVERR
,
IP_ROUTER_ALERT
, and IP_TRANSPARENT
are Linux-specific.
Be very careful with the SO_BROADCAST
option - it is not
privileged in Linux. It is easy to overload the network with
careless broadcasts. For new application protocols it is better
to use a multicast group instead of broadcasting. Broadcasting
is discouraged.
Some other BSD sockets implementations provide IP_RCVDSTADDR
and
IP_RECVIF
socket options to get the destination address and the
interface of received datagrams. Linux has the more general
IP_PKTINFO
for the same task.
Some BSD sockets implementations also provide an IP_RECVTTL
option, but an ancillary message with type IP_RECVTTL
is passed
with the incoming packet. This is different from the IP_TTL
option used in Linux.
Using the SOL_IP
socket options level isn't portable; BSD-based
stacks use the IPPROTO_IP
level.
INADDR_ANY
(0.0.0.0) and INADDR_BROADCAST
(255.255.255.255) are
byte-order-neutral.
This means htonl(3) has no effect on them.
Compatibility
For compatibility with Linux 2.0, the obsolete socket(AF_INET,
SOCK_PACKET,
protocol)
syntax is still supported to open a
packet(7) socket. This is deprecated and should be replaced by
socket(AF_PACKET, SOCK_RAW,
protocol)
instead. The main
difference is the new sockaddr_ll address structure for generic
link layer information instead of the old sockaddr_pkt
.