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