File: ip.7

package info (click to toggle)
manpages 1.29-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,796 kB
  • ctags: 5
  • sloc: sh: 79; makefile: 61
file content (843 lines) | stat: -rw-r--r-- 23,693 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
'\" t
.\" Don't change the line above. it tells man that tbl is needed.
.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
.\" Permission is granted to distribute possibly modified copies
.\" of this page provided the header is included verbatim,
.\" and in case of nontrivial modification author and date
.\" of the modification is added to the header.
.\" $Id: ip.7,v 1.13 1999/06/12 10:11:38 freitag Exp $
.TH IP  7 "11 May 1999" "Linux Man Page" "Linux Programmer's Manual" 
.SH NAME
ip \- Linux IPv4 protocol implementation
.SH SYNOPSIS
.B #include <sys/socket.h>
.br
.B #include <net/netinet.h> 
.sp
.IB tcp_socket " = socket(PF_INET, SOCK_STREAM, 0);"
.br 
.IB raw_socket " = socket(PF_INET, SOCK_RAW, " protocol ");"
.br
.IB udp_socket " = socket(PF_INET, SOCK_DGRAM, " protocol ");"
.SH DESCRIPTION 
Linux implements the Internet Protocol, version 4, 
described in RFC791 and RFC1122. 
.B ip 
contains a level 2 
multicasting implementation conforming to RFC1112.  It also contains an IP 
router including a packet filter.
.\" XXX: has someone verified that 2.1 is really 1812 compliant?
.PP
The programmer's interface is BSD sockets compatible.
For more information on sockets, see 
.BR socket (7). 
.PP
An IP socket is created by calling the
.BR socket (2) 
function as 
.BR "socket(PF_INET, socket_type, protocol)" .
Valid socket types are 
.B SOCK_STREAM 
to open a 
.BR tcp (7) 
socket, 
.B SOCK_DGRAM
to open a
.BR udp (7)
socket, or
.B SOCK_RAW
to open a 
.BR raw (7)
socket to access the IP protocol directly. 
.I protocol 
is the IP protocol in the IP header to be received or sent.  The only valid
values for
.I protocol
are
.B 0
and
.B IPPROTO_TCP
for TCP sockets and
.B 0
and
.B IPPROTO_UDP 
for UDP sockets.  For 
.B SOCK_RAW 
you may specify
a valid IANA IP protocol defined in 
RFC1700
assigned numbers.
.PP
.\" XXX ip current does an autobind in listen, but I'm not sure if that should
.\" be documented.
When a process wants to receive new incoming packets or connections, it 
should bind a socket to a local interface address using
.BR bind (2).
Only one IP socket may be bound to any given local (address, port) pair.
When 
.B INADDR_ANY 
is specified in the bind call the socket will be bound to
.I all
local interfaces. When 
.BR listen (2)
or
.BR connect (2)
are called on a unbound socket the socket is automatically bound to a
random free port with the local address set to
.BR INADDR_ANY .

A TCP local socket address that has been bound is unavailable for some time after closing,
unless the 
.B SO_REUSEADDR
flag has been set.  Care should be taken when using this flag as it
makes TCP less reliable.  

.SH ADDRESS FORMAT
An IP socket address is defined as a combination of an IP interface address
and a port number. The basic IP protocol does not supply port numbers, they
are implemented by higher level protocols like 
.BR udp (7)
and
.BR tcp (7).
On raw sockets
.B sin_port
is set to the IP protocol.

.PP
.RS
.nf
.ta 4n 19n 31n
struct sockaddr_in {
	sa_family_t	sin_family;	/* address family: AF_INET */
	u_int16_t	sin_port;	/* port in network byte order */
	struct in_addr  sin_addr;	/* internet address */
};

