xref: /freebsd/share/man/man4/inet.4 (revision db3357b8df2bcb9bad70c4694cd6eb95bbd15e44)
1afe61c15SRodney W. Grimes.\" Copyright (c) 1983, 1991, 1993
2afe61c15SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3afe61c15SRodney W. Grimes.\"
4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions
6afe61c15SRodney W. Grimes.\" are met:
7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
8afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
10afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
11afe61c15SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12afe61c15SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
13afe61c15SRodney W. Grimes.\"    must display the following acknowledgement:
14afe61c15SRodney W. Grimes.\"	This product includes software developed by the University of
15afe61c15SRodney W. Grimes.\"	California, Berkeley and its contributors.
16afe61c15SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
17afe61c15SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
18afe61c15SRodney W. Grimes.\"    without specific prior written permission.
19afe61c15SRodney W. Grimes.\"
20afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23afe61c15SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30afe61c15SRodney W. Grimes.\" SUCH DAMAGE.
31afe61c15SRodney W. Grimes.\"
32a2cc1fa2SGarrett Wollman.\"     From: @(#)inet.4	8.1 (Berkeley) 6/5/93
337f3dea24SPeter Wemm.\" $FreeBSD$
34afe61c15SRodney W. Grimes.\"
35a2cc1fa2SGarrett Wollman.Dd February 14, 1995
36afe61c15SRodney W. Grimes.Dt INET 4
373d45e180SRuslan Ermilov.Os
38afe61c15SRodney W. Grimes.Sh NAME
39afe61c15SRodney W. Grimes.Nm inet
40afe61c15SRodney W. Grimes.Nd Internet protocol family
41afe61c15SRodney W. Grimes.Sh SYNOPSIS
42afe61c15SRodney W. Grimes.Fd #include <sys/types.h>
43afe61c15SRodney W. Grimes.Fd #include <netinet/in.h>
44afe61c15SRodney W. Grimes.Sh DESCRIPTION
45afe61c15SRodney W. GrimesThe Internet protocol family is a collection of protocols
46afe61c15SRodney W. Grimeslayered atop the
47afe61c15SRodney W. Grimes.Em Internet  Protocol
48afe61c15SRodney W. Grimes.Pq Tn IP
49afe61c15SRodney W. Grimestransport layer, and utilizing the Internet address format.
50afe61c15SRodney W. GrimesThe Internet family provides protocol support for the
51afe61c15SRodney W. Grimes.Dv SOCK_STREAM , SOCK_DGRAM ,
52afe61c15SRodney W. Grimesand
53afe61c15SRodney W. Grimes.Dv SOCK_RAW
54afe61c15SRodney W. Grimessocket types; the
55afe61c15SRodney W. Grimes.Dv SOCK_RAW
56afe61c15SRodney W. Grimesinterface provides access to the
57afe61c15SRodney W. Grimes.Tn IP
58afe61c15SRodney W. Grimesprotocol.
59afe61c15SRodney W. Grimes.Sh ADDRESSING
60afe61c15SRodney W. GrimesInternet addresses are four byte quantities, stored in
61afe61c15SRodney W. Grimesnetwork standard format (on the
62afe61c15SRodney W. Grimes.Tn VAX
63afe61c15SRodney W. Grimesthese are word and byte
64afe61c15SRodney W. Grimesreversed).  The include file
65afe61c15SRodney W. Grimes.Aq Pa netinet/in.h
66afe61c15SRodney W. Grimesdefines this address
67afe61c15SRodney W. Grimesas a discriminated union.
68afe61c15SRodney W. Grimes.Pp
69afe61c15SRodney W. GrimesSockets bound to the Internet protocol family utilize
70afe61c15SRodney W. Grimesthe following addressing structure,
71afe61c15SRodney W. Grimes.Bd -literal -offset indent
72afe61c15SRodney W. Grimesstruct sockaddr_in {
730c3a1746SMike Pritchard	u_char	sin_len;
740c3a1746SMike Pritchard	u_char	sin_family;
75afe61c15SRodney W. Grimes	u_short	sin_port;
76afe61c15SRodney W. Grimes	struct	in_addr sin_addr;
77afe61c15SRodney W. Grimes	char	sin_zero[8];
78afe61c15SRodney W. Grimes};
79afe61c15SRodney W. Grimes.Ed
80afe61c15SRodney W. Grimes.Pp
81afe61c15SRodney W. GrimesSockets may be created with the local address
82afe61c15SRodney W. Grimes.Dv INADDR_ANY
83db3357b8SSheldon Hearnto affect
84afe61c15SRodney W. Grimes.Dq wildcard
85afe61c15SRodney W. Grimesmatching on incoming messages.
86afe61c15SRodney W. GrimesThe address in a
87afe61c15SRodney W. Grimes.Xr connect 2
88afe61c15SRodney W. Grimesor
89afe61c15SRodney W. Grimes.Xr sendto 2
90afe61c15SRodney W. Grimescall may be given as
91afe61c15SRodney W. Grimes.Dv INADDR_ANY
92afe61c15SRodney W. Grimesto mean
93afe61c15SRodney W. Grimes.Dq this host .
94afe61c15SRodney W. GrimesThe distinguished address
95afe61c15SRodney W. Grimes.Dv INADDR_BROADCAST
96afe61c15SRodney W. Grimesis allowed as a shorthand for the broadcast address on the primary
97afe61c15SRodney W. Grimesnetwork if the first network configured supports broadcast.
98afe61c15SRodney W. Grimes.Sh PROTOCOLS
99afe61c15SRodney W. GrimesThe Internet protocol family is comprised of
100afe61c15SRodney W. Grimesthe
101afe61c15SRodney W. Grimes.Tn IP
102a2cc1fa2SGarrett Wollmannetwork protocol, Internet Control
103afe61c15SRodney W. GrimesMessage Protocol
104afe61c15SRodney W. Grimes.Pq Tn ICMP ,
105a2cc1fa2SGarrett WollmanInternet Group Management Protocol
106a2cc1fa2SGarrett Wollman.Pq Tn IGMP ,
107afe61c15SRodney W. GrimesTransmission Control
108afe61c15SRodney W. GrimesProtocol
109afe61c15SRodney W. Grimes.Pq Tn TCP ,
110afe61c15SRodney W. Grimesand User Datagram Protocol
111afe61c15SRodney W. Grimes.Pq Tn UDP .
112afe61c15SRodney W. Grimes.Tn TCP
113afe61c15SRodney W. Grimesis used to support the
114afe61c15SRodney W. Grimes.Dv SOCK_STREAM
115afe61c15SRodney W. Grimesabstraction while
116afe61c15SRodney W. Grimes.Tn UDP
117afe61c15SRodney W. Grimesis used to support the
118afe61c15SRodney W. Grimes.Dv SOCK_DGRAM
119afe61c15SRodney W. Grimesabstraction.  A raw interface to
120afe61c15SRodney W. Grimes.Tn IP
121afe61c15SRodney W. Grimesis available
122afe61c15SRodney W. Grimesby creating an Internet socket of type
123afe61c15SRodney W. Grimes.Dv SOCK_RAW .
124afe61c15SRodney W. GrimesThe
125afe61c15SRodney W. Grimes.Tn ICMP
126afe61c15SRodney W. Grimesmessage protocol is accessible from a raw socket.
127afe61c15SRodney W. Grimes.Pp
128afe61c15SRodney W. GrimesThe 32-bit Internet address contains both network and host parts.
129a2cc1fa2SGarrett WollmanHowever, direct examination of addresses is discouraged.  For those
130a2cc1fa2SGarrett Wollmanprograms which absolutely need to break addresses into their component
131a2cc1fa2SGarrett Wollmanparts, the following
132afe61c15SRodney W. Grimes.Xr ioctl 2
133a2cc1fa2SGarrett Wollmancommands are provided for a datagram socket in the Internet domain;
134afe61c15SRodney W. Grimesthey have the same form as the
135afe61c15SRodney W. Grimes.Dv SIOCIFADDR
136afe61c15SRodney W. Grimescommand (see
137afe61c15SRodney W. Grimes.Xr intro 4 ) .
138afe61c15SRodney W. Grimes.Pp
139afe61c15SRodney W. Grimes.Bl -tag -width SIOCSIFNETMASK
140afe61c15SRodney W. Grimes.It Dv SIOCSIFNETMASK
141afe61c15SRodney W. GrimesSet interface network mask.
142afe61c15SRodney W. GrimesThe network mask defines the network part of the address;
143afe61c15SRodney W. Grimesif it contains more of the address than the address type would indicate,
144afe61c15SRodney W. Grimesthen subnets are in use.
145afe61c15SRodney W. Grimes.It Dv SIOCGIFNETMASK
146afe61c15SRodney W. GrimesGet interface network mask.
147afe61c15SRodney W. Grimes.El
148a2cc1fa2SGarrett Wollman.Sh ROUTING
149a2cc1fa2SGarrett WollmanThe current implementation of Internet protocols includes some routing-table
150a2cc1fa2SGarrett Wollmanadaptations to provide enhanced caching of certain end-to-end
151a2cc1fa2SGarrett Wollmaninformation necessary for Transaction TCP and Path MTU Discovery.  The
152a2cc1fa2SGarrett Wollmanfollowing changes are the most significant:
153a2cc1fa2SGarrett Wollman.Bl -enum
154a2cc1fa2SGarrett Wollman.It
155a2cc1fa2SGarrett WollmanAll IP routes, except those with the
156a2cc1fa2SGarrett Wollman.Dv RTF_CLONING
157a2cc1fa2SGarrett Wollmanflag and those to multicast destinations, have the
158a2cc1fa2SGarrett Wollman.Dv RTF_PRCLONING
159a2cc1fa2SGarrett Wollmanflag forcibly enabled (they are thus said to be
160a2cc1fa2SGarrett Wollman.Dq "protocol cloning" ) .
161a2cc1fa2SGarrett Wollman.It
162a2cc1fa2SGarrett WollmanWhen the last reference to an IP route is dropped, the route is
163a2cc1fa2SGarrett Wollmanexamined to determine if it was created by cloning such a route.  If
164a2cc1fa2SGarrett Wollmanthis is the case, the
165a2cc1fa2SGarrett Wollman.Dv RTF_PROTO3
166a2cc1fa2SGarrett Wollmanflag is turned on, and the expiration timer is initialized to go off
167a2cc1fa2SGarrett Wollmanin net.inet.ip.rtexpire seconds.  If such a route is re-referenced,
168a2cc1fa2SGarrett Wollmanthe flag and expiration timer are reset.
169a2cc1fa2SGarrett Wollman.It
170a2cc1fa2SGarrett WollmanA kernel timeout runs once every ten minutes, or sooner if there are
171a2cc1fa2SGarrett Wollmansoon-to-expire routes in the kernel routing table, and deletes the
172a2cc1fa2SGarrett Wollmanexpired routes.
173a2cc1fa2SGarrett Wollman.El
174a2cc1fa2SGarrett Wollman.Pp
175a2cc1fa2SGarrett WollmanA dynamic process is in place to modify the value of
176a2cc1fa2SGarrett Wollmannet.inet.ip.rtexpire if the number of cached routes grows too large.
177a2cc1fa2SGarrett WollmanIf after an expiration run there are still more than
178a2cc1fa2SGarrett Wollmannet.inet.ip.rtmaxcache unreferenced routes remaining, the rtexpire
179a2cc1fa2SGarrett Wollmanvalue is multiplied by 3/4, and any routes which have longer
180a2cc1fa2SGarrett Wollmanexpiration times have those times adjusted.  This process is damped
181a2cc1fa2SGarrett Wollmansomewhat by specification of a minimum rtexpire value
182a2cc1fa2SGarrett Wollman(net.inet.ip.rtminexpire), and by restricting the reduction to once in
183a2cc1fa2SGarrett Wollmana ten-minute period.
184a2cc1fa2SGarrett Wollman.Pp
185a2cc1fa2SGarrett WollmanIf some external process deletes the original route from which a
186a2cc1fa2SGarrett Wollmanprotocol-cloned route was generated, the ``child route'' is deleted.
187a2cc1fa2SGarrett Wollman(This is actually a generic mechanism in the routing code support for
188a2cc1fa2SGarrett Wollmanprotocol-requested cloning.)
189a2cc1fa2SGarrett Wollman.Pp
190a2cc1fa2SGarrett WollmanNo attempt is made to manage routes which were not created by protocol
191a2cc1fa2SGarrett Wollmancloning; these are assumed to be static, under the management of an
192a2cc1fa2SGarrett Wollmanexternal routing process, or under the management of a link layer
193a2cc1fa2SGarrett Wollman(e.g.,
194a2cc1fa2SGarrett Wollman.Tn ARP
195a2cc1fa2SGarrett Wollmanfor Ethernets).
196a2cc1fa2SGarrett Wollman.Pp
197a2cc1fa2SGarrett WollmanOnly certain types of network activity will result in the cloning of a
198a2cc1fa2SGarrett Wollmanroute using this mechanism.  Specifically, those protocols (such as
199a2cc1fa2SGarrett Wollman.Tn TCP
200a2cc1fa2SGarrett Wollmanand
201a2cc1fa2SGarrett Wollman.Tn UDP )
202a2cc1fa2SGarrett Wollmanwhich themselves cache a long-lasting reference to route for a destination
203a2cc1fa2SGarrett Wollmanwill trigger the mechanism; whereas raw
204a2cc1fa2SGarrett Wollman.Tn IP
205a2cc1fa2SGarrett Wollmanpackets, whether locally-generated or forwarded, will not.
20651b62b5aSYoshinobu Inoue.Ss MIB Variables
207a2cc1fa2SGarrett WollmanA number of variables are implemented in the net.inet branch of the
208a2cc1fa2SGarrett Wollman.Xr sysctl 3
20951b62b5aSYoshinobu InoueMIB.
21051b62b5aSYoshinobu InoueIn addition to the variables supported by the transport protocols
21151b62b5aSYoshinobu Inoue(for which the respective manual pages may be consulted),
21251b62b5aSYoshinobu Inouethe following general variables are defined:
2130f5d195dSDag-Erling Smørgrav.Bl -tag -width IPCTL_FASTFORWARDING
214a2cc1fa2SGarrett Wollman.It Dv IPCTL_FORWARDING
215a2cc1fa2SGarrett Wollman.Pq ip.forwarding
2160f5d195dSDag-Erling SmørgravBoolean: enable/disable forwarding of IP packets.
2170f5d195dSDag-Erling SmørgravDefaults to off.
2180f5d195dSDag-Erling Smørgrav.It Dv IPCTL_FASTFORWARDING
2190f5d195dSDag-Erling Smørgrav.Pq ip.fastforwarding
2200f5d195dSDag-Erling SmørgravBoolean: enable/disable the use of fast IP forwarding code.
2210f5d195dSDag-Erling SmørgravDefaults to off.
2220f5d195dSDag-Erling SmørgravWhen fast forwarding is enabled, IP packets are forwarded directly to
2230f5d195dSDag-Erling Smørgravthe appropriate network interface with a minimal validity checking, which
2240f5d195dSDag-Erling Smørgravgreatly improves the throughput.  On the other hand, they bypass the
2250f5d195dSDag-Erling Smørgravstandard procedures, such as IP option processing and
2260f5d195dSDag-Erling Smørgrav.Xr ipfirewall 4
2270f5d195dSDag-Erling Smørgravchecking.
2280f5d195dSDag-Erling SmørgravIt is not guaranteed that every packet will be fast-forwarded.
229a2cc1fa2SGarrett Wollman.It Dv IPCTL_SENDREDIRECTS
230a2cc1fa2SGarrett Wollman.Pq ip.redirect
231a2cc1fa2SGarrett WollmanBoolean: enable/disable sending of ICMP redirects in response to
232a2cc1fa2SGarrett Wollmanunforwardable
233a2cc1fa2SGarrett Wollman.Tn IP
2346d249eeeSSheldon Hearnpackets.
2356d249eeeSSheldon HearnDefaults to on.
236a2cc1fa2SGarrett Wollman.It Dv IPCTL_DEFTTL
237a2cc1fa2SGarrett Wollman.Pq ip.ttl
238a2cc1fa2SGarrett WollmanInteger: default time-to-live
239a2cc1fa2SGarrett Wollman.Pq Dq TTL
240a2cc1fa2SGarrett Wollmanto use for outgoing
241a2cc1fa2SGarrett Wollman.Tn IP
242a2cc1fa2SGarrett Wollmanpackets.
2430e5ca0d8SGarrett Wollman.It Dv IPCTL_SOURCEROUTE
2440e5ca0d8SGarrett Wollman.Pq ip.sourceroute
2450e5ca0d8SGarrett WollmanBoolean: enable/disable forwarding of source-routed IP packets (default false).
246a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTEXPIRE
247a2cc1fa2SGarrett Wollman.Pq ip.rtexpire
248a2cc1fa2SGarrett WollmanInteger: lifetime in seconds of protocol-cloned
249a2cc1fa2SGarrett Wollman.Tn IP
250a2cc1fa2SGarrett Wollmanroutes after the last reference drops (default one hour).  This value
251a2cc1fa2SGarrett Wollmanvaries dynamically as described above.
252a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMINEXPIRE
253a2cc1fa2SGarrett Wollman.Pq ip.rtminexpire
254a2cc1fa2SGarrett WollmanInteger: minimum value of ip.rtexpire (default ten seconds).  This
255a2cc1fa2SGarrett Wollmanvalue has no effect on user modifications, but restricts the dynamic
256a2cc1fa2SGarrett Wollmanadaptation described above.
257a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMAXCACHE
258a2cc1fa2SGarrett Wollman.Pq ip.rtmaxcache
259a2cc1fa2SGarrett WollmanInteger: trigger level of cached, unreferenced, protocol-cloned routes
260a2cc1fa2SGarrett Wollmanwhich initiates dynamic adaptation (default 128).
261a2cc1fa2SGarrett Wollman.El
262afe61c15SRodney W. Grimes.Sh SEE ALSO
263afe61c15SRodney W. Grimes.Xr ioctl 2 ,
264afe61c15SRodney W. Grimes.Xr socket 2 ,
265a2cc1fa2SGarrett Wollman.Xr sysctl 3 ,
2660b992c1dSWolfram Schneider.Xr icmp 4 ,
267afe61c15SRodney W. Grimes.Xr intro 4 ,
2680b992c1dSWolfram Schneider.Xr ip 4 ,
2690f5d195dSDag-Erling Smørgrav.Xr ipfirewall 4 ,
270afe61c15SRodney W. Grimes.Xr tcp 4 ,
271a2cc1fa2SGarrett Wollman.Xr ttcp 4 ,
2720b992c1dSWolfram Schneider.Xr udp 4
273afe61c15SRodney W. Grimes.Rs
274afe61c15SRodney W. Grimes.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
275afe61c15SRodney W. Grimes.%B PS1
276afe61c15SRodney W. Grimes.%N 7
277afe61c15SRodney W. Grimes.Re
278afe61c15SRodney W. Grimes.Rs
279afe61c15SRodney W. Grimes.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
280afe61c15SRodney W. Grimes.%B PS1
281afe61c15SRodney W. Grimes.%N 8
282afe61c15SRodney W. Grimes.Re
283afe61c15SRodney W. Grimes.Sh CAVEAT
284afe61c15SRodney W. GrimesThe Internet protocol support is subject to change as
285afe61c15SRodney W. Grimesthe Internet protocols develop.  Users should not depend
286afe61c15SRodney W. Grimeson details of the current implementation, but rather
287afe61c15SRodney W. Grimesthe services exported.
288afe61c15SRodney W. Grimes.Sh HISTORY
289afe61c15SRodney W. GrimesThe
290afe61c15SRodney W. Grimes.Nm
291afe61c15SRodney W. Grimesprotocol interface appeared in
292afe61c15SRodney W. Grimes.Bx 4.2 .
293a2cc1fa2SGarrett WollmanThe
294a2cc1fa2SGarrett Wollman.Dq protocol cloning
295a2cc1fa2SGarrett Wollmancode appeared in
29646f84fcbSMike Pritchard.Fx 2.1 .
297