Correct BSD License clause numbering from 1-2-4 to 1-2-3.
[dragonfly.git] / share / man / man4 / inet.4
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 .\" $DragonFly: src/share/man/man4/inet.4,v 1.8 2008/05/02 02:05:05 swildner Exp $
31 .\"
32 .Dd February 14, 1995
33 .Dt INET 4
34 .Os
35 .Sh NAME
36 .Nm inet
37 .Nd Internet protocol family
38 .Sh SYNOPSIS
39 .In sys/types.h
40 .In netinet/in.h
41 .Sh DESCRIPTION
42 The Internet protocol family is a collection of protocols
43 layered atop the
44 .Em Internet  Protocol
45 .Pq Tn IP
46 transport layer, and utilizing the Internet address format.
47 The Internet family provides protocol support for the
48 .Dv SOCK_STREAM , SOCK_DGRAM ,
49 and
50 .Dv SOCK_RAW
51 socket types; the
52 .Dv SOCK_RAW
53 interface provides access to the
54 .Tn IP
55 protocol.
56 .Sh ADDRESSING
57 Internet addresses are four byte quantities, stored in
58 network standard format (on the
59 .Tn VAX
60 these are word and byte
61 reversed).  The include file
62 .In netinet/in.h
63 defines this address
64 as a discriminated union.
65 .Pp
66 Sockets bound to the Internet protocol family utilize
67 the following addressing structure,
68 .Bd -literal -offset indent
69 struct sockaddr_in {
70         u_char  sin_len;
71         u_char  sin_family;
72         u_short sin_port;
73         struct  in_addr sin_addr;
74         char    sin_zero[8];
75 };
76 .Ed
77 .Pp
78 Sockets may be created with the local address
79 .Dv INADDR_ANY
80 to affect
81 .Dq wildcard
82 matching on incoming messages.
83 The address in a
84 .Xr connect 2
85 or
86 .Xr sendto 2
87 call may be given as
88 .Dv INADDR_ANY
89 to mean
90 .Dq this host .
91 The distinguished address
92 .Dv INADDR_BROADCAST
93 is allowed as a shorthand for the broadcast address on the primary
94 network if the first network configured supports broadcast.
95 .Sh PROTOCOLS
96 The Internet protocol family is comprised of
97 the
98 .Tn IP
99 network protocol, Internet Control
100 Message Protocol
101 .Pq Tn ICMP ,
102 Internet Group Management Protocol
103 .Pq Tn IGMP ,
104 Transmission Control
105 Protocol
106 .Pq Tn TCP ,
107 and User Datagram Protocol
108 .Pq Tn UDP .
109 .Tn TCP
110 is used to support the
111 .Dv SOCK_STREAM
112 abstraction while
113 .Tn UDP
114 is used to support the
115 .Dv SOCK_DGRAM
116 abstraction.  A raw interface to
117 .Tn IP
118 is available
119 by creating an Internet socket of type
120 .Dv SOCK_RAW .
121 The
122 .Tn ICMP
123 message protocol is accessible from a raw socket.
124 .Pp
125 The 32-bit Internet address contains both network and host parts.
126 However, direct examination of addresses is discouraged.  For those
127 programs which absolutely need to break addresses into their component
128 parts, the following
129 .Xr ioctl 2
130 commands are provided for a datagram socket in the Internet domain;
131 they have the same form as the
132 .Dv SIOCSIFADDR
133 and
134 .Dv SIOCGIFADDR
135 commands (see
136 .Xr intro 4 ) .
137 .Bl -tag -width ".Dv SIOCSIFNETMASK"
138 .It Dv SIOCSIFNETMASK
139 Set interface network mask.
140 The network mask defines the network part of the address;
141 if it contains more of the address than the address type would indicate,
142 then subnets are in use.
143 .It Dv SIOCGIFNETMASK
144 Get interface network mask.
145 .El
146 .Sh ROUTING
147 The current implementation of Internet protocols includes some routing-table
148 adaptations to provide enhanced caching of certain end-to-end
149 information necessary for Transaction TCP and Path MTU Discovery.  The
150 following changes are the most significant:
151 .Bl -enum
152 .It
153 All IP routes, except those with the
154 .Dv RTF_CLONING
155 flag and those to multicast destinations, have the
156 .Dv RTF_PRCLONING
157 flag forcibly enabled (they are thus said to be
158 .Dq "protocol cloning" ) .
159 .It
160 When the last reference to an IP route is dropped, the route is
161 examined to determine if it was created by cloning such a route.  If
162 this is the case, the
163 .Dv RTF_PROTO3
164 flag is turned on, and the expiration timer is initialized to go off in
165 .Va net.inet.ip.rtexpire
166 seconds.
167 If such a route is re-referenced, the flag and expiration timer are reset.
168 .It
169 A kernel timeout runs once every ten minutes, or sooner if there are
170 soon-to-expire routes in the kernel routing table, and deletes the
171 expired routes.
172 .El
173 .Pp
174 A dynamic process is in place to modify the value of
175 .Va net.inet.ip.rtexpire
176 if the number of cached routes grows too large.
177 If after an expiration run there are still more than
178 .Va net.inet.ip.rtmaxcache
179 unreferenced routes remaining, the rtexpire
180 value is multiplied by \(34, and any routes which have longer
181 expiration times have those times adjusted.  This process is damped
182 somewhat by specification of a minimum rtexpire value
183 .Va ( net.inet.ip.rtminexpire ) ,
184 and by restricting the reduction to once in a ten-minute period.
185 .Pp
186 If some external process deletes the original route from which a
187 protocol-cloned route was generated, the ``child route'' is deleted.
188 (This is actually a generic mechanism in the routing code support for
189 protocol-requested cloning.)
190 .Pp
191 No attempt is made to manage routes which were not created by protocol
192 cloning; these are assumed to be static, under the management of an
193 external routing process, or under the management of a link layer
194 (e.g.,
195 .Tn ARP
196 for Ethernets).
197 .Pp
198 Only certain types of network activity will result in the cloning of a
199 route using this mechanism.  Specifically, those protocols (such as
200 .Tn TCP
201 and
202 .Tn UDP )
203 which themselves cache a long-lasting reference to route for a destination
204 will trigger the mechanism; whereas raw
205 .Tn IP
206 packets, whether locally-generated or forwarded, will not.
207 .Ss MIB Variables
208 A number of variables are implemented in the net.inet branch of the
209 .Xr sysctl 3
210 MIB.
211 In addition to the variables supported by the transport protocols
212 (for which the respective manual pages may be consulted),
213 the following general variables are defined:
214 .Bl -tag -width IPCTL_FASTFORWARDING
215 .It Dv IPCTL_FORWARDING
216 .Pq ip.forwarding
217 Boolean: enable/disable forwarding of IP packets.
218 Defaults to off.
219 .It Dv IPCTL_FASTFORWARDING
220 .Pq ip.fastforwarding
221 Boolean: enable/disable the use of fast IP forwarding code.
222 Defaults to off.
223 When fast forwarding is enabled, IP packets are forwarded directly to
224 the appropriate network interface with a minimal validity checking, which
225 greatly improves the throughput.  On the other hand, they bypass the
226 standard procedures, such as IP option processing and
227 .Xr ipfirewall 4
228 checking.
229 It is not guaranteed that every packet will be fast-forwarded.
230 .It Dv IPCTL_SENDREDIRECTS
231 .Pq ip.redirect
232 Boolean: enable/disable sending of ICMP redirects in response to
233 unforwardable
234 .Tn IP
235 packets.
236 Defaults to on.
237 .It Dv IPCTL_DEFTTL
238 .Pq ip.ttl
239 Integer: default time-to-live
240 .Pq Dq TTL
241 to use for outgoing
242 .Tn IP
243 packets.
244 .It Dv IPCTL_SOURCEROUTE
245 .Pq ip.sourceroute
246 Boolean: enable/disable forwarding of source-routed IP packets (default false).
247 .It Dv IPCTL_RTEXPIRE
248 .Pq ip.rtexpire
249 Integer: lifetime in seconds of protocol-cloned
250 .Tn IP
251 routes after the last reference drops (default one hour).  This value
252 varies dynamically as described above.
253 .It Dv IPCTL_RTMINEXPIRE
254 .Pq ip.rtminexpire
255 Integer: minimum value of ip.rtexpire (default ten seconds).  This
256 value has no effect on user modifications, but restricts the dynamic
257 adaptation described above.
258 .It Dv IPCTL_RTMAXCACHE
259 .Pq ip.rtmaxcache
260 Integer: trigger level of cached, unreferenced, protocol-cloned routes
261 which initiates dynamic adaptation (default 128).
262 .El
263 .Sh SEE ALSO
264 .Xr ioctl 2 ,
265 .Xr socket 2 ,
266 .Xr sysctl 3 ,
267 .Xr icmp 4 ,
268 .Xr intro 4 ,
269 .Xr ip 4 ,
270 .Xr ipfirewall 4 ,
271 .Xr tcp 4 ,
272 .Xr udp 4
273 .Rs
274 .%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
275 .%B PS1
276 .%N 7
277 .Re
278 .Rs
279 .%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
280 .%B PS1
281 .%N 8
282 .Re
283 .Sh CAVEAT
284 The Internet protocol support is subject to change as
285 the Internet protocols develop.  Users should not depend
286 on details of the current implementation, but rather
287 the services exported.
288 .Sh HISTORY
289 The
290 .Nm
291 protocol interface appeared in
292 .Bx 4.2 .
293 The
294 .Dq protocol cloning
295 code appeared in
296 .Fx 2.1 .