/* Internet address. */
struct in_addr {
	u_int32_t	s_addr;	/* address in network byte order */
};
.ta
.fi
.RE
.PP
.I sin_family 
is always set to 
.BR AF_INET . 
This is required; in Linux 2.2 most networking functions return 
.B EINVAL
when this setting is missing.
.I sin_port
contains the port in network byte order. The port numbers below 1024 are called
.IR "reserved ports" .
Only processes with effective user id 0 or the 
.B CAP_NET_BIND_SERVICE 
capability may 
.BR bind (2)  
to these sockets. Note that the raw IPv4 protocol as such has no concept of a 
port, they are only implemented by higher protocols like
.BR tcp (7)
and
.BR udp (7).
.PP
.I sin_addr 
is the IP host address.
The 
.I addr
member of 
.B struct in_addr
contains the host interface address in network order. 
.B in_addr 
should be only accessed using the
.BR inet_aton (3),
.BR inet_addr (3),
.BR inet_makeaddr (3)
library functions or directly with the name resolver (see
.BR gethostbyname (3)).
IPv4 addresses are divided into unicast, broadcast 
and multicast addresses. Unicast addresses specify a single interface of a host,
broadcast addresses specify all hosts on a network and multicast addresses 
address all hosts in a multicast group. Datagrams to broadcast addresses
can be only sent or received when the 
.B SO_BROADCAST
socket flag is set.
In the current implementation connection oriented sockets are only allowed 
to use unicast addresses.
.\" Leave a loophole for XTP @)

Note that the address and the port are always stored in network order.
In particular, this means that you need to call
.BR htons (3) 
on the number that is assigned to a port. All address/port manipulation 
functions in the standard library work in network order.

There are several special addresses: 
.B INADDR_LOOPBACK
(127.0.0.1)
always refers to the local host via the loopback device;
.B INADDR_ANY 
(0.0.0.0)
means any address for binding;
.B INADDR_BROADCAST
(255.255.255.255)
means any host and has the same effect on bind as 
.B INADDR_ANY
for historical reasons.

.SH SOCKET OPTIONS

IP supports some protocol specific socket options that can be set with
.BR setsockopt (2)
and read with
.BR getsockopt (2).
The socket option level for IP is 
.B SOL_IP
. A boolean integer flag is zero when it is false, otherwise true.

.TP
.B IP_OPTIONS
Sets or get the IP options to be sent with every packet from this
socket.  The arguments are a pointer to a memory buffer containing the options 
and the option length.
The
.BR setsockopt (2)
call sets the IP options associated with a socket.
The maximum option size for IPv4 is 40 bytes. See RFC791 for the allowed
options. When the initial connection request packet for a
.B SOCK_STREAM
socket contains IP options, the IP options will be set automatically
to the options from the initial packet with routing headers reversed.
Incoming packets are not allowed to change options after the connection
is established.
The processing of all incoming source routing options
is disabled by default and can be enabled by using the
.B accept_source_route
sysctl.  Other options like timestamps are still handled.
For datagram sockets, IP options can be only set by the local user.
Calling
.BR getsockopt (2)
with
.I IP_OPTIONS
puts the current IP options used for sending into the supplied buffer.

.TP
.B IP_PKTINFO
Pass an
.I IP_PKTINFO
ancillary message that contains a 
.B pktinfo 
structure that supplies some information about the incoming packet. This
only works for datagram oriented sockets.
.IP
.RS
.ta 4n 19n 33n
.nf
struct in_pktinfo
{
	unsigned int	ipi_ifindex; 	/* Interface index */
	struct in_addr	ipi_spec_dst;	/* Routing destination address */
	struct in_addr	ipi_addr;	/* Header Destination address */
};
.fi
.RE
.IP
.\" XXX elaborate on that.
.B ipi_ifindex
is the unique index of the interface the packet was received on.
.\" XXX is that correct?
.B ipi_spec_dst
is the destination address of the routing table entry and
.B ipi_addr
is the destination address in the packet header.
If
.I IP_PKTINFO 
is passed to
.BR sendmsg (2)
then the outgoing packet will be sent over the interface
specified in
.B ipi_ifindex
with the destination address set to
.B ipi_spec_dst
.

.TP
.B IP_RECVTOS
If enabled the 
.I IP_TOS 
ancillary message is passed with incoming packets. It contains a byte which
specifies the Type of Service/Precedence field of the packet header.
Expects a boolean integer flag. 

.TP
.B IP_RECVTTL
When this flag is set
pass a 
.I IP_RECVTTL 
control message with the time to live 
field of the received packet as a byte. Not supported for
.B SOCK_STREAM
sockets.

.TP
.B IP_RECVOPTS
Pass all incoming IP options to the user in a
.I IP_OPTIONS 
control message. The routing header and other options are already filled in
for the local host. Not supported for
.I SOCK_STREAM 
sockets.

.TP
.B IP_RETOPTS
Identical to 
.I IP_RECVOPTS
but returns raw unprocessed options with timestamp and route record
options not filled in for this hop.

.TP
.B IP_TOS
Set or receive the Type-Of-Service (TOS) field that is sent with every IP packet 
originating from this socket. It is used to prioritize packets on the network.
TOS is a byte. There are some standard TOS flags defined:
.B IPTOS_LOWDELAY 
to minimize delays for interactive traffic,
.B IPTOS_THROUGHPUT
to optimize throughput,
.B IPTOS_RELIABILITY
to optimize for reliability,
.B IPTOS_MINCOST
should be used for "filler data" where slow transmission doesn't matter.
At most one of these TOS values can be specified. Other bits are invalid and
shall be cleared.
Linux sends 
.B IPTOS_LOWDELAY 
datagrams first by default,
but the exact behaviour depends on the configured queueing discipline. 
.\" XXX elaborate on this 
Some high priority levels may require an effective user id of 0 or the
.B CAP_NET_ADMIN
capability.
The priority can also be set in a protocol independent way by the (
.B SOL_SOCKET, SO_PRIORITY
) socket option (see
.BR socket (7)
). 

.TP  
.B IP_TTL
Set or retrieve the current time to live field that is send in every packet
send from this socket.

.TP
.B IP_HDRINCL
If enabled 
the user supplies an ip header in front of the user data. Only valid
for 
.B SOCK_RAW  
sockets. See
.BR raw (7)
for more information. When this flag is enabled the values set by
.IR IP_OPTIONS ,
.I IP_TTL
and
.I IP_TOS
are ignored.

.TP
.B IP_RECVERR
Enable extended reliable error message passing. 
When enabled on a datagram socket all
generated errors will be queued in a per-socket error queue. When the user
receives an error from a socket operation the errors can
be received by calling 
.BR recvmsg (2) 
with the 
.B MSG_ERRQUEUE 
flag set. The 
.B sock_extended_err 
structure describing the error will be passed in a ancillary message with 
the type 
.I IP_RECVERR 
and the level 
.BR SOL_IP . 
This is useful for reliable error handling on unconnected sockets.
The received data portion of the error queue
contains the error packet.
.IP
IP uses the 
.B sock_extended_err
structure as follows:
.I ee_origin 
is set to 
.B SO_EE_ORIGIN_ICMP 
for errors received as an ICMP packet, or
.B SO_EE_ORIGIN_LOCAL 
for locally generated errors. 
.I ee_type 
and 
.I ee_code 
are set from the type and code fields of the ICMP header.
.I ee_info
contains the discovered MTU for 
.B EMSGSIZE 
errors. 
.I ee_data 
is currently not used. When the error originated from the network, all IP options 
.RI ( IP_OPTIONS ", " IP_TTL ", "
etc.) enabled on the socket and contained in the 
error packet are passed as control messages. The payload of the packet
causing the error is returned as normal data.
.IP
.\" XXX: is it a good idea to document that? It is a dubious feature.
On 
.B SOCK_STREAM 
sockets,
.I IP_RECVERR 
has slightly different semantics. Instead of
saving the errors for the next timeout, it passes all incoming errors 
immediately to the 
user. This might be useful for very short-lived TCP connections which
need fast error handling. Use this option with care: it makes TCP unreliable
by not allowing it to recover properly from routing shifts and other normal
conditions and breaks the protocol specification. 
Note that TCP has no error queue; 
.B MSG_ERRQUEUE
is illegal on 
.B SOCK_STREAM 
sockets. 
Thus all errors are returned by socket function return or 
.B SO_ERROR
only. 
.IP
For raw sockets,
.I IP_RECVERR 
enables passing of all received ICMP errors to the
application, otherwise errors are only reported on connected sockets
.IP
It sets or retrieves an integer boolean flag. 
.I IP_RECVERR
defaults to off. 

