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