1 /* 2 * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)socket.h 8.4 (Berkeley) 2/21/94 30 * $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $ 31 */ 32 33 #ifndef _SYS_SOCKET_H_ 34 #define _SYS_SOCKET_H_ 35 36 #include <sys/cdefs.h> 37 #include <sys/_iovec.h> 38 39 #include <machine/alignbytes.h> 40 #include <machine/stdint.h> 41 42 #ifndef _SIZE_T_DECLARED 43 typedef __size_t size_t; 44 #define _SIZE_T_DECLARED 45 #endif 46 47 #ifndef _SSIZE_T_DECLARED 48 typedef __ssize_t ssize_t; 49 #define _SSIZE_T_DECLARED 50 #endif 51 52 #if __BSD_VISIBLE 53 #ifndef _GID_T_DECLARED 54 typedef __uint32_t gid_t; /* group id */ 55 #define _GID_T_DECLARED 56 #endif 57 58 #ifndef _UID_T_DECLARED 59 typedef __uint32_t uid_t; /* user id */ 60 #define _UID_T_DECLARED 61 #endif 62 63 #ifndef _OFF_T_DECLARED 64 typedef __off_t off_t; /* file offset */ 65 #define _OFF_T_DECLARED 66 #endif 67 #endif /* __BSD_VISIBLE */ 68 69 /* 70 * Definitions related to sockets: types, address families, options. 71 */ 72 73 /* 74 * Data types. 75 */ 76 #ifndef _SA_FAMILY_T_DECLARED 77 typedef __uint8_t sa_family_t; 78 #define _SA_FAMILY_T_DECLARED 79 #endif 80 81 #ifndef _SOCKLEN_T_DECLARED 82 #define _SOCKLEN_T_DECLARED 83 typedef __socklen_t socklen_t; 84 #endif 85 86 /* 87 * Types 88 */ 89 #define SOCK_STREAM 1 /* stream socket */ 90 #define SOCK_DGRAM 2 /* datagram socket */ 91 #define SOCK_RAW 3 /* raw-protocol interface */ 92 #if __BSD_VISIBLE 93 #define SOCK_RDM 4 /* reliably-delivered message */ 94 #endif 95 #define SOCK_SEQPACKET 5 /* sequenced packet stream */ 96 97 #if __BSD_VISIBLE 98 /* 99 * Creation flags, OR'ed into socket() and socketpair() type argument. 100 */ 101 #define SOCK_CLOEXEC 0x10000000 102 #define SOCK_NONBLOCK 0x20000000 103 #ifdef _KERNEL 104 /* 105 * For kern_accept(): don't inherit FNONBLOCK or FASYNC. 106 */ 107 #define SOCK_KERN_NOINHERIT 0x00100000 108 #endif 109 #endif 110 111 /* 112 * Option flags per-socket. 113 */ 114 #define SO_DEBUG 0x0001 /* turn on debugging info recording */ 115 #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ 116 #define SO_REUSEADDR 0x0004 /* allow local address reuse */ 117 #define SO_KEEPALIVE 0x0008 /* keep connections alive */ 118 #define SO_DONTROUTE 0x0010 /* just use interface addresses */ 119 #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ 120 #if __BSD_VISIBLE 121 #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ 122 #endif 123 #define SO_LINGER 0x0080 /* linger on close if data present */ 124 #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ 125 #if __BSD_VISIBLE 126 #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ 127 #define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ 128 #define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */ 129 #define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ 130 #define SO_RERROR 0x2000 /* Keep track of receive errors */ 131 #define SO_PASSCRED 0x4000 /* receive credentials */ 132 #endif 133 134 /* 135 * Additional options, not kept in so_options. 136 */ 137 #define SO_SNDBUF 0x1001 /* send buffer size */ 138 #define SO_RCVBUF 0x1002 /* receive buffer size */ 139 #define SO_SNDLOWAT 0x1003 /* send low-water mark */ 140 #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ 141 #define SO_SNDTIMEO 0x1005 /* send timeout */ 142 #define SO_RCVTIMEO 0x1006 /* receive timeout */ 143 #define SO_ERROR 0x1007 /* get error status and clear */ 144 #define SO_TYPE 0x1008 /* get socket type */ 145 #if __BSD_VISIBLE 146 /* 0x1009 reserved for FreeBSD compat */ 147 #define SO_SNDSPACE 0x100a /* get appr. send buffer free space */ 148 /* 0x1010 ~ 0x1014 reserved for FreeBSD compat */ 149 #define SO_USER_COOKIE 0x1015 /* user cookie */ 150 /* 0x1016 ~ 0x102f reserved for FreeBSD compat */ 151 #define SO_CPUHINT 0x1030 /* get socket's owner cpuid hint */ 152 #endif 153 154 /* 155 * Structure used for manipulating linger option. 156 */ 157 struct linger { 158 int l_onoff; /* option on/off */ 159 int l_linger; /* linger time */ 160 }; 161 162 #if __BSD_VISIBLE 163 struct accept_filter_arg { 164 char af_name[16]; 165 char af_arg[256-16]; 166 }; 167 #endif 168 169 /* 170 * Level number for (get/set)sockopt() to apply to socket itself. 171 */ 172 #define SOL_SOCKET 0xffff /* options for socket level */ 173 174 /* 175 * Address families. 176 */ 177 #define AF_UNSPEC 0 /* unspecified */ 178 #define AF_UNIX 1 /* local to host (pipes, portals) */ 179 #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 180 #define AF_INET6 28 /* IPv6 */ 181 #if __BSD_VISIBLE 182 #define AF_LOCAL AF_UNIX 183 #define AF_IMPLINK 3 /* arpanet imp addresses */ 184 #define AF_PUP 4 /* pup protocols: e.g. BSP */ 185 #define AF_CHAOS 5 /* mit CHAOS protocols */ 186 #define AF_NETBIOS 6 /* SMB protocols */ 187 #define AF_ISO 7 /* ISO protocols */ 188 #define AF_OSI AF_ISO 189 #define AF_ECMA 8 /* European computer manufacturers */ 190 #define AF_DATAKIT 9 /* datakit protocols */ 191 #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 192 #define AF_SNA 11 /* IBM SNA */ 193 #define AF_DECnet 12 /* DECnet */ 194 #define AF_DLI 13 /* DEC Direct data link interface */ 195 #define AF_LAT 14 /* LAT */ 196 #define AF_HYLINK 15 /* NSC Hyperchannel */ 197 #define AF_APPLETALK 16 /* Apple Talk */ 198 #define AF_ROUTE 17 /* Internal Routing Protocol */ 199 #define AF_LINK 18 /* Link layer interface */ 200 #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ 201 #define AF_COIP 20 /* connection-oriented IP, aka ST II */ 202 #define AF_CNT 21 /* Computer Network Technology */ 203 #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ 204 #define AF_IPX 23 /* Novell Internet Protocol */ 205 #define AF_SIP 24 /* Simple Internet Protocol */ 206 #define pseudo_AF_PIP 25 /* Help Identify PIP packets */ 207 #define AF_ISDN 26 /* Integrated Services Digital Network*/ 208 #define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ 209 #define pseudo_AF_KEY 27 /* Internal key-management function */ 210 #define AF_NATM 29 /* native ATM access */ 211 #define AF_ATM 30 /* ATM */ 212 #define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers 213 * in interface output routine 214 */ 215 #define AF_NETGRAPH 32 /* Netgraph sockets */ 216 #define AF_BLUETOOTH 33 /* Bluetooth */ 217 #define AF_MPLS 34 /* Multi-Protocol Label Switching */ 218 #define AF_IEEE80211 35 /* IEEE 802.11 protocol */ 219 #define AF_ARP 36 /* (rev.) addr. res. prot. (RFC 826) */ 220 221 #define AF_MAX 37 222 #endif /* __BSD_VISIBLE */ 223 224 /* 225 * Structure used by kernel to store most 226 * addresses. 227 */ 228 struct sockaddr { 229 __uint8_t sa_len; /* total length */ 230 sa_family_t sa_family; /* address family */ 231 char sa_data[14]; /* actually longer; address value */ 232 }; 233 #if __BSD_VISIBLE 234 #define SOCK_MAXADDRLEN 255 /* longest possible addresses */ 235 #endif 236 237 #ifdef _KERNEL 238 239 #ifndef _SYS_LIBKERN_H_ 240 #include <sys/libkern.h> /* for bcmp() */ 241 #endif 242 243 static __inline boolean_t sa_equal(const struct sockaddr * a1,const struct sockaddr * a2)244 sa_equal(const struct sockaddr *a1, const struct sockaddr *a2) 245 { 246 return (bcmp(a1, a2, a1->sa_len) == 0); 247 } 248 #endif 249 250 #if __BSD_VISIBLE 251 /* 252 * Structure used by kernel to pass protocol 253 * information in raw sockets. 254 */ 255 struct sockproto { 256 __uint16_t sp_family; /* address family */ 257 __uint16_t sp_protocol; /* protocol */ 258 }; 259 #endif /* __BSD_VISIBLE */ 260 261 /* 262 * RFC 2553: protocol-independent placeholder for socket addresses 263 */ 264 #define _SS_MAXSIZE 128 265 #define _SS_ALIGNSIZE (sizeof(__int64_t)) 266 #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - sizeof(sa_family_t)) 267 #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - sizeof(sa_family_t) - \ 268 _SS_PAD1SIZE - _SS_ALIGNSIZE) 269 270 struct sockaddr_storage { 271 __uint8_t ss_len; /* address length */ 272 sa_family_t ss_family; /* address family */ 273 char __ss_pad1[_SS_PAD1SIZE]; 274 __int64_t __ss_align; /* force desired structure storage alignment */ 275 char __ss_pad2[_SS_PAD2SIZE]; 276 }; 277 278 #if __BSD_VISIBLE 279 /* 280 * Protocol families, same as address families for now. 281 */ 282 #define PF_UNSPEC AF_UNSPEC 283 #define PF_LOCAL AF_LOCAL 284 #define PF_UNIX PF_LOCAL /* backward compatibility */ 285 #define PF_INET AF_INET 286 #define PF_IMPLINK AF_IMPLINK 287 #define PF_PUP AF_PUP 288 #define PF_CHAOS AF_CHAOS 289 #define PF_NETBIOS AF_NETBIOS 290 #define PF_ISO AF_ISO 291 #define PF_OSI AF_ISO 292 #define PF_ECMA AF_ECMA 293 #define PF_DATAKIT AF_DATAKIT 294 #define PF_CCITT AF_CCITT 295 #define PF_SNA AF_SNA 296 #define PF_DECnet AF_DECnet 297 #define PF_DLI AF_DLI 298 #define PF_LAT AF_LAT 299 #define PF_HYLINK AF_HYLINK 300 #define PF_APPLETALK AF_APPLETALK 301 #define PF_ROUTE AF_ROUTE 302 #define PF_LINK AF_LINK 303 #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ 304 #define PF_COIP AF_COIP 305 #define PF_CNT AF_CNT 306 #define PF_SIP AF_SIP 307 #define PF_IPX AF_IPX /* same format as AF_NS */ 308 #define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ 309 #define PF_PIP pseudo_AF_PIP 310 #define PF_ISDN AF_ISDN 311 #define PF_KEY pseudo_AF_KEY 312 #define PF_INET6 AF_INET6 313 #define PF_NATM AF_NATM 314 #define PF_ATM AF_ATM 315 #define PF_NETGRAPH AF_NETGRAPH 316 #define PF_BLUETOOTH AF_BLUETOOTH 317 #define PF_ARP AF_ARP 318 319 #define PF_MAX AF_MAX 320 321 /* 322 * Definitions for network related sysctl, CTL_NET. 323 * 324 * Second level is protocol family. 325 * Third level is protocol number. 326 * 327 * Further levels are defined by the individual families below. 328 */ 329 #define NET_MAXID AF_MAX 330 331 #define CTL_NET_NAMES { \ 332 { 0, 0 }, \ 333 { "unix", CTLTYPE_NODE }, \ 334 { "inet", CTLTYPE_NODE }, \ 335 { "implink", CTLTYPE_NODE }, \ 336 { "pup", CTLTYPE_NODE }, \ 337 { "chaos", CTLTYPE_NODE }, \ 338 { "xerox_ns", CTLTYPE_NODE }, \ 339 { "iso", CTLTYPE_NODE }, \ 340 { "emca", CTLTYPE_NODE }, \ 341 { "datakit", CTLTYPE_NODE }, \ 342 { "ccitt", CTLTYPE_NODE }, \ 343 { "ibm_sna", CTLTYPE_NODE }, \ 344 { "decnet", CTLTYPE_NODE }, \ 345 { "dec_dli", CTLTYPE_NODE }, \ 346 { "lat", CTLTYPE_NODE }, \ 347 { "hylink", CTLTYPE_NODE }, \ 348 { "appletalk", CTLTYPE_NODE }, \ 349 { "route", CTLTYPE_NODE }, \ 350 { "link_layer", CTLTYPE_NODE }, \ 351 { "xtp", CTLTYPE_NODE }, \ 352 { "coip", CTLTYPE_NODE }, \ 353 { "cnt", CTLTYPE_NODE }, \ 354 { "rtip", CTLTYPE_NODE }, \ 355 { "ipx", CTLTYPE_NODE }, \ 356 { "sip", CTLTYPE_NODE }, \ 357 { "pip", CTLTYPE_NODE }, \ 358 { "isdn", CTLTYPE_NODE }, \ 359 { "key", CTLTYPE_NODE }, \ 360 { "inet6", CTLTYPE_NODE }, \ 361 { "natm", CTLTYPE_NODE }, \ 362 { "atm", CTLTYPE_NODE }, \ 363 { "hdrcomplete", CTLTYPE_NODE }, \ 364 { "netgraph", CTLTYPE_NODE }, \ 365 { "bluetooth", CTLTYPE_NODE}, \ 366 } 367 368 /* 369 * PF_ROUTE - Routing table 370 * 371 * Three additional levels are defined: 372 * Fourth: address family, 0 is wildcard 373 * Fifth: type of info, defined below 374 * Sixth: flag(s) to mask with for NET_RT_FLAGS 375 */ 376 #define NET_RT_DUMP 1 /* dump; may limit to a.f. */ 377 #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ 378 #define NET_RT_IFLIST 3 /* survey interface list */ 379 #define NET_RT_MAXID 4 380 381 #define CTL_NET_RT_NAMES { \ 382 { 0, 0 }, \ 383 { "dump", CTLTYPE_STRUCT }, \ 384 { "flags", CTLTYPE_STRUCT }, \ 385 { "iflist", CTLTYPE_STRUCT }, \ 386 } 387 #endif /* __BSD_VISIBLE */ 388 389 /* 390 * Maximum queue length specifiable by listen. 391 */ 392 #define SOMAXCONN 128 393 394 #if __BSD_VISIBLE 395 /* 396 * Maximum setsockopt buffer size 397 */ 398 #define SOMAXOPT_SIZE 65536 399 #define SOMAXOPT_SIZE0 (32 * 1024 * 1024) /* for root getsockopt */ 400 #endif 401 402 /* 403 * Message header for recvmsg and sendmsg calls. 404 * Used value-result for recvmsg, value only for sendmsg. 405 */ 406 struct msghdr { 407 void *msg_name; /* optional address */ 408 socklen_t msg_namelen; /* size of address */ 409 struct iovec *msg_iov; /* scatter/gather array */ 410 int msg_iovlen; /* # elements in msg_iov */ 411 void *msg_control; /* ancillary data, see below */ 412 socklen_t msg_controllen; /* ancillary data buffer len */ 413 int msg_flags; /* flags on received message */ 414 }; 415 416 #define MSG_OOB 0x00000001 /* process out-of-band data */ 417 #define MSG_PEEK 0x00000002 /* peek at incoming message */ 418 #define MSG_DONTROUTE 0x00000004 /* send without using routing tables */ 419 #define MSG_EOR 0x00000008 /* data completes record */ 420 #define MSG_TRUNC 0x00000010 /* data discarded before delivery */ 421 #define MSG_CTRUNC 0x00000020 /* control data lost before delivery */ 422 #define MSG_WAITALL 0x00000040 /* wait for full request or error */ 423 #if __BSD_VISIBLE 424 #define MSG_DONTWAIT 0x00000080 /* this message should be nonblocking */ 425 #define MSG_EOF 0x00000100 /* data completes connection */ 426 #define MSG_UNUSED09 0x00000200 /* was: notification message (SCTP) */ 427 #endif 428 #define MSG_NOSIGNAL 0x00000400 /* No SIGPIPE to unconnected socket stream */ 429 #if __BSD_VISIBLE 430 #define MSG_SYNC 0x00000800 /* No asynchronized pru_send */ 431 #define MSG_CMSG_CLOEXEC 0x00001000 /* make received fds close-on-exec */ 432 /* 0x2000 unused */ 433 /* 0x4000 unused */ 434 /* 0x8000 unused */ 435 /* 436 * These override FIONBIO. MSG_FNONBLOCKING is functionally equivalent to 437 * MSG_DONTWAIT. 438 */ 439 #define MSG_FBLOCKING 0x00010000 /* force blocking operation */ 440 #define MSG_FNONBLOCKING 0x00020000 /* force non-blocking operation */ 441 #define MSG_FMASK 0xFFFF0000 /* force mask */ 442 #endif 443 444 /* 445 * Header for ancillary data objects in msg_control buffer. 446 * Used for additional information with/about a datagram 447 * not expressible by flags. The format is a sequence 448 * of message elements headed by cmsghdr structures. 449 */ 450 struct cmsghdr { 451 socklen_t cmsg_len; /* data byte count, including hdr */ 452 int cmsg_level; /* originating protocol */ 453 int cmsg_type; /* protocol-specific type */ 454 /* followed by u_char cmsg_data[]; */ 455 }; 456 457 #if __BSD_VISIBLE 458 /* 459 * While we may have more groups than this, the cmsgcred struct must 460 * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow 461 * this. 462 */ 463 #define CMGROUP_MAX 16 464 465 /* 466 * Credentials structure, used to verify the identity of a peer 467 * process that has sent us a message. This is allocated by the 468 * peer process but filled in by the kernel. This prevents the 469 * peer from lying about its identity. (Note that cmcred_groups[0] 470 * is the effective GID.) 471 */ 472 struct cmsgcred { 473 __pid_t cmcred_pid; /* PID of sending process */ 474 uid_t cmcred_uid; /* real UID of sending process */ 475 uid_t cmcred_euid; /* effective UID of sending process */ 476 gid_t cmcred_gid; /* real GID of sending process */ 477 short cmcred_ngroups; /* number or groups */ 478 gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ 479 }; 480 481 /* Alignment requirement for CMSG struct manipulation */ 482 #define _CMSG_ALIGN(n) (((n) + __ALIGNBYTES) & ~__ALIGNBYTES) 483 484 #ifdef _KERNEL 485 #define CMSG_ALIGN(n) _CMSG_ALIGN(n) 486 #endif 487 #endif /* __BSD_VISIBLE */ 488 489 /* given pointer to struct cmsghdr, return pointer to data */ 490 #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ 491 _CMSG_ALIGN(sizeof(struct cmsghdr))) 492 493 /* given pointer to struct cmsghdr, return pointer to next cmsghdr */ 494 #define CMSG_NXTHDR(mhdr, cmsg) \ 495 (((char *)(cmsg) + _CMSG_ALIGN((cmsg)->cmsg_len) + \ 496 _CMSG_ALIGN(sizeof(struct cmsghdr)) > \ 497 (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ 498 NULL : \ 499 (struct cmsghdr *)((char *)(cmsg) + _CMSG_ALIGN((cmsg)->cmsg_len))) 500 501 /* 502 * RFC 2292 requires to check msg_controllen, in case that the kernel returns 503 * an empty list for some reasons. 504 */ 505 #define CMSG_FIRSTHDR(mhdr) \ 506 ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ 507 (struct cmsghdr *)(mhdr)->msg_control : \ 508 NULL) 509 510 #if __BSD_VISIBLE 511 /* RFC 2292 additions */ 512 513 #define CMSG_SPACE(l) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(l)) 514 #define CMSG_LEN(l) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (l)) 515 #endif 516 517 /* "Socket"-level control message types: */ 518 #define SCM_RIGHTS 0x01 /* access rights (array of int) */ 519 #if __BSD_VISIBLE 520 #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ 521 #define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ 522 #endif 523 524 /* 525 * howto arguments for shutdown(2), specified by Posix.1g. 526 */ 527 #define SHUT_RD 0 /* shut down the reading side */ 528 #define SHUT_WR 1 /* shut down the writing side */ 529 #define SHUT_RDWR 2 /* shut down both sides */ 530 531 #if __BSD_VISIBLE 532 /* 533 * sendfile(2) header/trailer struct 534 */ 535 struct sf_hdtr { 536 struct iovec *headers; /* pointer to an array of header struct iovec's */ 537 int hdr_cnt; /* number of header iovec's */ 538 struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ 539 int trl_cnt; /* number of trailer iovec's */ 540 }; 541 #endif 542 543 #if !defined(_KERNEL) || defined(_KERNEL_VIRTUAL) 544 545 __BEGIN_DECLS 546 int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); 547 int bind(int, const struct sockaddr *, socklen_t); 548 int connect(int, const struct sockaddr *, socklen_t); 549 int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict); 550 int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict); 551 int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); 552 int listen(int, int); 553 ssize_t recv(int, void *, size_t, int); 554 ssize_t recvfrom(int, void * __restrict, size_t, int, 555 struct sockaddr * __restrict, socklen_t * __restrict); 556 ssize_t recvmsg(int, struct msghdr *, int); 557 ssize_t send(int, const void *, size_t, int); 558 ssize_t sendmsg(int, const struct msghdr *, int); 559 ssize_t sendto(int, const void *, 560 size_t, int, const struct sockaddr *, socklen_t); 561 int setsockopt(int, int, int, const void *, socklen_t); 562 int shutdown(int, int); 563 #if __POSIX_VISIBLE >= 200112 564 int sockatmark(int); 565 #endif 566 int socket(int, int, int); 567 int socketpair(int, int, int, int *); 568 569 #if __BSD_VISIBLE 570 int accept4(int, struct sockaddr *, socklen_t *, int); 571 int extaccept(int, int, struct sockaddr *, socklen_t *); 572 int extconnect(int, int, struct sockaddr *, socklen_t); 573 void pfctlinput(int, struct sockaddr *); 574 int sendfile(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int); 575 #endif 576 __END_DECLS 577 578 #endif /* !_KERNEL || _KERNEL_VIRTUAL */ 579 580 #endif /* !_SYS_SOCKET_H_ */ 581