.TP
.B IP_PMTU_DISCOVER
Sets or receives the Path MTU Discovery setting
for a socket. When enabled, Linux will perform Path MTU Discovery
as defined in RFC1191
on this socket. The don't fragment flag is set on all outgoing datagrams.
The system-wide default is controlled by the 
.B ip_no_pmtu_disc 
sysctl for 
.B SOCK_STREAM 
sockets, and disabled on all others. For non
.B SOCK_STREAM 
sockets it is the user's responsibility to packetize the data 
in MTU sized chunks and to do the retransmits if necessary. 
The kernel will reject packets that are bigger than the known
path MTU if this flag is set (with
.B EMSGSIZE
). 

.TS
tab(:);
c l
l l.
Path MTU discovery flags:Meaning
IP_PMTUDISC_WANT:Use per-route settings.
IP_PMTUDISC_DONT:Never do Path MTU Discovery.
IP_PMTUDISC_DO:Always do Path MTU Discovery. 
.TE   


When PMTU discovery is enabled the kernel automatically keeps track of
the path MTU per destination host. 
When it is connected to a specific peer with
.BR connect (2)
the currently known path MTU can be retrieved conveniently using the 
.B IP_MTU 
socket option (e.g. after a 
.B EMSGSIZE 
error occurred).  It may change over time. 
For connectionless sockets with many destinations 
the new also MTU for a given destination can also be accessed using the 
error queue (see 
.BR IP_RECVERR ).
A new error will be queued for every incoming MTU update.

While MTU discovery is in progress initial packets from datagram sockets
may be dropped.  Applications using UDP should be aware of this and not
take it into account for their packet retransmit strategy.

To bootstrap the path MTU discovery process on unconnected sockets it
is possible to start with a big datagram size
(up to 64K-headers bytes long) and let it shrink by updates of the path MTU.
.\" XXX this is an ugly hack

To get an initial estimate of the
path MTU connect a datagram socket to the destination address using
.BR connect (2)
and retrieve the MTU by calling
.BR getsockopt (2)
with the
.B IP_MTU
option.     

