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