xref: /freebsd/share/man/man4/inet.4 (revision b5e7e9995091a8dbcf193564b2ceaf886252fc9b)
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
4232eef9aeSRuslan Ermilov.In sys/types.h
4332eef9aeSRuslan Ermilov.In 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
64b5e7e999SRuslan Ermilovreversed).
65b5e7e999SRuslan ErmilovThe include file
66afe61c15SRodney W. Grimes.Aq Pa netinet/in.h
67afe61c15SRodney W. Grimesdefines this address
68afe61c15SRodney W. Grimesas a discriminated union.
69afe61c15SRodney W. Grimes.Pp
70afe61c15SRodney W. GrimesSockets bound to the Internet protocol family utilize
71afe61c15SRodney W. Grimesthe following addressing structure,
72afe61c15SRodney W. Grimes.Bd -literal -offset indent
73afe61c15SRodney W. Grimesstruct sockaddr_in {
7475eb8a43SRuslan Ermilov	uint8_t		sin_len;
7575eb8a43SRuslan Ermilov	sa_family_t	sin_family;
7675eb8a43SRuslan Ermilov	in_port_t	sin_port;
77afe61c15SRodney W. Grimes	struct in_addr	sin_addr;
78afe61c15SRodney W. Grimes	char		sin_zero[8];
79afe61c15SRodney W. Grimes};
80afe61c15SRodney W. Grimes.Ed
81afe61c15SRodney W. Grimes.Pp
82afe61c15SRodney W. GrimesSockets may be created with the local address
83afe61c15SRodney W. Grimes.Dv INADDR_ANY
84db3357b8SSheldon Hearnto affect
85afe61c15SRodney W. Grimes.Dq wildcard
86afe61c15SRodney W. Grimesmatching on incoming messages.
87afe61c15SRodney W. GrimesThe address in a
88afe61c15SRodney W. Grimes.Xr connect 2
89afe61c15SRodney W. Grimesor
90afe61c15SRodney W. Grimes.Xr sendto 2
91afe61c15SRodney W. Grimescall may be given as
92afe61c15SRodney W. Grimes.Dv INADDR_ANY
93afe61c15SRodney W. Grimesto mean
94afe61c15SRodney W. Grimes.Dq this host .
95afe61c15SRodney W. GrimesThe distinguished address
96afe61c15SRodney W. Grimes.Dv INADDR_BROADCAST
97afe61c15SRodney W. Grimesis allowed as a shorthand for the broadcast address on the primary
98afe61c15SRodney W. Grimesnetwork if the first network configured supports broadcast.
99afe61c15SRodney W. Grimes.Sh PROTOCOLS
100afe61c15SRodney W. GrimesThe Internet protocol family is comprised of
101afe61c15SRodney W. Grimesthe
102afe61c15SRodney W. Grimes.Tn IP
103a2cc1fa2SGarrett Wollmannetwork protocol, Internet Control
104afe61c15SRodney W. GrimesMessage Protocol
105afe61c15SRodney W. Grimes.Pq Tn ICMP ,
106a2cc1fa2SGarrett WollmanInternet Group Management Protocol
107a2cc1fa2SGarrett Wollman.Pq Tn IGMP ,
108afe61c15SRodney W. GrimesTransmission Control
109afe61c15SRodney W. GrimesProtocol
110afe61c15SRodney W. Grimes.Pq Tn TCP ,
111afe61c15SRodney W. Grimesand User Datagram Protocol
112afe61c15SRodney W. Grimes.Pq Tn UDP .
113afe61c15SRodney W. Grimes.Tn TCP
114afe61c15SRodney W. Grimesis used to support the
115afe61c15SRodney W. Grimes.Dv SOCK_STREAM
116afe61c15SRodney W. Grimesabstraction while
117afe61c15SRodney W. Grimes.Tn UDP
118afe61c15SRodney W. Grimesis used to support the
119afe61c15SRodney W. Grimes.Dv SOCK_DGRAM
120b5e7e999SRuslan Ermilovabstraction.
121b5e7e999SRuslan ErmilovA raw interface to
122afe61c15SRodney W. Grimes.Tn IP
123afe61c15SRodney W. Grimesis available
124afe61c15SRodney W. Grimesby creating an Internet socket of type
125afe61c15SRodney W. Grimes.Dv SOCK_RAW .
126afe61c15SRodney W. GrimesThe
127afe61c15SRodney W. Grimes.Tn ICMP
128afe61c15SRodney W. Grimesmessage protocol is accessible from a raw socket.
129afe61c15SRodney W. Grimes.Pp
130afe61c15SRodney W. GrimesThe 32-bit Internet address contains both network and host parts.
131b5e7e999SRuslan ErmilovHowever, direct examination of addresses is discouraged.
132b5e7e999SRuslan ErmilovFor those
133a2cc1fa2SGarrett Wollmanprograms which absolutely need to break addresses into their component
134a2cc1fa2SGarrett Wollmanparts, the following
135afe61c15SRodney W. Grimes.Xr ioctl 2
136a2cc1fa2SGarrett Wollmancommands are provided for a datagram socket in the Internet domain;
137afe61c15SRodney W. Grimesthey have the same form as the
138afe61c15SRodney W. Grimes.Dv SIOCIFADDR
139afe61c15SRodney W. Grimescommand (see
140afe61c15SRodney W. Grimes.Xr intro 4 ) .
141afe61c15SRodney W. Grimes.Pp
142afe61c15SRodney W. Grimes.Bl -tag -width SIOCSIFNETMASK
143afe61c15SRodney W. Grimes.It Dv SIOCSIFNETMASK
144afe61c15SRodney W. GrimesSet interface network mask.
145afe61c15SRodney W. GrimesThe network mask defines the network part of the address;
146afe61c15SRodney W. Grimesif it contains more of the address than the address type would indicate,
147afe61c15SRodney W. Grimesthen subnets are in use.
148afe61c15SRodney W. Grimes.It Dv SIOCGIFNETMASK
149afe61c15SRodney W. GrimesGet interface network mask.
150afe61c15SRodney W. Grimes.El
151a2cc1fa2SGarrett Wollman.Sh ROUTING
152a2cc1fa2SGarrett WollmanThe current implementation of Internet protocols includes some routing-table
153a2cc1fa2SGarrett Wollmanadaptations to provide enhanced caching of certain end-to-end
154b5e7e999SRuslan Ermilovinformation necessary for Transaction TCP and Path MTU Discovery.
155b5e7e999SRuslan ErmilovThe
156a2cc1fa2SGarrett Wollmanfollowing changes are the most significant:
157a2cc1fa2SGarrett Wollman.Bl -enum
158a2cc1fa2SGarrett Wollman.It
159a2cc1fa2SGarrett WollmanAll IP routes, except those with the
160a2cc1fa2SGarrett Wollman.Dv RTF_CLONING
161a2cc1fa2SGarrett Wollmanflag and those to multicast destinations, have the
162a2cc1fa2SGarrett Wollman.Dv RTF_PRCLONING
163a2cc1fa2SGarrett Wollmanflag forcibly enabled (they are thus said to be
164a2cc1fa2SGarrett Wollman.Dq "protocol cloning" ) .
165a2cc1fa2SGarrett Wollman.It
166a2cc1fa2SGarrett WollmanWhen the last reference to an IP route is dropped, the route is
167b5e7e999SRuslan Ermilovexamined to determine if it was created by cloning such a route.
168b5e7e999SRuslan ErmilovIf this is the case, the
169a2cc1fa2SGarrett Wollman.Dv RTF_PROTO3
170a2cc1fa2SGarrett Wollmanflag is turned on, and the expiration timer is initialized to go off
171b5e7e999SRuslan Ermilovin net.inet.ip.rtexpire seconds.
172b5e7e999SRuslan ErmilovIf such a route is re-referenced,
173a2cc1fa2SGarrett Wollmanthe flag and expiration timer are reset.
174a2cc1fa2SGarrett Wollman.It
175a2cc1fa2SGarrett WollmanA kernel timeout runs once every ten minutes, or sooner if there are
176a2cc1fa2SGarrett Wollmansoon-to-expire routes in the kernel routing table, and deletes the
177a2cc1fa2SGarrett Wollmanexpired routes.
178a2cc1fa2SGarrett Wollman.El
179a2cc1fa2SGarrett Wollman.Pp
180a2cc1fa2SGarrett WollmanA dynamic process is in place to modify the value of
181a2cc1fa2SGarrett Wollmannet.inet.ip.rtexpire if the number of cached routes grows too large.
182a2cc1fa2SGarrett WollmanIf after an expiration run there are still more than
183a2cc1fa2SGarrett Wollmannet.inet.ip.rtmaxcache unreferenced routes remaining, the rtexpire
184a2cc1fa2SGarrett Wollmanvalue is multiplied by 3/4, and any routes which have longer
185b5e7e999SRuslan Ermilovexpiration times have those times adjusted.
186b5e7e999SRuslan ErmilovThis process is damped somewhat by specification of a minimum rtexpire value
187a2cc1fa2SGarrett Wollman(net.inet.ip.rtminexpire), and by restricting the reduction to once in
188a2cc1fa2SGarrett Wollmana ten-minute period.
189a2cc1fa2SGarrett Wollman.Pp
190a2cc1fa2SGarrett WollmanIf some external process deletes the original route from which a
191b5e7e999SRuslan Ermilovprotocol-cloned route was generated, the
192b5e7e999SRuslan Ermilov.Dq child route
193b5e7e999SRuslan Ermilovis deleted.
194a2cc1fa2SGarrett Wollman(This is actually a generic mechanism in the routing code support for
195a2cc1fa2SGarrett Wollmanprotocol-requested cloning.)
196a2cc1fa2SGarrett Wollman.Pp
197a2cc1fa2SGarrett WollmanNo attempt is made to manage routes which were not created by protocol
198a2cc1fa2SGarrett Wollmancloning; these are assumed to be static, under the management of an
199a2cc1fa2SGarrett Wollmanexternal routing process, or under the management of a link layer
200a2cc1fa2SGarrett Wollman(e.g.,
201a2cc1fa2SGarrett Wollman.Tn ARP
202a2cc1fa2SGarrett Wollmanfor Ethernets).
203a2cc1fa2SGarrett Wollman.Pp
204a2cc1fa2SGarrett WollmanOnly certain types of network activity will result in the cloning of a
205b5e7e999SRuslan Ermilovroute using this mechanism.
206b5e7e999SRuslan ErmilovSpecifically, those protocols (such as
207a2cc1fa2SGarrett Wollman.Tn TCP
208a2cc1fa2SGarrett Wollmanand
209a2cc1fa2SGarrett Wollman.Tn UDP )
210a2cc1fa2SGarrett Wollmanwhich themselves cache a long-lasting reference to route for a destination
211a2cc1fa2SGarrett Wollmanwill trigger the mechanism; whereas raw
212a2cc1fa2SGarrett Wollman.Tn IP
213a2cc1fa2SGarrett Wollmanpackets, whether locally-generated or forwarded, will not.
21451b62b5aSYoshinobu Inoue.Ss MIB Variables
215a2cc1fa2SGarrett WollmanA number of variables are implemented in the net.inet branch of the
216a2cc1fa2SGarrett Wollman.Xr sysctl 3
21751b62b5aSYoshinobu InoueMIB.
21851b62b5aSYoshinobu InoueIn addition to the variables supported by the transport protocols
21951b62b5aSYoshinobu Inoue(for which the respective manual pages may be consulted),
22051b62b5aSYoshinobu Inouethe following general variables are defined:
2210f5d195dSDag-Erling Smørgrav.Bl -tag -width IPCTL_FASTFORWARDING
222a2cc1fa2SGarrett Wollman.It Dv IPCTL_FORWARDING
223a2cc1fa2SGarrett Wollman.Pq ip.forwarding
2240f5d195dSDag-Erling SmørgravBoolean: enable/disable forwarding of IP packets.
2250f5d195dSDag-Erling SmørgravDefaults to off.
2260f5d195dSDag-Erling Smørgrav.It Dv IPCTL_FASTFORWARDING
2270f5d195dSDag-Erling Smørgrav.Pq ip.fastforwarding
2280f5d195dSDag-Erling SmørgravBoolean: enable/disable the use of fast IP forwarding code.
2290f5d195dSDag-Erling SmørgravDefaults to off.
2300f5d195dSDag-Erling SmørgravWhen fast forwarding is enabled, IP packets are forwarded directly to
2310f5d195dSDag-Erling Smørgravthe appropriate network interface with a minimal validity checking, which
232b5e7e999SRuslan Ermilovgreatly improves the throughput.
233b5e7e999SRuslan ErmilovOn the other hand, they bypass the
2340f5d195dSDag-Erling Smørgravstandard procedures, such as IP option processing and
2350f5d195dSDag-Erling Smørgrav.Xr ipfirewall 4
2360f5d195dSDag-Erling Smørgravchecking.
2370f5d195dSDag-Erling SmørgravIt is not guaranteed that every packet will be fast-forwarded.
238a2cc1fa2SGarrett Wollman.It Dv IPCTL_SENDREDIRECTS
239a2cc1fa2SGarrett Wollman.Pq ip.redirect
240a2cc1fa2SGarrett WollmanBoolean: enable/disable sending of ICMP redirects in response to
241a2cc1fa2SGarrett Wollmanunforwardable
242a2cc1fa2SGarrett Wollman.Tn IP
2436d249eeeSSheldon Hearnpackets.
2446d249eeeSSheldon HearnDefaults to on.
245a2cc1fa2SGarrett Wollman.It Dv IPCTL_DEFTTL
246a2cc1fa2SGarrett Wollman.Pq ip.ttl
247a2cc1fa2SGarrett WollmanInteger: default time-to-live
248a2cc1fa2SGarrett Wollman.Pq Dq TTL
249a2cc1fa2SGarrett Wollmanto use for outgoing
250a2cc1fa2SGarrett Wollman.Tn IP
251a2cc1fa2SGarrett Wollmanpackets.
2523d140861SRuslan Ermilov.It Dv IPCTL_ACCEPTSOURCEROUTE
2533d140861SRuslan Ermilov.Pq ip.accept_sourceroute
2543d140861SRuslan ErmilovBoolean: enable/disable accepting of source-routed IP packets (default false).
2550e5ca0d8SGarrett Wollman.It Dv IPCTL_SOURCEROUTE
2560e5ca0d8SGarrett Wollman.Pq ip.sourceroute
2570e5ca0d8SGarrett WollmanBoolean: enable/disable forwarding of source-routed IP packets (default false).
258a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTEXPIRE
259a2cc1fa2SGarrett Wollman.Pq ip.rtexpire
260a2cc1fa2SGarrett WollmanInteger: lifetime in seconds of protocol-cloned
261a2cc1fa2SGarrett Wollman.Tn IP
262b5e7e999SRuslan Ermilovroutes after the last reference drops (default one hour).
263b5e7e999SRuslan ErmilovThis value varies dynamically as described above.
264a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMINEXPIRE
265a2cc1fa2SGarrett Wollman.Pq ip.rtminexpire
266b5e7e999SRuslan ErmilovInteger: minimum value of ip.rtexpire (default ten seconds).
267b5e7e999SRuslan ErmilovThis value has no effect on user modifications, but restricts the dynamic
268a2cc1fa2SGarrett Wollmanadaptation described above.
269a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMAXCACHE
270a2cc1fa2SGarrett Wollman.Pq ip.rtmaxcache
271a2cc1fa2SGarrett WollmanInteger: trigger level of cached, unreferenced, protocol-cloned routes
272a2cc1fa2SGarrett Wollmanwhich initiates dynamic adaptation (default 128).
273a2cc1fa2SGarrett Wollman.El
274afe61c15SRodney W. Grimes.Sh SEE ALSO
275afe61c15SRodney W. Grimes.Xr ioctl 2 ,
276afe61c15SRodney W. Grimes.Xr socket 2 ,
277a2cc1fa2SGarrett Wollman.Xr sysctl 3 ,
2780b992c1dSWolfram Schneider.Xr icmp 4 ,
279afe61c15SRodney W. Grimes.Xr intro 4 ,
2800b992c1dSWolfram Schneider.Xr ip 4 ,
2810f5d195dSDag-Erling Smørgrav.Xr ipfirewall 4 ,
282afe61c15SRodney W. Grimes.Xr tcp 4 ,
283a2cc1fa2SGarrett Wollman.Xr ttcp 4 ,
2840b992c1dSWolfram Schneider.Xr udp 4
285afe61c15SRodney W. Grimes.Rs
286afe61c15SRodney W. Grimes.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
287afe61c15SRodney W. Grimes.%B PS1
288afe61c15SRodney W. Grimes.%N 7
289afe61c15SRodney W. Grimes.Re
290afe61c15SRodney W. Grimes.Rs
291afe61c15SRodney W. Grimes.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
292afe61c15SRodney W. Grimes.%B PS1
293afe61c15SRodney W. Grimes.%N 8
294afe61c15SRodney W. Grimes.Re
295afe61c15SRodney W. Grimes.Sh CAVEAT
296afe61c15SRodney W. GrimesThe Internet protocol support is subject to change as
297afe61c15SRodney W. Grimesthe Internet protocols develop.  Users should not depend
298afe61c15SRodney W. Grimeson details of the current implementation, but rather
299afe61c15SRodney W. Grimesthe services exported.
300afe61c15SRodney W. Grimes.Sh HISTORY
301afe61c15SRodney W. GrimesThe
302afe61c15SRodney W. Grimes.Nm
303afe61c15SRodney W. Grimesprotocol interface appeared in
304afe61c15SRodney W. Grimes.Bx 4.2 .
305a2cc1fa2SGarrett WollmanThe
306a2cc1fa2SGarrett Wollman.Dq protocol cloning
307a2cc1fa2SGarrett Wollmancode appeared in
30846f84fcbSMike Pritchard.Fx 2.1 .
309