.TP
.B IP_MTU
Retrieve the current known path MTU of the current socket. 
Only valid when the socket has been connected. Returns an integer. Only valid
as a 
.BR getsockopt (2). 
.\"
.TP
.B IP_ROUTER_ALERT
Pass all to-be forwarded packets with the 
IP Router Alert 
option 
set to this socket. Only valid for raw sockets. This is useful, for instance, for user
space RSVP daemons. The tapped packets are not forwarded by the kernel, it is 
the users responsibility to send them out again. Socket binding is ignored,
such packets are only filtered by protocol.
Expects an integer flag. 
.\"
.TP
.B IP_MULTICAST_TTL
Set or reads the time-to-live value of outgoing multicast packets for this
socket. It is
very important for multicast packets to set the smallest TTL possible. 
The default is 1 which means that multicast packets don't leave the local
network unless the user program explicitly requests it. Argument is an
integer.
.\"
.TP
.B IP_MULTICAST_LOOP
Sets or reads a boolean integer argument whether sent multicast packets should be
looped back to the local sockets.
.\"
.TP
.B IP_ADD_MEMBERSHIP
Join a multicast group. Argument is a 
.B struct ip_mreqn
structure. 
.PP
.RS
.nf
.ta 4n 19n 34n
struct ip_mreqn
{
	struct in_addr	imr_multiaddr;	/* IP multicast group address */
	struct in_addr	imr_address;	/* IP address of local interface */
	int	imr_ifindex;	/* interface index */
};
.fi
.RE
.IP
.I imr_multiaddr
contains the address of the multicast group the application wants to join or leave.
It must be a valid multicast address. 
.I imr_address
is the address of the local interface with which the system should join the multicast
group; if it is equal to 
.B INADDR_ANY
an appropriate interface is chosen by the system.
.I imr_ifindex
is the interface index of the interface that should join/leave the
.I imr_multiaddr 
group, or 0 to indicate any interface. 
.IP
For compatibility, the old 
.B ip_mreq 
structure is still supported. It differs from 
.B ip_mreqn 
only by not including
the 
.I imr_ifindex 
field. Only valid as a 
.BR setsockopt (2).
.\"
.TP
.B IP_DROP_MEMBERSHIP
Leave a multicast group. Argument is an
.B ip_mreqn 
or 
.B ip_mreq 
structure similar to
.IR IP_ADD_MEMBERSHIP . 
.\"
.TP
.B IP_MULTICAST_IF
Set the local device for a multicast socket. Argument is an
.B ip_mreqn 
or 
.B ip_mreq 
structure similar to 
.IR IP_ADD_MEMBERSHIP .
.IP
When an invalid socket option is passed,
.B ENOPROTOOPT
is returned. 
.SH SYSCTLS
The IP protocol
supports the sysctl interface to configure some global options. The sysctls
can be accessed by reading or writing the 
.B /proc/sys/net/ipv4/* 
files or using the
.BR sysctl (2)
interface.
.\"
.TP
.B ip_default_ttl 
Set the default time-to-live value of outgoing packets. This can be changed
per socket with the 
.I IP_TTL 
option.
.\"
.TP
.B ip_forward
Enable IP forwarding with a boolean flag. IP forwarding can be also set on a 
per interface basis. 
.\"
.TP
.B ip_dynaddr
Enable dynamic socket address and masquerading entry rewriting on interface 
address change. This is useful for dialup interface with changing IP addresses.
0 means no rewriting, 1 turns it on and 2 enables verbose mode.
.\"
.TP
.B ip_autoconfig
Not documented.
.\"
.TP
.B ip_local_port_range
Contains two integers that define the default local port range allocated to
sockets. Allocation starts with the first number and ends with the second number.
Note that these should not conflict with the ports used by masquerading (although
the case is handled). Also arbitary choices may cause problems with some
firewall packet filters that make assumptions about the local ports in use.
First number should be at least >1024, better >4096 to avoid clashes with well
known ports and to minimize firewall problems. 
.\"
.TP
.B ip_no_pmtu_disc
If enabled, don't do Path MTU Discovery for TCP sockets by default. Path MTU
discovery may fail if misconfigured firewalls (that drop all ICMP packets) or
misconfigured interfaces (e.g., a point-to-point link where the both ends don't
agree on the MTU) are on the path. It is better to fix the broken routers on
the path than to turn off Path MTU Discovery globally, because not doing it
incurs a high cost to the network.
.\"
.TP
.B ipfrag_high_thresh, ipfrag_low_thresh 
If the amount of queued IP fragments reaches 
.B ipfrag_high_thresh ,
the queue 
is pruned down to 
.B ipfrag_low_thresh . 
Contains an integer with the number of 
bytes.
.TP
.B ip_always_defrag
[New with Kernel 2.2.13; in earlier kernel version the feature was controlled
at compile time by the
.B CONFIG_IP_ALWAYS_DEFRAG 
option]

When this boolean frag is enabled (not equal 0) incoming fragments 
(parts of IP packets
that arose when some host between origin and destination decided
that the packets were too large and cut them into pieces) will be
reassembled (defragmented) before being processed, even if they are
about to be forwarded.

Only enable if running either a firewall that is the sole link
to your network or a transparent proxy; never ever turn on here for a
normal router or host. Otherwise fragmented communication may me disturbed
when the fragments would travel over different links. Defragmentation
also has a large memory and CPU time cost.

This is automagically turned on when masquerading or transparent
proxying are configured.
.TP
.B neigh/*
See 
.BR arp (7). 
.\" XXX Document the conf/*/* sysctls 
.\" XXX Document the route/* sysctls
.\" XXX document them all
.SH IOCTLS
All ioctls described in
.BR socket (7) 
apply to ip.
.PP 
The ioctls to configure firewalling are documented in
.BR ipfw (7)
from the 
.B ipchains 
package.  
.PP
Ioctls to configure generic device parameters are described in 
.BR netdevice (7).  
.\" XXX Add a chapter about multicasting
.SH NOTES
Be very careful with the 
.B 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.   
.PP
Some other BSD sockets implementations provide 
.I IP_RCVDSTADDR 
and 
.I IP_RECVIF 
socket options to get the destination address and the interface of 
received datagrams. Linux has the more general 
.I IP_PKTINFO
for the same task. 
.PP
.SH ERRORS
.\" XXX document all errors. We should really fix the kernels to give more uniform
.\"     error returns (ENOMEM vs ENOBUFS, EPERM vs EACCES etc.)  
.TP
.B ENOTCONN
The operation is only defined on a connected socket, but the socket wasn't
connected.
.TP
.B EINVAL
Invalid argument passed. 
For send operations this can be caused by sending to a 
.I blackhole
route.
.TP
.B EMSGSIZE 
Datagram is bigger than an MTU on the path and it cannot be fragmented.
.TP
.B EACCES
The user tried to execute an operation without the necessary permissions. 
These include:
Sending a packet to a broadcast address without having the 
.B SO_BROADCAST
flag set.
Sending a packet via a 
.I prohibit
route.
Modifying firewall settings without 
.B CAP_NET_ADMIN
or effective user id 0.
Binding to a reserved port without the
.B CAP_NET_BIND_SERVICE
capacibility or effective user id 0. 

