Print this page
13175 Add support for IP_RECVTOS
13182 CMSG_ macros should have man pages
Change-ID: I784aa36cfd3c17e3cccbf1fd329fa7e69b663ef9
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man7p/ip.7p
+++ new/usr/src/man/man7p/ip.7p
1 1 '\" te
2 +.\" Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
2 3 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 4 .\" Copyright 2008 AT&T
4 5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 -.TH IP 7P "Dec 3, 2008"
8 +.TH IP 7P "Sep 18, 2020"
8 9 .SH NAME
9 10 ip, IP \- Internet Protocol
10 11 .SH SYNOPSIS
11 12 .LP
12 13 .nf
13 14 \fB#include <sys/socket.h>\fR
14 15 .fi
15 16
16 17 .LP
17 18 .nf
18 19 \fB#include <netinet/in.h>\fR
19 20 .fi
20 21
21 22 .LP
22 23 .nf
23 24 \fBs = socket(AF_INET, SOCK_RAW, proto);\fR
24 25 .fi
25 26
26 27 .LP
27 28 .nf
28 29 \fBt = t_open ("/dev/rawip", O_RDWR);\fR
29 30 .fi
30 31
31 32 .SH DESCRIPTION
32 33 .sp
33 34 .LP
34 35 IP is the internetwork datagram delivery protocol that is central to the
35 36 Internet protocol family. Programs may use \fBIP\fR through higher-level
36 37 protocols such as the Transmission Control Protocol (TCP) or the User Datagram
37 38 Protocol (UDP), or may interface directly to IP. See \fBtcp\fR(7P) and
38 39 \fBudp\fR(7P). Direct access may be by means of the socket interface, using a
39 40 "raw socket," or by means of the Transport Level Interface (TLI). The protocol
40 41 options defined in the IP specification may be set in outgoing datagrams.
41 42 .sp
42 43 .LP
43 44 Packets sent to or from this system may be subject to IPsec policy. See
44 45 \fBipsec\fR(7P) for more information.
45 46 .SH APPLICATION PROGRAMMING INTERFACE
46 47 .sp
47 48 .LP
48 49 The STREAMS driver \fB/dev/rawip\fR is the TLI transport provider that provides
49 50 raw access to IP.
50 51 .sp
51 52 .LP
52 53 Raw IP sockets are connectionless and are normally used with the \fBsendto()\fR
53 54 and \fBrecvfrom()\fR calls (see \fBsend\fR(3SOCKET) and \fBrecv\fR(3SOCKET)),
54 55 although the \fBconnect\fR(3SOCKET) call may also be used to fix the
55 56 destination for future datagram. In this case, the \fBread\fR(2) or
56 57 \fBrecv\fR(3SOCKET) and \fBwrite\fR(2) or \fBsend\fR(3SOCKET) calls may be
57 58 used. If \fIproto\fR is \fBIPPROTO_RAW\fR or \fBIPPROTO_IGMP\fR, the
58 59 application is expected to include a complete IP header when sending.
59 60 Otherwise, that protocol number will be set in outgoing datagrams and used to
60 61 filter incoming datagrams and an IP header will be generated and prepended to
61 62 each outgoing datagram. In either case, received datagrams are returned with
62 63 the IP header and options intact.
63 64 .sp
64 65 .LP
65 66 If an application uses \fBIP_HDRINCL\fR and provides the IP header contents,
66 67 the IP stack does not modify the following supplied fields under any
67 68 conditions: Type of Service, DF Flag, Protocol, and Destination Address. The IP
68 69 Options and IHL fields are set by use of \fBIP_OPTIONS\fR, and \fBTotal
69 70 Length\fR is updated to include any options. Version is set to the default.
70 71 Identification is chosen by the normal IP ID selection logic. The source
71 72 address is updated if none was specified and the TTL is changed if the packet
↓ open down ↓ |
54 lines elided |
↑ open up ↑ |
72 73 has a broadcast destination address. Since an applicaton cannot send down
73 74 fragments (as IP assigns the IP ID), Fragment Offset is always 0. The IP
74 75 Checksum field is computed by IP. None of the data beyond the IP header are
75 76 changed, including the application-provided transport header.
76 77 .sp
77 78 .LP
78 79 The socket options supported at the IP level are:
79 80 .sp
80 81 .ne 2
81 82 .na
82 -\fB\fBIP_OPTIONS\fR\fR
83 +\fBIP_OPTIONS\fR
83 84 .ad
84 85 .RS 22n
85 86 IP options for outgoing datagrams. This socket option may be used to set IP
86 87 options to be included in each outgoing datagram. IP options to be sent are set
87 88 with \fBsetsockopt()\fR (see \fBgetsockopt\fR(3SOCKET)). The
88 89 \fBgetsockopt\fR(3SOCKET) call returns the IP options set in the last
89 90 \fBsetsockopt()\fR call. IP options on received datagrams are visible to user
90 91 programs only using raw IP sockets. The format of IP options given in
91 92 \fBsetsockopt()\fR matches those defined in the IP specification with one
92 93 exception: the list of addresses for the source routing options must include
93 94 the first-hop gateway at the beginning of the list of gateways. The first-hop
94 95 gateway address will be extracted from the option list and the size adjusted
95 96 accordingly before use. IP options may be used with any socket type in the
96 97 Internet family.
97 98 .RE
98 99
99 100 .sp
100 101 .ne 2
101 102 .na
102 -\fB\fBIP_SEC_OPT\fR\fR
103 +\fBIP_SEC_OPT\fR
103 104 .ad
104 105 .RS 22n
105 106 Enable or obtain IPsec security settings for this socket. For more details on
106 107 the protection services of IPsec, see \fBipsec\fR(7P).
107 108 .RE
108 109
109 110 .sp
110 111 .ne 2
111 112 .na
112 -\fB\fBIP_ADD_MEMBERSHIP\fR\fR
113 +\fBIP_ADD_MEMBERSHIP\fR
113 114 .ad
114 115 .RS 22n
115 116 Join a multicast group.
116 117 .RE
117 118
118 119 .sp
119 120 .ne 2
120 121 .na
121 -\fB\fBIP_DROP_MEMBERSHIP\fR\fR
122 +\fBIP_DROP_MEMBERSHIP\fR
122 123 .ad
123 124 .RS 22n
124 125 Leave a multicast group.
125 126 .RE
126 127
127 128 .sp
128 129 .ne 2
129 130 .na
130 -\fB\fBIP_BOUND_IF\fR\fR
131 +\fBIP_BOUND_IF\fR
131 132 .ad
132 133 .RS 22n
133 134 Limit reception and transmission of packets to this interface. Takes an
134 135 integer as an argument. The integer is the selected interface index.
135 136 .RE
136 137
137 138 .sp
138 139 .LP
139 -The following options take \fBin_pktinfo_t\fR as the parameter:
140 +The following option takes \fBin_pktinfo_t\fR as the parameter:
140 141 .sp
141 142 .ne 2
142 143 .na
143 -\fB\fBIP_PKTINFO\fR\fR
144 +\fBIP_PKTINFO\fR
144 145 .ad
145 146 .sp .6
146 147 .RS 4n
147 148 Set the source address and/or transmit interface of the packet(s). Note that
148 149 the IP_BOUND_IF socket option takes precedence over the interface index passed
149 150 in IP_PKTINFO.
150 151 .sp
151 152 .in +2
152 153 .nf
153 154 struct in_pktinfo {
154 155 unsigned int ipi_ifindex;/* send/recv interface index */
155 156 struct in_addr ipi_spec_dst;/* matched source addr. */
156 157 struct in_addr ipi_addr;/* src/dst addr. in IP hdr */
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
157 158 } in_pktinfo_t;
158 159 .fi
159 160 .in -2
160 161
161 162 When passed in (on transmit) via ancillary data with IP_PKTINFO, ipi_spec_dst
162 163 is used as the source address and ipi_ifindex is used as the interface index to
163 164 send the packet out.
164 165 .RE
165 166
166 167 .sp
168 +.LP
169 +The following options are boolean switches controlling the reception of
170 +ancillary data:
171 +
172 +.sp
167 173 .ne 2
168 174 .na
169 -\fB\fBIP_RECVPKTINFO\fR\fR
175 +\fBIP_RECVDSTADDR\fR
170 176 .ad
171 -.sp .6
172 -.RS 4n
177 +.RS 22n
178 +When enabled on a SOCK_DGRAM socket, enables receipt of the destination
179 +IP address of the incoming packet. Returns \fBinaddr_t\fR as ancillary
180 +data.
181 +.RE
182 +
183 +.sp
184 +.ne 2
185 +.na
186 +\fBIP_RECVIF\fR
187 +.ad
188 +.RS 22n
189 +Enable/disable receipt of the inbound interface index. Returns \fBuint_t\fR as
190 +ancillary data.
191 +.RE
192 +
193 +.sp
194 +.ne 2
195 +.na
196 +\fBIP_RECVOPTS\fR
197 +.ad
198 +.RS 22n
199 +When enabled on a SOCK_DGRAM socket, enables receipt of the IP options
200 +from the incoming packet. Returns variable-length IP options, up to 40
201 +bytes, as ancillary data.
202 +.RE
203 +
204 +.sp
205 +.ne 2
206 +.na
207 +\fBIP_RECVPKTINFO\fR
208 +.ad
209 +.RS 22n
173 210 Enable/disable receipt of the index of the interface the packet arrived on, the
174 211 local address that was matched for reception, and the inbound packet's actual
175 -destination address. Takes boolean as the parameter. Returns struct
176 -in_pktinfo_t as ancillary data.
212 +destination address. Takes boolean as the parameter. Returns
213 +\fBin_pktinfo_t\fR as ancillary data.
177 214 .RE
215 +.RE
178 216
179 217 .sp
218 +.ne 2
219 +.na
220 +\fBIP_RECVSLLA\fR
221 +.ad
222 +.RS 22n
223 +When enabled on a SOCK_DGRAM socket, enables receipt of the source link-layer
224 +address for the incoming packet. Returns \fBstruct sockaddr_dl\fR as
225 +ancillary data.
226 +.RE
227 +
228 +.sp
229 +.ne 2
230 +.na
231 +\fBIP_RECVTTL\fR
232 +.ad
233 +.RS 22n
234 +When enabled on a SOCK_DGRAM socket, the IP TTL (time to live) field for an
235 +incoming datagram is returned as \fBuint8_t\fR in ancillary data.
236 +.RE
237 +
238 +.sp
239 +.ne 2
240 +.na
241 +\fBIP_RECVTOS\fR
242 +.ad
243 +.RS 22n
244 +When enabled, the IP TOS (type of service) field is returned as \fBuint8_t\fR
245 +in ancillary data. For \fBSOCK_DGRAM\fR sockets, the ancillary data item is
246 +included for every call to \fBrecvmsg()\fR. For \fBSOCK_STREAM\fR sockets,
247 +where there is no direct mapping between received TCP segments and receive
248 +operations, the ancillary data item will only be present when the value has
249 +changed.
250 +.RE
251 +
252 +.sp
180 253 .LP
181 254 The following options take a \fBstruct ip_mreq\fR as the parameter. The
182 255 structure contains a multicast address which must be set to the \fBCLASS-D\fR
183 256 \fBIP\fR multicast address and an interface address. Normally the interface
184 257 address is set to \fBINADDR_ANY\fR which causes the kernel to choose the
185 258 interface on which to join.
186 259 .sp
187 260 .ne 2
188 261 .na
189 -\fB\fBIP_BLOCK_SOURCE\fR\fR
262 +\fBIP_BLOCK_SOURCE\fR
190 263 .ad
191 264 .RS 29n
192 265 Block multicast packets whose source address matches the given source address.
193 266 The specified group must be joined previously using IP_ADD_MEMBERSHIP or
194 267 MCAST_JOIN_GROUP.
195 268 .RE
196 269
197 270 .sp
198 271 .ne 2
199 272 .na
200 -\fB\fBIP_UNBLOCK_SOURCE\fR\fR
273 +\fBIP_UNBLOCK_SOURCE\fR
201 274 .ad
202 275 .RS 29n
203 276 Unblock (begin receiving) multicast packets which were previously blocked using
204 277 IP_BLOCK_SOURCE.
205 278 .RE
206 279
207 280 .sp
208 281 .ne 2
209 282 .na
210 -\fB\fBIP_ADD_SOURCE_MEMBERSHIP\fR\fR
283 +\fBIP_ADD_SOURCE_MEMBERSHIP\fR
211 284 .ad
212 285 .RS 29n
213 286 Begin receiving packets for the given multicast group whose source address
214 287 matches the specified address.
215 288 .RE
216 289
217 290 .sp
218 291 .ne 2
219 292 .na
220 -\fB\fBIP_DROP_SOURCE_MEMBERSHIP\fR\fR
293 +\fBIP_DROP_SOURCE_MEMBERSHIP\fR
221 294 .ad
222 295 .RS 29n
223 296 Stop receiving packets for the given multicast group whose source address
224 297 matches the specified address.
225 298 .RE
226 299
227 300 .sp
228 301 .LP
229 302 The following options take a \fBstruct ip_mreq_source\fR as the parameter. The
230 303 structure contains a multicast address (which must be set to the CLASS-D IP
231 304 multicast address), an interface address, and a source address.
232 305 .sp
233 306 .ne 2
234 307 .na
235 -\fB\fBMCAST_JOIN_GROUP\fR\fR
308 +\fBMCAST_JOIN_GROUP\fR
236 309 .ad
237 310 .RS 28n
238 311 Join a multicast group. Functionally equivalent to IP_ADD_MEMBERSHIP.
239 312 .RE
240 313
241 314 .sp
242 315 .ne 2
243 316 .na
244 -\fB\fBMCAST_BLOCK_SOURCE\fR\fR
317 +\fBMCAST_BLOCK_SOURCE\fR
245 318 .ad
246 319 .RS 28n
247 320 Block multicast packets whose source address matches the given source address.
248 321 The specified group must be joined previously using IP_ADD_MEMBERSHIP or
249 322 MCAST_JOIN_GROUP.
250 323 .RE
251 324
252 325 .sp
253 326 .ne 2
254 327 .na
255 -\fB\fBMCAST_UNBLOCK_SOURCE\fR\fR
328 +\fBMCAST_UNBLOCK_SOURCE\fR
256 329 .ad
257 330 .RS 28n
258 331 Unblock (begin receiving) multicast packets which were previously blocked using
259 332 MCAST_BLOCK_SOURCE.
260 333 .RE
261 334
262 335 .sp
263 336 .ne 2
264 337 .na
265 -\fB\fBMCAST_LEAVE_GROUP\fR\fR
338 +\fBMCAST_LEAVE_GROUP\fR
266 339 .ad
267 340 .RS 28n
268 341 Leave a multicast group. Functionally equivalent to IP_DROP_MEMBERSHIP.
269 342 .RE
270 343
271 344 .sp
272 345 .ne 2
273 346 .na
274 -\fB\fBMCAST_JOIN_SOURCE_GROUP\fR\fR
347 +\fBMCAST_JOIN_SOURCE_GROUP\fR
275 348 .ad
276 349 .RS 28n
277 350 Begin receiving packets for the given multicast group whose source address
278 351 matches the specified address.
279 352 .RE
280 353
281 354 .sp
282 355 .ne 2
283 356 .na
284 -\fB\fBMCAST_LEAVE_SOURCE_GROUP\fR\fR
357 +\fBMCAST_LEAVE_SOURCE_GROUP\fR
285 358 .ad
286 359 .RS 28n
287 360 Stop receiving packets for the given multicast group whose source address
288 361 matches the specified address.
289 362 .RE
290 363
291 364 .sp
292 365 .LP
293 366 The following options take a struct \fBgroup_req\fR or struct
294 367 \fBgroup_source_req\fR as the parameter. The `\fBgroup_req\fR structure
295 368 contains an interface index and a multicast address which must be set to the
296 369 CLASS-D multicast address. The \fBgroup_source_req\fR structure is used for
297 370 those options which include a source address. It contains an interface index,
298 371 multicast address, and source address.
299 372 .sp
300 373 .ne 2
301 374 .na
302 -\fB\fBIP_MULTICAST_IF\fR\fR
375 +\fBIP_MULTICAST_IF\fR
303 376 .ad
304 377 .RS 21n
305 378 The outgoing interface for multicast packets. This option takes a \fBstruct\fR
306 379 \fBin_addr\fR as an argument, and it selects that interface for outgoing IP
307 380 multicast packets. If the address specified is \fBINADDR_ANY\fR, it uses the
308 381 unicast routing table to select the outgoing interface (which is the default
309 382 behavior).
310 383 .RE
311 384
312 385 .sp
313 386 .ne 2
314 387 .na
315 -\fB\fBIP_MULTICAST_TTL\fR\fR
388 +\fBIP_MULTICAST_TTL\fR
316 389 .ad
317 390 .RS 21n
318 391 Time to live for multicast datagrams. This option takes an unsigned character
319 392 as an argument. Its value is the TTL that IP uses on outgoing multicast
320 393 datagrams. The default is \fB1\fR.
321 394 .RE
322 395
323 396 .sp
324 397 .ne 2
325 398 .na
326 -\fB\fBIP_MULTICAST_LOOP\fR\fR
399 +\fBIP_MULTICAST_LOOP\fR
327 400 .ad
328 401 .RS 21n
329 402 Loopback for multicast datagrams. Normally multicast datagrams are delivered
330 403 to members on the sending host (or sending zone). Setting the unsigned
331 404 character argument to 0 causes the opposite behavior, meaning that when
332 405 multiple zones are present, the datagrams are delivered to all zones except the
333 406 sending zone.
334 407 .RE
335 408
336 409 .sp
337 410 .ne 2
338 411 .na
339 -\fB\fBIP_RECVIF\fR\fR
412 +\fBIP_TOS\fR
340 413 .ad
341 414 .RS 21n
342 -Receive the inbound interface index.
343 -.RE
344 -
345 -.sp
346 -.ne 2
347 -.na
348 -\fB\fBIP_TOS\fR\fR
349 -.ad
350 -.RS 21n
351 415 This option takes an integer argument as its input value. The least significant
352 416 8 bits of the value are used to set the Type Of Service field in the IP header
353 417 of the outgoing packets.
354 418 .RE
355 419
356 420 .sp
357 421 .ne 2
358 422 .na
359 -\fB\fBIP_NEXTHOP\fR\fR
423 +\fBIP_NEXTHOP\fR
360 424 .ad
361 425 .RS 21n
362 426 This option specifies the address of the onlink nexthop for traffic originating
363 427 from that socket. It causes the routing table to be bypassed and outgoing
364 428 traffic is sent directly to the specified nexthop. This option takes an
365 429 ipaddr_t argument representing the IPv4 address of the nexthop as the input
366 430 value. The IP_NEXTHOP option takes precedence over IPOPT_LSRR. IP_BOUND_IF and
367 431 SO_DONTROUTE take precedence over IP_NEXTHOP. This option has no meaning for
368 432 broadcast and multicast packets. The application must ensure that the specified
369 433 nexthop is alive. An application may want to specify the IP_NEXTHOP option on a
370 434 TCP listener socket only for incoming requests to a particular IP address. In
371 435 this case, it must avoid binding the socket to INADDR_ANY and instead must bind
372 436 the listener socket to the specific IP address. In addition, typically the
373 437 application may want the incoming and outgoing interface to be the same. In
374 438 this case, the application must select a suitable nexthop that is onlink and
375 439 reachable via the desired interface and do a setsockopt (IP_NEXTHOP) on it.
376 440 Then it must bind to the IP address of the desired interface. Setting the
377 441 IP_NEXTHOP option requires the PRIV_SYS_NET_CONFIG privilege.
378 442 .RE
379 443
380 444 .sp
381 445 .LP
382 446 The multicast socket options (IP_MULTICAST_IF, IP_MULTICAST_TTL,
383 447 IP_MULTICAST_LOOP and IP_RECVIF) can be used with any datagram socket type in
384 448 the Internet family.
385 449 .sp
386 450 .LP
387 451 At the socket level, the socket option \fBSO_DONTROUTE\fR may be applied. This
388 452 option forces datagrams being sent to bypass routing and forwarding by forcing
389 453 the IP Time To Live field to \fB1\fR, meaning that the packet will not be
390 454 forwarded by routers.
391 455 .sp
392 456 .LP
393 457 Raw IP datagrams can also be sent and received using the TLI connectionless
394 458 primitives.
395 459 .sp
396 460 .LP
397 461 Datagrams flow through the IP layer in two directions: from the network
398 462 \fIup\fR to user processes and from user processes \fIdown\fR to the network.
399 463 Using this orientation, IP is layered \fIabove\fR the network interface drivers
400 464 and \fIbelow\fR the transport protocols such as UDP and TCP. The Internet
401 465 Control Message Protocol (ICMP) is logically a part of IP. See \fBicmp\fR(7P).
402 466 .sp
403 467 .LP
404 468 IP provides for a checksum of the header part, but not the data part, of the
405 469 datagram. The checksum value is computed and set in the process of sending
406 470 datagrams and checked when receiving datagrams.
407 471 .sp
408 472 .LP
409 473 IP options in received datagrams are processed in the IP layer according to the
410 474 protocol specification. Currently recognized IP options include: security,
411 475 loose source and record route (LSRR), strict source and record route (SSRR),
412 476 record route, and internet timestamp.
413 477 .sp
414 478 .LP
415 479 By default, the IP layer will not forward IPv4 packets that are not addressed
416 480 to it. This behavior can be overridden by using \fBrouteadm\fR(1M) to enable
417 481 the ipv4-forwarding option. IPv4 forwarding is configured at boot time based on
418 482 the setting of \fBrouteadm\fR(1M)'s ipv4-forwarding option.
419 483 .sp
420 484 .LP
421 485 For backwards compatibility, IPv4 forwarding can be enabled or disabled using
422 486 \fBndd\fR(1M)'s ip_forwarding variable. It is set to 1 if IPv4 forwarding is
423 487 enabled, or 0 if it is disabled.
424 488 .sp
425 489 .LP
426 490 Additionally, finer-grained forwarding can be configured in IP. Each interface
427 491 can be configured to forward IP packets by setting the IFF_ROUTER interface
428 492 flag. This flag can be set and cleared using \fBifconfig\fR(1M)'s router and
429 493 router options. If an interface's IFF_ROUTER flag is set, packets can be
430 494 forwarded to or from the interface. If it is clear, packets will neither be
431 495 forwarded from this interface to others, nor forwarded to this interface.
432 496 Setting the ip_forwarding variable sets all of the IPv4 interfaces' IFF_ROUTER
433 497 flags.
434 498 .sp
435 499 .LP
436 500 For backwards compatibility, each interface creates an
437 501 \fB<ifname>:ip_forwarding /dev/ip\fR variable that can be modified using
438 502 \fBndd\fR(1M). An interface's \fB:ip_forwarding ndd\fR variable is a boolean
439 503 variable that mirrors the status of its IFF_ROUTER interface flag. It is set to
440 504 1 if the flag is set, or 0 if it is clear. This interface specific \fB<ifname>
441 505 :ip_forwarding ndd\fR variable is obsolete and may be removed in a future
442 506 release of Solaris. The \fBifconfig\fR(1M) router and -router interfaces are
443 507 preferred.
444 508 .sp
445 509 .LP
446 510 The IP layer sends an ICMP message back to the source host in many cases when
447 511 it receives a datagram that can not be handled. A "time exceeded" ICMP message
448 512 is sent if the "time to live" field in the IP header drops to zero in the
449 513 process of forwarding a datagram. A "destination unreachable" message is sent
450 514 if a datagram can not be forwarded because there is no route to the final
451 515 destination, or if it can not be fragmented. If the datagram is addressed to
452 516 the local host but is destined for a protocol that is not supported or a port
453 517 that is not in use, a destination unreachable message is also sent. The IP
454 518 layer may send an ICMP "source quench" message if it is receiving datagrams too
455 519 quickly. ICMP messages are only sent for the first fragment of a fragmented
456 520 datagram and are never returned in response to errors in other ICMP messages.
457 521 .sp
458 522 .LP
459 523 The IP layer supports fragmentation and reassembly. Datagrams are fragmented on
460 524 output if the datagram is larger than the maximum transmission unit (MTU) of
461 525 the network interface. Fragments of received datagrams are dropped from the
462 526 reassembly queues if the complete datagram is not reconstructed within a short
463 527 time period.
464 528 .sp
465 529 .LP
466 530 Errors in sending discovered at the network interface driver layer are passed
467 531 by IP back up to the user process.
468 532 .sp
469 533 .LP
470 534 Multi-Data Transmit allows more than one packet to be sent from the IP module
471 535 to another in a given call, thereby reducing the per-packet processing costs.
472 536 The behavior of Multi-Data Transmit can be overrideen by using \fBndd\fR(1M) to
473 537 set the \fB/dev/ip\fR variable, ip_multidata_outbound to 0. Note, the IP module
474 538 will only initiate Multi-Data Transmit if the network interface driver supports
475 539 it.
476 540 .SH PACKET EVENTS
477 541 .sp
478 542 .LP
479 543 Through the netinfo framework, this driver provides the following packet
480 544 events:
481 545 .sp
482 546 .ne 2
483 547 .na
484 548 \fBPhysical in\fR
485 549 .ad
486 550 .RS 16n
487 551 Packets received on a network interface from an external source.
488 552 .RE
489 553
490 554 .sp
491 555 .ne 2
492 556 .na
493 557 \fBPhysical out\fR
494 558 .ad
495 559 .RS 16n
496 560 Packets to be sent out a network interface.
497 561 .RE
498 562
499 563 .sp
500 564 .ne 2
501 565 .na
502 566 \fBForwarding\fR
503 567 .ad
504 568 .RS 16n
505 569 Packets being forwarded through this host to another network.
506 570 .RE
507 571
508 572 .sp
509 573 .ne 2
510 574 .na
511 575 \fBloopback in\fR
512 576 .ad
513 577 .RS 16n
514 578 Packets that have been sent by a local application to another.
515 579 .RE
516 580
517 581 .sp
518 582 .ne 2
519 583 .na
520 584 \fBloopback out\fR
521 585 .ad
522 586 .RS 16n
523 587 Packets about to be received by a local application from another.
524 588 .RE
525 589
526 590 .sp
527 591 .LP
528 592 Currently, only a single function may be registered for each event. As a
529 593 result, if the slot for an event is already occupied by someone else, a second
530 594 attempt to register a callback fails.
531 595 .sp
532 596 .LP
533 597 To receive packet events in a kernel module, it is first necessary to obtain a
534 598 handle for either IPv4 or IPv6 traffic. This is achieved by passing NHF_INET
535 599 or NHF_INET6 through to a net_protocol_lookup() call. The value returned from
536 600 this call must then be passed into a call to net_register_hook(), along with
537 601 a description of the hook to add. For a description of the structure passed
538 602 through to the callback, please see \fBhook_pkt_event\fR(9S). For IP
539 603 packets, this structure is filled out as follows:
540 604 .sp
541 605 .ne 2
542 606 .na
543 607 \fBhpe_ifp\fR
544 608 .ad
545 609 .RS 11n
546 610 Identifier indicating the inbound interface for packets received with the
547 611 "physical in" event.
548 612 .RE
549 613
550 614 .sp
551 615 .ne 2
552 616 .na
553 617 \fBhpe_ofp\fR
554 618 .ad
555 619 .RS 11n
556 620 Identifier indicating the outbound interface for packets received with the
557 621 "physical out" event.
558 622 .RE
559 623
560 624 .sp
561 625 .ne 2
562 626 .na
563 627 \fBhpe_hdr\fR
564 628 .ad
565 629 .RS 11n
566 630 Pointer to the start of the IP header (not the ethernet header).
567 631 .RE
568 632
569 633 .sp
570 634 .ne 2
571 635 .na
572 636 \fBhpe_mp\fR
573 637 .ad
574 638 .RS 11n
575 639 Pointer to the start of the mblk_t chain containing the IP packet.
576 640 .RE
577 641
578 642 .sp
579 643 .ne 2
580 644 .na
581 645 \fBhpe_mb\fR
582 646 .ad
583 647 .RS 11n
584 648 Pointer to the mblk_t with the IP header in it.
585 649 .RE
586 650
587 651 .SH NETWORK INTERFACE EVENTS
588 652 .sp
589 653 .LP
590 654 In addition to events describing packets as they move through the system, it is
591 655 also possible to receive notification of events relating to network interfaces.
592 656 These events are all reported back through the same callback. The list of
593 657 events is as follows:
594 658 .sp
595 659 .ne 2
596 660 .na
597 661 \fBplumb\fR
598 662 .ad
599 663 .RS 18n
600 664 A new network interface has been instantiated.
601 665 .RE
602 666
603 667 .sp
604 668 .ne 2
605 669 .na
606 670 \fBunplumb\fR
607 671 .ad
608 672 .RS 18n
609 673 A network interface is no longer associated with this protocol.
610 674 .RE
611 675
612 676 .sp
613 677 .ne 2
614 678 .na
615 679 \fBup\fR
616 680 .ad
617 681 .RS 18n
618 682 At least one logical interface is now ready to receive packets.
619 683 .RE
620 684
621 685 .sp
622 686 .ne 2
623 687 .na
624 688 \fBdown\fR
625 689 .ad
626 690 .RS 18n
627 691 There are no logical interfaces expecting to receive packets.
628 692 .RE
629 693
630 694 .sp
631 695 .ne 2
632 696 .na
↓ open down ↓ |
263 lines elided |
↑ open up ↑ |
633 697 \fBaddress change\fR
634 698 .ad
635 699 .RS 18n
636 700 An address has changed on a logical interface.
637 701 .RE
638 702
639 703 .SH SEE ALSO
640 704 .sp
641 705 .LP
642 706 \fBifconfig\fR(1M), \fBrouteadm\fR(1M), \fBndd\fR(1M), \fBread\fR(2),
643 -\fBwrite\fR(2), \fBbind\fR(3SOCKET), \fBconnect\fR(3SOCKET),
644 -\fBgetsockopt\fR(3SOCKET), \fBrecv\fR(3SOCKET), \fBsend\fR(3SOCKET),
645 -\fBdefaultrouter\fR(4), \fBicmp\fR(7P), \fBif_tcp\fR(7P), \fBinet\fR(7P),
646 -\fBip6\fR(7P), \fBipsec\fR(7P), \fBrouting\fR(7P), \fBtcp\fR(7P),
647 -\fBudp\fR(7P), \fBnet_hook_register\fR(9F), \fBhook_pkt_event\fR(9S)
707 +\fBwrite\fR(2), \fBsocket.h\fR(3HEAD), \fBbind\fR(3SOCKET),
708 +\fBconnect\fR(3SOCKET), \fBgetsockopt\fR(3SOCKET), \fBrecv\fR(3SOCKET),
709 +\fBsend\fR(3SOCKET), \fBdefaultrouter\fR(4), \fBicmp\fR(7P), \fBif_tcp\fR(7P),
710 +\fBinet\fR(7P), \fBip\fR(7P), \fBip6\fR(7P), \fBipsec\fR(7P),
711 +\fBrouting\fR(7P), \fBtcp\fR(7P), \fBudp\fR(7P), \fBnet_hook_register\fR(9F),
712 +\fBhook_pkt_event\fR(9S)
648 713 .sp
649 714 .LP
650 715 Braden, R., \fIRFC 1122, Requirements for Internet Hosts \(mi Communication
651 716 Layers\fR, Information Sciences Institute, University of Southern California,
652 717 October 1989.
653 718 .sp
654 719 .LP
655 720 Postel, J., \fIRFC 791, Internet Protocol \(mi DARPA Internet Program Protocol
656 721 Specification\fR, Information Sciences Institute, University of Southern
657 722 California, September 1981.
658 723 .SH DIAGNOSTICS
659 724 .sp
660 725 .LP
661 726 A socket operation may fail with one of the following errors returned:
662 727 .sp
663 728 .ne 2
664 729 .na
665 -\fB\fBEACCES\fR\fR
730 +\fBEACCES\fR
666 731 .ad
667 732 .RS 17n
668 733 A \fBbind()\fR operation was attempted with a "reserved" port number and the
669 734 effective user ID of the process was not the privileged user.
670 735 .sp
671 736 Setting the IP_NEXTHOP was attempted by a process lacking the
672 737 PRIV_SYS_NET_CONFIG privilege.
673 738 .RE
674 739
675 740 .sp
676 741 .ne 2
677 742 .na
678 -\fB\fBEADDRINUSE\fR\fR
743 +\fBEADDRINUSE\fR
679 744 .ad
680 745 .RS 17n
681 746 A \fBbind()\fR operation was attempted on a socket with a network address/port
682 747 pair that has already been bound to another socket.
683 748 .RE
684 749
685 750 .sp
686 751 .ne 2
687 752 .na
688 -\fB\fBEADDRNOTAVAIL\fR\fR
753 +\fBEADDRNOTAVAIL\fR
689 754 .ad
690 755 .RS 17n
691 756 A \fBbind()\fR operation was attempted for an address that is not configured on
692 757 this machine.
693 758 .RE
694 759
695 760 .sp
696 761 .ne 2
697 762 .na
698 -\fB\fBEINVAL\fR\fR
763 +\fBEINVAL\fR
699 764 .ad
700 765 .RS 17n
701 766 A \fBsendmsg()\fR operation with a non-NULL \fBmsg_accrights\fR was attempted.
702 767 .RE
703 768
704 769 .sp
705 770 .ne 2
706 771 .na
707 -\fB\fBEINVAL\fR\fR
772 +\fBEINVAL\fR
708 773 .ad
709 774 .RS 17n
710 775 A \fBgetsockopt()\fR or \fBsetsockopt()\fR operation with an unknown socket
711 776 option name was given.
712 777 .RE
713 778
714 779 .sp
715 780 .ne 2
716 781 .na
717 -\fB\fBEINVAL\fR\fR
782 +\fBEINVAL\fR
718 783 .ad
719 784 .RS 17n
720 785 A \fBgetsockopt()\fR or \fBsetsockopt()\fR operation was attempted with the
721 786 \fBIP\fR option field improperly formed; an option field was shorter than the
722 787 minimum value or longer than the option buffer provided.
723 788 .RE
724 789
725 790 .sp
726 791 .ne 2
727 792 .na
728 -\fB\fBEISCONN\fR\fR
793 +\fBEISCONN\fR
729 794 .ad
730 795 .RS 17n
731 796 A \fBconnect()\fR operation was attempted on a socket on which a
732 797 \fBconnect()\fR operation had already been performed, and the socket could not
733 798 be successfully disconnected before making the new connection.
734 799 .RE
735 800
736 801 .sp
737 802 .ne 2
738 803 .na
739 -\fB\fBEISCONN\fR\fR
804 +\fBEISCONN\fR
740 805 .ad
741 806 .RS 17n
742 807 A \fBsendto()\fR or \fBsendmsg()\fR operation specifying an address to which
743 808 the message should be sent was attempted on a socket on which a \fBconnect()\fR
744 809 operation had already been performed.
745 810 .RE
746 811
747 812 .sp
748 813 .ne 2
749 814 .na
750 -\fB\fBEMSGSIZE\fR\fR
815 +\fBEMSGSIZE\fR
751 816 .ad
752 817 .RS 17n
753 818 A \fBsend()\fR, \fBsendto()\fR, or \fBsendmsg()\fR operation was attempted to
754 819 send a datagram that was too large for an interface, but was not allowed to be
755 820 fragmented (such as broadcasts).
756 821 .RE
757 822
758 823 .sp
759 824 .ne 2
760 825 .na
761 -\fB\fBENETUNREACH\fR\fR
826 +\fBENETUNREACH\fR
762 827 .ad
763 828 .RS 17n
764 829 An attempt was made to establish a connection by means of \fBconnect()\fR, or
765 830 to send a datagram by means of \fBsendto()\fR or \fBsendmsg()\fR, where there
766 831 was no matching entry in the routing table; or if an ICMP "destination
767 832 unreachable" message was received.
768 833 .RE
769 834
770 835 .sp
771 836 .ne 2
772 837 .na
773 -\fB\fBENOTCONN\fR\fR
838 +\fBENOTCONN\fR
774 839 .ad
775 840 .RS 17n
776 841 A \fBsend()\fR or \fBwrite()\fR operation, or a \fBsendto()\fR or
777 842 \fBsendmsg()\fR operation not specifying an address to which the message should
778 843 be sent, was attempted on a socket on which a \fBconnect()\fR operation had not
779 844 already been performed.
780 845 .RE
781 846
782 847 .sp
783 848 .ne 2
784 849 .na
785 -\fB\fBENOBUFS\fR\fR
850 +\fBENOBUFS\fR
786 851 .ad
787 852 .RS 17n
788 853 The system ran out of memory for fragmentation buffers or other internal data
789 854 structures.
790 855 .RE
791 856
792 857 .sp
793 858 .ne 2
794 859 .na
795 -\fB\fBENOBUFS\fR\fR
860 +\fBENOBUFS\fR
796 861 .ad
797 862 .RS 17n
798 863 \fBSO_SNDBUF\fR or \fBSO_RCVBUF\fR exceeds a system limit.
799 864 .RE
800 865
801 866 .sp
802 867 .ne 2
803 868 .na
804 -\fB\fBEINVAL\fR\fR
869 +\fBEINVAL\fR
805 870 .ad
806 871 .RS 17n
807 872 Invalid length for \fBIP_OPTIONS\fR.
808 873 .RE
809 874
810 875 .sp
811 876 .ne 2
812 877 .na
813 -\fB\fBEHOSTUNREACH\fR\fR
878 +\fBEHOSTUNREACH\fR
814 879 .ad
815 880 .RS 17n
816 881 Invalid address for \fBIP_MULTICAST_IF\fR.
817 882 .sp
818 883 Invalid (offlink) nexthop address for IP_NEXTHOP.
819 884 .RE
820 885
821 886 .sp
822 887 .ne 2
823 888 .na
824 -\fB\fBEINVAL\fR\fR
889 +\fBEINVAL\fR
825 890 .ad
826 891 .RS 17n
827 892 Not a multicast address for \fBIP_ADD_MEMBERSHIP\fR and
828 893 \fBIP_DROP_MEMBERSHIP\fR.
829 894 .RE
830 895
831 896 .sp
832 897 .ne 2
833 898 .na
834 -\fB\fBEADDRNOTAVAIL\fR\fR
899 +\fBEADDRNOTAVAIL\fR
835 900 .ad
836 901 .RS 17n
837 902 Bad interface address for \fBIP_ADD_MEMBERSHIP\fR and \fBIP_DROP_MEMBERSHIP\fR.
838 903 .RE
839 904
840 905 .sp
841 906 .ne 2
842 907 .na
843 -\fB\fBEADDRINUSE\fR\fR
908 +\fBEADDRINUSE\fR
844 909 .ad
845 910 .RS 17n
846 911 Address already joined for \fBIP_ADD_MEMBERSHIP\fR.
847 912 .RE
848 913
849 914 .sp
850 915 .ne 2
851 916 .na
852 -\fB\fBENOENT\fR\fR
917 +\fBENOENT\fR
853 918 .ad
854 919 .RS 17n
855 920 Address not joined for \fBIP_DROP_MEMBERSHIP\fR.
856 921 .RE
857 922
858 923 .sp
859 924 .ne 2
860 925 .na
861 -\fB\fBENOPROTOOPT\fR\fR
926 +\fBENOPROTOOPT\fR
862 927 .ad
863 928 .RS 17n
864 929 Invalid socket type.
865 930 .RE
866 931
867 932 .sp
868 933 .ne 2
869 934 .na
870 -\fB\fBEPERM\fR\fR
935 +\fBEPERM\fR
871 936 .ad
872 937 .RS 17n
873 938 No permissions.
874 939 .RE
875 940
876 941 .SH NOTES
877 942 .sp
878 943 .LP
879 944 Raw sockets should receive \fBICMP\fR error packets relating to the protocol;
880 945 currently such packets are simply discarded.
881 946 .sp
882 947 .LP
883 948 Users of higher-level protocols such as \fBTCP\fR and \fBUDP\fR should be able
884 949 to see received IP options.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX