17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5e4f35dbaSgt * Common Development and Distribution License (the "License"). 6e4f35dbaSgt * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22e11c3f44Smeem * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 317c478bd9Sstevel@tonic-gate * The Regents of the University of California 327c478bd9Sstevel@tonic-gate * All Rights Reserved 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 357c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 367c478bd9Sstevel@tonic-gate * contributors. 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifndef _SYS_SOCKET_H 407c478bd9Sstevel@tonic-gate #define _SYS_SOCKET_H 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #include <sys/types.h> 437c478bd9Sstevel@tonic-gate #include <sys/uio.h> 447c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 457c478bd9Sstevel@tonic-gate #include <sys/socket_impl.h> 467c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 477c478bd9Sstevel@tonic-gate #ifndef _KERNEL 487c478bd9Sstevel@tonic-gate #include <sys/netconfig.h> 497c478bd9Sstevel@tonic-gate #endif /* !_KERNEL */ 507c478bd9Sstevel@tonic-gate #include <netinet/in.h> 517c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #ifdef __cplusplus 547c478bd9Sstevel@tonic-gate extern "C" { 557c478bd9Sstevel@tonic-gate #endif 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate #ifndef _SOCKLEN_T 587c478bd9Sstevel@tonic-gate #define _SOCKLEN_T 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate /* 617c478bd9Sstevel@tonic-gate * The socklen definitions are reproduced in netinet/in.h for the inet6_ 627c478bd9Sstevel@tonic-gate * functions. Exposing all of sys/socket.h via netinet/in.h breaks existing 637c478bd9Sstevel@tonic-gate * applications and is not required by austin. 647c478bd9Sstevel@tonic-gate */ 657c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) 667c478bd9Sstevel@tonic-gate typedef size_t socklen_t; 677c478bd9Sstevel@tonic-gate #else 687c478bd9Sstevel@tonic-gate typedef uint32_t socklen_t; 697c478bd9Sstevel@tonic-gate #endif /* defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) || defined(_BOOT) 727c478bd9Sstevel@tonic-gate typedef socklen_t *_RESTRICT_KYWD Psocklen_t; 737c478bd9Sstevel@tonic-gate #else 747c478bd9Sstevel@tonic-gate typedef void *_RESTRICT_KYWD Psocklen_t; 757c478bd9Sstevel@tonic-gate #endif /* defined(_XPG4_2) || defined(_BOOT) */ 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #endif /* _SOCKLEN_T */ 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* 807c478bd9Sstevel@tonic-gate * Definitions related to sockets: types, address families, options. 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 837c478bd9Sstevel@tonic-gate #ifndef NC_TPI_CLTS 847c478bd9Sstevel@tonic-gate #define NC_TPI_CLTS 1 /* must agree with netconfig.h */ 857c478bd9Sstevel@tonic-gate #define NC_TPI_COTS 2 /* must agree with netconfig.h */ 867c478bd9Sstevel@tonic-gate #define NC_TPI_COTS_ORD 3 /* must agree with netconfig.h */ 877c478bd9Sstevel@tonic-gate #define NC_TPI_RAW 4 /* must agree with netconfig.h */ 887c478bd9Sstevel@tonic-gate #endif /* !NC_TPI_CLTS */ 897c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * Types 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 957c478bd9Sstevel@tonic-gate #define SOCK_STREAM NC_TPI_COTS /* stream socket */ 967c478bd9Sstevel@tonic-gate #define SOCK_DGRAM NC_TPI_CLTS /* datagram socket */ 977c478bd9Sstevel@tonic-gate #define SOCK_RAW NC_TPI_RAW /* raw-protocol interface */ 987c478bd9Sstevel@tonic-gate #else 997c478bd9Sstevel@tonic-gate #define SOCK_STREAM 2 /* stream socket */ 1007c478bd9Sstevel@tonic-gate #define SOCK_DGRAM 1 /* datagram socket */ 1017c478bd9Sstevel@tonic-gate #define SOCK_RAW 4 /* raw-protocol interface */ 1027c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 1037c478bd9Sstevel@tonic-gate #define SOCK_RDM 5 /* reliably-delivered message */ 1047c478bd9Sstevel@tonic-gate #define SOCK_SEQPACKET 6 /* sequenced packet stream */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * Option flags per-socket. 1087c478bd9Sstevel@tonic-gate */ 1097c478bd9Sstevel@tonic-gate #define SO_DEBUG 0x0001 /* turn on debugging info recording */ 1107c478bd9Sstevel@tonic-gate #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ 1117c478bd9Sstevel@tonic-gate #define SO_REUSEADDR 0x0004 /* allow local address reuse */ 1127c478bd9Sstevel@tonic-gate #define SO_KEEPALIVE 0x0008 /* keep connections alive */ 1137c478bd9Sstevel@tonic-gate #define SO_DONTROUTE 0x0010 /* just use interface addresses */ 1147c478bd9Sstevel@tonic-gate #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ 1157c478bd9Sstevel@tonic-gate #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ 1167c478bd9Sstevel@tonic-gate #define SO_LINGER 0x0080 /* linger on close if data present */ 1177c478bd9Sstevel@tonic-gate #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ 1187c478bd9Sstevel@tonic-gate #define SO_DGRAM_ERRIND 0x0200 /* Application wants delayed error */ 1197c478bd9Sstevel@tonic-gate #define SO_RECVUCRED 0x0400 /* Application wants ucred of sender */ 1207c478bd9Sstevel@tonic-gate 1210a0e9771SDarren Reed /* 1220a0e9771SDarren Reed * Socket options are passed using a signed integer, but it is also rare 1230a0e9771SDarren Reed * for more than one to ever be passed at the same time with setsockopt 1240a0e9771SDarren Reed * and only one at a time can be retrieved with getsockopt. 1250a0e9771SDarren Reed * 1260a0e9771SDarren Reed * Since the lower numbers cannot be renumbered for compatibility reasons, 1270a0e9771SDarren Reed * it would seem that we need to start a new number space (0x40000000 - 1280a0e9771SDarren Reed * 0x7fffffff) for those that don't need to be stored as a bit flag 1290a0e9771SDarren Reed * somewhere. This limits the flag options to 30 but that seems to be 1300a0e9771SDarren Reed * plenty, anyway. 0x40000000 is reserved for future use. 1310a0e9771SDarren Reed */ 1320a0e9771SDarren Reed #define SO_ATTACH_FILTER 0x40000001 1330a0e9771SDarren Reed #define SO_DETACH_FILTER 0x40000002 1340a0e9771SDarren Reed 1357c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1367c478bd9Sstevel@tonic-gate #define SO_SND_COPYAVOID 0x0800 /* Internal: use zero-copy */ 1370f1702c5SYu Xiangning #define SO_SND_BUFINFO 0x1000 /* Internal: get buffer info */ 1380f1702c5SYu Xiangning /* when doing zero-copy */ 1390f1702c5SYu Xiangning 1400f1702c5SYu Xiangning struct so_snd_bufinfo { 1410f1702c5SYu Xiangning ushort_t sbi_wroff; /* Write offset */ 1420f1702c5SYu Xiangning ssize_t sbi_maxblk; /* Max size of a single mblk */ 1430f1702c5SYu Xiangning ssize_t sbi_maxpsz; /* Max total size of a mblk chain */ 1440f1702c5SYu Xiangning ushort_t sbi_tail; /* Extra space available at the end */ 1450f1702c5SYu Xiangning }; 1467c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* 1497c478bd9Sstevel@tonic-gate * N.B.: The following definition is present only for compatibility 1507c478bd9Sstevel@tonic-gate * with release 3.0. It will disappear in later releases. 1517c478bd9Sstevel@tonic-gate */ 1527c478bd9Sstevel@tonic-gate #define SO_DONTLINGER (~SO_LINGER) /* ~SO_LINGER */ 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate /* 1557c478bd9Sstevel@tonic-gate * Additional options, not kept in so_options. 1567c478bd9Sstevel@tonic-gate */ 1577c478bd9Sstevel@tonic-gate #define SO_SNDBUF 0x1001 /* send buffer size */ 1587c478bd9Sstevel@tonic-gate #define SO_RCVBUF 0x1002 /* receive buffer size */ 1597c478bd9Sstevel@tonic-gate #define SO_SNDLOWAT 0x1003 /* send low-water mark */ 1607c478bd9Sstevel@tonic-gate #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ 1617c478bd9Sstevel@tonic-gate #define SO_SNDTIMEO 0x1005 /* send timeout */ 1627c478bd9Sstevel@tonic-gate #define SO_RCVTIMEO 0x1006 /* receive timeout */ 1637c478bd9Sstevel@tonic-gate #define SO_ERROR 0x1007 /* get error status and clear */ 1647c478bd9Sstevel@tonic-gate #define SO_TYPE 0x1008 /* get socket type */ 1657c478bd9Sstevel@tonic-gate #define SO_PROTOTYPE 0x1009 /* get/set protocol type */ 16645916cd2Sjpk #define SO_ANON_MLP 0x100a /* create MLP on anonymous bind */ 16745916cd2Sjpk #define SO_MAC_EXEMPT 0x100b /* allow dominated unlabeled peers */ 16888cda078Skcpoon #define SO_DOMAIN 0x100c /* get socket domain */ 1690f1702c5SYu Xiangning #define SO_RCVPSH 0x100d /* receive interval to push data */ 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate /* "Socket"-level control message types: */ 1727c478bd9Sstevel@tonic-gate #define SCM_RIGHTS 0x1010 /* access rights (array of int) */ 1737c478bd9Sstevel@tonic-gate #define SO_SECATTR 0x1011 /* socket's security attributes */ 1747c478bd9Sstevel@tonic-gate #define SCM_UCRED 0x1012 /* sender's ucred */ 175e4f35dbaSgt #define SO_TIMESTAMP 0x1013 /* socket-level timestamp option */ 176e4f35dbaSgt #define SCM_TIMESTAMP SO_TIMESTAMP /* socket control message timestamp */ 1775d0bc3edSsommerfe #define SO_ALLZONES 0x1014 /* bind in all zones */ 178ae347574Skcpoon #define SO_EXCLBIND 0x1015 /* exclusive binding */ 179*5d3b8cb7SBill Sommerfeld #define SO_MAC_IMPLICIT 0x1016 /* hide mac labels on wire */ 1805d0bc3edSsommerfe 1817c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1827c478bd9Sstevel@tonic-gate #define SO_SRCADDR 0x2001 /* Internal: AF_UNIX source address */ 1837c478bd9Sstevel@tonic-gate #define SO_FILEP 0x2002 /* Internal: AF_UNIX file pointer */ 1847c478bd9Sstevel@tonic-gate #define SO_UNIX_CLOSE 0x2003 /* Internal: AF_UNIX peer closed */ 1857c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1887c478bd9Sstevel@tonic-gate /* 1897c478bd9Sstevel@tonic-gate * new socket open flags to identify socket and acceptor streams 1907c478bd9Sstevel@tonic-gate */ 1917c478bd9Sstevel@tonic-gate #define SO_ACCEPTOR 0x20000 /* acceptor socket */ 1927c478bd9Sstevel@tonic-gate #define SO_SOCKSTR 0x40000 /* normal socket stream */ 1930f1702c5SYu Xiangning #define SO_FALLBACK 0x80000 /* fallback to TPI socket */ 1940f1702c5SYu Xiangning 1950f1702c5SYu Xiangning /* 1960f1702c5SYu Xiangning * Flags for socket_create() and socket_newconn() 1970f1702c5SYu Xiangning */ 1980f1702c5SYu Xiangning #define SOCKET_SLEEP KM_SLEEP 1990f1702c5SYu Xiangning #define SOCKET_NOSLEEP KM_NOSLEEP 2000f1702c5SYu Xiangning 2010f1702c5SYu Xiangning 2020f1702c5SYu Xiangning /* 2030f1702c5SYu Xiangning * flags used by sockfs when falling back to tpi socket 2040f1702c5SYu Xiangning */ 2050f1702c5SYu Xiangning #define SO_FB_START 0x1 2060f1702c5SYu Xiangning #define SO_FB_FINISH 0x2 2070f1702c5SYu Xiangning 2087c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * Structure used for manipulating linger option. 2127c478bd9Sstevel@tonic-gate */ 2137c478bd9Sstevel@tonic-gate struct linger { 2147c478bd9Sstevel@tonic-gate int l_onoff; /* option on/off */ 2157c478bd9Sstevel@tonic-gate int l_linger; /* linger time */ 2167c478bd9Sstevel@tonic-gate }; 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate /* 219e11c3f44Smeem * Levels for (get/set)sockopt() that don't apply to a specific protocol. 2207c478bd9Sstevel@tonic-gate */ 2217c478bd9Sstevel@tonic-gate #define SOL_SOCKET 0xffff /* options for socket level */ 222e11c3f44Smeem #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 223e11c3f44Smeem #define SOL_ROUTE 0xfffe /* options for routing socket level */ 224e11c3f44Smeem #endif 2250a0e9771SDarren Reed #define SOL_PACKET 0xfffd /* options for packet level */ 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate /* 2287c478bd9Sstevel@tonic-gate * Address families. 22910e6dadfSbrendan * 23010e6dadfSbrendan * Some of these constant names are copied for the DTrace IP provider in 23110e6dadfSbrendan * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept 23210e6dadfSbrendan * in sync. 2337c478bd9Sstevel@tonic-gate */ 2347c478bd9Sstevel@tonic-gate #define AF_UNSPEC 0 /* unspecified */ 2357c478bd9Sstevel@tonic-gate #define AF_UNIX 1 /* local to host (pipes, portals) */ 236406d6273SPalle Lyckegaard #define AF_LOCAL AF_UNIX /* Synonym for AF_UNIX */ 237406d6273SPalle Lyckegaard #define AF_FILE AF_UNIX /* Synonym for AF_UNIX */ 2387c478bd9Sstevel@tonic-gate #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ 2397c478bd9Sstevel@tonic-gate #define AF_IMPLINK 3 /* arpanet imp addresses */ 2407c478bd9Sstevel@tonic-gate #define AF_PUP 4 /* pup protocols: e.g. BSP */ 2417c478bd9Sstevel@tonic-gate #define AF_CHAOS 5 /* mit CHAOS protocols */ 2427c478bd9Sstevel@tonic-gate #define AF_NS 6 /* XEROX NS protocols */ 2437c478bd9Sstevel@tonic-gate #define AF_NBS 7 /* nbs protocols */ 2447c478bd9Sstevel@tonic-gate #define AF_ECMA 8 /* european computer manufacturers */ 2457c478bd9Sstevel@tonic-gate #define AF_DATAKIT 9 /* datakit protocols */ 2467c478bd9Sstevel@tonic-gate #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ 2477c478bd9Sstevel@tonic-gate #define AF_SNA 11 /* IBM SNA */ 2487c478bd9Sstevel@tonic-gate #define AF_DECnet 12 /* DECnet */ 2497c478bd9Sstevel@tonic-gate #define AF_DLI 13 /* Direct data link interface */ 2507c478bd9Sstevel@tonic-gate #define AF_LAT 14 /* LAT */ 2517c478bd9Sstevel@tonic-gate #define AF_HYLINK 15 /* NSC Hyperchannel */ 2527c478bd9Sstevel@tonic-gate #define AF_APPLETALK 16 /* Apple Talk */ 2537c478bd9Sstevel@tonic-gate #define AF_NIT 17 /* Network Interface Tap */ 2547c478bd9Sstevel@tonic-gate #define AF_802 18 /* IEEE 802.2, also ISO 8802 */ 2557c478bd9Sstevel@tonic-gate #define AF_OSI 19 /* umbrella for all families used */ 2567c478bd9Sstevel@tonic-gate #define AF_X25 20 /* CCITT X.25 in particular */ 2577c478bd9Sstevel@tonic-gate #define AF_OSINET 21 /* AFI = 47, IDI = 4 */ 2587c478bd9Sstevel@tonic-gate #define AF_GOSIP 22 /* U.S. Government OSI */ 2597c478bd9Sstevel@tonic-gate #define AF_IPX 23 /* Novell Internet Protocol */ 2607c478bd9Sstevel@tonic-gate #define AF_ROUTE 24 /* Internal Routing Protocol */ 2617c478bd9Sstevel@tonic-gate #define AF_LINK 25 /* Link-layer interface */ 2627c478bd9Sstevel@tonic-gate #define AF_INET6 26 /* Internet Protocol, Version 6 */ 2637c478bd9Sstevel@tonic-gate #define AF_KEY 27 /* Security Association DB socket */ 2647c478bd9Sstevel@tonic-gate #define AF_NCA 28 /* NCA socket */ 2657c478bd9Sstevel@tonic-gate #define AF_POLICY 29 /* Security Policy DB socket */ 266b86efd96Sagiri #define AF_INET_OFFLOAD 30 /* Sun private; do not use */ 2674eaa4710SRishi Srivatsavai #define AF_TRILL 31 /* TRILL interface */ 2680a0e9771SDarren Reed #define AF_PACKET 32 /* PF_PACKET Linux socket interface */ 2697c478bd9Sstevel@tonic-gate 2700a0e9771SDarren Reed #define AF_MAX 32 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate /* 2737c478bd9Sstevel@tonic-gate * Protocol families, same as address families for now. 2747c478bd9Sstevel@tonic-gate */ 2757c478bd9Sstevel@tonic-gate #define PF_UNSPEC AF_UNSPEC 2767c478bd9Sstevel@tonic-gate #define PF_UNIX AF_UNIX 277406d6273SPalle Lyckegaard #define PF_LOCAL PF_UNIX 278406d6273SPalle Lyckegaard #define PF_FILE PF_UNIX 2797c478bd9Sstevel@tonic-gate #define PF_INET AF_INET 2807c478bd9Sstevel@tonic-gate #define PF_IMPLINK AF_IMPLINK 2817c478bd9Sstevel@tonic-gate #define PF_PUP AF_PUP 2827c478bd9Sstevel@tonic-gate #define PF_CHAOS AF_CHAOS 2837c478bd9Sstevel@tonic-gate #define PF_NS AF_NS 2847c478bd9Sstevel@tonic-gate #define PF_NBS AF_NBS 2857c478bd9Sstevel@tonic-gate #define PF_ECMA AF_ECMA 2867c478bd9Sstevel@tonic-gate #define PF_DATAKIT AF_DATAKIT 2877c478bd9Sstevel@tonic-gate #define PF_CCITT AF_CCITT 2887c478bd9Sstevel@tonic-gate #define PF_SNA AF_SNA 2897c478bd9Sstevel@tonic-gate #define PF_DECnet AF_DECnet 2907c478bd9Sstevel@tonic-gate #define PF_DLI AF_DLI 2917c478bd9Sstevel@tonic-gate #define PF_LAT AF_LAT 2927c478bd9Sstevel@tonic-gate #define PF_HYLINK AF_HYLINK 2937c478bd9Sstevel@tonic-gate #define PF_APPLETALK AF_APPLETALK 2947c478bd9Sstevel@tonic-gate #define PF_NIT AF_NIT 2957c478bd9Sstevel@tonic-gate #define PF_802 AF_802 2967c478bd9Sstevel@tonic-gate #define PF_OSI AF_OSI 2977c478bd9Sstevel@tonic-gate #define PF_X25 AF_X25 2987c478bd9Sstevel@tonic-gate #define PF_OSINET AF_OSINET 2997c478bd9Sstevel@tonic-gate #define PF_GOSIP AF_GOSIP 3007c478bd9Sstevel@tonic-gate #define PF_IPX AF_IPX 3017c478bd9Sstevel@tonic-gate #define PF_ROUTE AF_ROUTE 3027c478bd9Sstevel@tonic-gate #define PF_LINK AF_LINK 3037c478bd9Sstevel@tonic-gate #define PF_INET6 AF_INET6 3047c478bd9Sstevel@tonic-gate #define PF_KEY AF_KEY 3057c478bd9Sstevel@tonic-gate #define PF_NCA AF_NCA 3067c478bd9Sstevel@tonic-gate #define PF_POLICY AF_POLICY 307b86efd96Sagiri #define PF_INET_OFFLOAD AF_INET_OFFLOAD /* Sun private; do not use */ 3084eaa4710SRishi Srivatsavai #define PF_TRILL AF_TRILL 3090a0e9771SDarren Reed #define PF_PACKET AF_PACKET 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate #define PF_MAX AF_MAX 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate /* 3147c478bd9Sstevel@tonic-gate * Maximum queue length specifiable by listen. 3157c478bd9Sstevel@tonic-gate */ 3167c478bd9Sstevel@tonic-gate #define SOMAXCONN 128 3177c478bd9Sstevel@tonic-gate 3187c478bd9Sstevel@tonic-gate /* 3197c478bd9Sstevel@tonic-gate * Message header for recvmsg and sendmsg calls. 3207c478bd9Sstevel@tonic-gate */ 3217c478bd9Sstevel@tonic-gate struct msghdr { 3227c478bd9Sstevel@tonic-gate void *msg_name; /* optional address */ 3237c478bd9Sstevel@tonic-gate socklen_t msg_namelen; /* size of address */ 3247c478bd9Sstevel@tonic-gate struct iovec *msg_iov; /* scatter/gather array */ 3257c478bd9Sstevel@tonic-gate int msg_iovlen; /* # elements in msg_iov */ 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) || defined(_KERNEL) 3287c478bd9Sstevel@tonic-gate void *msg_control; /* ancillary data */ 3297c478bd9Sstevel@tonic-gate socklen_t msg_controllen; /* ancillary data buffer len */ 3307c478bd9Sstevel@tonic-gate int msg_flags; /* flags on received message */ 3317c478bd9Sstevel@tonic-gate #else 3327c478bd9Sstevel@tonic-gate caddr_t msg_accrights; /* access rights sent/received */ 3337c478bd9Sstevel@tonic-gate int msg_accrightslen; 3347c478bd9Sstevel@tonic-gate #endif /* defined(_XPG4_2) || defined(_KERNEL) */ 3357c478bd9Sstevel@tonic-gate }; 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate /* 3407c478bd9Sstevel@tonic-gate * N.B.: we assume that omsghdr and nmsghdr are isomorphic, with 3417c478bd9Sstevel@tonic-gate * the sole exception that nmsghdr has the additional msg_flags 3427c478bd9Sstevel@tonic-gate * field at the end. 3437c478bd9Sstevel@tonic-gate */ 3447c478bd9Sstevel@tonic-gate struct omsghdr { 3457c478bd9Sstevel@tonic-gate void *msg_name; /* optional address */ 3467c478bd9Sstevel@tonic-gate socklen_t msg_namelen; /* size of address */ 3477c478bd9Sstevel@tonic-gate struct iovec *msg_iov; /* scatter/gather array */ 3487c478bd9Sstevel@tonic-gate int msg_iovlen; /* # elements in msg_iov */ 3497c478bd9Sstevel@tonic-gate caddr_t msg_accrights; /* access rights sent/received */ 3507c478bd9Sstevel@tonic-gate int msg_accrightslen; 3517c478bd9Sstevel@tonic-gate }; 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate #define nmsghdr msghdr 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate struct omsghdr32 { 3587c478bd9Sstevel@tonic-gate caddr32_t msg_name; /* optional address */ 3597c478bd9Sstevel@tonic-gate uint32_t msg_namelen; /* size of address */ 3607c478bd9Sstevel@tonic-gate caddr32_t msg_iov; /* scatter/gather array */ 3617c478bd9Sstevel@tonic-gate int32_t msg_iovlen; /* # elements in msg_iov */ 3627c478bd9Sstevel@tonic-gate caddr32_t msg_accrights; /* access rights sent/received */ 3637c478bd9Sstevel@tonic-gate uint32_t msg_accrightslen; 3647c478bd9Sstevel@tonic-gate }; 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate struct msghdr32 { 3677c478bd9Sstevel@tonic-gate caddr32_t msg_name; /* optional address */ 3687c478bd9Sstevel@tonic-gate uint32_t msg_namelen; /* size of address */ 3697c478bd9Sstevel@tonic-gate caddr32_t msg_iov; /* scatter/gather array */ 3707c478bd9Sstevel@tonic-gate int32_t msg_iovlen; /* # elements in msg_iov */ 3717c478bd9Sstevel@tonic-gate caddr32_t msg_control; /* ancillary data */ 3727c478bd9Sstevel@tonic-gate uint32_t msg_controllen; /* ancillary data buffer len */ 3737c478bd9Sstevel@tonic-gate int32_t msg_flags; /* flags on received message */ 3747c478bd9Sstevel@tonic-gate }; 3757c478bd9Sstevel@tonic-gate 3767c478bd9Sstevel@tonic-gate #define nmsghdr32 msghdr32 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 3797c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 3807c478bd9Sstevel@tonic-gate 3817c478bd9Sstevel@tonic-gate #define MSG_OOB 0x1 /* process out-of-band data */ 3827c478bd9Sstevel@tonic-gate #define MSG_PEEK 0x2 /* peek at incoming message */ 3837c478bd9Sstevel@tonic-gate #define MSG_DONTROUTE 0x4 /* send without using routing tables */ 3847c478bd9Sstevel@tonic-gate /* Added for XPGv2 compliance */ 3857c478bd9Sstevel@tonic-gate #define MSG_EOR 0x8 /* Terminates a record */ 3867c478bd9Sstevel@tonic-gate #define MSG_CTRUNC 0x10 /* Control data truncated */ 3877c478bd9Sstevel@tonic-gate #define MSG_TRUNC 0x20 /* Normal data truncated */ 3887c478bd9Sstevel@tonic-gate #define MSG_WAITALL 0x40 /* Wait for complete recv or error */ 3890f1702c5SYu Xiangning #define MSG_DUPCTRL 0x800 /* Save control message for use with */ 3900f1702c5SYu Xiangning /* with left over data */ 3917c478bd9Sstevel@tonic-gate /* End of XPGv2 compliance */ 3927c478bd9Sstevel@tonic-gate #define MSG_DONTWAIT 0x80 /* Don't block for this recv */ 3937c478bd9Sstevel@tonic-gate #define MSG_NOTIFICATION 0x100 /* Notification, not data */ 3947c478bd9Sstevel@tonic-gate #define MSG_XPG4_2 0x8000 /* Private: XPG4.2 flag */ 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate #define MSG_MAXIOVLEN 16 3977c478bd9Sstevel@tonic-gate 3980f1702c5SYu Xiangning #ifdef _KERNEL 3990f1702c5SYu Xiangning 4000f1702c5SYu Xiangning /* 4010f1702c5SYu Xiangning * for kernel socket only 4020f1702c5SYu Xiangning */ 4030f1702c5SYu Xiangning #define MSG_MBLK_QUICKRELE 0x10000000 /* free mblk chain */ 4040f1702c5SYu Xiangning /* in timely manner */ 4050f1702c5SYu Xiangning #define MSG_USERSPACE 0x20000000 /* buffer from user space */ 4060f1702c5SYu Xiangning 4070f1702c5SYu Xiangning #endif /* _KERNEL */ 4080f1702c5SYu Xiangning 4090f1702c5SYu Xiangning 4107c478bd9Sstevel@tonic-gate /* Added for XPGv2 compliance */ 4117c478bd9Sstevel@tonic-gate #define SHUT_RD 0 4127c478bd9Sstevel@tonic-gate #define SHUT_WR 1 4137c478bd9Sstevel@tonic-gate #define SHUT_RDWR 2 4147c478bd9Sstevel@tonic-gate 4157c478bd9Sstevel@tonic-gate struct cmsghdr { 4167c478bd9Sstevel@tonic-gate socklen_t cmsg_len; /* data byte count, including hdr */ 4177c478bd9Sstevel@tonic-gate int cmsg_level; /* originating protocol */ 4187c478bd9Sstevel@tonic-gate int cmsg_type; /* protocol-specific type */ 4197c478bd9Sstevel@tonic-gate }; 4207c478bd9Sstevel@tonic-gate 4217c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) || defined(_KERNEL) 4227c478bd9Sstevel@tonic-gate #if defined(__sparc) 4237c478bd9Sstevel@tonic-gate /* To maintain backward compatibility, alignment needs to be 8 on sparc. */ 4247c478bd9Sstevel@tonic-gate #define _CMSG_HDR_ALIGNMENT 8 4257c478bd9Sstevel@tonic-gate #else 4267c478bd9Sstevel@tonic-gate /* for __i386 (and other future architectures) */ 4277c478bd9Sstevel@tonic-gate #define _CMSG_HDR_ALIGNMENT 4 4287c478bd9Sstevel@tonic-gate #endif /* defined(__sparc) */ 4297c478bd9Sstevel@tonic-gate #endif /* defined(_XPG4_2) || defined(_KERNEL) */ 4307c478bd9Sstevel@tonic-gate 4317c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) 4327c478bd9Sstevel@tonic-gate /* 4337c478bd9Sstevel@tonic-gate * The cmsg headers (and macros dealing with them) were made available as 4347c478bd9Sstevel@tonic-gate * part of UNIX95 and hence need to be protected with a _XPG4_2 define. 4357c478bd9Sstevel@tonic-gate */ 4367c478bd9Sstevel@tonic-gate #define _CMSG_DATA_ALIGNMENT (sizeof (int)) 4377c478bd9Sstevel@tonic-gate #define _CMSG_HDR_ALIGN(x) (((uintptr_t)(x) + _CMSG_HDR_ALIGNMENT - 1) & \ 4387c478bd9Sstevel@tonic-gate ~(_CMSG_HDR_ALIGNMENT - 1)) 4397c478bd9Sstevel@tonic-gate #define _CMSG_DATA_ALIGN(x) (((uintptr_t)(x) + _CMSG_DATA_ALIGNMENT - 1) & \ 4407c478bd9Sstevel@tonic-gate ~(_CMSG_DATA_ALIGNMENT - 1)) 4417c478bd9Sstevel@tonic-gate #define CMSG_DATA(c) \ 4427c478bd9Sstevel@tonic-gate ((unsigned char *)_CMSG_DATA_ALIGN((struct cmsghdr *)(c) + 1)) 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate #define CMSG_FIRSTHDR(m) \ 4457c478bd9Sstevel@tonic-gate (((m)->msg_controllen < sizeof (struct cmsghdr)) ? \ 4467c478bd9Sstevel@tonic-gate (struct cmsghdr *)0 : (struct cmsghdr *)((m)->msg_control)) 4477c478bd9Sstevel@tonic-gate 4487c478bd9Sstevel@tonic-gate #define CMSG_NXTHDR(m, c) \ 4497c478bd9Sstevel@tonic-gate (((c) == 0) ? CMSG_FIRSTHDR(m) : \ 4507c478bd9Sstevel@tonic-gate ((((uintptr_t)_CMSG_HDR_ALIGN((char *)(c) + \ 4517c478bd9Sstevel@tonic-gate ((struct cmsghdr *)(c))->cmsg_len) + sizeof (struct cmsghdr)) > \ 4527c478bd9Sstevel@tonic-gate (((uintptr_t)((struct msghdr *)(m))->msg_control) + \ 4537c478bd9Sstevel@tonic-gate ((uintptr_t)((struct msghdr *)(m))->msg_controllen))) ? \ 4547c478bd9Sstevel@tonic-gate ((struct cmsghdr *)0) : \ 4557c478bd9Sstevel@tonic-gate ((struct cmsghdr *)_CMSG_HDR_ALIGN((char *)(c) + \ 4567c478bd9Sstevel@tonic-gate ((struct cmsghdr *)(c))->cmsg_len)))) 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate /* Amount of space + padding needed for a message of length l */ 4597c478bd9Sstevel@tonic-gate #define CMSG_SPACE(l) \ 4607c478bd9Sstevel@tonic-gate ((unsigned int)_CMSG_HDR_ALIGN(sizeof (struct cmsghdr) + (l))) 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate /* Value to be used in cmsg_len, does not include trailing padding */ 4637c478bd9Sstevel@tonic-gate #define CMSG_LEN(l) \ 4647c478bd9Sstevel@tonic-gate ((unsigned int)_CMSG_DATA_ALIGN(sizeof (struct cmsghdr)) + (l)) 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate #endif /* _XPG4_2 */ 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate #ifdef _XPG4_2 4697c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 4707c478bd9Sstevel@tonic-gate #pragma redefine_extname bind __xnet_bind 4717c478bd9Sstevel@tonic-gate #pragma redefine_extname connect __xnet_connect 4727c478bd9Sstevel@tonic-gate #pragma redefine_extname recvmsg __xnet_recvmsg 4737c478bd9Sstevel@tonic-gate #pragma redefine_extname sendmsg __xnet_sendmsg 4747c478bd9Sstevel@tonic-gate #pragma redefine_extname sendto __xnet_sendto 4757c478bd9Sstevel@tonic-gate #pragma redefine_extname socket __xnet_socket 4767c478bd9Sstevel@tonic-gate #pragma redefine_extname socketpair __xnet_socketpair 4777c478bd9Sstevel@tonic-gate #pragma redefine_extname getsockopt __xnet_getsockopt 4787c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 4797c478bd9Sstevel@tonic-gate #define bind __xnet_bind 4807c478bd9Sstevel@tonic-gate #define connect __xnet_connect 4817c478bd9Sstevel@tonic-gate #define recvmsg __xnet_recvmsg 4827c478bd9Sstevel@tonic-gate #define sendmsg __xnet_sendmsg 4837c478bd9Sstevel@tonic-gate #define sendto __xnet_sendto 4847c478bd9Sstevel@tonic-gate #define socket __xnet_socket 4857c478bd9Sstevel@tonic-gate #define socketpair __xnet_socketpair 4867c478bd9Sstevel@tonic-gate #define getsockopt __xnet_getsockopt 4877c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate #endif /* _XPG4_2 */ 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) && !defined(_XPG5) 4927c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 4937c478bd9Sstevel@tonic-gate #pragma redefine_extname listen __xnet_listen 4947c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 4957c478bd9Sstevel@tonic-gate #define listen __xnet_listen 4967c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 4977c478bd9Sstevel@tonic-gate #endif /* (_XPG4_2) && !defined(_XPG5) */ 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) || defined(_BOOT) 5007c478bd9Sstevel@tonic-gate #ifdef __STDC__ 5017c478bd9Sstevel@tonic-gate extern int accept(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t); 5027c478bd9Sstevel@tonic-gate extern int bind(int, const struct sockaddr *, socklen_t); 5037c478bd9Sstevel@tonic-gate extern int connect(int, const struct sockaddr *, socklen_t); 5047c478bd9Sstevel@tonic-gate extern int getpeername(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t); 5057c478bd9Sstevel@tonic-gate extern int getsockname(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t); 5067c478bd9Sstevel@tonic-gate extern int getsockopt(int, int, int, void *_RESTRICT_KYWD, Psocklen_t); 5077c478bd9Sstevel@tonic-gate extern int listen(int, int); /* XXX - fixme??? where do I go */ 5087c478bd9Sstevel@tonic-gate extern int socketpair(int, int, int, int *); 5097c478bd9Sstevel@tonic-gate extern ssize_t recv(int, void *, size_t, int); 5107c478bd9Sstevel@tonic-gate extern ssize_t recvfrom(int, void *_RESTRICT_KYWD, size_t, int, 5117c478bd9Sstevel@tonic-gate struct sockaddr *_RESTRICT_KYWD, Psocklen_t); 5127c478bd9Sstevel@tonic-gate extern ssize_t recvmsg(int, struct msghdr *, int); 5137c478bd9Sstevel@tonic-gate extern ssize_t send(int, const void *, size_t, int); 5147c478bd9Sstevel@tonic-gate extern ssize_t sendmsg(int, const struct msghdr *, int); 5157c478bd9Sstevel@tonic-gate extern ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, 5167c478bd9Sstevel@tonic-gate socklen_t); 5177c478bd9Sstevel@tonic-gate extern int setsockopt(int, int, int, const void *, socklen_t); 5187c478bd9Sstevel@tonic-gate extern int shutdown(int, int); 5197c478bd9Sstevel@tonic-gate extern int socket(int, int, int); 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) 5227c478bd9Sstevel@tonic-gate extern int sockatmark(int); 5237c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ 5247c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 5257c478bd9Sstevel@tonic-gate extern int accept(); 5267c478bd9Sstevel@tonic-gate extern int bind(); 5277c478bd9Sstevel@tonic-gate extern int connect(); 5287c478bd9Sstevel@tonic-gate extern int getpeername(); 5297c478bd9Sstevel@tonic-gate extern int getsockname(); 5307c478bd9Sstevel@tonic-gate extern int getsockopt(); 5317c478bd9Sstevel@tonic-gate extern int listen(); 5327c478bd9Sstevel@tonic-gate extern int recv(); 5337c478bd9Sstevel@tonic-gate extern int recvfrom(); 5347c478bd9Sstevel@tonic-gate extern int send(); 5357c478bd9Sstevel@tonic-gate extern int sendto(); 5367c478bd9Sstevel@tonic-gate extern int setsockopt(); 5377c478bd9Sstevel@tonic-gate extern int sockatmark(); 5387c478bd9Sstevel@tonic-gate extern int socket(); 5397c478bd9Sstevel@tonic-gate extern int recvmsg(); 5407c478bd9Sstevel@tonic-gate extern int sendmsg(); 5417c478bd9Sstevel@tonic-gate extern int shutdown(); 5427c478bd9Sstevel@tonic-gate extern int socketpair(); 5437c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 5447c478bd9Sstevel@tonic-gate #endif /* !defined(_KERNEL) || defined(_BOOT) */ 5457c478bd9Sstevel@tonic-gate 5467c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5477c478bd9Sstevel@tonic-gate } 5487c478bd9Sstevel@tonic-gate #endif 5497c478bd9Sstevel@tonic-gate 5507c478bd9Sstevel@tonic-gate #endif /* _SYS_SOCKET_H */ 551