.TP
.B EADDRINUSE
Tried to bind to an address already in use.
.TP
.BR ENOMEM " and " ENOBUFS
Not enough memory available. 
.TP
.BR ENOPROTOOPT " and " EOPNOTSUPP
Invalid socket option passed.
.TP
.B EPERM
User doesn't have permission to set high priority, change configuration,
or send signals to the requested process or group,
.TP
.B EADDRNOTAVAIL
A non-existent interface was requested or the requested source address was
not local.
.TP
.B EAGAIN
Operation on a non-blocking socket would block.
.TP
.B ESOCKTNOSUPPORT
The socket is not configured or an unknown socket type was requested.
.TP
.B EISCONN
.BR connect (2)
was called on an already connected socket.
.TP
.B EALREADY
An connection operation on a non-blocking socket is already in progress.
.TP
.B ECONNABORTED
A connection was closed during an
.BR accept (2). 
.TP
.B EPIPE
The connection was unexpectedly closed or shut down by the other end.
.TP
.B ENOENT
.B SIOCGSTAMP 
was called on a socket where no packet arrived.
.TP
.B EHOSTUNREACH
No valid routing table entry matches the destination address.  This error
can be caused by a ICMP message from a remote router or for the local
routing table.
.TP
.B ENODEV 
Network device not available or not capable of sending IP.
.TP
.B ENOPKG 
A kernel subsystem was not configured.
.TP
.B ENOBUFS, ENOMEM
Not enough free memory.  
This often means that the memory allocation is limited by the socket buffer
limits, not by the system memory, but this is not 100% consistent.
.PP
Other errors may be generated by the overlaying protocols; see
.BR tcp (7),
.BR raw (7),
.BR udp (7)
and
.BR socket (7).
.SH VERSIONS
.IR IP_PKTINFO , 
.IR IP_MTU , 
.IR IP_PMTU_DISCOVER , 
.IR IP_PKTINFO , 
.IR IP_RECVERR
and
.IR IP_ROUTER_ALERT
are new options in Linux 2.2.  
.PP
.B struct ip_mreqn 
is new in Linux 2.2.  Linux 2.0 only supported 
.BR ip_mreq .
.PP
The sysctls were introduced with Linux 2.2. 
.SH COMPATIBILITY
For compatibility with Linux 2.0, the obsolete 
.BI "socket(PF_INET, SOCK_RAW, "protocol ")"
syntax is still supported to open a 
.BR packet (7) 
socket. This is deprecated and should be replaced by
.BI "socket(PF_PACKET, SOCK_RAW, "protocol ")"
instead. The main difference is the
new 
.B sockaddr_ll 
address structure for generic link layer information instead of the old 
.B sockaddr_pkt.
.SH BUGS
There are too many inconsistent error values. 
.PP
The ioctls to configure IP-specific interface options and ARP tables are
not described.
.SH AUTHORS
This man page was written by Andi Kleen. 
.SH SEE ALSO 
.BR sendmsg (2),
.BR recvmsg (2),
.BR socket (7),
.BR netlink (7),
.BR tcp (7),
.BR udp (7),
.BR raw (7),
.BR ipfw (7).
.PP
RFC791 for the original IP specification.
.br
RFC1122 for the IPv4 host requirements.
.br
RFC1812 for the IPv4 router requirements.
\"  LocalWords:  XXX autobind INADDR REUSEADDR