Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/socket.h
+++ new/usr/src/uts/common/sys/socket.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23 + *
22 24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23 25 */
24 26
25 27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26 28 /* All Rights Reserved */
27 29
28 30 /*
29 31 * University Copyright- Copyright (c) 1982, 1986, 1988
30 32 * The Regents of the University of California
31 33 * All Rights Reserved
32 34 *
33 35 * University Acknowledgment- Portions of this document are derived from
34 36 * software developed by the University of California, Berkeley, and its
35 37 * contributors.
36 38 */
37 39
38 40 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
39 41
40 42 #ifndef _SYS_SOCKET_H
41 43 #define _SYS_SOCKET_H
42 44
43 45 #include <sys/types.h>
44 46 #include <sys/uio.h>
45 47 #include <sys/feature_tests.h>
46 48 #include <sys/socket_impl.h>
47 49 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
48 50 #ifndef _KERNEL
49 51 #include <sys/netconfig.h>
50 52 #endif /* !_KERNEL */
51 53 #include <netinet/in.h>
52 54 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
53 55
54 56 #ifdef __cplusplus
55 57 extern "C" {
56 58 #endif
57 59
58 60 #ifndef _SOCKLEN_T
59 61 #define _SOCKLEN_T
60 62
61 63 /*
62 64 * The socklen definitions are reproduced in netinet/in.h for the inet6_
63 65 * functions. Exposing all of sys/socket.h via netinet/in.h breaks existing
64 66 * applications and is not required by austin.
65 67 */
66 68 #if defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64)
67 69 typedef size_t socklen_t;
68 70 #else
69 71 typedef uint32_t socklen_t;
70 72 #endif /* defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) */
71 73
72 74 #if defined(_XPG4_2) || defined(_BOOT)
73 75 typedef socklen_t *_RESTRICT_KYWD Psocklen_t;
74 76 #else
75 77 typedef void *_RESTRICT_KYWD Psocklen_t;
76 78 #endif /* defined(_XPG4_2) || defined(_BOOT) */
77 79
78 80 #endif /* _SOCKLEN_T */
79 81
80 82 /*
81 83 * Definitions related to sockets: types, address families, options.
82 84 */
83 85 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
84 86 #ifndef NC_TPI_CLTS
85 87 #define NC_TPI_CLTS 1 /* must agree with netconfig.h */
86 88 #define NC_TPI_COTS 2 /* must agree with netconfig.h */
87 89 #define NC_TPI_COTS_ORD 3 /* must agree with netconfig.h */
88 90 #define NC_TPI_RAW 4 /* must agree with netconfig.h */
89 91 #endif /* !NC_TPI_CLTS */
90 92 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
91 93
92 94 /*
93 95 * Types
94 96 */
95 97 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
96 98 #define SOCK_STREAM NC_TPI_COTS /* stream socket */
97 99 #define SOCK_DGRAM NC_TPI_CLTS /* datagram socket */
98 100 #define SOCK_RAW NC_TPI_RAW /* raw-protocol interface */
99 101 #else
100 102 #define SOCK_STREAM 2 /* stream socket */
101 103 #define SOCK_DGRAM 1 /* datagram socket */
102 104 #define SOCK_RAW 4 /* raw-protocol interface */
103 105 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
104 106 #define SOCK_RDM 5 /* reliably-delivered message */
105 107 #define SOCK_SEQPACKET 6 /* sequenced packet stream */
106 108 #define SOCK_TYPE_MASK 0xffff /* type reside in these bits only */
107 109
108 110 /*
109 111 * Flags for socket() and accept4()
110 112 */
111 113 #define SOCK_CLOEXEC 0x080000 /* like open(2) O_CLOEXEC for socket */
112 114 #define SOCK_NONBLOCK 0x100000 /* like O_NONBLOCK */
113 115 #define SOCK_NDELAY 0x200000 /* like O_NDELAY */
114 116
115 117 /*
116 118 * Option flags per-socket.
117 119 */
118 120 #define SO_DEBUG 0x0001 /* turn on debugging info recording */
119 121 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
120 122 #define SO_REUSEADDR 0x0004 /* allow local address reuse */
121 123 #define SO_KEEPALIVE 0x0008 /* keep connections alive */
122 124 #define SO_DONTROUTE 0x0010 /* just use interface addresses */
123 125 #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
124 126 #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
125 127 #define SO_LINGER 0x0080 /* linger on close if data present */
126 128 #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
127 129 #define SO_DGRAM_ERRIND 0x0200 /* Application wants delayed error */
128 130 #define SO_RECVUCRED 0x0400 /* Application wants ucred of sender */
129 131
130 132 /*
131 133 * Socket options are passed using a signed integer, but it is also rare
132 134 * for more than one to ever be passed at the same time with setsockopt
133 135 * and only one at a time can be retrieved with getsockopt.
134 136 *
135 137 * Since the lower numbers cannot be renumbered for compatibility reasons,
136 138 * it would seem that we need to start a new number space (0x40000000 -
137 139 * 0x7fffffff) for those that don't need to be stored as a bit flag
138 140 * somewhere. This limits the flag options to 30 but that seems to be
139 141 * plenty, anyway. 0x40000000 is reserved for future use.
140 142 */
141 143 #define SO_ATTACH_FILTER 0x40000001
142 144 #define SO_DETACH_FILTER 0x40000002
143 145
144 146 #ifdef _KERNEL
145 147 #define SO_SND_COPYAVOID 0x0800 /* Internal: use zero-copy */
146 148 #define SO_SND_BUFINFO 0x1000 /* Internal: get buffer info */
147 149 /* when doing zero-copy */
148 150
149 151 struct so_snd_bufinfo {
150 152 ushort_t sbi_wroff; /* Write offset */
151 153 ssize_t sbi_maxblk; /* Max size of a single mblk */
152 154 ssize_t sbi_maxpsz; /* Max total size of a mblk chain */
153 155 ushort_t sbi_tail; /* Extra space available at the end */
154 156 };
155 157 #endif /* _KERNEL */
156 158
157 159 /*
158 160 * N.B.: The following definition is present only for compatibility
159 161 * with release 3.0. It will disappear in later releases.
160 162 */
161 163 #define SO_DONTLINGER (~SO_LINGER) /* ~SO_LINGER */
162 164
163 165 /*
164 166 * Additional options, not kept in so_options.
165 167 */
166 168 #define SO_SNDBUF 0x1001 /* send buffer size */
167 169 #define SO_RCVBUF 0x1002 /* receive buffer size */
168 170 #define SO_SNDLOWAT 0x1003 /* send low-water mark */
169 171 #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
170 172 #define SO_SNDTIMEO 0x1005 /* send timeout */
171 173 #define SO_RCVTIMEO 0x1006 /* receive timeout */
172 174 #define SO_ERROR 0x1007 /* get error status and clear */
173 175 #define SO_TYPE 0x1008 /* get socket type */
174 176 #define SO_PROTOTYPE 0x1009 /* get/set protocol type */
175 177 #define SO_ANON_MLP 0x100a /* create MLP on anonymous bind */
176 178 #define SO_MAC_EXEMPT 0x100b /* allow dominated unlabeled peers */
177 179 #define SO_DOMAIN 0x100c /* get socket domain */
178 180 #define SO_RCVPSH 0x100d /* receive interval to push data */
179 181
180 182 /* "Socket"-level control message types: */
181 183 #define SCM_RIGHTS 0x1010 /* access rights (array of int) */
182 184 #define SO_SECATTR 0x1011 /* socket's security attributes */
183 185 #define SCM_UCRED 0x1012 /* sender's ucred */
184 186 #define SO_TIMESTAMP 0x1013 /* socket-level timestamp option */
185 187 #define SCM_TIMESTAMP SO_TIMESTAMP /* socket control message timestamp */
186 188 #define SO_ALLZONES 0x1014 /* bind in all zones */
187 189 #define SO_EXCLBIND 0x1015 /* exclusive binding */
188 190 #define SO_MAC_IMPLICIT 0x1016 /* hide mac labels on wire */
189 191 #define SO_VRRP 0x1017 /* VRRP control socket */
190 192
191 193 #ifdef _KERNEL
192 194 #define SO_SRCADDR 0x2001 /* Internal: AF_UNIX source address */
193 195 #define SO_FILEP 0x2002 /* Internal: AF_UNIX file pointer */
194 196 #define SO_UNIX_CLOSE 0x2003 /* Internal: AF_UNIX peer closed */
195 197 #endif /* _KERNEL */
196 198
197 199 /*
198 200 * Socket filter options
199 201 */
200 202 #define FIL_ATTACH 0x1 /* attach filter */
201 203 #define FIL_DETACH 0x2 /* detach filter */
202 204 #define FIL_LIST 0x3 /* list attached filters */
203 205
204 206 #define FILNAME_MAX 32
205 207 /*
206 208 * Structure returned by FIL_LIST
207 209 */
208 210 struct fil_info {
209 211 int fi_flags; /* see below (FILF_*) */
210 212 int fi_pos; /* position (0 is bottom) */
211 213 char fi_name[FILNAME_MAX]; /* filter name */
212 214 };
213 215
214 216 #define FILF_PROG 0x1 /* programmatic attach */
215 217 #define FILF_AUTO 0x2 /* automatic attach */
216 218 #define FILF_BYPASS 0x4 /* filter is not active */
217 219
218 220 #ifdef _KERNEL
219 221 /*
220 222 * new socket open flags to identify socket and acceptor streams
221 223 */
222 224 #define SO_ACCEPTOR 0x20000 /* acceptor socket */
223 225 #define SO_SOCKSTR 0x40000 /* normal socket stream */
224 226 #define SO_FALLBACK 0x80000 /* fallback to TPI socket */
225 227
226 228 /*
227 229 * Flags for socket_create() and socket_newconn()
228 230 */
229 231 #define SOCKET_SLEEP KM_SLEEP
230 232 #define SOCKET_NOSLEEP KM_NOSLEEP
231 233
232 234 #endif /* _KERNEL */
233 235
234 236 /*
235 237 * Structure used for manipulating linger option.
236 238 */
237 239 struct linger {
238 240 int l_onoff; /* option on/off */
239 241 int l_linger; /* linger time */
240 242 };
241 243
242 244 /*
243 245 * Levels for (get/set)sockopt() that don't apply to a specific protocol.
244 246 */
245 247 #define SOL_SOCKET 0xffff /* options for socket level */
246 248 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
247 249 #define SOL_ROUTE 0xfffe /* options for routing socket level */
248 250 #endif
249 251 #define SOL_PACKET 0xfffd /* options for packet level */
250 252 #define SOL_FILTER 0xfffc /* options for socket filter level */
251 253
252 254 /*
253 255 * Address families.
254 256 *
255 257 * Some of these constant names are copied for the DTrace IP provider in
256 258 * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept
257 259 * in sync.
258 260 */
259 261 #define AF_UNSPEC 0 /* unspecified */
260 262 #define AF_UNIX 1 /* local to host (pipes, portals) */
261 263 #define AF_LOCAL AF_UNIX /* Synonym for AF_UNIX */
262 264 #define AF_FILE AF_UNIX /* Synonym for AF_UNIX */
263 265 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
264 266 #define AF_IMPLINK 3 /* arpanet imp addresses */
265 267 #define AF_PUP 4 /* pup protocols: e.g. BSP */
266 268 #define AF_CHAOS 5 /* mit CHAOS protocols */
267 269 #define AF_NS 6 /* XEROX NS protocols */
268 270 #define AF_NBS 7 /* nbs protocols */
269 271 #define AF_ECMA 8 /* european computer manufacturers */
270 272 #define AF_DATAKIT 9 /* datakit protocols */
271 273 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
272 274 #define AF_SNA 11 /* IBM SNA */
273 275 #define AF_DECnet 12 /* DECnet */
274 276 #define AF_DLI 13 /* Direct data link interface */
275 277 #define AF_LAT 14 /* LAT */
276 278 #define AF_HYLINK 15 /* NSC Hyperchannel */
277 279 #define AF_APPLETALK 16 /* Apple Talk */
278 280 #define AF_NIT 17 /* Network Interface Tap */
279 281 #define AF_802 18 /* IEEE 802.2, also ISO 8802 */
280 282 #define AF_OSI 19 /* umbrella for all families used */
281 283 #define AF_X25 20 /* CCITT X.25 in particular */
282 284 #define AF_OSINET 21 /* AFI = 47, IDI = 4 */
283 285 #define AF_GOSIP 22 /* U.S. Government OSI */
284 286 #define AF_IPX 23 /* Novell Internet Protocol */
285 287 #define AF_ROUTE 24 /* Internal Routing Protocol */
286 288 #define AF_LINK 25 /* Link-layer interface */
287 289 #define AF_INET6 26 /* Internet Protocol, Version 6 */
288 290 #define AF_KEY 27 /* Security Association DB socket */
289 291 #define AF_NCA 28 /* NCA socket */
290 292 #define AF_POLICY 29 /* Security Policy DB socket */
291 293 #define AF_INET_OFFLOAD 30 /* Sun private; do not use */
292 294 #define AF_TRILL 31 /* TRILL interface */
293 295 #define AF_PACKET 32 /* PF_PACKET Linux socket interface */
294 296
295 297 #define AF_MAX 32
296 298
297 299 /*
298 300 * Protocol families, same as address families for now.
299 301 */
300 302 #define PF_UNSPEC AF_UNSPEC
301 303 #define PF_UNIX AF_UNIX
302 304 #define PF_LOCAL PF_UNIX
303 305 #define PF_FILE PF_UNIX
304 306 #define PF_INET AF_INET
305 307 #define PF_IMPLINK AF_IMPLINK
306 308 #define PF_PUP AF_PUP
307 309 #define PF_CHAOS AF_CHAOS
308 310 #define PF_NS AF_NS
309 311 #define PF_NBS AF_NBS
310 312 #define PF_ECMA AF_ECMA
311 313 #define PF_DATAKIT AF_DATAKIT
312 314 #define PF_CCITT AF_CCITT
313 315 #define PF_SNA AF_SNA
314 316 #define PF_DECnet AF_DECnet
315 317 #define PF_DLI AF_DLI
316 318 #define PF_LAT AF_LAT
317 319 #define PF_HYLINK AF_HYLINK
318 320 #define PF_APPLETALK AF_APPLETALK
319 321 #define PF_NIT AF_NIT
320 322 #define PF_802 AF_802
321 323 #define PF_OSI AF_OSI
322 324 #define PF_X25 AF_X25
323 325 #define PF_OSINET AF_OSINET
324 326 #define PF_GOSIP AF_GOSIP
325 327 #define PF_IPX AF_IPX
326 328 #define PF_ROUTE AF_ROUTE
327 329 #define PF_LINK AF_LINK
328 330 #define PF_INET6 AF_INET6
329 331 #define PF_KEY AF_KEY
330 332 #define PF_NCA AF_NCA
331 333 #define PF_POLICY AF_POLICY
332 334 #define PF_INET_OFFLOAD AF_INET_OFFLOAD /* Sun private; do not use */
333 335 #define PF_TRILL AF_TRILL
334 336 #define PF_PACKET AF_PACKET
335 337
336 338 #define PF_MAX AF_MAX
337 339
338 340 /*
339 341 * Maximum queue length specifiable by listen.
340 342 */
341 343 #define SOMAXCONN 128
342 344
343 345 /*
344 346 * Message header for recvmsg and sendmsg calls.
345 347 */
346 348 struct msghdr {
347 349 void *msg_name; /* optional address */
348 350 socklen_t msg_namelen; /* size of address */
349 351 struct iovec *msg_iov; /* scatter/gather array */
350 352 int msg_iovlen; /* # elements in msg_iov */
351 353
352 354 #if defined(_XPG4_2) || defined(_KERNEL)
353 355 void *msg_control; /* ancillary data */
354 356 socklen_t msg_controllen; /* ancillary data buffer len */
355 357 int msg_flags; /* flags on received message */
356 358 #else
357 359 caddr_t msg_accrights; /* access rights sent/received */
358 360 int msg_accrightslen;
359 361 #endif /* defined(_XPG4_2) || defined(_KERNEL) */
360 362 };
361 363
362 364 #if defined(_KERNEL)
363 365
364 366 /*
365 367 * N.B.: we assume that omsghdr and nmsghdr are isomorphic, with
366 368 * the sole exception that nmsghdr has the additional msg_flags
367 369 * field at the end.
368 370 */
369 371 struct omsghdr {
370 372 void *msg_name; /* optional address */
371 373 socklen_t msg_namelen; /* size of address */
372 374 struct iovec *msg_iov; /* scatter/gather array */
373 375 int msg_iovlen; /* # elements in msg_iov */
374 376 caddr_t msg_accrights; /* access rights sent/received */
375 377 int msg_accrightslen;
376 378 };
377 379
378 380 #define nmsghdr msghdr
379 381
380 382 #if defined(_SYSCALL32)
381 383
382 384 struct omsghdr32 {
383 385 caddr32_t msg_name; /* optional address */
384 386 uint32_t msg_namelen; /* size of address */
385 387 caddr32_t msg_iov; /* scatter/gather array */
386 388 int32_t msg_iovlen; /* # elements in msg_iov */
387 389 caddr32_t msg_accrights; /* access rights sent/received */
388 390 uint32_t msg_accrightslen;
389 391 };
390 392
391 393 struct msghdr32 {
392 394 caddr32_t msg_name; /* optional address */
393 395 uint32_t msg_namelen; /* size of address */
394 396 caddr32_t msg_iov; /* scatter/gather array */
395 397 int32_t msg_iovlen; /* # elements in msg_iov */
396 398 caddr32_t msg_control; /* ancillary data */
397 399 uint32_t msg_controllen; /* ancillary data buffer len */
398 400 int32_t msg_flags; /* flags on received message */
399 401 };
400 402
401 403 #define nmsghdr32 msghdr32
402 404
403 405 #endif /* _SYSCALL32 */
404 406 #endif /* _KERNEL */
405 407
406 408 #define MSG_OOB 0x1 /* process out-of-band data */
407 409 #define MSG_PEEK 0x2 /* peek at incoming message */
408 410 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
409 411 /* Added for XPGv2 compliance */
410 412 #define MSG_EOR 0x8 /* Terminates a record */
411 413 #define MSG_CTRUNC 0x10 /* Control data truncated */
412 414 #define MSG_TRUNC 0x20 /* Normal data truncated */
413 415 #define MSG_WAITALL 0x40 /* Wait for complete recv or error */
414 416 #define MSG_DUPCTRL 0x800 /* Save control message for use with */
415 417 /* with left over data */
416 418 /* End of XPGv2 compliance */
417 419 #define MSG_DONTWAIT 0x80 /* Don't block for this recv */
418 420 #define MSG_NOTIFICATION 0x100 /* Notification, not data */
419 421 #define MSG_XPG4_2 0x8000 /* Private: XPG4.2 flag */
420 422
421 423 #define MSG_MAXIOVLEN 16
422 424
423 425 #ifdef _KERNEL
424 426
425 427 /*
426 428 * for kernel socket only
427 429 */
428 430 #define MSG_MBLK_QUICKRELE 0x10000000 /* free mblk chain */
429 431 /* in timely manner */
430 432 #define MSG_USERSPACE 0x20000000 /* buffer from user space */
431 433
432 434 #endif /* _KERNEL */
433 435
434 436
435 437 /* Added for XPGv2 compliance */
436 438 #define SHUT_RD 0
437 439 #define SHUT_WR 1
438 440 #define SHUT_RDWR 2
439 441
440 442 struct cmsghdr {
441 443 socklen_t cmsg_len; /* data byte count, including hdr */
442 444 int cmsg_level; /* originating protocol */
443 445 int cmsg_type; /* protocol-specific type */
444 446 };
445 447
446 448 #if defined(_XPG4_2) || defined(_KERNEL)
447 449 #if defined(__sparc)
448 450 /* To maintain backward compatibility, alignment needs to be 8 on sparc. */
449 451 #define _CMSG_HDR_ALIGNMENT 8
450 452 #else
451 453 /* for __i386 (and other future architectures) */
452 454 #define _CMSG_HDR_ALIGNMENT 4
453 455 #endif /* defined(__sparc) */
454 456 #endif /* defined(_XPG4_2) || defined(_KERNEL) */
455 457
456 458 #if defined(_XPG4_2)
457 459 /*
458 460 * The cmsg headers (and macros dealing with them) were made available as
459 461 * part of UNIX95 and hence need to be protected with a _XPG4_2 define.
460 462 */
461 463 #define _CMSG_DATA_ALIGNMENT (sizeof (int))
462 464 #define _CMSG_HDR_ALIGN(x) (((uintptr_t)(x) + _CMSG_HDR_ALIGNMENT - 1) & \
463 465 ~(_CMSG_HDR_ALIGNMENT - 1))
464 466 #define _CMSG_DATA_ALIGN(x) (((uintptr_t)(x) + _CMSG_DATA_ALIGNMENT - 1) & \
465 467 ~(_CMSG_DATA_ALIGNMENT - 1))
466 468 #define CMSG_DATA(c) \
467 469 ((unsigned char *)_CMSG_DATA_ALIGN((struct cmsghdr *)(c) + 1))
468 470
469 471 #define CMSG_FIRSTHDR(m) \
470 472 (((m)->msg_controllen < sizeof (struct cmsghdr)) ? \
471 473 (struct cmsghdr *)0 : (struct cmsghdr *)((m)->msg_control))
472 474
473 475 #define CMSG_NXTHDR(m, c) \
474 476 (((c) == 0) ? CMSG_FIRSTHDR(m) : \
475 477 ((((uintptr_t)_CMSG_HDR_ALIGN((char *)(c) + \
476 478 ((struct cmsghdr *)(c))->cmsg_len) + sizeof (struct cmsghdr)) > \
477 479 (((uintptr_t)((struct msghdr *)(m))->msg_control) + \
478 480 ((uintptr_t)((struct msghdr *)(m))->msg_controllen))) ? \
479 481 ((struct cmsghdr *)0) : \
480 482 ((struct cmsghdr *)_CMSG_HDR_ALIGN((char *)(c) + \
481 483 ((struct cmsghdr *)(c))->cmsg_len))))
482 484
483 485 /* Amount of space + padding needed for a message of length l */
484 486 #define CMSG_SPACE(l) \
485 487 ((unsigned int)_CMSG_HDR_ALIGN(sizeof (struct cmsghdr) + (l)))
486 488
487 489 /* Value to be used in cmsg_len, does not include trailing padding */
488 490 #define CMSG_LEN(l) \
489 491 ((unsigned int)_CMSG_DATA_ALIGN(sizeof (struct cmsghdr)) + (l))
490 492
491 493 #endif /* _XPG4_2 */
492 494
493 495 #ifdef _XPG4_2
494 496 #ifdef __PRAGMA_REDEFINE_EXTNAME
495 497 #pragma redefine_extname bind __xnet_bind
496 498 #pragma redefine_extname connect __xnet_connect
497 499 #pragma redefine_extname recvmsg __xnet_recvmsg
498 500 #pragma redefine_extname sendmsg __xnet_sendmsg
499 501 #pragma redefine_extname sendto __xnet_sendto
500 502 #pragma redefine_extname socket __xnet_socket
501 503 #pragma redefine_extname socketpair __xnet_socketpair
502 504 #pragma redefine_extname getsockopt __xnet_getsockopt
503 505 #else /* __PRAGMA_REDEFINE_EXTNAME */
504 506 #define bind __xnet_bind
505 507 #define connect __xnet_connect
506 508 #define recvmsg __xnet_recvmsg
507 509 #define sendmsg __xnet_sendmsg
508 510 #define sendto __xnet_sendto
509 511 #define socket __xnet_socket
510 512 #define socketpair __xnet_socketpair
511 513 #define getsockopt __xnet_getsockopt
512 514 #endif /* __PRAGMA_REDEFINE_EXTNAME */
513 515
514 516 #endif /* _XPG4_2 */
↓ open down ↓ |
483 lines elided |
↑ open up ↑ |
515 517
516 518 #if defined(_XPG4_2) && !defined(_XPG5)
517 519 #ifdef __PRAGMA_REDEFINE_EXTNAME
518 520 #pragma redefine_extname listen __xnet_listen
519 521 #else /* __PRAGMA_REDEFINE_EXTNAME */
520 522 #define listen __xnet_listen
521 523 #endif /* __PRAGMA_REDEFINE_EXTNAME */
522 524 #endif /* (_XPG4_2) && !defined(_XPG5) */
523 525
524 526 #if !defined(_KERNEL) || defined(_BOOT)
525 -#ifdef __STDC__
526 527 extern int accept(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t);
527 528 extern int accept4(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t, int);
528 529 extern int bind(int, const struct sockaddr *, socklen_t);
529 530 extern int connect(int, const struct sockaddr *, socklen_t);
530 531 extern int getpeername(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t);
531 532 extern int getsockname(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t);
532 533 extern int getsockopt(int, int, int, void *_RESTRICT_KYWD, Psocklen_t);
533 534 extern int listen(int, int); /* XXX - fixme??? where do I go */
534 535 extern int socketpair(int, int, int, int *);
535 536 extern ssize_t recv(int, void *, size_t, int);
536 537 extern ssize_t recvfrom(int, void *_RESTRICT_KYWD, size_t, int,
537 538 struct sockaddr *_RESTRICT_KYWD, Psocklen_t);
538 539 extern ssize_t recvmsg(int, struct msghdr *, int);
539 540 extern ssize_t send(int, const void *, size_t, int);
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
540 541 extern ssize_t sendmsg(int, const struct msghdr *, int);
541 542 extern ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *,
542 543 socklen_t);
543 544 extern int setsockopt(int, int, int, const void *, socklen_t);
544 545 extern int shutdown(int, int);
545 546 extern int socket(int, int, int);
546 547
547 548 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
548 549 extern int sockatmark(int);
549 550 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
550 -#else /* __STDC__ */
551 -extern int accept();
552 -extern int accept4();
553 -extern int bind();
554 -extern int connect();
555 -extern int getpeername();
556 -extern int getsockname();
557 -extern int getsockopt();
558 -extern int listen();
559 -extern int recv();
560 -extern int recvfrom();
561 -extern int send();
562 -extern int sendto();
563 -extern int setsockopt();
564 -extern int sockatmark();
565 -extern int socket();
566 -extern int recvmsg();
567 -extern int sendmsg();
568 -extern int shutdown();
569 -extern int socketpair();
570 -#endif /* __STDC__ */
571 551 #endif /* !defined(_KERNEL) || defined(_BOOT) */
572 552
573 553 #ifdef __cplusplus
574 554 }
575 555 #endif
576 556
577 557 #endif /* _SYS_SOCKET_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX