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/man3head/socket.h.3head.man.txt
+++ new/usr/src/man/man3head/socket.h.3head.man.txt
1 1 SOCKET.H(3HEAD) Headers SOCKET.H(3HEAD)
2 2
3 3
4 4
5 5 NAME
6 - socket.h, socket - Internet Protocol family
6 + socket.h, socket, CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR,
7 + CMSG_SPACE - Internet Protocol family
7 8
8 9 SYNOPSIS
9 10 #include <sys/socket.h>
10 11
11 12
12 13 DESCRIPTION
13 14 The <sys/socket.h> header defines the unsigned integral type
14 15 sa_family_t through typedef.
15 16
16 17
17 18 The <sys/socket.h> header defines the sockaddr structure that includes
18 19 the following members:
19 20
20 21 sa_family_t sa_family /* address family */
21 22 char sa_data[] /* socket address (variable-length
22 23 data) */
23 24
24 25
25 26 libxnet Interfaces
26 27 The <sys/socket.h> header defines the msghdr structure for libxnet
27 28 interfaces that includes the following members:
28 29
29 30 void *msg_name /* optional address */
30 31 socklen_t msg_namelen /* size of address */
31 32 struct iovec *msg_iov /* scatter/gather array */
32 33 int msg_iovlen /* members in msg_iov */
33 34 void *msg_control /* ancillary data, see below */
34 35 socklen_t msg_controllen /* ancillary data buffer len */
35 36 int msg_flags /* flags on received message */
36 37
37 38
38 39
39 40 The <sys/socket.h> header defines the cmsghdr structure for libxnet
40 41 that includes the following members:
41 42
42 43 socklen_t cmsg_len /* data byte count, including hdr */
43 44 int cmsg_level /* originating protocol */
44 45 int cmsg_type /* protocol-specific type */
45 46
46 47
47 48
48 49 Ancillary data consists of a sequence of pairs, each consisting of a
49 50 cmsghdr structure followed by a data array. The data array contains the
50 51 ancillary data message, and the cmsghdr structure contains descriptive
51 52 information that allows an application to correctly parse the data.
52 53
53 54
54 55 The values for cmsg_level will be legal values for the level argument
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
55 56 to the getsockopt() and setsockopt() functions. The SCM_RIGHTS type is
56 57 supported for level SOL_SOCKET.
57 58
58 59
59 60 Ancillary data is also possible at the socket level. The <sys/socket.h>
60 61 header defines the following macros for use as the cmsg_type values
61 62 when cmsg_level is SOL_SOCKET.
62 63
63 64 SCM_RIGHTS
64 65 Indicates that the data array contains the access rights
65 - to be sent or received.
66 + (set of open file descriptors) to be sent or received.
66 67
67 68
68 69 SCM_UCRED
69 70 Indicates that the data array contains a ucred_t to be
70 71 received. The ucred_t is the credential of the sending
71 72 process at the time the message was sent. This is a Sun-
72 73 specific, Evolving interface. See ucred_get(3C).
73 74
74 75
75 76
76 - The IPv4 data formats generally use the same values for data passed
77 - back in cmsghdr as for setsockopt() to enable the feature. The IPv4
78 - data formats are listed below with the associated payload for each.
77 + The IPv4 ancillary data formats are listed below by cmsg_level and
78 + cmsg_type, along with the associated payload for each.
79 79
80 - IPPROTO_IP
81 - IP_RECVDSTADDR
80 + IPPROTO_IP, IP_RECVDSTADDR -- SOCK_DGRAM only
82 81
83 82 ipaddr_t, IP address
84 83
85 84
86 - IPPROTO_IP
87 - IP_RECVOPTS
85 + IPPROTO_IP, IP_RECVIF
88 86
87 + uint_t, ifIndex number
88 +
89 +
90 + IPPROTO_IP, IP_RECVOPTS -- SOCK_DGRAM only
91 +
89 92 variable-length IP options, up to 40 bytes
90 93
91 94
92 - IPPROTO_IP
93 - IP_RECVIF
95 + IPPROTO_IP, IP_RECVPKTINFO -- SOCK_DGRAM only
94 96
95 - uint_t, ifIndex number
97 + in_pktinfo_t
96 98
97 99
98 - IPPROTO_IP
99 - IP_RECVSLLA
100 + IPPROTO_IP, IP_RECVSLLA -- SOCK_DGRAM only
100 101
101 102 struct sockaddr_dl, link layer address
102 103
103 104
104 - IPPROTO_IP
105 - IP_RECVTTL
105 + IPPROTO_IP, IP_RECVTTL -- SOCK_DGRAM only
106 106
107 - uint8_t
107 + uint8_t, the IP TTL (time to live)
108 108
109 109
110 - SOL_SOCKET
111 - SO_RECVUCRED
110 + IPPROTO_IP, IP_RECVTOS
112 111
113 - ucred_t -- cmsghdr.cmsg_type is SCM_UCRED, not SO_RECVUCRED
112 + uint8_t, the IP TOS (type of service)
114 113
115 114
115 + SOL_SOCKET, SO_UCRED
116 116
117 - The IPv6 data formats use different values for enabling the option and
118 - for passing the value back to the application. The IPv6 data formats
119 - are listed below with the associated payload for each.
117 + ucred_t
120 118
121 - IPPROTO_IPV6
122 - IPV6_RECVPKTINFO
123 119
124 - in_pktinfo, cmsg_type IPV6_PKTINFO
125 120
121 + The IPv6 ancillary data formats are listed below by cmsg_level and
122 + cmsg_type, along with the associated payload for each.
126 123
127 - IPPROTO_IPV6
128 - IPV6_RECVTCLASS
124 + IPPROTO_IPV6, IPV6_PKTINFO
129 125
130 - uint_t, cmsg_type IPV6_TCLASS
126 + in_pktinfo_t
131 127
132 128
133 - IPPROTO_IPV6
134 - IPV6_RECVPATHMTU
129 + IPPROTO_IPV6, IPV6_TCLASS
135 130
136 - ip6_mtuinfo, cmsg_type IPV6_PATHMTU
131 + uint_t
137 132
138 133
139 - IPPROTO_IPV6
140 - IPV6_RECVHOPLIMIT
134 + IPPROTO_IPV6, IPV6_PATHMTU
141 135
142 - uint_t, cmsg_type IPV6_HOPLIMIT
136 + ip6_mtuinfo
143 137
144 138
145 - IPPROTO_IPV6
146 - IPV6_RECVHOPOPTS
139 + IPPROTO_IPV6, IPV6_HOPLIMIT
147 140
148 - variable-length IPv6 options, cmsg_type IPV6_HOPOPTS
141 + uint_t
149 142
150 143
151 - IPPROTO_IPV6
152 - IPV6_RECVDSTOPTS
144 + IPPROTO_IPV6, IPV6_HOPOPTS
153 145
154 - variable-length IPv6 options, cmsg_type IPV6_DSTOPTS
146 + variable-length IPv6 options
155 147
156 148
157 - IPPROTO_IPV6
158 - IPV6_RECVRTHDR
149 + IPPROTO_IPV6, IPV6_DSTOPTS
159 150
160 - variable-length IPv6 options, cmsg_type IPV6_RTHDR
151 + variable-length IPv6 options
161 152
162 153
163 - IPPROTO_IPV6
164 - IPV6_RECVRTHDRDSTOPTS
154 + IPPROTO_IPV6, IPV6_RTHDR
165 155
166 - variable-length IPv6 options, cmsg_type IPV6_DSTOPTS
156 + variable-length IPv6 options
167 157
168 158
159 + IPPROTO_IPV6, IPV6_DSTOPTS
169 160
161 + variable-length IPv6 options
162 +
163 +
164 +
170 165 The <sys/socket.h> header defines the following macros to gain access
171 166 to the data arrays in the ancillary data associated with a message
172 167 header:
173 168
174 169 CMSG_DATA(cmsg)
175 170
176 171 If the argument is a pointer to a cmsghdr structure, this macro
177 172 returns an unsigned character pointer to the data array associated
178 173 with the cmsghdr structure.
179 174
180 175
181 176 CMSG_NXTHDR(mhdr, cmsg)
182 177
183 178 If the first argument is a pointer to a msghdr structure and the
184 179 second argument is a pointer to a cmsghdr structure in the
185 180 ancillary data, pointed to by the msg_control field of that msghdr
186 181 structure, this macro returns a pointer to the next cmsghdr
187 182 structure, or a null pointer if this structure is the last cmsghdr
188 183 in the ancillary data.
189 184
190 185
191 186 CMSG_FIRSTHDR(mhdr)
192 187
193 188 If the argument is a pointer to a msghdr structure, this macro
194 189 returns a pointer to the first cmsghdr structure in the ancillary
195 190 data associated with this msghdr structure, or a null pointer if
196 191 there is no ancillary data associated with the msghdr structure.
197 192
198 193
199 194 CMSG_SPACE(len)
200 195
201 196 Given the length of an ancillary data object, CMSG_SPACE() returns
202 197 the space required by the object and its cmsghdr structure,
203 198 including any padding needed to satisfy alignment requirements.
204 199 This macro can be used, for example, to allocate space dynamically
205 200 for the ancillary data. This macro should not be used to initialize
206 201 the cmsg_len member of a cmsghdr structure. Use the CMSG_LEN()
207 202 macro instead.
208 203
209 204
210 205 CMSG_LEN(len)
211 206
212 207 Given the length of an ancillary data object, CMSG_LEN() returns
213 208 the value to store in the cmsg_len member of the cmsghdr structure,
214 209 taking into account any padding needed to satisfy alignment
215 210 requirements.
216 211
217 212
218 213
219 214 The <sys/socket.h> header defines the linger structure that includes
220 215 the following members:
221 216
222 217 int l_onoff /* indicates whether linger option is enabled */
223 218 int l_linger /* linger time, in seconds */
224 219
225 220
226 221
227 222 The <sys/socket.h> header defines the following macros:
228 223
229 224 SOCK_DGRAM
230 225 Datagram socket
231 226
232 227
233 228 SOCK_STREAM
234 229 Byte-stream socket
235 230
236 231
237 232 SOCK_SEQPACKET
238 233 Sequenced-packet socket
239 234
240 235
241 236
242 237 The <sys/socket.h> header defines the following macros for use as the
243 238 level argument of setsockopt() and getsockopt().
244 239
245 240 SOL_SOCKET
246 241 Options to be accessed at the socket level, not the
247 242 protocol level.
248 243
249 244
250 245 SOL_ROUTE
251 246 Options to be accessed at the routing socket level, not
252 247 the protocol level.
253 248
254 249
255 250
256 251 The <sys/socket.h> header defines the following macros for use as the
257 252 option_name argument of getsockopt() or setsockopt() calls:
258 253
259 254 SO_DEBUG
260 255 Debugging information is being recorded.
261 256
262 257
263 258 SO_ACCEPTCONN
264 259 Socket is accepting connections.
265 260
266 261
267 262 SO_BROADCAST
268 263 Transmission of broadcast messages is supported.
269 264
270 265
271 266 SO_REUSEADDR
272 267 Reuse of local addresses is supported.
273 268
274 269
275 270 SO_KEEPALIVE
276 271 Connections are kept alive with periodic messages.
277 272
278 273
279 274 SO_LINGER
280 275 Socket lingers on close.
281 276
282 277
283 278 SO_OOBINLINE
284 279 Out-of-band data is transmitted in line.
285 280
286 281
287 282 SO_SNDBUF
288 283 Send buffer size.
289 284
290 285
291 286 SO_RCVBUF
292 287 Receive buffer size.
293 288
294 289
295 290 SO_ERROR
296 291 Socket error status.
297 292
298 293
299 294 SO_TYPE
300 295 Socket type.
301 296
302 297
303 298 SO_RECVUCRED
304 299 Request the reception of user credential ancillary
305 300 data. This is a Sun-specific, Evolving interface. See
306 301 ucred_get(3C).
307 302
308 303
309 304 SO_MAC_EXEMPT
310 305 Mandatory Access Control (MAC) exemption for unlabeled
311 306 peers. This option is available only if the system is
312 307 configured with Trusted Extensions.
313 308
314 309
315 310 SO_ALLZONES
316 311 Bypass zone boundaries (privileged).
317 312
318 313
319 314
320 315 The <sys/socket.h> header defines the following macros for use as the
321 316 valid values for the msg_flags field in the msghdr structure, or the
322 317 flags parameter in recvfrom(), recvmsg(), sendto(), or sendmsg() calls:
323 318
324 319 MSG_CTRUNC
325 320 Control data truncated.
326 321
327 322
328 323 MSG_EOR
329 324 Terminates a record (if supported by the protocol).
330 325
331 326
332 327 MSG_OOB
333 328 Out-of-band data.
334 329
335 330
336 331 MSG_PEEK
337 332 Leave received data in queue.
338 333
339 334
340 335 MSG_TRUNC
341 336 Normal data truncated.
342 337
343 338
344 339 MSG_WAITALL
345 340 Wait for complete message.
346 341
347 342
348 343 MSG_NOSIGNAL
349 344 Do not generate SIGPIPE signal.
350 345
351 346
352 347
353 348 The <sys/socket.h> header defines the following macros:
354 349
355 350 AF_UNIX
356 351 UNIX domain sockets
357 352
358 353
359 354 AF_INET
360 355 Internet domain sockets
361 356
362 357
363 358
364 359 The <sys/socket.h> header defines the following macros:
365 360
366 361 SHUT_RD
367 362 Disables further receive operations.
368 363
369 364
370 365 SHUT_WR
371 366 Disables further send operations.
372 367
373 368
374 369 SHUT_RDWR
375 370 Disables further send and receive operations.
376 371
377 372
378 373 libsocket Interfaces
379 374 The <sys/socket.h> header defines the msghdr structure for libsocket
380 375 interfaces that includes the following members:
381 376
382 377 void *msg_name /* optional address */
383 378 socklen_t msg_namelen /* size of address */
384 379 struct iovec *msg_iov /* scatter/gather array */
385 380 int msg_iovlen /* # elements in msg_iov */
386 381 caddr_t msg_accrights /* access rights sent/received */
387 382
388 383
389 384
390 385 The msg_name and msg_namelen parameters specify the destination address
391 386 when the socket is unconnected The msg_name can be specified as a NULL
392 387 pointer if no names are desired or required. The msg_iov and msg_iovlen
393 388 parameters describe the scatter-gather locations, as described in
394 389 read(2). The msg_accrights parameter specifies the buffer in which
395 390 access rights sent along with the message are received. The
396 391 msg_accrightslen specifies the length of the buffer.
397 392
398 393 ATTRIBUTES
399 394 See attributes(5) for descriptions of the following attributes:
400 395
401 396
402 397
403 398
404 399 +--------------------+-----------------+
405 400 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
406 401 +--------------------+-----------------+
407 402 |Interface Stability | Standard |
408 403 +--------------------+-----------------+
409 404
410 405 SEE ALSO
411 406 accept(3SOCKET), accept(3XNET), bind(3SOCKET), bind(3XNET),
412 407 connect(3SOCKET), connect(3XNET), getpeername(3SOCKET),
413 408 getpeername(3XNET), getpeerucred(3C), getsockname(3SOCKET),
414 409 getsockname(3XNET), getsockopt(3SOCKET), getsockopt(3XNET),
↓ open down ↓ |
235 lines elided |
↑ open up ↑ |
415 410 libsocket(3LIB), listen(3SOCKET), listen(3XNET), recv(3SOCKET),
416 411 recv(3XNET), recvfrom(3SOCKET), recvfrom(3XNET), recvmsg(3SOCKET),
417 412 recvmsg(3XNET), send(3SOCKET), send(3XNET), sendmsg(3SOCKET),
418 413 sendmsg(3XNET), sendto(3SOCKET), sendto(3XNET), setsockopt(3SOCKET),
419 414 setsockopt(3XNET), shutdown(3SOCKET), shutdown(3XNET),
420 415 sockaddr(3SOCKET), socket(3SOCKET), socket(3XNET), socketpair(3SOCKET),
421 416 socketpair(3XNET), ucred_get(3C), attributes(5), standards(5)
422 417
423 418
424 419
425 - June 18, 2017 SOCKET.H(3HEAD)
420 + September 18, 2020 SOCKET.H(3HEAD)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX