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