]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/inet.4
Add ELF Tool Chain's brandelf(1) to contrib
[FreeBSD/FreeBSD.git] / share / man / man4 / inet.4
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. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     From: @(#)inet.4        8.1 (Berkeley) 6/5/93
29 .\" $FreeBSD$
30 .\"
31 .Dd April 7, 2015
32 .Dt INET 4
33 .Os
34 .Sh NAME
35 .Nm inet
36 .Nd Internet protocol family
37 .Sh SYNOPSIS
38 .In sys/types.h
39 .In netinet/in.h
40 .Sh DESCRIPTION
41 The Internet protocol family is a collection of protocols
42 layered atop the
43 .Em Internet Protocol
44 .Pq Tn IP
45 transport layer, and utilizing the Internet address format.
46 The Internet family provides protocol support for the
47 .Dv SOCK_STREAM , SOCK_DGRAM ,
48 and
49 .Dv SOCK_RAW
50 socket types; the
51 .Dv SOCK_RAW
52 interface provides access to the
53 .Tn IP
54 protocol.
55 .Sh ADDRESSING
56 Internet addresses are four byte quantities, stored in
57 network standard format (on little endian machines, such as the
58 .Tn alpha ,
59 .Tn amd64
60 and
61 .Tn i386
62 these are word and byte reversed).
63 The include file
64 .In netinet/in.h
65 defines this address
66 as a discriminated union.
67 .Pp
68 Sockets bound to the Internet protocol family utilize
69 the following addressing structure,
70 .Bd -literal -offset indent
71 struct sockaddr_in {
72         uint8_t         sin_len;
73         sa_family_t     sin_family;
74         in_port_t       sin_port;
75         struct in_addr  sin_addr;
76         char            sin_zero[8];
77 };
78 .Ed
79 .Pp
80 Sockets may be created with the local address
81 .Dv INADDR_ANY
82 to affect
83 .Dq wildcard
84 matching on incoming messages.
85 The address in a
86 .Xr connect 2
87 or
88 .Xr sendto 2
89 call may be given as
90 .Dv INADDR_ANY
91 to mean
92 .Dq this host .
93 The distinguished address
94 .Dv INADDR_BROADCAST
95 is allowed as a shorthand for the broadcast address on the primary
96 network if the first network configured supports broadcast.
97 .Sh PROTOCOLS
98 The Internet protocol family is comprised of
99 the
100 .Tn IP
101 network protocol, Internet Control
102 Message Protocol
103 .Pq Tn ICMP ,
104 Internet Group Management Protocol
105 .Pq Tn IGMP ,
106 Transmission Control
107 Protocol
108 .Pq Tn TCP ,
109 and User Datagram Protocol
110 .Pq Tn UDP .
111 .Tn TCP
112 is used to support the
113 .Dv SOCK_STREAM
114 abstraction while
115 .Tn UDP
116 is used to support the
117 .Dv SOCK_DGRAM
118 abstraction.
119 A raw interface to
120 .Tn IP
121 is available
122 by creating an Internet socket of type
123 .Dv SOCK_RAW .
124 The
125 .Tn ICMP
126 message protocol is accessible from a raw socket.
127 .Pp
128 The
129 .Nm
130 address on an interface consist of the address itself, the
131 netmask, either broadcast address in case of a broadcast
132 interface or peers address in case of point-to-point interface.
133 The following
134 .Xr ioctl 2
135 commands are provided for a datagram socket in the Internet domain:
136 .Pp
137 .Bl -tag -width ".Dv SIOCGIFBRDADDR" -offset indent -compact   
138 .It Dv SIOCAIFADDR
139 Add address to an interface.
140 The command requires
141 .Ft struct in_aliasreq
142 as argument.
143 .It Dv SIOCDIFADDR
144 Delete address from an interface.
145 The command requires
146 .Ft struct ifreq
147 as argument.
148 .It Dv SIOCGIFADDR
149 .It Dv SIOCGIFBRDADDR
150 .It Dv SIOCGIFDSTADDR
151 .It Dv SIOCGIFNETMASK
152 Return address information from interface. The returned value
153 is in
154 .Ft struct ifreq .
155 This way of address information retrieval is obsoleted, a
156 preferred way is to use
157 .Xr getifaddrs 3
158 API.
159 .El
160 .Ss MIB Variables
161 A number of variables are implemented in the net.inet branch of the
162 .Xr sysctl 3
163 MIB.
164 In addition to the variables supported by the transport protocols
165 (for which the respective manual pages may be consulted),
166 the following general variables are defined:
167 .Bl -tag -width IPCTL_FASTFORWARDING
168 .It Dv IPCTL_FORWARDING
169 .Pq ip.forwarding
170 Boolean: enable/disable forwarding of IP packets.
171 Defaults to off.
172 .It Dv IPCTL_FASTFORWARDING
173 .Pq ip.fastforwarding
174 Boolean: enable/disable the use of
175 .Tn fast IP forwarding
176 code.
177 Defaults to off.
178 When
179 .Tn fast IP forwarding
180 is enabled, IP packets are forwarded directly to the appropriate network
181 interface with direct processing to completion, which greatly improves
182 the throughput.
183 All packets for local IP addresses, non-unicast, or with IP options are
184 handled by the normal IP input processing path.
185 All features of the normal (slow) IP forwarding path are supported
186 including firewall (through
187 .Xr pfil 9
188 hooks) checking, except
189 .Xr ipsec 4
190 tunnel brokering.
191 The
192 .Tn IP fastforwarding
193 path does not generate ICMP redirect or source quench messages.
194 .It Dv IPCTL_SENDREDIRECTS
195 .Pq ip.redirect
196 Boolean: enable/disable sending of ICMP redirects in response to
197 .Tn IP
198 packets for which a better, and for the sender directly reachable, route
199 and next hop is known.
200 Defaults to on.
201 .It Dv IPCTL_DEFTTL
202 .Pq ip.ttl
203 Integer: default time-to-live
204 .Pq Dq TTL
205 to use for outgoing
206 .Tn IP
207 packets.
208 .It Dv IPCTL_ACCEPTSOURCEROUTE
209 .Pq ip.accept_sourceroute
210 Boolean: enable/disable accepting of source-routed IP packets (default false).
211 .It Dv IPCTL_SOURCEROUTE
212 .Pq ip.sourceroute
213 Boolean: enable/disable forwarding of source-routed IP packets (default false).
214 .It Va ip.process_options
215 Integer: control IP options processing.
216 By setting this variable to 0, all IP options in the incoming packets
217 will be ignored, and the packets will be passed unmodified.
218 By setting to 1, IP options in the incoming packets will be processed
219 accordingly.
220 By setting to 2, an
221 .Tn ICMP
222 .Dq "prohibited by filter"
223 message will be sent back in response to incoming packets with IP options.
224 Default is 1.
225 This
226 .Xr sysctl 8
227 variable affects packets destined for a local host as well as packets
228 forwarded to some other host.
229 .It Va ip.rfc6864
230 Boolean: control IP IDs generation behaviour.
231 True value enables RFC6864 support, which specifies that IP ID field of
232 .Em atomic
233 datagrams can be set to any value.
234 The
235 .Fx implementation sets it to zero.
236 Enabled by default.
237 .It Va ip.random_id
238 Boolean: control IP IDs generation behaviour.
239 Setting this
240 .Xr sysctl 8
241 to 1 causes the ID field in
242 .Em non-atomic
243 IP datagrams (or all IP datagrams, if
244 .Va ip.rfc6864
245 is disabled) to be randomized instead of incremented by 1 with each packet
246 generated.
247 This closes a minor information leak which allows remote observers to
248 determine the rate of packet generation on the machine by watching the
249 counter.
250 At the same time, on high-speed links, it can decrease the ID reuse
251 cycle greatly.
252 Default is 0 (sequential IP IDs).
253 IPv6 flow IDs and fragment IDs are always random.
254 .It Va ip.maxfragpackets
255 Integer: maximum number of fragmented packets the host will accept and hold
256 in the reassembling queue simultaneously.
257 0 means that the host will not accept any fragmented packets.
258 \-1 means that the host will accept as many fragmented packets as it receives.
259 .It Va ip.maxfragsperpacket
260 Integer: maximum number of fragments the host will accept and hold
261 in the reassembling queue for a packet.
262 0 means that the host will not accept any fragmented packets.
263 .El
264 .Sh SEE ALSO
265 .Xr ioctl 2 ,
266 .Xr socket 2 ,
267 .Xr getifaddrs 3 ,
268 .Xr sysctl 3 ,
269 .Xr icmp 4 ,
270 .Xr intro 4 ,
271 .Xr ip 4 ,
272 .Xr ipfirewall 4 ,
273 .Xr route 4 ,
274 .Xr tcp 4 ,
275 .Xr udp 4 ,
276 .Xr pfil 9
277 .Rs
278 .%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
279 .%B PS1
280 .%N 7
281 .Re
282 .Rs
283 .%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
284 .%B PS1
285 .%N 8
286 .Re
287 .Sh HISTORY
288 The
289 .Nm
290 protocol interface appeared in
291 .Bx 4.2 .
292 The
293 .Dq protocol cloning
294 code appeared in
295 .Fx 2.1 .
296 .Sh CAVEATS
297 The Internet protocol support is subject to change as
298 the Internet protocols develop.
299 Users should not depend
300 on details of the current implementation, but rather
301 the services exported.