poll - Fix events == 0 handling for TAP and TUN, fix console spam
[dragonfly.git] / share / man / man4 / inet.4
blobcb857dcf2262729ae54e99eb48572f948a8af408
1 .\" Copyright (c) 1983, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     From: @(#)inet.4        8.1 (Berkeley) 6/5/93
29 .\" $FreeBSD: src/share/man/man4/inet.4,v 1.11.2.6 2001/12/17 11:30:12 ru Exp $
30 .\"
31 .Dd March 22, 2015
32 .Dt INET 4
33 .Os
34 .Sh NAME
35 .Nm inet
36 .Nd Internet protocol family
37 .Sh SYNOPSIS
38 .In sys/types.h
39 .In netinet/in.h
40 .Sh DESCRIPTION
41 The Internet protocol family is a collection of protocols
42 layered atop the
43 .Em Internet Protocol
44 .Pq Tn IP
45 transport layer, and utilizing the Internet address format.
46 The Internet family provides protocol support for the
47 .Dv SOCK_STREAM , SOCK_DGRAM ,
48 and
49 .Dv SOCK_RAW
50 socket types; the
51 .Dv SOCK_RAW
52 interface provides access to the
53 .Tn IP
54 protocol.
55 .Sh ADDRESSING
56 Internet addresses are four byte quantities, stored in
57 network standard format (on the
58 .Tn VAX
59 these are word and byte reversed).
60 The include file
61 .In netinet/in.h
62 defines this address
63 as a discriminated union.
64 .Pp
65 Sockets bound to the Internet protocol family utilize
66 the following addressing structure,
67 .Bd -literal -offset indent
68 struct sockaddr_in {
69         u_char          sin_len;
70         sa_family_t     sin_family;
71         u_short         sin_port;
72         struct in_addr  sin_addr;
73         char            sin_zero[8];
75 .Ed
76 .Pp
77 Sockets may be created with the local address
78 .Dv INADDR_ANY
79 to affect
80 .Dq wildcard
81 matching on incoming messages.
82 The address in a
83 .Xr connect 2
85 .Xr sendto 2
86 call may be given as
87 .Dv INADDR_ANY
88 to mean
89 .Dq this host .
90 The distinguished address
91 .Dv INADDR_BROADCAST
92 is allowed as a shorthand for the broadcast address on the primary
93 network if the first network configured supports broadcast.
94 .Sh PROTOCOLS
95 The Internet protocol family is comprised of
96 the
97 .Tn IP
98 network protocol, Internet Control
99 Message Protocol
100 .Pq Tn ICMP ,
101 Internet Group Management Protocol
102 .Pq Tn IGMP ,
103 Transmission Control
104 Protocol
105 .Pq Tn TCP ,
106 and User Datagram Protocol
107 .Pq Tn UDP .
108 .Tn TCP
109 is used to support the
110 .Dv SOCK_STREAM
111 abstraction while
112 .Tn UDP
113 is used to support the
114 .Dv SOCK_DGRAM
115 abstraction.
116 A raw interface to
117 .Tn IP
118 is available
119 by creating an Internet socket of type
120 .Dv SOCK_RAW .
122 .Tn ICMP
123 message protocol is accessible from a raw socket.
125 The 32-bit Internet address contains both network and host parts.
126 However, direct examination of addresses is discouraged.
127 For those
128 programs which absolutely need to break addresses into their component
129 parts, the following
130 .Xr ioctl 2
131 commands are provided for a datagram socket in the Internet domain;
132 they have the same form as the
133 .Dv SIOCSIFADDR
135 .Dv SIOCGIFADDR
136 commands (see
137 .Xr intro 4 ) .
138 .Bl -tag -width ".Dv SIOCSIFNETMASK"
139 .It Dv SIOCSIFNETMASK
140 Set interface network mask.
141 The network mask defines the network part of the address;
142 if it contains more of the address than the address type would indicate,
143 then subnets are in use.
144 .It Dv SIOCGIFNETMASK
145 Get interface network mask.
147 .Sh ROUTING
148 The current implementation of Internet protocols includes some routing-table
149 adaptations to provide enhanced caching of certain end-to-end
150 information necessary for Transaction TCP and Path MTU Discovery.
151 The following changes are the most significant:
152 .Bl -enum
154 All IP routes, except those with the
155 .Dv RTF_CLONING
156 flag and those to multicast destinations, have the
157 .Dv RTF_PRCLONING
158 flag forcibly enabled (they are thus said to be
159 .Dq "protocol cloning" ) .
161 When the last reference to an IP route is dropped, the route is
162 examined to determine if it was created by cloning such a route.
163 If this is the case, the
164 .Dv RTF_PROTO3
165 flag is turned on, and the expiration timer is initialized to go off in
166 .Va net.inet.ip.rtexpire
167 seconds.
168 If such a route is re-referenced, the flag and expiration timer are reset.
170 A kernel timeout runs once every ten minutes, or sooner if there are
171 soon-to-expire routes in the kernel routing table, and deletes the
172 expired routes.
175 A dynamic process is in place to modify the value of
176 .Va net.inet.ip.rtexpire
177 if the number of cached routes grows too large.
178 If after an expiration run there are still more than
179 .Va net.inet.ip.rtmaxcache
180 unreferenced routes remaining, the rtexpire
181 value is multiplied by \(34, and any routes which have longer
182 expiration times have those times adjusted.
183 This process is damped somewhat by specification of a minimum rtexpire value
184 .Va ( net.inet.ip.rtminexpire ) ,
185 and by restricting the reduction to once in a ten-minute period.
187 If some external process deletes the original route from which a
188 protocol-cloned route was generated, the ``child route'' is deleted.
189 (This is actually a generic mechanism in the routing code support for
190 protocol-requested cloning.)
192 No attempt is made to manage routes which were not created by protocol
193 cloning; these are assumed to be static, under the management of an
194 external routing process, or under the management of a link layer
195 (e.g.,
196 .Tn ARP
197 for Ethernets).
199 Only certain types of network activity will result in the cloning of a
200 route using this mechanism.
201 Specifically, those protocols (such as
202 .Tn TCP
204 .Tn UDP )
205 which themselves cache a long-lasting reference to route for a destination
206 will trigger the mechanism; whereas raw
207 .Tn IP
208 packets, whether locally-generated or forwarded, will not.
209 .Ss MIB Variables
210 A number of variables are implemented in the net.inet branch of the
211 .Xr sysctl 3
212 MIB.
213 In addition to the variables supported by the transport protocols
214 (for which the respective manual pages may be consulted),
215 the following general variables are defined:
216 .Bl -tag -width IPCTL_FASTFORWARDING
217 .It Dv IPCTL_FORWARDING
218 .Pq ip.forwarding
219 Boolean: enable/disable forwarding of IP packets.
220 Defaults to off.
221 .It Dv IPCTL_FASTFORWARDING
222 .Pq ip.fastforwarding
223 Boolean: enable/disable the use of fast IP forwarding code.
224 Defaults to off.
225 When fast forwarding is enabled, IP packets are forwarded directly to
226 the appropriate network interface with a minimal validity checking, which
227 greatly improves the throughput.
228 On the other hand, they bypass the
229 standard procedures, such as IP option processing and
230 .Xr ipfirewall 4
231 checking.
232 It is not guaranteed that every packet will be fast-forwarded.
233 .It Dv IPCTL_SENDREDIRECTS
234 .Pq ip.redirect
235 Boolean: enable/disable sending of ICMP redirects in response to
236 unforwardable
237 .Tn IP
238 packets.
239 Defaults to on.
240 .It Dv IPCTL_DEFTTL
241 .Pq ip.ttl
242 Integer: default time-to-live
243 .Pq Dq TTL
244 to use for outgoing
245 .Tn IP
246 packets.
247 .It Dv IPCTL_SOURCEROUTE
248 .Pq ip.sourceroute
249 Boolean: enable/disable forwarding of source-routed IP packets (default false).
250 .It Dv IPCTL_RTEXPIRE
251 .Pq ip.rtexpire
252 Integer: lifetime in seconds of protocol-cloned
253 .Tn IP
254 routes after the last reference drops (default one hour).
255 This value varies dynamically as described above.
256 .It Dv IPCTL_RTMINEXPIRE
257 .Pq ip.rtminexpire
258 Integer: minimum value of ip.rtexpire (default ten seconds).
259 This value has no effect on user modifications, but restricts the dynamic
260 adaptation described above.
261 .It Dv IPCTL_RTMAXCACHE
262 .Pq ip.rtmaxcache
263 Integer: trigger level of cached, unreferenced, protocol-cloned routes
264 which initiates dynamic adaptation (default 128).
266 .Sh SEE ALSO
267 .Xr ioctl 2 ,
268 .Xr socket 2 ,
269 .Xr sysctl 3 ,
270 .Xr icmp 4 ,
271 .Xr intro 4 ,
272 .Xr ip 4 ,
273 .Xr ipfirewall 4 ,
274 .Xr tcp 4 ,
275 .Xr udp 4
277 .%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
278 .%B PS1
279 .%N 7
282 .%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
283 .%B PS1
284 .%N 8
286 .Sh CAVEATS
287 The Internet protocol support is subject to change as
288 the Internet protocols develop.
289 Users should not depend on details of the current implementation, but rather
290 the services exported.
291 .Sh HISTORY
294 protocol interface appeared in
295 .Bx 4.2 .
297 .Dq protocol cloning
298 code appeared in
299 .Fx 2.1 .