xref: /titanic_44/usr/src/uts/common/sys/socketvar.h (revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0)
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
52caf0dcdSrshoaib  * Common Development and Distribution License (the "License").
62caf0dcdSrshoaib  * 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  */
212caf0dcdSrshoaib 
227c478bd9Sstevel@tonic-gate /*
2374e20cfeSnh145002  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
327c478bd9Sstevel@tonic-gate  * The Regents of the University of California
337c478bd9Sstevel@tonic-gate  * All Rights Reserved
347c478bd9Sstevel@tonic-gate  *
357c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
367c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
377c478bd9Sstevel@tonic-gate  * contributors.
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifndef _SYS_SOCKETVAR_H
417c478bd9Sstevel@tonic-gate #define	_SYS_SOCKETVAR_H
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #include <sys/types.h>
467c478bd9Sstevel@tonic-gate #include <sys/stream.h>
477c478bd9Sstevel@tonic-gate #include <sys/t_lock.h>
487c478bd9Sstevel@tonic-gate #include <sys/cred.h>
497c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
507c478bd9Sstevel@tonic-gate #include <sys/file.h>
517c478bd9Sstevel@tonic-gate #include <sys/param.h>
527c478bd9Sstevel@tonic-gate #include <sys/zone.h>
53c28749e9Skais #include <inet/kssl/ksslapi.h>
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
567c478bd9Sstevel@tonic-gate extern "C" {
577c478bd9Sstevel@tonic-gate #endif
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * Internal representation used for addresses.
637c478bd9Sstevel@tonic-gate  */
647c478bd9Sstevel@tonic-gate struct soaddr {
657c478bd9Sstevel@tonic-gate 	struct sockaddr	*soa_sa;	/* Actual address */
667c478bd9Sstevel@tonic-gate 	t_uscalar_t	soa_len;	/* Length in bytes for kmem_free */
677c478bd9Sstevel@tonic-gate 	t_uscalar_t	soa_maxlen;	/* Allocated length */
687c478bd9Sstevel@tonic-gate };
697c478bd9Sstevel@tonic-gate /* Maximum size address for transports that have ADDR_size == 1 */
707c478bd9Sstevel@tonic-gate #define	SOA_DEFSIZE	128
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * Internal representation of the address used to represent addresses
747c478bd9Sstevel@tonic-gate  * in the loopback transport for AF_UNIX. While the sockaddr_un is used
757c478bd9Sstevel@tonic-gate  * as the sockfs layer address for AF_UNIX the pathnames contained in
767c478bd9Sstevel@tonic-gate  * these addresses are not unique (due to relative pathnames) thus can not
777c478bd9Sstevel@tonic-gate  * be used in the transport.
787c478bd9Sstevel@tonic-gate  *
797c478bd9Sstevel@tonic-gate  * The transport level address consists of a magic number (used to separate the
807c478bd9Sstevel@tonic-gate  * name space for specific and implicit binds). For a specific bind
817c478bd9Sstevel@tonic-gate  * this is followed by a "vnode *" which ensures that all specific binds
827c478bd9Sstevel@tonic-gate  * have a unique transport level address. For implicit binds the latter
837c478bd9Sstevel@tonic-gate  * part of the address is a byte string (of the same length as a pointer)
847c478bd9Sstevel@tonic-gate  * that is assigned by the loopback transport.
857c478bd9Sstevel@tonic-gate  *
867c478bd9Sstevel@tonic-gate  * The uniqueness assumes that the loopback transport has a separate namespace
877c478bd9Sstevel@tonic-gate  * for sockets in order to avoid name conflicts with e.g. TLI use of the
887c478bd9Sstevel@tonic-gate  * same transport.
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate struct so_ux_addr {
917c478bd9Sstevel@tonic-gate 	void	*soua_vp;	/* vnode pointer or assigned by tl */
927c478bd9Sstevel@tonic-gate 	uint_t	soua_magic;	/* See below */
937c478bd9Sstevel@tonic-gate };
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate #define	SOU_MAGIC_EXPLICIT	0x75787670	/* "uxvp" */
967c478bd9Sstevel@tonic-gate #define	SOU_MAGIC_IMPLICIT	0x616e6f6e	/* "anon" */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate struct sockaddr_ux {
997c478bd9Sstevel@tonic-gate 	sa_family_t		sou_family;	/* AF_UNIX */
1007c478bd9Sstevel@tonic-gate 	struct so_ux_addr	sou_addr;
1017c478bd9Sstevel@tonic-gate };
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate typedef struct sonodeops sonodeops_t;
104ff550d0eSmasputra typedef struct sonode sonode_t;
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /*
1077c478bd9Sstevel@tonic-gate  * The sonode represents a socket. A sonode never exist in the file system
1087c478bd9Sstevel@tonic-gate  * name space and can not be opened using open() - only the socket, socketpair
1097c478bd9Sstevel@tonic-gate  * and accept calls create sonodes.
1107c478bd9Sstevel@tonic-gate  *
1117c478bd9Sstevel@tonic-gate  * When an AF_UNIX socket is bound to a pathname the sockfs
1127c478bd9Sstevel@tonic-gate  * creates a VSOCK vnode in the underlying file system. However, the vnodeops
1137c478bd9Sstevel@tonic-gate  * etc in this VNODE remain those of the underlying file system.
1147c478bd9Sstevel@tonic-gate  * Sockfs uses the v_stream pointer in the underlying file system VSOCK node
1157c478bd9Sstevel@tonic-gate  * to find the sonode bound to the pathname. The bound pathname vnode
1167c478bd9Sstevel@tonic-gate  * is accessed through so_ux_vp.
1177c478bd9Sstevel@tonic-gate  *
1187c478bd9Sstevel@tonic-gate  * A socket always corresponds to a VCHR stream representing the transport
1197c478bd9Sstevel@tonic-gate  * provider (e.g. /dev/tcp). This information is retrieved from the kernel
1207c478bd9Sstevel@tonic-gate  * socket configuration table and entered into so_accessvp. sockfs uses
1217c478bd9Sstevel@tonic-gate  * this to perform VOP_ACCESS checks before allowing an open of the transport
1227c478bd9Sstevel@tonic-gate  * provider.
1237c478bd9Sstevel@tonic-gate  *
1247c478bd9Sstevel@tonic-gate  * The locking of sockfs uses the so_lock mutex plus the SOLOCKED
1257c478bd9Sstevel@tonic-gate  * and SOREADLOCKED flags in so_flag. The mutex protects all the state
1267c478bd9Sstevel@tonic-gate  * in the sonode. The SOLOCKED flag is used to single-thread operations from
1277c478bd9Sstevel@tonic-gate  * sockfs users to prevent e.g. multiple bind() calls to operate on the
1287c478bd9Sstevel@tonic-gate  * same sonode concurrently. The SOREADLOCKED flag is used to ensure that
1297c478bd9Sstevel@tonic-gate  * only one thread sleeps in kstrgetmsg for a given sonode. This is needed
1307c478bd9Sstevel@tonic-gate  * to ensure atomic operation for things like MSG_WAITALL.
1317c478bd9Sstevel@tonic-gate  *
1327c478bd9Sstevel@tonic-gate  * Note that so_lock is sometimes held across calls that might go to sleep
1337c478bd9Sstevel@tonic-gate  * (kmem_alloc and soallocproto*). This implies that no other lock in
1347c478bd9Sstevel@tonic-gate  * the system should be held when calling into sockfs; from the system call
1357c478bd9Sstevel@tonic-gate  * side or from strrput. If locks are held while calling into sockfs
1367c478bd9Sstevel@tonic-gate  * the system might hang when running low on memory.
1377c478bd9Sstevel@tonic-gate  */
1387c478bd9Sstevel@tonic-gate struct sonode {
1397c478bd9Sstevel@tonic-gate 	struct	vnode	*so_vnode;	/* vnode associated with this sonode */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate 	sonodeops_t	*so_ops;	/* operations vector for this sonode */
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate 	/*
1447c478bd9Sstevel@tonic-gate 	 * These fields are initialized once.
1457c478bd9Sstevel@tonic-gate 	 */
1467c478bd9Sstevel@tonic-gate 	dev_t		so_dev;		/* device the sonode represents */
1477c478bd9Sstevel@tonic-gate 	struct	vnode	*so_accessvp;	/* vnode for the /dev entry */
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 	/* The locks themselves */
1507c478bd9Sstevel@tonic-gate 	kmutex_t	so_lock;	/* protects sonode fields */
1517c478bd9Sstevel@tonic-gate 	kmutex_t	so_plumb_lock;	/* serializes plumbs, and the related */
1527c478bd9Sstevel@tonic-gate 					/* fields so_version and so_pushcnt */
1537c478bd9Sstevel@tonic-gate 	kcondvar_t	so_state_cv;	/* synchronize state changes */
1547c478bd9Sstevel@tonic-gate 	kcondvar_t	so_ack_cv;	/* wait for TPI acks */
1557c478bd9Sstevel@tonic-gate 	kcondvar_t	so_connind_cv;	/* wait for T_CONN_IND */
1567c478bd9Sstevel@tonic-gate 	kcondvar_t	so_want_cv;	/* wait due to SOLOCKED */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate 	/* These fields are protected by so_lock */
1597c478bd9Sstevel@tonic-gate 	uint_t	so_state;		/* internal state flags SS_*, below */
1607c478bd9Sstevel@tonic-gate 	uint_t	so_mode;		/* characteristics on socket. SM_* */
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate 	mblk_t	*so_ack_mp;		/* TPI ack received from below */
1637c478bd9Sstevel@tonic-gate 	mblk_t	*so_conn_ind_head;	/* b_next list of T_CONN_IND */
1647c478bd9Sstevel@tonic-gate 	mblk_t	*so_conn_ind_tail;
1657c478bd9Sstevel@tonic-gate 	mblk_t	*so_unbind_mp;		/* Preallocated T_UNBIND_REQ message */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate 	ushort_t so_flag;		/* flags, see below */
1687c478bd9Sstevel@tonic-gate 	dev_t	so_fsid;		/* file system identifier */
1697c478bd9Sstevel@tonic-gate 	time_t  so_atime;		/* time of last access */
1707c478bd9Sstevel@tonic-gate 	time_t  so_mtime;		/* time of last modification */
1717c478bd9Sstevel@tonic-gate 	time_t  so_ctime;		/* time of last attributes change */
1727c478bd9Sstevel@tonic-gate 	int	so_count;		/* count of opened references */
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate 	/* Needed to recreate the same socket for accept */
1757c478bd9Sstevel@tonic-gate 	short	so_family;
1767c478bd9Sstevel@tonic-gate 	short	so_type;
1777c478bd9Sstevel@tonic-gate 	short	so_protocol;
1787c478bd9Sstevel@tonic-gate 	short	so_version;		/* From so_socket call */
1797c478bd9Sstevel@tonic-gate 	short	so_pushcnt;		/* Number of modules above "sockmod" */
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate 	/* Options */
1827c478bd9Sstevel@tonic-gate 	short	so_options;		/* From socket call, see socket.h */
1837c478bd9Sstevel@tonic-gate 	struct linger	so_linger;	/* SO_LINGER value */
1847c478bd9Sstevel@tonic-gate 	int	so_sndbuf;		/* SO_SNDBUF value */
1857c478bd9Sstevel@tonic-gate 	int	so_rcvbuf;		/* SO_RCVBUF value */
1867c478bd9Sstevel@tonic-gate 	int	so_sndlowat;		/* send low water mark */
1877c478bd9Sstevel@tonic-gate 	int	so_rcvlowat;		/* receive low water mark */
1887c478bd9Sstevel@tonic-gate #ifdef notyet
1897c478bd9Sstevel@tonic-gate 	int	so_sndtimeo;		/* Not yet implemented */
1907c478bd9Sstevel@tonic-gate 	int	so_rcvtimeo;		/* Not yet implemented */
1917c478bd9Sstevel@tonic-gate #endif /* notyet */
1927c478bd9Sstevel@tonic-gate 	ushort_t so_error;		/* error affecting connection */
1937c478bd9Sstevel@tonic-gate 	ushort_t so_delayed_error;	/* From T_uderror_ind */
1947c478bd9Sstevel@tonic-gate 	int	so_backlog;		/* Listen backlog */
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate 	/*
1977c478bd9Sstevel@tonic-gate 	 * The counts (so_oobcnt and so_oobsigcnt) track the number of
1987c478bd9Sstevel@tonic-gate 	 * urgent indicates that are (logically) queued on the stream head
1997c478bd9Sstevel@tonic-gate 	 * read queue. The urgent data is queued on the stream head
2007c478bd9Sstevel@tonic-gate 	 * as follows.
2017c478bd9Sstevel@tonic-gate 	 *
2027c478bd9Sstevel@tonic-gate 	 * In the normal case the SIGURG is not generated until
2037c478bd9Sstevel@tonic-gate 	 * the T_EXDATA_IND arrives at the stream head. However, transports
2047c478bd9Sstevel@tonic-gate 	 * that have an early indication that urgent data is pending
2057c478bd9Sstevel@tonic-gate 	 * (e.g. TCP receiving a "new" urgent pointer value) can send up
2067c478bd9Sstevel@tonic-gate 	 * an M_PCPROTO/SIGURG message to generate the signal early.
2077c478bd9Sstevel@tonic-gate 	 *
2087c478bd9Sstevel@tonic-gate 	 * The mark is indicated by either:
2097c478bd9Sstevel@tonic-gate 	 *  - a T_EXDATA_IND (with no M_DATA b_cont) with MSGMARK set.
2107c478bd9Sstevel@tonic-gate 	 *    When this message is consumed by sorecvmsg the socket layer
2117c478bd9Sstevel@tonic-gate 	 *    sets SS_RCVATMARK until data has been consumed past the mark.
2127c478bd9Sstevel@tonic-gate 	 *  - a message with MSGMARKNEXT set (indicating that the
2137c478bd9Sstevel@tonic-gate 	 *    first byte of the next message constitutes the mark). When
2147c478bd9Sstevel@tonic-gate 	 *    the last byte of the MSGMARKNEXT message is consumed in
2157c478bd9Sstevel@tonic-gate 	 *    the stream head the stream head sets STRATMARK. This flag
2167c478bd9Sstevel@tonic-gate 	 *    is cleared when at least one byte is read. (Note that
2177c478bd9Sstevel@tonic-gate 	 *    the MSGMARKNEXT messages can be of zero length when there
2187c478bd9Sstevel@tonic-gate 	 *    is no previous data to which the marknext can be attached.)
2197c478bd9Sstevel@tonic-gate 	 *
2207c478bd9Sstevel@tonic-gate 	 * While the T_EXDATA_IND method is the common case which is used
2217c478bd9Sstevel@tonic-gate 	 * with all TPI transports, the MSGMARKNEXT method is needed to
2227c478bd9Sstevel@tonic-gate 	 * indicate the mark when e.g. the TCP urgent byte has not been
2237c478bd9Sstevel@tonic-gate 	 * received yet but the TCP urgent pointer has made TCP generate
2247c478bd9Sstevel@tonic-gate 	 * the M_PCSIG/SIGURG.
2257c478bd9Sstevel@tonic-gate 	 *
2267c478bd9Sstevel@tonic-gate 	 * The signal (the M_PCSIG carrying the SIGURG) and the mark
2277c478bd9Sstevel@tonic-gate 	 * indication can not be delivered as a single message, since
2287c478bd9Sstevel@tonic-gate 	 * the signal should be delivered as high priority and any mark
2297c478bd9Sstevel@tonic-gate 	 * indication must flow with the data. This implies that immediately
2307c478bd9Sstevel@tonic-gate 	 * when the SIGURG has been delivered if the stream head queue is
2317c478bd9Sstevel@tonic-gate 	 * empty it is impossible to determine if this will be the position
2327c478bd9Sstevel@tonic-gate 	 * of the mark. This race condition is resolved by using MSGNOTMARKNEXT
2337c478bd9Sstevel@tonic-gate 	 * messages and the STRNOTATMARK flag in the stream head. The
2347c478bd9Sstevel@tonic-gate 	 * SIOCATMARK code calls the stream head to wait for either a
2357c478bd9Sstevel@tonic-gate 	 * non-empty queue or one of the STR*ATMARK flags being set.
2367c478bd9Sstevel@tonic-gate 	 * This implies that any transport that is sending M_PCSIG(SIGURG)
2377c478bd9Sstevel@tonic-gate 	 * should send the appropriate MSGNOTMARKNEXT message (which can be
2387c478bd9Sstevel@tonic-gate 	 * zero length) after sending an M_PCSIG to prevent SIOCATMARK
2397c478bd9Sstevel@tonic-gate 	 * from sleeping unnecessarily.
2407c478bd9Sstevel@tonic-gate 	 */
2417c478bd9Sstevel@tonic-gate 	mblk_t	*so_oobmsg;		/* outofline oob data */
2427c478bd9Sstevel@tonic-gate 	uint_t	so_oobsigcnt;		/* Number of SIGURG generated */
2437c478bd9Sstevel@tonic-gate 	uint_t	so_oobcnt;		/* Number of T_EXDATA_IND queued */
2447c478bd9Sstevel@tonic-gate 	pid_t	so_pgrp;		/* pgrp for signals */
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate 	/* From T_info_ack */
2477c478bd9Sstevel@tonic-gate 	t_uscalar_t	so_tsdu_size;
2487c478bd9Sstevel@tonic-gate 	t_uscalar_t	so_etsdu_size;
2497c478bd9Sstevel@tonic-gate 	t_scalar_t	so_addr_size;
2507c478bd9Sstevel@tonic-gate 	t_uscalar_t	so_opt_size;
2517c478bd9Sstevel@tonic-gate 	t_uscalar_t	so_tidu_size;
2527c478bd9Sstevel@tonic-gate 	t_scalar_t	so_serv_type;
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate 	/* From T_capability_ack */
2557c478bd9Sstevel@tonic-gate 	t_uscalar_t	so_acceptor_id;
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate 	/* Internal provider information */
2587c478bd9Sstevel@tonic-gate 	struct tpi_provinfo	*so_provinfo;
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate 	/*
2617c478bd9Sstevel@tonic-gate 	 * The local and remote addresses have multiple purposes
2627c478bd9Sstevel@tonic-gate 	 * but one of the key reasons for their existence and careful
2637c478bd9Sstevel@tonic-gate 	 * tracking in sockfs is to support getsockname and getpeername
2647c478bd9Sstevel@tonic-gate 	 * when the transport does not handle the TI_GET*NAME ioctls
265*da6c28aaSamw 	 * and caching when it does (signaled by valid bits in so_state).
2667c478bd9Sstevel@tonic-gate 	 * When all transports support the new TPI (with T_ADDR_REQ)
2677c478bd9Sstevel@tonic-gate 	 * we can revisit this code.
2687c478bd9Sstevel@tonic-gate 	 * The other usage of so_faddr is to keep the "connected to"
2697c478bd9Sstevel@tonic-gate 	 * address for datagram sockets.
2707c478bd9Sstevel@tonic-gate 	 * Finally, for AF_UNIX both local and remote addresses are used
2717c478bd9Sstevel@tonic-gate 	 * to record the sockaddr_un since we use a separate namespace
2727c478bd9Sstevel@tonic-gate 	 * in the loopback transport.
2737c478bd9Sstevel@tonic-gate 	 */
2747c478bd9Sstevel@tonic-gate 	struct soaddr so_laddr;		/* Local address */
2757c478bd9Sstevel@tonic-gate 	struct soaddr so_faddr;		/* Peer address */
2767c478bd9Sstevel@tonic-gate #define	so_laddr_sa	so_laddr.soa_sa
2777c478bd9Sstevel@tonic-gate #define	so_faddr_sa	so_faddr.soa_sa
2787c478bd9Sstevel@tonic-gate #define	so_laddr_len	so_laddr.soa_len
2797c478bd9Sstevel@tonic-gate #define	so_faddr_len	so_faddr.soa_len
2807c478bd9Sstevel@tonic-gate #define	so_laddr_maxlen	so_laddr.soa_maxlen
2817c478bd9Sstevel@tonic-gate #define	so_faddr_maxlen	so_faddr.soa_maxlen
2827c478bd9Sstevel@tonic-gate 	mblk_t		*so_eaddr_mp;	/* for so_delayed_error */
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate 	/*
2857c478bd9Sstevel@tonic-gate 	 * For AF_UNIX sockets:
2867c478bd9Sstevel@tonic-gate 	 * so_ux_laddr/faddr records the internal addresses used with the
2877c478bd9Sstevel@tonic-gate 	 * transport.
2887c478bd9Sstevel@tonic-gate 	 * so_ux_vp and v_stream->sd_vnode form the cross-
2897c478bd9Sstevel@tonic-gate 	 * linkage between the underlying fs vnode corresponding to
2907c478bd9Sstevel@tonic-gate 	 * the bound sockaddr_un and the socket node.
2917c478bd9Sstevel@tonic-gate 	 */
2927c478bd9Sstevel@tonic-gate 	struct so_ux_addr so_ux_laddr;	/* laddr bound with the transport */
2937c478bd9Sstevel@tonic-gate 	struct so_ux_addr so_ux_faddr;	/* temporary peer address */
2947c478bd9Sstevel@tonic-gate 	struct vnode	*so_ux_bound_vp; /* bound AF_UNIX file system vnode */
2957c478bd9Sstevel@tonic-gate 	struct sonode	*so_next;	/* next sonode on socklist	*/
2967c478bd9Sstevel@tonic-gate 	struct sonode	*so_prev;	/* previous sonode on socklist	*/
2977c478bd9Sstevel@tonic-gate 	mblk_t	*so_discon_ind_mp;	/* T_DISCON_IND received from below */
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate 					/* put here for delayed processing  */
3007c478bd9Sstevel@tonic-gate 	void		*so_priv;	/* sonode private data */
3017c478bd9Sstevel@tonic-gate 	cred_t		*so_peercred;	/* connected socket peer cred */
3027c478bd9Sstevel@tonic-gate 	pid_t		so_cpid;	/* connected socket peer cached pid */
3037c478bd9Sstevel@tonic-gate 	zoneid_t	so_zoneid;	/* opener's zoneid */
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate 	kmem_cache_t	*so_cache;	/* object cache of this "sonode". */
3067c478bd9Sstevel@tonic-gate 	void		*so_obj;	/* object to free */
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 	/*
3097c478bd9Sstevel@tonic-gate 	 * For NL7C sockets:
3107c478bd9Sstevel@tonic-gate 	 *
3117c478bd9Sstevel@tonic-gate 	 * so_nl7c_flags	the NL7C state of URL processing.
3127c478bd9Sstevel@tonic-gate 	 *
3137c478bd9Sstevel@tonic-gate 	 * so_nl7c_rcv_mp	mblk_t chain of already received data to be
3147c478bd9Sstevel@tonic-gate 	 *			passed up to the app after NL7C gives up on
3157c478bd9Sstevel@tonic-gate 	 *			a socket.
3167c478bd9Sstevel@tonic-gate 	 *
3177c478bd9Sstevel@tonic-gate 	 * so_nl7c_rcv_rval	returned rval for last mblk_t from above.
3187c478bd9Sstevel@tonic-gate 	 *
3197c478bd9Sstevel@tonic-gate 	 * so_nl7c_uri		the URI currently being processed.
3207c478bd9Sstevel@tonic-gate 	 *
3217c478bd9Sstevel@tonic-gate 	 * so_nl7c_rtime	URI request gethrestime_sec().
3222c9e429eSbrutus 	 *
3232c9e429eSbrutus 	 * so_nl7c_addr		pointer returned by nl7c_addr_lookup().
3247c478bd9Sstevel@tonic-gate 	 */
3257c478bd9Sstevel@tonic-gate 	uint64_t	so_nl7c_flags;
3267c478bd9Sstevel@tonic-gate 	mblk_t		*so_nl7c_rcv_mp;
3277c478bd9Sstevel@tonic-gate 	int64_t		so_nl7c_rcv_rval;
3287c478bd9Sstevel@tonic-gate 	void		*so_nl7c_uri;
3297c478bd9Sstevel@tonic-gate 	time_t		so_nl7c_rtime;
3302c9e429eSbrutus 	void		*so_nl7c_addr;
331c28749e9Skais 
332c28749e9Skais 	/* For sockets acting as an in-kernel SSL proxy */
333c28749e9Skais 	kssl_endpt_type_t	so_kssl_type;	/* is proxy/is proxied/none */
334c28749e9Skais 	kssl_ent_t		so_kssl_ent;	/* SSL config entry */
335c28749e9Skais 	kssl_ctx_t		so_kssl_ctx;	/* SSL session context */
3367c478bd9Sstevel@tonic-gate };
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate /* flags */
3397c478bd9Sstevel@tonic-gate #define	SOMOD		0x0001		/* update socket modification time */
3407c478bd9Sstevel@tonic-gate #define	SOACC		0x0002		/* update socket access time */
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate #define	SOLOCKED	0x0010		/* use to serialize open/closes */
3437c478bd9Sstevel@tonic-gate #define	SOREADLOCKED	0x0020		/* serialize kstrgetmsg calls */
3447c478bd9Sstevel@tonic-gate #define	SOWANT		0x0040		/* some process waiting on lock */
3457c478bd9Sstevel@tonic-gate #define	SOCLONE		0x0080		/* child of clone driver */
3467c478bd9Sstevel@tonic-gate #define	SOASYNC_UNBIND	0x0100		/* wait for ACK of async unbind */
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate /*
3497c478bd9Sstevel@tonic-gate  * Socket state bits.
3507c478bd9Sstevel@tonic-gate  */
3517c478bd9Sstevel@tonic-gate #define	SS_ISCONNECTED		0x00000001 /* socket connected to a peer */
3527c478bd9Sstevel@tonic-gate #define	SS_ISCONNECTING		0x00000002 /* in process, connecting to peer */
3537c478bd9Sstevel@tonic-gate #define	SS_ISDISCONNECTING	0x00000004 /* in process of disconnecting */
3547c478bd9Sstevel@tonic-gate #define	SS_CANTSENDMORE		0x00000008 /* can't send more data to peer */
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate #define	SS_CANTRCVMORE		0x00000010 /* can't receive more data */
3577c478bd9Sstevel@tonic-gate #define	SS_ISBOUND		0x00000020 /* socket is bound */
3587c478bd9Sstevel@tonic-gate #define	SS_NDELAY		0x00000040 /* FNDELAY non-blocking */
3597c478bd9Sstevel@tonic-gate #define	SS_NONBLOCK		0x00000080 /* O_NONBLOCK non-blocking */
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate #define	SS_ASYNC		0x00000100 /* async i/o notify */
3627c478bd9Sstevel@tonic-gate #define	SS_ACCEPTCONN		0x00000200 /* listen done */
3637c478bd9Sstevel@tonic-gate #define	SS_HASCONNIND		0x00000400 /* T_CONN_IND for poll */
3647c478bd9Sstevel@tonic-gate #define	SS_SAVEDEOR		0x00000800 /* Saved MSG_EOR rcv side state */
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate #define	SS_RCVATMARK		0x00001000 /* at mark on input */
3677c478bd9Sstevel@tonic-gate #define	SS_OOBPEND		0x00002000 /* OOB pending or present - poll */
3687c478bd9Sstevel@tonic-gate #define	SS_HAVEOOBDATA		0x00004000 /* OOB data present */
3697c478bd9Sstevel@tonic-gate #define	SS_HADOOBDATA		0x00008000 /* OOB data consumed */
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate #define	SS_FADDR_NOXLATE	0x00020000 /* No xlation of faddr for AF_UNIX */
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate #define	SS_HASDATA		0x00040000 /* NCAfs: data available */
3747c478bd9Sstevel@tonic-gate #define	SS_DONEREAD		0x00080000 /* NCAfs: all data read */
3757c478bd9Sstevel@tonic-gate #define	SS_MOREDATA		0x00100000 /* NCAfs: NCA has more data */
3767c478bd9Sstevel@tonic-gate 
377ff550d0eSmasputra #define	SS_DIRECT		0x00200000 /* transport is directly below */
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate #define	SS_LADDR_VALID		0x01000000	/* so_laddr valid for user */
3807c478bd9Sstevel@tonic-gate #define	SS_FADDR_VALID		0x02000000	/* so_faddr valid for user */
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate /* Set of states when the socket can't be rebound */
3837c478bd9Sstevel@tonic-gate #define	SS_CANTREBIND	(SS_ISCONNECTED|SS_ISCONNECTING|SS_ISDISCONNECTING|\
3847c478bd9Sstevel@tonic-gate 			    SS_CANTSENDMORE|SS_CANTRCVMORE|SS_ACCEPTCONN)
3857c478bd9Sstevel@tonic-gate 
3867c478bd9Sstevel@tonic-gate /*
3877c478bd9Sstevel@tonic-gate  * Characteristics of sockets. Not changed after the socket is created.
3887c478bd9Sstevel@tonic-gate  */
3897c478bd9Sstevel@tonic-gate #define	SM_PRIV			0x001	/* privileged for broadcast, raw... */
3907c478bd9Sstevel@tonic-gate #define	SM_ATOMIC		0x002	/* atomic data transmission */
3917c478bd9Sstevel@tonic-gate #define	SM_ADDR			0x004	/* addresses given with messages */
3927c478bd9Sstevel@tonic-gate #define	SM_CONNREQUIRED		0x008	/* connection required by protocol */
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate #define	SM_FDPASSING		0x010	/* passes file descriptors */
3957c478bd9Sstevel@tonic-gate #define	SM_EXDATA		0x020	/* Can handle T_EXDATA_REQ */
3967c478bd9Sstevel@tonic-gate #define	SM_OPTDATA		0x040	/* Can handle T_OPTDATA_REQ */
3977c478bd9Sstevel@tonic-gate #define	SM_BYTESTREAM		0x080	/* Byte stream - can use M_DATA */
3987c478bd9Sstevel@tonic-gate 
3997c478bd9Sstevel@tonic-gate #define	SM_ACCEPTOR_ID		0x100	/* so_acceptor_id is valid */
4007c478bd9Sstevel@tonic-gate 
4017c478bd9Sstevel@tonic-gate /*
4027c478bd9Sstevel@tonic-gate  * Socket versions. Used by the socket library when calling _so_socket().
4037c478bd9Sstevel@tonic-gate  */
4047c478bd9Sstevel@tonic-gate #define	SOV_STREAM	0	/* Not a socket - just a stream */
4057c478bd9Sstevel@tonic-gate #define	SOV_DEFAULT	1	/* Select based on so_default_version */
4067c478bd9Sstevel@tonic-gate #define	SOV_SOCKSTREAM	2	/* Socket plus streams operations */
4077c478bd9Sstevel@tonic-gate #define	SOV_SOCKBSD	3	/* Socket with no streams operations */
4087c478bd9Sstevel@tonic-gate #define	SOV_XPG4_2	4	/* Xnet socket */
4097c478bd9Sstevel@tonic-gate 
4107c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER)
4117c478bd9Sstevel@tonic-gate /*
4127c478bd9Sstevel@tonic-gate  * Used for mapping family/type/protocol to vnode.
4137c478bd9Sstevel@tonic-gate  * Defined here so that crash can use it.
4147c478bd9Sstevel@tonic-gate  */
4157c478bd9Sstevel@tonic-gate struct sockparams {
4167c478bd9Sstevel@tonic-gate 	int	sp_domain;
4177c478bd9Sstevel@tonic-gate 	int	sp_type;
4187c478bd9Sstevel@tonic-gate 	int	sp_protocol;
4197c478bd9Sstevel@tonic-gate 	char	*sp_devpath;
4207c478bd9Sstevel@tonic-gate 	int	sp_devpathlen;	/* Is 0 if sp_devpath is a static string */
4217c478bd9Sstevel@tonic-gate 	vnode_t	*sp_vnode;
4227c478bd9Sstevel@tonic-gate 	struct sockparams *sp_next;
4237c478bd9Sstevel@tonic-gate };
4247c478bd9Sstevel@tonic-gate 
4257c478bd9Sstevel@tonic-gate extern struct sockparams *sphead;
4267c478bd9Sstevel@tonic-gate 
4277c478bd9Sstevel@tonic-gate /*
4287c478bd9Sstevel@tonic-gate  * Used to traverse the list of AF_UNIX sockets to construct the kstat
4297c478bd9Sstevel@tonic-gate  * for netstat(1m).
4307c478bd9Sstevel@tonic-gate  */
4317c478bd9Sstevel@tonic-gate struct socklist {
4327c478bd9Sstevel@tonic-gate 	kmutex_t	sl_lock;
4337c478bd9Sstevel@tonic-gate 	struct sonode	*sl_list;
4347c478bd9Sstevel@tonic-gate };
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate extern struct socklist socklist;
4377c478bd9Sstevel@tonic-gate /*
4387c478bd9Sstevel@tonic-gate  * ss_full_waits is the number of times the reader thread
4397c478bd9Sstevel@tonic-gate  * waits when the queue is full and ss_empty_waits is the number
4407c478bd9Sstevel@tonic-gate  * of times the consumer thread waits when the queue is empty.
4417c478bd9Sstevel@tonic-gate  * No locks for these as they are just indicators of whether
4427c478bd9Sstevel@tonic-gate  * disk or network or both is slow or fast.
4437c478bd9Sstevel@tonic-gate  */
4447c478bd9Sstevel@tonic-gate struct sendfile_stats {
4457c478bd9Sstevel@tonic-gate 	uint32_t ss_file_cached;
4467c478bd9Sstevel@tonic-gate 	uint32_t ss_file_not_cached;
4477c478bd9Sstevel@tonic-gate 	uint32_t ss_full_waits;
4487c478bd9Sstevel@tonic-gate 	uint32_t ss_empty_waits;
4497c478bd9Sstevel@tonic-gate 	uint32_t ss_file_segmap;
4507c478bd9Sstevel@tonic-gate };
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate /*
4537c478bd9Sstevel@tonic-gate  * A single sendfile request is represented by snf_req.
4547c478bd9Sstevel@tonic-gate  */
4557c478bd9Sstevel@tonic-gate typedef struct snf_req {
4567c478bd9Sstevel@tonic-gate 	struct snf_req	*sr_next;
4577c478bd9Sstevel@tonic-gate 	mblk_t		*sr_mp_head;
4587c478bd9Sstevel@tonic-gate 	mblk_t		*sr_mp_tail;
4597c478bd9Sstevel@tonic-gate 	kmutex_t	sr_lock;
4607c478bd9Sstevel@tonic-gate 	kcondvar_t	sr_cv;
4617c478bd9Sstevel@tonic-gate 	uint_t		sr_qlen;
4627c478bd9Sstevel@tonic-gate 	int		sr_hiwat;
4637c478bd9Sstevel@tonic-gate 	int		sr_lowat;
4647c478bd9Sstevel@tonic-gate 	int		sr_operation;
4657c478bd9Sstevel@tonic-gate 	struct vnode	*sr_vp;
4667c478bd9Sstevel@tonic-gate 	file_t 		*sr_fp;
4677c478bd9Sstevel@tonic-gate 	ssize_t		sr_maxpsz;
4687c478bd9Sstevel@tonic-gate 	u_offset_t	sr_file_off;
4697c478bd9Sstevel@tonic-gate 	u_offset_t	sr_file_size;
4707c478bd9Sstevel@tonic-gate #define	SR_READ_DONE	0x80000000
4717c478bd9Sstevel@tonic-gate 	int		sr_read_error;
4727c478bd9Sstevel@tonic-gate 	int		sr_write_error;
4737c478bd9Sstevel@tonic-gate } snf_req_t;
4747c478bd9Sstevel@tonic-gate 
4757c478bd9Sstevel@tonic-gate /* A queue of sendfile requests */
4767c478bd9Sstevel@tonic-gate struct sendfile_queue {
4777c478bd9Sstevel@tonic-gate 	snf_req_t	*snfq_req_head;
4787c478bd9Sstevel@tonic-gate 	snf_req_t	*snfq_req_tail;
4797c478bd9Sstevel@tonic-gate 	kmutex_t	snfq_lock;
4807c478bd9Sstevel@tonic-gate 	kcondvar_t	snfq_cv;
4817c478bd9Sstevel@tonic-gate 	int		snfq_svc_threads;	/* # of service threads */
4827c478bd9Sstevel@tonic-gate 	int		snfq_idle_cnt;		/* # of idling threads */
4837c478bd9Sstevel@tonic-gate 	int		snfq_max_threads;
4847c478bd9Sstevel@tonic-gate 	int		snfq_req_cnt;		/* Number of requests */
4857c478bd9Sstevel@tonic-gate };
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate #define	READ_OP			1
4887c478bd9Sstevel@tonic-gate #define	SNFQ_TIMEOUT		(60 * 5 * hz)	/* 5 minutes */
4897c478bd9Sstevel@tonic-gate 
4907c478bd9Sstevel@tonic-gate /* Socket network operations switch */
4917c478bd9Sstevel@tonic-gate struct sonodeops {
4927c478bd9Sstevel@tonic-gate 	int	(*sop_accept)(struct sonode *, int, struct sonode **);
4937c478bd9Sstevel@tonic-gate 	int	(*sop_bind)(struct sonode *, struct sockaddr *, socklen_t,
4947c478bd9Sstevel@tonic-gate 		    int);
4957c478bd9Sstevel@tonic-gate 	int	(*sop_listen)(struct sonode *, int);
4967c478bd9Sstevel@tonic-gate 	int	(*sop_connect)(struct sonode *, const struct sockaddr *,
4977c478bd9Sstevel@tonic-gate 		    socklen_t, int, int);
4987c478bd9Sstevel@tonic-gate 	int	(*sop_recvmsg)(struct sonode *, struct msghdr *,
4997c478bd9Sstevel@tonic-gate 		    struct uio *);
5007c478bd9Sstevel@tonic-gate 	int	(*sop_sendmsg)(struct sonode *, struct msghdr *,
5017c478bd9Sstevel@tonic-gate 		    struct uio *);
5027c478bd9Sstevel@tonic-gate 	int	(*sop_getpeername)(struct sonode *);
5037c478bd9Sstevel@tonic-gate 	int	(*sop_getsockname)(struct sonode *);
5047c478bd9Sstevel@tonic-gate 	int	(*sop_shutdown)(struct sonode *, int);
5057c478bd9Sstevel@tonic-gate 	int	(*sop_getsockopt)(struct sonode *, int, int, void *,
5067c478bd9Sstevel@tonic-gate 		    socklen_t *, int);
5077c478bd9Sstevel@tonic-gate 	int 	(*sop_setsockopt)(struct sonode *, int, int, const void *,
5087c478bd9Sstevel@tonic-gate 		    socklen_t);
5097c478bd9Sstevel@tonic-gate };
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate #define	SOP_ACCEPT(so, fflag, nsop)	\
5127c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_accept((so), (fflag), (nsop)))
5137c478bd9Sstevel@tonic-gate #define	SOP_BIND(so, name, namelen, flags)	\
5147c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_bind((so), (name), (namelen), (flags)))
5157c478bd9Sstevel@tonic-gate #define	SOP_LISTEN(so, backlog)	\
5167c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_listen((so), (backlog)))
5177c478bd9Sstevel@tonic-gate #define	SOP_CONNECT(so, name, namelen, fflag, flags)	\
5187c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_connect((so), (name), (namelen), (fflag), (flags)))
5197c478bd9Sstevel@tonic-gate #define	SOP_RECVMSG(so, msg, uiop)	\
5207c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_recvmsg((so), (msg), (uiop)))
5217c478bd9Sstevel@tonic-gate #define	SOP_SENDMSG(so, msg, uiop)	\
5227c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_sendmsg((so), (msg), (uiop)))
5237c478bd9Sstevel@tonic-gate #define	SOP_GETPEERNAME(so)	\
5247c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_getpeername((so)))
5257c478bd9Sstevel@tonic-gate #define	SOP_GETSOCKNAME(so)	\
5267c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_getsockname((so)))
5277c478bd9Sstevel@tonic-gate #define	SOP_SHUTDOWN(so, how)	\
5287c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_shutdown((so), (how)))
5297c478bd9Sstevel@tonic-gate #define	SOP_GETSOCKOPT(so, level, optionname, optval, optlenp, flags)	\
5307c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_getsockopt((so), (level), (optionname),	\
5317c478bd9Sstevel@tonic-gate 	    (optval), (optlenp), (flags)))
5327c478bd9Sstevel@tonic-gate #define	SOP_SETSOCKOPT(so, level, optionname, optval, optlen)		\
5337c478bd9Sstevel@tonic-gate 	((so)->so_ops->sop_setsockopt((so), (level), (optionname),	\
5347c478bd9Sstevel@tonic-gate 	    (optval), (optlen)))
5357c478bd9Sstevel@tonic-gate 
5367c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) || defined(_KMEMUSER) */
5377c478bd9Sstevel@tonic-gate 
5387c478bd9Sstevel@tonic-gate #ifdef _KERNEL
5397c478bd9Sstevel@tonic-gate 
5407c478bd9Sstevel@tonic-gate #define	ISALIGNED_cmsghdr(addr) \
5417c478bd9Sstevel@tonic-gate 		(((uintptr_t)(addr) & (_CMSG_HDR_ALIGNMENT - 1)) == 0)
5427c478bd9Sstevel@tonic-gate 
5437c478bd9Sstevel@tonic-gate #define	ROUNDUP_cmsglen(len) \
5447c478bd9Sstevel@tonic-gate 	(((len) + _CMSG_HDR_ALIGNMENT - 1) & ~(_CMSG_HDR_ALIGNMENT - 1))
5457c478bd9Sstevel@tonic-gate 
5467c478bd9Sstevel@tonic-gate /*
5479acbbeafSnn35248  * Macros that operate on struct cmsghdr.
5489acbbeafSnn35248  * Used in parsing msg_control.
5499acbbeafSnn35248  * The CMSG_VALID macro does not assume that the last option buffer is padded.
5507c478bd9Sstevel@tonic-gate  */
5517c478bd9Sstevel@tonic-gate #define	CMSG_NEXT(cmsg)						\
5527c478bd9Sstevel@tonic-gate 	(struct cmsghdr *)((uintptr_t)(cmsg) +			\
5537c478bd9Sstevel@tonic-gate 	    ROUNDUP_cmsglen((cmsg)->cmsg_len))
5549acbbeafSnn35248 #define	CMSG_CONTENT(cmsg)	(&((cmsg)[1]))
5559acbbeafSnn35248 #define	CMSG_CONTENTLEN(cmsg)	((cmsg)->cmsg_len - sizeof (struct cmsghdr))
5569acbbeafSnn35248 #define	CMSG_VALID(cmsg, start, end)					\
5579acbbeafSnn35248 	(ISALIGNED_cmsghdr(cmsg) &&					\
5589acbbeafSnn35248 	((uintptr_t)(cmsg) >= (uintptr_t)(start)) &&			\
5599acbbeafSnn35248 	((uintptr_t)(cmsg) < (uintptr_t)(end)) &&			\
5609acbbeafSnn35248 	((ssize_t)(cmsg)->cmsg_len >= sizeof (struct cmsghdr)) &&	\
5619acbbeafSnn35248 	((uintptr_t)(cmsg) + (cmsg)->cmsg_len <= (uintptr_t)(end)))
5627c478bd9Sstevel@tonic-gate 
5637c478bd9Sstevel@tonic-gate /*
5647c478bd9Sstevel@tonic-gate  * Maximum size of any argument that is copied in (addresses, options,
5657c478bd9Sstevel@tonic-gate  * access rights). MUST be at least MAXPATHLEN + 3.
5667c478bd9Sstevel@tonic-gate  * BSD and SunOS 4.X limited this to MLEN or MCLBYTES.
5677c478bd9Sstevel@tonic-gate  */
5687c478bd9Sstevel@tonic-gate #define	SO_MAXARGSIZE	8192
5697c478bd9Sstevel@tonic-gate 
5707c478bd9Sstevel@tonic-gate /*
5717c478bd9Sstevel@tonic-gate  * Convert between vnode and sonode
5727c478bd9Sstevel@tonic-gate  */
5737c478bd9Sstevel@tonic-gate #define	VTOSO(vp)	((struct sonode *)((vp)->v_data))
5747c478bd9Sstevel@tonic-gate #define	SOTOV(sp)	((sp)->so_vnode)
5757c478bd9Sstevel@tonic-gate 
5767c478bd9Sstevel@tonic-gate /*
5777c478bd9Sstevel@tonic-gate  * Internal flags for sobind()
5787c478bd9Sstevel@tonic-gate  */
5797c478bd9Sstevel@tonic-gate #define	_SOBIND_REBIND		0x01	/* Bind to existing local address */
5807c478bd9Sstevel@tonic-gate #define	_SOBIND_UNSPEC		0x02	/* Bind to unspecified address */
5817c478bd9Sstevel@tonic-gate #define	_SOBIND_LOCK_HELD	0x04	/* so_excl_lock held by caller */
5827c478bd9Sstevel@tonic-gate #define	_SOBIND_NOXLATE		0x08	/* No addr translation for AF_UNIX */
5837c478bd9Sstevel@tonic-gate #define	_SOBIND_XPG4_2		0x10	/* xpg4.2 semantics */
5847c478bd9Sstevel@tonic-gate #define	_SOBIND_SOCKBSD		0x20	/* BSD semantics */
5857c478bd9Sstevel@tonic-gate #define	_SOBIND_LISTEN		0x40	/* Make into SS_ACCEPTCONN */
5867c478bd9Sstevel@tonic-gate #define	_SOBIND_SOCKETPAIR	0x80	/* Internal flag for so_socketpair() */
5877c478bd9Sstevel@tonic-gate 					/* to enable listen with backlog = 1 */
5887c478bd9Sstevel@tonic-gate 
5897c478bd9Sstevel@tonic-gate /*
5907c478bd9Sstevel@tonic-gate  * Internal flags for sounbind()
5917c478bd9Sstevel@tonic-gate  */
5927c478bd9Sstevel@tonic-gate #define	_SOUNBIND_REBIND	0x01	/* Don't clear fields - will rebind */
5937c478bd9Sstevel@tonic-gate 
5947c478bd9Sstevel@tonic-gate /*
5957c478bd9Sstevel@tonic-gate  * Internal flags for soconnect()
5967c478bd9Sstevel@tonic-gate  */
5977c478bd9Sstevel@tonic-gate #define	_SOCONNECT_NOXLATE	0x01	/* No addr translation for AF_UNIX */
5987c478bd9Sstevel@tonic-gate #define	_SOCONNECT_DID_BIND	0x02	/* Unbind when connect fails */
5997c478bd9Sstevel@tonic-gate #define	_SOCONNECT_XPG4_2	0x04	/* xpg4.2 semantics */
6007c478bd9Sstevel@tonic-gate 
6017c478bd9Sstevel@tonic-gate /*
6027c478bd9Sstevel@tonic-gate  * Internal flags for sodisconnect()
6037c478bd9Sstevel@tonic-gate  */
6047c478bd9Sstevel@tonic-gate #define	_SODISCONNECT_LOCK_HELD	0x01	/* so_excl_lock held by caller */
6057c478bd9Sstevel@tonic-gate 
6067c478bd9Sstevel@tonic-gate /*
6077c478bd9Sstevel@tonic-gate  * Internal flags for sotpi_getsockopt().
6087c478bd9Sstevel@tonic-gate  */
6097c478bd9Sstevel@tonic-gate #define	_SOGETSOCKOPT_XPG4_2	0x01	/* xpg4.2 semantics */
6107c478bd9Sstevel@tonic-gate 
6117c478bd9Sstevel@tonic-gate /*
6127c478bd9Sstevel@tonic-gate  * Internal flags for soallocproto*()
6137c478bd9Sstevel@tonic-gate  */
6147c478bd9Sstevel@tonic-gate #define	_ALLOC_NOSLEEP		0	/* Don't sleep for memory */
6157c478bd9Sstevel@tonic-gate #define	_ALLOC_INTR		1	/* Sleep until interrupt */
6167c478bd9Sstevel@tonic-gate #define	_ALLOC_SLEEP		2	/* Sleep forever */
6177c478bd9Sstevel@tonic-gate 
6187c478bd9Sstevel@tonic-gate /*
6197c478bd9Sstevel@tonic-gate  * Internal structure for handling AF_UNIX file descriptor passing
6207c478bd9Sstevel@tonic-gate  */
6217c478bd9Sstevel@tonic-gate struct fdbuf {
6227c478bd9Sstevel@tonic-gate 	int		fd_size;	/* In bytes, for kmem_free */
6237c478bd9Sstevel@tonic-gate 	int		fd_numfd;	/* Number of elements below */
6247c478bd9Sstevel@tonic-gate 	char		*fd_ebuf;	/* Extra buffer to free  */
6257c478bd9Sstevel@tonic-gate 	int		fd_ebuflen;
6267c478bd9Sstevel@tonic-gate 	frtn_t		fd_frtn;
6277c478bd9Sstevel@tonic-gate 	struct file	*fd_fds[1];	/* One or more */
6287c478bd9Sstevel@tonic-gate };
6297c478bd9Sstevel@tonic-gate #define	FDBUF_HDRSIZE	(sizeof (struct fdbuf) - sizeof (struct file *))
6307c478bd9Sstevel@tonic-gate 
6317c478bd9Sstevel@tonic-gate /*
6327c478bd9Sstevel@tonic-gate  * Variable that can be patched to set what version of socket socket()
6337c478bd9Sstevel@tonic-gate  * will create.
6347c478bd9Sstevel@tonic-gate  */
6357c478bd9Sstevel@tonic-gate extern int so_default_version;
6367c478bd9Sstevel@tonic-gate 
6377c478bd9Sstevel@tonic-gate #ifdef DEBUG
6387c478bd9Sstevel@tonic-gate /* Turn on extra testing capabilities */
6397c478bd9Sstevel@tonic-gate #define	SOCK_TEST
6407c478bd9Sstevel@tonic-gate #endif /* DEBUG */
6417c478bd9Sstevel@tonic-gate 
6427c478bd9Sstevel@tonic-gate #ifdef DEBUG
6437c478bd9Sstevel@tonic-gate char	*pr_state(uint_t, uint_t);
6447c478bd9Sstevel@tonic-gate char	*pr_addr(int, struct sockaddr *, t_uscalar_t);
6457c478bd9Sstevel@tonic-gate int	so_verify_oobstate(struct sonode *);
6467c478bd9Sstevel@tonic-gate #endif /* DEBUG */
6477c478bd9Sstevel@tonic-gate 
6487c478bd9Sstevel@tonic-gate /*
6497c478bd9Sstevel@tonic-gate  * DEBUG macros
6507c478bd9Sstevel@tonic-gate  */
6517c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(__lint)
6527c478bd9Sstevel@tonic-gate #define	SOCK_DEBUG
6537c478bd9Sstevel@tonic-gate 
6547c478bd9Sstevel@tonic-gate extern int sockdebug;
6557c478bd9Sstevel@tonic-gate extern int sockprinterr;
6567c478bd9Sstevel@tonic-gate 
6577c478bd9Sstevel@tonic-gate #define	eprint(args)	printf args
6587c478bd9Sstevel@tonic-gate #define	eprintso(so, args) \
6597c478bd9Sstevel@tonic-gate { if (sockprinterr && ((so)->so_options & SO_DEBUG)) printf args; }
6607c478bd9Sstevel@tonic-gate #define	eprintline(error)					\
6617c478bd9Sstevel@tonic-gate {								\
6627c478bd9Sstevel@tonic-gate 	if (error != EINTR && (sockprinterr || sockdebug > 0))	\
6637c478bd9Sstevel@tonic-gate 		printf("socket error %d: line %d file %s\n",	\
6647c478bd9Sstevel@tonic-gate 			(error), __LINE__, __FILE__);		\
6657c478bd9Sstevel@tonic-gate }
6667c478bd9Sstevel@tonic-gate 
6677c478bd9Sstevel@tonic-gate #define	eprintsoline(so, error)					\
6687c478bd9Sstevel@tonic-gate { if (sockprinterr && ((so)->so_options & SO_DEBUG))		\
6697c478bd9Sstevel@tonic-gate 	printf("socket(%p) error %d: line %d file %s\n",	\
6707c478bd9Sstevel@tonic-gate 		(so), (error), __LINE__, __FILE__);		\
6717c478bd9Sstevel@tonic-gate }
6727c478bd9Sstevel@tonic-gate #define	dprint(level, args)	{ if (sockdebug > (level)) printf args; }
6737c478bd9Sstevel@tonic-gate #define	dprintso(so, level, args) \
6747c478bd9Sstevel@tonic-gate { if (sockdebug > (level) && ((so)->so_options & SO_DEBUG)) printf args; }
6757c478bd9Sstevel@tonic-gate 
6767c478bd9Sstevel@tonic-gate #else /* define(DEBUG) && !defined(__lint) */
6777c478bd9Sstevel@tonic-gate 
6787c478bd9Sstevel@tonic-gate #define	eprint(args)		{}
6797c478bd9Sstevel@tonic-gate #define	eprintso(so, args)	{}
6807c478bd9Sstevel@tonic-gate #define	eprintline(error)	{}
6817c478bd9Sstevel@tonic-gate #define	eprintsoline(so, error)	{}
6827c478bd9Sstevel@tonic-gate #define	dprint(level, args)	{}
6837c478bd9Sstevel@tonic-gate #define	dprintso(so, level, args) {}
6847c478bd9Sstevel@tonic-gate #ifdef DEBUG
6857c478bd9Sstevel@tonic-gate #undef DEBUG
6867c478bd9Sstevel@tonic-gate #endif
6877c478bd9Sstevel@tonic-gate 
6887c478bd9Sstevel@tonic-gate #endif /* defined(DEBUG) && !defined(__lint) */
6897c478bd9Sstevel@tonic-gate 
6907c478bd9Sstevel@tonic-gate extern struct vfsops			sock_vfsops;
6917c478bd9Sstevel@tonic-gate extern struct vnodeops			*socktpi_vnodeops;
6927c478bd9Sstevel@tonic-gate extern const struct fs_operation_def	socktpi_vnodeops_template[];
6937c478bd9Sstevel@tonic-gate 
6947c478bd9Sstevel@tonic-gate extern sonodeops_t			sotpi_sonodeops;
6957c478bd9Sstevel@tonic-gate 
6967c478bd9Sstevel@tonic-gate extern dev_t				sockdev;
6977c478bd9Sstevel@tonic-gate 
6987c478bd9Sstevel@tonic-gate /*
6997c478bd9Sstevel@tonic-gate  * sockfs functions
7007c478bd9Sstevel@tonic-gate  */
7017c478bd9Sstevel@tonic-gate extern int	sock_getmsg(vnode_t *, struct strbuf *, struct strbuf *,
7027c478bd9Sstevel@tonic-gate 			uchar_t *, int *, int, rval_t *);
7037c478bd9Sstevel@tonic-gate extern int	sock_putmsg(vnode_t *, struct strbuf *, struct strbuf *,
7047c478bd9Sstevel@tonic-gate 			uchar_t, int, int);
7057c478bd9Sstevel@tonic-gate struct sonode	*sotpi_create(vnode_t *, int, int, int, int, struct sonode *,
7067c478bd9Sstevel@tonic-gate 			int *);
707*da6c28aaSamw extern int	socktpi_open(struct vnode **, int, struct cred *,
708*da6c28aaSamw 			caller_context_t *);
7097c478bd9Sstevel@tonic-gate extern int	so_sock2stream(struct sonode *);
7107c478bd9Sstevel@tonic-gate extern void	so_stream2sock(struct sonode *);
7117c478bd9Sstevel@tonic-gate extern int	sockinit(int, char *);
7127c478bd9Sstevel@tonic-gate extern struct vnode
7137c478bd9Sstevel@tonic-gate 		*makesockvp(struct vnode *, int, int, int);
7147c478bd9Sstevel@tonic-gate extern void	sockfree(struct sonode *);
7157c478bd9Sstevel@tonic-gate extern void	so_update_attrs(struct sonode *, int);
7167c478bd9Sstevel@tonic-gate extern int	soconfig(int, int, int,	char *, int);
7177c478bd9Sstevel@tonic-gate extern struct vnode
7187c478bd9Sstevel@tonic-gate 		*solookup(int, int, int, char *, int *);
7197c478bd9Sstevel@tonic-gate extern void	so_lock_single(struct sonode *);
7207c478bd9Sstevel@tonic-gate extern void	so_unlock_single(struct sonode *, int);
7217c478bd9Sstevel@tonic-gate extern int	so_lock_read(struct sonode *, int);
7227c478bd9Sstevel@tonic-gate extern int	so_lock_read_intr(struct sonode *, int);
7237c478bd9Sstevel@tonic-gate extern void	so_unlock_read(struct sonode *);
7247c478bd9Sstevel@tonic-gate extern void	*sogetoff(mblk_t *, t_uscalar_t, t_uscalar_t, uint_t);
7257c478bd9Sstevel@tonic-gate extern void	so_getopt_srcaddr(void *, t_uscalar_t,
7267c478bd9Sstevel@tonic-gate 			void **, t_uscalar_t *);
7277c478bd9Sstevel@tonic-gate extern int	so_getopt_unix_close(void *, t_uscalar_t);
7287c478bd9Sstevel@tonic-gate extern int	so_addr_verify(struct sonode *, const struct sockaddr *,
7297c478bd9Sstevel@tonic-gate 			socklen_t);
7307c478bd9Sstevel@tonic-gate extern int	so_ux_addr_xlate(struct sonode *, struct sockaddr *,
7317c478bd9Sstevel@tonic-gate 			socklen_t, int, void **, socklen_t *);
7327c478bd9Sstevel@tonic-gate extern void	fdbuf_free(struct fdbuf *);
7337c478bd9Sstevel@tonic-gate extern mblk_t	*fdbuf_allocmsg(int, struct fdbuf *);
7347c478bd9Sstevel@tonic-gate extern int	fdbuf_create(void *, int, struct fdbuf **);
7357c478bd9Sstevel@tonic-gate extern void	so_closefds(void *, t_uscalar_t, int, int);
7367c478bd9Sstevel@tonic-gate extern int	so_getfdopt(void *, t_uscalar_t, int, void **, int *);
7377c478bd9Sstevel@tonic-gate t_uscalar_t	so_optlen(void *, t_uscalar_t, int);
7387c478bd9Sstevel@tonic-gate extern void	so_cmsg2opt(void *, t_uscalar_t, int, mblk_t *);
7397c478bd9Sstevel@tonic-gate extern t_uscalar_t
7407c478bd9Sstevel@tonic-gate 		so_cmsglen(mblk_t *, void *, t_uscalar_t, int);
7417c478bd9Sstevel@tonic-gate extern int	so_opt2cmsg(mblk_t *, void *, t_uscalar_t, int,
7427c478bd9Sstevel@tonic-gate 			void *, t_uscalar_t);
7437c478bd9Sstevel@tonic-gate extern void	soisconnecting(struct sonode *);
7447c478bd9Sstevel@tonic-gate extern void	soisconnected(struct sonode *);
7457c478bd9Sstevel@tonic-gate extern void	soisdisconnected(struct sonode *, int);
7467c478bd9Sstevel@tonic-gate extern void	socantsendmore(struct sonode *);
7477c478bd9Sstevel@tonic-gate extern void	socantrcvmore(struct sonode *);
7487c478bd9Sstevel@tonic-gate extern void	soseterror(struct sonode *, int);
7497c478bd9Sstevel@tonic-gate extern int	sogeterr(struct sonode *);
7507c478bd9Sstevel@tonic-gate extern int	sogetrderr(vnode_t *, int, int *);
7517c478bd9Sstevel@tonic-gate extern int	sogetwrerr(vnode_t *, int, int *);
7527c478bd9Sstevel@tonic-gate extern void	so_unix_close(struct sonode *);
7537c478bd9Sstevel@tonic-gate extern mblk_t	*soallocproto(size_t, int);
7547c478bd9Sstevel@tonic-gate extern mblk_t	*soallocproto1(const void *, ssize_t, ssize_t, int);
7557c478bd9Sstevel@tonic-gate extern void	soappendmsg(mblk_t *, const void *, ssize_t);
7567c478bd9Sstevel@tonic-gate extern mblk_t	*soallocproto2(const void *, ssize_t, const void *, ssize_t,
7577c478bd9Sstevel@tonic-gate 			ssize_t, int);
7587c478bd9Sstevel@tonic-gate extern mblk_t	*soallocproto3(const void *, ssize_t, const void *, ssize_t,
7597c478bd9Sstevel@tonic-gate 			const void *, ssize_t, ssize_t, int);
7607c478bd9Sstevel@tonic-gate extern int	sowaitprim(struct sonode *, t_scalar_t, t_scalar_t,
7617c478bd9Sstevel@tonic-gate 			t_uscalar_t, mblk_t **, clock_t);
7627c478bd9Sstevel@tonic-gate extern int	sowaitokack(struct sonode *, t_scalar_t);
7637c478bd9Sstevel@tonic-gate extern int	sowaitack(struct sonode *, mblk_t **, clock_t);
7647c478bd9Sstevel@tonic-gate extern void	soqueueack(struct sonode *, mblk_t *);
7657c478bd9Sstevel@tonic-gate extern int	sowaitconnind(struct sonode *, int, mblk_t **);
7667c478bd9Sstevel@tonic-gate extern void	soqueueconnind(struct sonode *, mblk_t *);
7677c478bd9Sstevel@tonic-gate extern int	soflushconnind(struct sonode *, t_scalar_t);
7687c478bd9Sstevel@tonic-gate extern void	so_drain_discon_ind(struct sonode *);
7697c478bd9Sstevel@tonic-gate extern void	so_flush_discon_ind(struct sonode *);
7707c478bd9Sstevel@tonic-gate extern int	sowaitconnected(struct sonode *, int, int);
7717c478bd9Sstevel@tonic-gate 
772ff550d0eSmasputra extern int	sostream_direct(struct sonode *, struct uio *,
773ff550d0eSmasputra 		    mblk_t *, cred_t *);
7747c478bd9Sstevel@tonic-gate extern int	sosend_dgram(struct sonode *, struct sockaddr *,
7757c478bd9Sstevel@tonic-gate 		    socklen_t, struct uio *, int);
7767c478bd9Sstevel@tonic-gate extern int	sosend_svc(struct sonode *, struct uio *, t_scalar_t, int, int);
7777c478bd9Sstevel@tonic-gate extern void	so_installhooks(struct sonode *);
7787c478bd9Sstevel@tonic-gate extern int	so_strinit(struct sonode *, struct sonode *);
7797c478bd9Sstevel@tonic-gate extern int	sotpi_recvmsg(struct sonode *, struct nmsghdr *,
7807c478bd9Sstevel@tonic-gate 		    struct uio *);
7817c478bd9Sstevel@tonic-gate extern int	sotpi_getpeername(struct sonode *);
7827c478bd9Sstevel@tonic-gate extern int	sotpi_getsockopt(struct sonode *, int, int, void *,
7837c478bd9Sstevel@tonic-gate 		    socklen_t *, int);
7847c478bd9Sstevel@tonic-gate extern int	sotpi_setsockopt(struct sonode *, int, int, const void *,
7857c478bd9Sstevel@tonic-gate 		    socklen_t);
7867c478bd9Sstevel@tonic-gate extern int	socktpi_ioctl(struct vnode *, int, intptr_t, int,
787*da6c28aaSamw 		    struct cred *, int *, caller_context_t *);
7887c478bd9Sstevel@tonic-gate extern int	sodisconnect(struct sonode *, t_scalar_t, int);
7897c478bd9Sstevel@tonic-gate extern ssize_t	soreadfile(file_t *, uchar_t *, u_offset_t, int *, size_t);
7907c478bd9Sstevel@tonic-gate extern int	so_set_asyncsigs(vnode_t *, pid_t, int, int, cred_t *);
7917c478bd9Sstevel@tonic-gate extern int	so_set_events(struct sonode *, vnode_t *, cred_t *);
7927c478bd9Sstevel@tonic-gate extern int	so_flip_async(struct sonode *, vnode_t *, int, cred_t *);
7937c478bd9Sstevel@tonic-gate extern int	so_set_siggrp(struct sonode *, vnode_t *, pid_t, int, cred_t *);
7947c478bd9Sstevel@tonic-gate extern void	*sock_kstat_init(zoneid_t);
7957c478bd9Sstevel@tonic-gate extern void	sock_kstat_fini(zoneid_t, void *);
796745b2690Stz204579 extern struct sonode *getsonode(int, int *, file_t **);
7977c478bd9Sstevel@tonic-gate 
7987c478bd9Sstevel@tonic-gate /*
799*da6c28aaSamw  * Function wrappers (mostly around the sonode switch) for
8007c478bd9Sstevel@tonic-gate  * backward compatibility.
8017c478bd9Sstevel@tonic-gate  */
8027c478bd9Sstevel@tonic-gate extern int	soaccept(struct sonode *, int, struct sonode **);
8037c478bd9Sstevel@tonic-gate extern int	sobind(struct sonode *, struct sockaddr *, socklen_t,
8047c478bd9Sstevel@tonic-gate 		    int, int);
8057c478bd9Sstevel@tonic-gate extern int	solisten(struct sonode *, int);
8067c478bd9Sstevel@tonic-gate extern int	soconnect(struct sonode *, const struct sockaddr *, socklen_t,
8077c478bd9Sstevel@tonic-gate 		    int, int);
8087c478bd9Sstevel@tonic-gate extern int	sorecvmsg(struct sonode *, struct nmsghdr *, struct uio *);
8097c478bd9Sstevel@tonic-gate extern int	sosendmsg(struct sonode *, struct nmsghdr *, struct uio *);
8107c478bd9Sstevel@tonic-gate extern int	sogetpeername(struct sonode *);
8117c478bd9Sstevel@tonic-gate extern int	sogetsockname(struct sonode *);
8127c478bd9Sstevel@tonic-gate extern int	soshutdown(struct sonode *, int);
8137c478bd9Sstevel@tonic-gate extern int	sogetsockopt(struct sonode *, int, int, void *, socklen_t *,
8147c478bd9Sstevel@tonic-gate 		    int);
8157c478bd9Sstevel@tonic-gate extern int	sosetsockopt(struct sonode *, int, int, const void *,
8167c478bd9Sstevel@tonic-gate 		    t_uscalar_t);
8177c478bd9Sstevel@tonic-gate 
8187c478bd9Sstevel@tonic-gate extern struct sonode	*socreate(vnode_t *, int, int, int, int,
8197c478bd9Sstevel@tonic-gate 			    struct sonode *, int *);
8207c478bd9Sstevel@tonic-gate 
8217c478bd9Sstevel@tonic-gate extern int	so_copyin(const void *, void *, size_t, int);
8227c478bd9Sstevel@tonic-gate extern int	so_copyout(const void *, void *, size_t, int);
8237c478bd9Sstevel@tonic-gate 
824*da6c28aaSamw extern int	socktpi_access(struct vnode *, int, int, struct cred *,
825*da6c28aaSamw 		    caller_context_t *);
826*da6c28aaSamw extern int	socktpi_fid(struct vnode *, struct fid *, caller_context_t *);
827*da6c28aaSamw extern int	socktpi_fsync(struct vnode *, int, struct cred *,
828*da6c28aaSamw 		    caller_context_t *);
8297c478bd9Sstevel@tonic-gate extern int	socktpi_getattr(struct vnode *, struct vattr *, int,
830*da6c28aaSamw 		    struct cred *, caller_context_t *);
831*da6c28aaSamw extern int	socktpi_seek(struct vnode *, offset_t, offset_t *,
832*da6c28aaSamw 		    caller_context_t *);
8337c478bd9Sstevel@tonic-gate extern int	socktpi_setattr(struct vnode *, struct vattr *, int,
8347c478bd9Sstevel@tonic-gate 		    struct cred *, caller_context_t *);
835*da6c28aaSamw extern int	socktpi_setfl(vnode_t *, int, int, cred_t *,
836*da6c28aaSamw 		    caller_context_t *);
8377c478bd9Sstevel@tonic-gate 
8387c478bd9Sstevel@tonic-gate /* SCTP sockfs */
8397c478bd9Sstevel@tonic-gate extern struct sonode	*sosctp_create(vnode_t *, int, int, int, int,
8407c478bd9Sstevel@tonic-gate 			    struct sonode *, int *);
8417c478bd9Sstevel@tonic-gate extern int sosctp_init(void);
8427c478bd9Sstevel@tonic-gate 
84374e20cfeSnh145002 /* SDP sockfs */
84474e20cfeSnh145002 extern struct sonode    *sosdp_create(vnode_t *, int, int, int, int,
84574e20cfeSnh145002 			    struct sonode *, int *);
84674e20cfeSnh145002 extern int sosdp_init(void);
84774e20cfeSnh145002 
8487c478bd9Sstevel@tonic-gate #endif
8497c478bd9Sstevel@tonic-gate 
8507c478bd9Sstevel@tonic-gate /*
8517c478bd9Sstevel@tonic-gate  * Internal structure for obtaining sonode information from the socklist.
8527c478bd9Sstevel@tonic-gate  * These types match those corresponding in the sonode structure.
8537c478bd9Sstevel@tonic-gate  * This is not a published interface, and may change at any time.
8547c478bd9Sstevel@tonic-gate  */
8557c478bd9Sstevel@tonic-gate struct sockinfo {
8567c478bd9Sstevel@tonic-gate 	uint_t		si_size;		/* real length of this struct */
8577c478bd9Sstevel@tonic-gate 	short		si_family;
8587c478bd9Sstevel@tonic-gate 	short		si_type;
8597c478bd9Sstevel@tonic-gate 	ushort_t	si_flag;
8607c478bd9Sstevel@tonic-gate 	uint_t		si_state;
8617c478bd9Sstevel@tonic-gate 	uint_t		si_ux_laddr_sou_magic;
8627c478bd9Sstevel@tonic-gate 	uint_t		si_ux_faddr_sou_magic;
8637c478bd9Sstevel@tonic-gate 	t_scalar_t	si_serv_type;
8647c478bd9Sstevel@tonic-gate 	t_uscalar_t	si_laddr_soa_len;
8657c478bd9Sstevel@tonic-gate 	t_uscalar_t	si_faddr_soa_len;
8667c478bd9Sstevel@tonic-gate 	uint16_t	si_laddr_family;
8677c478bd9Sstevel@tonic-gate 	uint16_t	si_faddr_family;
8687c478bd9Sstevel@tonic-gate 	char		si_laddr_sun_path[MAXPATHLEN + 1]; /* NULL terminated */
8697c478bd9Sstevel@tonic-gate 	char		si_faddr_sun_path[MAXPATHLEN + 1];
8707c478bd9Sstevel@tonic-gate 	zoneid_t	si_szoneid;
8717c478bd9Sstevel@tonic-gate };
8727c478bd9Sstevel@tonic-gate 
8737c478bd9Sstevel@tonic-gate 
8747c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
8757c478bd9Sstevel@tonic-gate }
8767c478bd9Sstevel@tonic-gate #endif
8777c478bd9Sstevel@tonic-gate 
8787c478bd9Sstevel@tonic-gate #endif	/* _SYS_SOCKETVAR_H */
879