1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 32*7c478bd9Sstevel@tonic-gate * The Regents of the University of California 33*7c478bd9Sstevel@tonic-gate * All Rights Reserved 34*7c478bd9Sstevel@tonic-gate * 35*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 36*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 37*7c478bd9Sstevel@tonic-gate * contributors. 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifndef _SYS_SOCKETVAR_H 41*7c478bd9Sstevel@tonic-gate #define _SYS_SOCKETVAR_H 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 46*7c478bd9Sstevel@tonic-gate #include <sys/stream.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 48*7c478bd9Sstevel@tonic-gate #include <sys/cred.h> 49*7c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 50*7c478bd9Sstevel@tonic-gate #include <sys/file.h> 51*7c478bd9Sstevel@tonic-gate #include <sys/param.h> 52*7c478bd9Sstevel@tonic-gate #include <sys/zone.h> 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 55*7c478bd9Sstevel@tonic-gate extern "C" { 56*7c478bd9Sstevel@tonic-gate #endif 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate /* 61*7c478bd9Sstevel@tonic-gate * Internal representation used for addresses. 62*7c478bd9Sstevel@tonic-gate */ 63*7c478bd9Sstevel@tonic-gate struct soaddr { 64*7c478bd9Sstevel@tonic-gate struct sockaddr *soa_sa; /* Actual address */ 65*7c478bd9Sstevel@tonic-gate t_uscalar_t soa_len; /* Length in bytes for kmem_free */ 66*7c478bd9Sstevel@tonic-gate t_uscalar_t soa_maxlen; /* Allocated length */ 67*7c478bd9Sstevel@tonic-gate }; 68*7c478bd9Sstevel@tonic-gate /* Maximum size address for transports that have ADDR_size == 1 */ 69*7c478bd9Sstevel@tonic-gate #define SOA_DEFSIZE 128 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* 72*7c478bd9Sstevel@tonic-gate * Internal representation of the address used to represent addresses 73*7c478bd9Sstevel@tonic-gate * in the loopback transport for AF_UNIX. While the sockaddr_un is used 74*7c478bd9Sstevel@tonic-gate * as the sockfs layer address for AF_UNIX the pathnames contained in 75*7c478bd9Sstevel@tonic-gate * these addresses are not unique (due to relative pathnames) thus can not 76*7c478bd9Sstevel@tonic-gate * be used in the transport. 77*7c478bd9Sstevel@tonic-gate * 78*7c478bd9Sstevel@tonic-gate * The transport level address consists of a magic number (used to separate the 79*7c478bd9Sstevel@tonic-gate * name space for specific and implicit binds). For a specific bind 80*7c478bd9Sstevel@tonic-gate * this is followed by a "vnode *" which ensures that all specific binds 81*7c478bd9Sstevel@tonic-gate * have a unique transport level address. For implicit binds the latter 82*7c478bd9Sstevel@tonic-gate * part of the address is a byte string (of the same length as a pointer) 83*7c478bd9Sstevel@tonic-gate * that is assigned by the loopback transport. 84*7c478bd9Sstevel@tonic-gate * 85*7c478bd9Sstevel@tonic-gate * The uniqueness assumes that the loopback transport has a separate namespace 86*7c478bd9Sstevel@tonic-gate * for sockets in order to avoid name conflicts with e.g. TLI use of the 87*7c478bd9Sstevel@tonic-gate * same transport. 88*7c478bd9Sstevel@tonic-gate */ 89*7c478bd9Sstevel@tonic-gate struct so_ux_addr { 90*7c478bd9Sstevel@tonic-gate void *soua_vp; /* vnode pointer or assigned by tl */ 91*7c478bd9Sstevel@tonic-gate uint_t soua_magic; /* See below */ 92*7c478bd9Sstevel@tonic-gate }; 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate #define SOU_MAGIC_EXPLICIT 0x75787670 /* "uxvp" */ 95*7c478bd9Sstevel@tonic-gate #define SOU_MAGIC_IMPLICIT 0x616e6f6e /* "anon" */ 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate struct sockaddr_ux { 98*7c478bd9Sstevel@tonic-gate sa_family_t sou_family; /* AF_UNIX */ 99*7c478bd9Sstevel@tonic-gate struct so_ux_addr sou_addr; 100*7c478bd9Sstevel@tonic-gate }; 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate typedef struct sonodeops sonodeops_t; 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate /* 105*7c478bd9Sstevel@tonic-gate * The sonode represents a socket. A sonode never exist in the file system 106*7c478bd9Sstevel@tonic-gate * name space and can not be opened using open() - only the socket, socketpair 107*7c478bd9Sstevel@tonic-gate * and accept calls create sonodes. 108*7c478bd9Sstevel@tonic-gate * 109*7c478bd9Sstevel@tonic-gate * When an AF_UNIX socket is bound to a pathname the sockfs 110*7c478bd9Sstevel@tonic-gate * creates a VSOCK vnode in the underlying file system. However, the vnodeops 111*7c478bd9Sstevel@tonic-gate * etc in this VNODE remain those of the underlying file system. 112*7c478bd9Sstevel@tonic-gate * Sockfs uses the v_stream pointer in the underlying file system VSOCK node 113*7c478bd9Sstevel@tonic-gate * to find the sonode bound to the pathname. The bound pathname vnode 114*7c478bd9Sstevel@tonic-gate * is accessed through so_ux_vp. 115*7c478bd9Sstevel@tonic-gate * 116*7c478bd9Sstevel@tonic-gate * A socket always corresponds to a VCHR stream representing the transport 117*7c478bd9Sstevel@tonic-gate * provider (e.g. /dev/tcp). This information is retrieved from the kernel 118*7c478bd9Sstevel@tonic-gate * socket configuration table and entered into so_accessvp. sockfs uses 119*7c478bd9Sstevel@tonic-gate * this to perform VOP_ACCESS checks before allowing an open of the transport 120*7c478bd9Sstevel@tonic-gate * provider. 121*7c478bd9Sstevel@tonic-gate * 122*7c478bd9Sstevel@tonic-gate * The locking of sockfs uses the so_lock mutex plus the SOLOCKED 123*7c478bd9Sstevel@tonic-gate * and SOREADLOCKED flags in so_flag. The mutex protects all the state 124*7c478bd9Sstevel@tonic-gate * in the sonode. The SOLOCKED flag is used to single-thread operations from 125*7c478bd9Sstevel@tonic-gate * sockfs users to prevent e.g. multiple bind() calls to operate on the 126*7c478bd9Sstevel@tonic-gate * same sonode concurrently. The SOREADLOCKED flag is used to ensure that 127*7c478bd9Sstevel@tonic-gate * only one thread sleeps in kstrgetmsg for a given sonode. This is needed 128*7c478bd9Sstevel@tonic-gate * to ensure atomic operation for things like MSG_WAITALL. 129*7c478bd9Sstevel@tonic-gate * 130*7c478bd9Sstevel@tonic-gate * Note that so_lock is sometimes held across calls that might go to sleep 131*7c478bd9Sstevel@tonic-gate * (kmem_alloc and soallocproto*). This implies that no other lock in 132*7c478bd9Sstevel@tonic-gate * the system should be held when calling into sockfs; from the system call 133*7c478bd9Sstevel@tonic-gate * side or from strrput. If locks are held while calling into sockfs 134*7c478bd9Sstevel@tonic-gate * the system might hang when running low on memory. 135*7c478bd9Sstevel@tonic-gate */ 136*7c478bd9Sstevel@tonic-gate struct sonode { 137*7c478bd9Sstevel@tonic-gate struct vnode *so_vnode; /* vnode associated with this sonode */ 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate sonodeops_t *so_ops; /* operations vector for this sonode */ 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate /* 142*7c478bd9Sstevel@tonic-gate * These fields are initialized once. 143*7c478bd9Sstevel@tonic-gate */ 144*7c478bd9Sstevel@tonic-gate dev_t so_dev; /* device the sonode represents */ 145*7c478bd9Sstevel@tonic-gate struct vnode *so_accessvp; /* vnode for the /dev entry */ 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate /* The locks themselves */ 148*7c478bd9Sstevel@tonic-gate kmutex_t so_lock; /* protects sonode fields */ 149*7c478bd9Sstevel@tonic-gate kmutex_t so_plumb_lock; /* serializes plumbs, and the related */ 150*7c478bd9Sstevel@tonic-gate /* fields so_version and so_pushcnt */ 151*7c478bd9Sstevel@tonic-gate kcondvar_t so_state_cv; /* synchronize state changes */ 152*7c478bd9Sstevel@tonic-gate kcondvar_t so_ack_cv; /* wait for TPI acks */ 153*7c478bd9Sstevel@tonic-gate kcondvar_t so_connind_cv; /* wait for T_CONN_IND */ 154*7c478bd9Sstevel@tonic-gate kcondvar_t so_want_cv; /* wait due to SOLOCKED */ 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate /* These fields are protected by so_lock */ 157*7c478bd9Sstevel@tonic-gate uint_t so_state; /* internal state flags SS_*, below */ 158*7c478bd9Sstevel@tonic-gate uint_t so_mode; /* characteristics on socket. SM_* */ 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate mblk_t *so_ack_mp; /* TPI ack received from below */ 161*7c478bd9Sstevel@tonic-gate mblk_t *so_conn_ind_head; /* b_next list of T_CONN_IND */ 162*7c478bd9Sstevel@tonic-gate mblk_t *so_conn_ind_tail; 163*7c478bd9Sstevel@tonic-gate mblk_t *so_unbind_mp; /* Preallocated T_UNBIND_REQ message */ 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate ushort_t so_flag; /* flags, see below */ 166*7c478bd9Sstevel@tonic-gate dev_t so_fsid; /* file system identifier */ 167*7c478bd9Sstevel@tonic-gate time_t so_atime; /* time of last access */ 168*7c478bd9Sstevel@tonic-gate time_t so_mtime; /* time of last modification */ 169*7c478bd9Sstevel@tonic-gate time_t so_ctime; /* time of last attributes change */ 170*7c478bd9Sstevel@tonic-gate int so_count; /* count of opened references */ 171*7c478bd9Sstevel@tonic-gate 172*7c478bd9Sstevel@tonic-gate /* Needed to recreate the same socket for accept */ 173*7c478bd9Sstevel@tonic-gate short so_family; 174*7c478bd9Sstevel@tonic-gate short so_type; 175*7c478bd9Sstevel@tonic-gate short so_protocol; 176*7c478bd9Sstevel@tonic-gate short so_version; /* From so_socket call */ 177*7c478bd9Sstevel@tonic-gate short so_pushcnt; /* Number of modules above "sockmod" */ 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate /* Options */ 180*7c478bd9Sstevel@tonic-gate short so_options; /* From socket call, see socket.h */ 181*7c478bd9Sstevel@tonic-gate struct linger so_linger; /* SO_LINGER value */ 182*7c478bd9Sstevel@tonic-gate int so_sndbuf; /* SO_SNDBUF value */ 183*7c478bd9Sstevel@tonic-gate int so_rcvbuf; /* SO_RCVBUF value */ 184*7c478bd9Sstevel@tonic-gate int so_sndlowat; /* send low water mark */ 185*7c478bd9Sstevel@tonic-gate int so_rcvlowat; /* receive low water mark */ 186*7c478bd9Sstevel@tonic-gate #ifdef notyet 187*7c478bd9Sstevel@tonic-gate int so_sndtimeo; /* Not yet implemented */ 188*7c478bd9Sstevel@tonic-gate int so_rcvtimeo; /* Not yet implemented */ 189*7c478bd9Sstevel@tonic-gate #endif /* notyet */ 190*7c478bd9Sstevel@tonic-gate ushort_t so_error; /* error affecting connection */ 191*7c478bd9Sstevel@tonic-gate ushort_t so_delayed_error; /* From T_uderror_ind */ 192*7c478bd9Sstevel@tonic-gate int so_backlog; /* Listen backlog */ 193*7c478bd9Sstevel@tonic-gate 194*7c478bd9Sstevel@tonic-gate /* 195*7c478bd9Sstevel@tonic-gate * The counts (so_oobcnt and so_oobsigcnt) track the number of 196*7c478bd9Sstevel@tonic-gate * urgent indicates that are (logically) queued on the stream head 197*7c478bd9Sstevel@tonic-gate * read queue. The urgent data is queued on the stream head 198*7c478bd9Sstevel@tonic-gate * as follows. 199*7c478bd9Sstevel@tonic-gate * 200*7c478bd9Sstevel@tonic-gate * In the normal case the SIGURG is not generated until 201*7c478bd9Sstevel@tonic-gate * the T_EXDATA_IND arrives at the stream head. However, transports 202*7c478bd9Sstevel@tonic-gate * that have an early indication that urgent data is pending 203*7c478bd9Sstevel@tonic-gate * (e.g. TCP receiving a "new" urgent pointer value) can send up 204*7c478bd9Sstevel@tonic-gate * an M_PCPROTO/SIGURG message to generate the signal early. 205*7c478bd9Sstevel@tonic-gate * 206*7c478bd9Sstevel@tonic-gate * The mark is indicated by either: 207*7c478bd9Sstevel@tonic-gate * - a T_EXDATA_IND (with no M_DATA b_cont) with MSGMARK set. 208*7c478bd9Sstevel@tonic-gate * When this message is consumed by sorecvmsg the socket layer 209*7c478bd9Sstevel@tonic-gate * sets SS_RCVATMARK until data has been consumed past the mark. 210*7c478bd9Sstevel@tonic-gate * - a message with MSGMARKNEXT set (indicating that the 211*7c478bd9Sstevel@tonic-gate * first byte of the next message constitutes the mark). When 212*7c478bd9Sstevel@tonic-gate * the last byte of the MSGMARKNEXT message is consumed in 213*7c478bd9Sstevel@tonic-gate * the stream head the stream head sets STRATMARK. This flag 214*7c478bd9Sstevel@tonic-gate * is cleared when at least one byte is read. (Note that 215*7c478bd9Sstevel@tonic-gate * the MSGMARKNEXT messages can be of zero length when there 216*7c478bd9Sstevel@tonic-gate * is no previous data to which the marknext can be attached.) 217*7c478bd9Sstevel@tonic-gate * 218*7c478bd9Sstevel@tonic-gate * While the T_EXDATA_IND method is the common case which is used 219*7c478bd9Sstevel@tonic-gate * with all TPI transports, the MSGMARKNEXT method is needed to 220*7c478bd9Sstevel@tonic-gate * indicate the mark when e.g. the TCP urgent byte has not been 221*7c478bd9Sstevel@tonic-gate * received yet but the TCP urgent pointer has made TCP generate 222*7c478bd9Sstevel@tonic-gate * the M_PCSIG/SIGURG. 223*7c478bd9Sstevel@tonic-gate * 224*7c478bd9Sstevel@tonic-gate * The signal (the M_PCSIG carrying the SIGURG) and the mark 225*7c478bd9Sstevel@tonic-gate * indication can not be delivered as a single message, since 226*7c478bd9Sstevel@tonic-gate * the signal should be delivered as high priority and any mark 227*7c478bd9Sstevel@tonic-gate * indication must flow with the data. This implies that immediately 228*7c478bd9Sstevel@tonic-gate * when the SIGURG has been delivered if the stream head queue is 229*7c478bd9Sstevel@tonic-gate * empty it is impossible to determine if this will be the position 230*7c478bd9Sstevel@tonic-gate * of the mark. This race condition is resolved by using MSGNOTMARKNEXT 231*7c478bd9Sstevel@tonic-gate * messages and the STRNOTATMARK flag in the stream head. The 232*7c478bd9Sstevel@tonic-gate * SIOCATMARK code calls the stream head to wait for either a 233*7c478bd9Sstevel@tonic-gate * non-empty queue or one of the STR*ATMARK flags being set. 234*7c478bd9Sstevel@tonic-gate * This implies that any transport that is sending M_PCSIG(SIGURG) 235*7c478bd9Sstevel@tonic-gate * should send the appropriate MSGNOTMARKNEXT message (which can be 236*7c478bd9Sstevel@tonic-gate * zero length) after sending an M_PCSIG to prevent SIOCATMARK 237*7c478bd9Sstevel@tonic-gate * from sleeping unnecessarily. 238*7c478bd9Sstevel@tonic-gate */ 239*7c478bd9Sstevel@tonic-gate mblk_t *so_oobmsg; /* outofline oob data */ 240*7c478bd9Sstevel@tonic-gate uint_t so_oobsigcnt; /* Number of SIGURG generated */ 241*7c478bd9Sstevel@tonic-gate uint_t so_oobcnt; /* Number of T_EXDATA_IND queued */ 242*7c478bd9Sstevel@tonic-gate pid_t so_pgrp; /* pgrp for signals */ 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate /* From T_info_ack */ 245*7c478bd9Sstevel@tonic-gate t_uscalar_t so_tsdu_size; 246*7c478bd9Sstevel@tonic-gate t_uscalar_t so_etsdu_size; 247*7c478bd9Sstevel@tonic-gate t_scalar_t so_addr_size; 248*7c478bd9Sstevel@tonic-gate t_uscalar_t so_opt_size; 249*7c478bd9Sstevel@tonic-gate t_uscalar_t so_tidu_size; 250*7c478bd9Sstevel@tonic-gate t_scalar_t so_serv_type; 251*7c478bd9Sstevel@tonic-gate 252*7c478bd9Sstevel@tonic-gate /* From T_capability_ack */ 253*7c478bd9Sstevel@tonic-gate t_uscalar_t so_acceptor_id; 254*7c478bd9Sstevel@tonic-gate 255*7c478bd9Sstevel@tonic-gate /* Internal provider information */ 256*7c478bd9Sstevel@tonic-gate struct tpi_provinfo *so_provinfo; 257*7c478bd9Sstevel@tonic-gate 258*7c478bd9Sstevel@tonic-gate /* 259*7c478bd9Sstevel@tonic-gate * The local and remote addresses have multiple purposes 260*7c478bd9Sstevel@tonic-gate * but one of the key reasons for their existence and careful 261*7c478bd9Sstevel@tonic-gate * tracking in sockfs is to support getsockname and getpeername 262*7c478bd9Sstevel@tonic-gate * when the transport does not handle the TI_GET*NAME ioctls 263*7c478bd9Sstevel@tonic-gate * and caching when it does (signalled by valid bits in so_state). 264*7c478bd9Sstevel@tonic-gate * When all transports support the new TPI (with T_ADDR_REQ) 265*7c478bd9Sstevel@tonic-gate * we can revisit this code. 266*7c478bd9Sstevel@tonic-gate * The other usage of so_faddr is to keep the "connected to" 267*7c478bd9Sstevel@tonic-gate * address for datagram sockets. 268*7c478bd9Sstevel@tonic-gate * Finally, for AF_UNIX both local and remote addresses are used 269*7c478bd9Sstevel@tonic-gate * to record the sockaddr_un since we use a separate namespace 270*7c478bd9Sstevel@tonic-gate * in the loopback transport. 271*7c478bd9Sstevel@tonic-gate */ 272*7c478bd9Sstevel@tonic-gate struct soaddr so_laddr; /* Local address */ 273*7c478bd9Sstevel@tonic-gate struct soaddr so_faddr; /* Peer address */ 274*7c478bd9Sstevel@tonic-gate #define so_laddr_sa so_laddr.soa_sa 275*7c478bd9Sstevel@tonic-gate #define so_faddr_sa so_faddr.soa_sa 276*7c478bd9Sstevel@tonic-gate #define so_laddr_len so_laddr.soa_len 277*7c478bd9Sstevel@tonic-gate #define so_faddr_len so_faddr.soa_len 278*7c478bd9Sstevel@tonic-gate #define so_laddr_maxlen so_laddr.soa_maxlen 279*7c478bd9Sstevel@tonic-gate #define so_faddr_maxlen so_faddr.soa_maxlen 280*7c478bd9Sstevel@tonic-gate mblk_t *so_eaddr_mp; /* for so_delayed_error */ 281*7c478bd9Sstevel@tonic-gate 282*7c478bd9Sstevel@tonic-gate /* 283*7c478bd9Sstevel@tonic-gate * For AF_UNIX sockets: 284*7c478bd9Sstevel@tonic-gate * so_ux_laddr/faddr records the internal addresses used with the 285*7c478bd9Sstevel@tonic-gate * transport. 286*7c478bd9Sstevel@tonic-gate * so_ux_vp and v_stream->sd_vnode form the cross- 287*7c478bd9Sstevel@tonic-gate * linkage between the underlying fs vnode corresponding to 288*7c478bd9Sstevel@tonic-gate * the bound sockaddr_un and the socket node. 289*7c478bd9Sstevel@tonic-gate */ 290*7c478bd9Sstevel@tonic-gate struct so_ux_addr so_ux_laddr; /* laddr bound with the transport */ 291*7c478bd9Sstevel@tonic-gate struct so_ux_addr so_ux_faddr; /* temporary peer address */ 292*7c478bd9Sstevel@tonic-gate struct vnode *so_ux_bound_vp; /* bound AF_UNIX file system vnode */ 293*7c478bd9Sstevel@tonic-gate struct sonode *so_next; /* next sonode on socklist */ 294*7c478bd9Sstevel@tonic-gate struct sonode *so_prev; /* previous sonode on socklist */ 295*7c478bd9Sstevel@tonic-gate mblk_t *so_discon_ind_mp; /* T_DISCON_IND received from below */ 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate /* put here for delayed processing */ 298*7c478bd9Sstevel@tonic-gate void *so_priv; /* sonode private data */ 299*7c478bd9Sstevel@tonic-gate cred_t *so_peercred; /* connected socket peer cred */ 300*7c478bd9Sstevel@tonic-gate pid_t so_cpid; /* connected socket peer cached pid */ 301*7c478bd9Sstevel@tonic-gate zoneid_t so_zoneid; /* opener's zoneid */ 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate kmem_cache_t *so_cache; /* object cache of this "sonode". */ 304*7c478bd9Sstevel@tonic-gate void *so_obj; /* object to free */ 305*7c478bd9Sstevel@tonic-gate 306*7c478bd9Sstevel@tonic-gate /* 307*7c478bd9Sstevel@tonic-gate * For NL7C sockets: 308*7c478bd9Sstevel@tonic-gate * 309*7c478bd9Sstevel@tonic-gate * so_nl7c_flags the NL7C state of URL processing. 310*7c478bd9Sstevel@tonic-gate * 311*7c478bd9Sstevel@tonic-gate * so_nl7c_rcv_mp mblk_t chain of already received data to be 312*7c478bd9Sstevel@tonic-gate * passed up to the app after NL7C gives up on 313*7c478bd9Sstevel@tonic-gate * a socket. 314*7c478bd9Sstevel@tonic-gate * 315*7c478bd9Sstevel@tonic-gate * so_nl7c_rcv_rval returned rval for last mblk_t from above. 316*7c478bd9Sstevel@tonic-gate * 317*7c478bd9Sstevel@tonic-gate * so_nl7c_uri the URI currently being processed. 318*7c478bd9Sstevel@tonic-gate * 319*7c478bd9Sstevel@tonic-gate * so_nl7c_rtime URI request gethrestime_sec(). 320*7c478bd9Sstevel@tonic-gate */ 321*7c478bd9Sstevel@tonic-gate uint64_t so_nl7c_flags; 322*7c478bd9Sstevel@tonic-gate mblk_t *so_nl7c_rcv_mp; 323*7c478bd9Sstevel@tonic-gate int64_t so_nl7c_rcv_rval; 324*7c478bd9Sstevel@tonic-gate void *so_nl7c_uri; 325*7c478bd9Sstevel@tonic-gate time_t so_nl7c_rtime; 326*7c478bd9Sstevel@tonic-gate }; 327*7c478bd9Sstevel@tonic-gate 328*7c478bd9Sstevel@tonic-gate /* flags */ 329*7c478bd9Sstevel@tonic-gate #define SOMOD 0x0001 /* update socket modification time */ 330*7c478bd9Sstevel@tonic-gate #define SOACC 0x0002 /* update socket access time */ 331*7c478bd9Sstevel@tonic-gate 332*7c478bd9Sstevel@tonic-gate #define SOLOCKED 0x0010 /* use to serialize open/closes */ 333*7c478bd9Sstevel@tonic-gate #define SOREADLOCKED 0x0020 /* serialize kstrgetmsg calls */ 334*7c478bd9Sstevel@tonic-gate #define SOWANT 0x0040 /* some process waiting on lock */ 335*7c478bd9Sstevel@tonic-gate #define SOCLONE 0x0080 /* child of clone driver */ 336*7c478bd9Sstevel@tonic-gate #define SOASYNC_UNBIND 0x0100 /* wait for ACK of async unbind */ 337*7c478bd9Sstevel@tonic-gate 338*7c478bd9Sstevel@tonic-gate /* 339*7c478bd9Sstevel@tonic-gate * Socket state bits. 340*7c478bd9Sstevel@tonic-gate */ 341*7c478bd9Sstevel@tonic-gate #define SS_ISCONNECTED 0x00000001 /* socket connected to a peer */ 342*7c478bd9Sstevel@tonic-gate #define SS_ISCONNECTING 0x00000002 /* in process, connecting to peer */ 343*7c478bd9Sstevel@tonic-gate #define SS_ISDISCONNECTING 0x00000004 /* in process of disconnecting */ 344*7c478bd9Sstevel@tonic-gate #define SS_CANTSENDMORE 0x00000008 /* can't send more data to peer */ 345*7c478bd9Sstevel@tonic-gate 346*7c478bd9Sstevel@tonic-gate #define SS_CANTRCVMORE 0x00000010 /* can't receive more data */ 347*7c478bd9Sstevel@tonic-gate #define SS_ISBOUND 0x00000020 /* socket is bound */ 348*7c478bd9Sstevel@tonic-gate #define SS_NDELAY 0x00000040 /* FNDELAY non-blocking */ 349*7c478bd9Sstevel@tonic-gate #define SS_NONBLOCK 0x00000080 /* O_NONBLOCK non-blocking */ 350*7c478bd9Sstevel@tonic-gate 351*7c478bd9Sstevel@tonic-gate #define SS_ASYNC 0x00000100 /* async i/o notify */ 352*7c478bd9Sstevel@tonic-gate #define SS_ACCEPTCONN 0x00000200 /* listen done */ 353*7c478bd9Sstevel@tonic-gate #define SS_HASCONNIND 0x00000400 /* T_CONN_IND for poll */ 354*7c478bd9Sstevel@tonic-gate #define SS_SAVEDEOR 0x00000800 /* Saved MSG_EOR rcv side state */ 355*7c478bd9Sstevel@tonic-gate 356*7c478bd9Sstevel@tonic-gate #define SS_RCVATMARK 0x00001000 /* at mark on input */ 357*7c478bd9Sstevel@tonic-gate #define SS_OOBPEND 0x00002000 /* OOB pending or present - poll */ 358*7c478bd9Sstevel@tonic-gate #define SS_HAVEOOBDATA 0x00004000 /* OOB data present */ 359*7c478bd9Sstevel@tonic-gate #define SS_HADOOBDATA 0x00008000 /* OOB data consumed */ 360*7c478bd9Sstevel@tonic-gate 361*7c478bd9Sstevel@tonic-gate #define SS_FADDR_NOXLATE 0x00020000 /* No xlation of faddr for AF_UNIX */ 362*7c478bd9Sstevel@tonic-gate 363*7c478bd9Sstevel@tonic-gate #define SS_HASDATA 0x00040000 /* NCAfs: data available */ 364*7c478bd9Sstevel@tonic-gate #define SS_DONEREAD 0x00080000 /* NCAfs: all data read */ 365*7c478bd9Sstevel@tonic-gate #define SS_MOREDATA 0x00100000 /* NCAfs: NCA has more data */ 366*7c478bd9Sstevel@tonic-gate 367*7c478bd9Sstevel@tonic-gate #define SS_TCP_FAST_ACCEPT 0x00200000 /* Use TCP's accept fast-path */ 368*7c478bd9Sstevel@tonic-gate 369*7c478bd9Sstevel@tonic-gate #define SS_LADDR_VALID 0x01000000 /* so_laddr valid for user */ 370*7c478bd9Sstevel@tonic-gate #define SS_FADDR_VALID 0x02000000 /* so_faddr valid for user */ 371*7c478bd9Sstevel@tonic-gate 372*7c478bd9Sstevel@tonic-gate /* Set of states when the socket can't be rebound */ 373*7c478bd9Sstevel@tonic-gate #define SS_CANTREBIND (SS_ISCONNECTED|SS_ISCONNECTING|SS_ISDISCONNECTING|\ 374*7c478bd9Sstevel@tonic-gate SS_CANTSENDMORE|SS_CANTRCVMORE|SS_ACCEPTCONN) 375*7c478bd9Sstevel@tonic-gate 376*7c478bd9Sstevel@tonic-gate /* 377*7c478bd9Sstevel@tonic-gate * Characteristics of sockets. Not changed after the socket is created. 378*7c478bd9Sstevel@tonic-gate */ 379*7c478bd9Sstevel@tonic-gate #define SM_PRIV 0x001 /* privileged for broadcast, raw... */ 380*7c478bd9Sstevel@tonic-gate #define SM_ATOMIC 0x002 /* atomic data transmission */ 381*7c478bd9Sstevel@tonic-gate #define SM_ADDR 0x004 /* addresses given with messages */ 382*7c478bd9Sstevel@tonic-gate #define SM_CONNREQUIRED 0x008 /* connection required by protocol */ 383*7c478bd9Sstevel@tonic-gate 384*7c478bd9Sstevel@tonic-gate #define SM_FDPASSING 0x010 /* passes file descriptors */ 385*7c478bd9Sstevel@tonic-gate #define SM_EXDATA 0x020 /* Can handle T_EXDATA_REQ */ 386*7c478bd9Sstevel@tonic-gate #define SM_OPTDATA 0x040 /* Can handle T_OPTDATA_REQ */ 387*7c478bd9Sstevel@tonic-gate #define SM_BYTESTREAM 0x080 /* Byte stream - can use M_DATA */ 388*7c478bd9Sstevel@tonic-gate 389*7c478bd9Sstevel@tonic-gate #define SM_ACCEPTOR_ID 0x100 /* so_acceptor_id is valid */ 390*7c478bd9Sstevel@tonic-gate 391*7c478bd9Sstevel@tonic-gate /* 392*7c478bd9Sstevel@tonic-gate * Socket versions. Used by the socket library when calling _so_socket(). 393*7c478bd9Sstevel@tonic-gate */ 394*7c478bd9Sstevel@tonic-gate #define SOV_STREAM 0 /* Not a socket - just a stream */ 395*7c478bd9Sstevel@tonic-gate #define SOV_DEFAULT 1 /* Select based on so_default_version */ 396*7c478bd9Sstevel@tonic-gate #define SOV_SOCKSTREAM 2 /* Socket plus streams operations */ 397*7c478bd9Sstevel@tonic-gate #define SOV_SOCKBSD 3 /* Socket with no streams operations */ 398*7c478bd9Sstevel@tonic-gate #define SOV_XPG4_2 4 /* Xnet socket */ 399*7c478bd9Sstevel@tonic-gate 400*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER) 401*7c478bd9Sstevel@tonic-gate /* 402*7c478bd9Sstevel@tonic-gate * Used for mapping family/type/protocol to vnode. 403*7c478bd9Sstevel@tonic-gate * Defined here so that crash can use it. 404*7c478bd9Sstevel@tonic-gate */ 405*7c478bd9Sstevel@tonic-gate struct sockparams { 406*7c478bd9Sstevel@tonic-gate int sp_domain; 407*7c478bd9Sstevel@tonic-gate int sp_type; 408*7c478bd9Sstevel@tonic-gate int sp_protocol; 409*7c478bd9Sstevel@tonic-gate char *sp_devpath; 410*7c478bd9Sstevel@tonic-gate int sp_devpathlen; /* Is 0 if sp_devpath is a static string */ 411*7c478bd9Sstevel@tonic-gate vnode_t *sp_vnode; 412*7c478bd9Sstevel@tonic-gate struct sockparams *sp_next; 413*7c478bd9Sstevel@tonic-gate }; 414*7c478bd9Sstevel@tonic-gate 415*7c478bd9Sstevel@tonic-gate extern struct sockparams *sphead; 416*7c478bd9Sstevel@tonic-gate 417*7c478bd9Sstevel@tonic-gate /* 418*7c478bd9Sstevel@tonic-gate * Used to traverse the list of AF_UNIX sockets to construct the kstat 419*7c478bd9Sstevel@tonic-gate * for netstat(1m). 420*7c478bd9Sstevel@tonic-gate */ 421*7c478bd9Sstevel@tonic-gate struct socklist { 422*7c478bd9Sstevel@tonic-gate kmutex_t sl_lock; 423*7c478bd9Sstevel@tonic-gate struct sonode *sl_list; 424*7c478bd9Sstevel@tonic-gate }; 425*7c478bd9Sstevel@tonic-gate 426*7c478bd9Sstevel@tonic-gate extern struct socklist socklist; 427*7c478bd9Sstevel@tonic-gate /* 428*7c478bd9Sstevel@tonic-gate * ss_full_waits is the number of times the reader thread 429*7c478bd9Sstevel@tonic-gate * waits when the queue is full and ss_empty_waits is the number 430*7c478bd9Sstevel@tonic-gate * of times the consumer thread waits when the queue is empty. 431*7c478bd9Sstevel@tonic-gate * No locks for these as they are just indicators of whether 432*7c478bd9Sstevel@tonic-gate * disk or network or both is slow or fast. 433*7c478bd9Sstevel@tonic-gate */ 434*7c478bd9Sstevel@tonic-gate struct sendfile_stats { 435*7c478bd9Sstevel@tonic-gate uint32_t ss_file_cached; 436*7c478bd9Sstevel@tonic-gate uint32_t ss_file_not_cached; 437*7c478bd9Sstevel@tonic-gate uint32_t ss_full_waits; 438*7c478bd9Sstevel@tonic-gate uint32_t ss_empty_waits; 439*7c478bd9Sstevel@tonic-gate uint32_t ss_file_segmap; 440*7c478bd9Sstevel@tonic-gate }; 441*7c478bd9Sstevel@tonic-gate 442*7c478bd9Sstevel@tonic-gate /* 443*7c478bd9Sstevel@tonic-gate * A single sendfile request is represented by snf_req. 444*7c478bd9Sstevel@tonic-gate */ 445*7c478bd9Sstevel@tonic-gate typedef struct snf_req { 446*7c478bd9Sstevel@tonic-gate struct snf_req *sr_next; 447*7c478bd9Sstevel@tonic-gate mblk_t *sr_mp_head; 448*7c478bd9Sstevel@tonic-gate mblk_t *sr_mp_tail; 449*7c478bd9Sstevel@tonic-gate kmutex_t sr_lock; 450*7c478bd9Sstevel@tonic-gate kcondvar_t sr_cv; 451*7c478bd9Sstevel@tonic-gate uint_t sr_qlen; 452*7c478bd9Sstevel@tonic-gate int sr_hiwat; 453*7c478bd9Sstevel@tonic-gate int sr_lowat; 454*7c478bd9Sstevel@tonic-gate int sr_operation; 455*7c478bd9Sstevel@tonic-gate struct vnode *sr_vp; 456*7c478bd9Sstevel@tonic-gate file_t *sr_fp; 457*7c478bd9Sstevel@tonic-gate ssize_t sr_maxpsz; 458*7c478bd9Sstevel@tonic-gate u_offset_t sr_file_off; 459*7c478bd9Sstevel@tonic-gate u_offset_t sr_file_size; 460*7c478bd9Sstevel@tonic-gate #define SR_READ_DONE 0x80000000 461*7c478bd9Sstevel@tonic-gate int sr_read_error; 462*7c478bd9Sstevel@tonic-gate int sr_write_error; 463*7c478bd9Sstevel@tonic-gate } snf_req_t; 464*7c478bd9Sstevel@tonic-gate 465*7c478bd9Sstevel@tonic-gate /* A queue of sendfile requests */ 466*7c478bd9Sstevel@tonic-gate struct sendfile_queue { 467*7c478bd9Sstevel@tonic-gate snf_req_t *snfq_req_head; 468*7c478bd9Sstevel@tonic-gate snf_req_t *snfq_req_tail; 469*7c478bd9Sstevel@tonic-gate kmutex_t snfq_lock; 470*7c478bd9Sstevel@tonic-gate kcondvar_t snfq_cv; 471*7c478bd9Sstevel@tonic-gate int snfq_svc_threads; /* # of service threads */ 472*7c478bd9Sstevel@tonic-gate int snfq_idle_cnt; /* # of idling threads */ 473*7c478bd9Sstevel@tonic-gate int snfq_max_threads; 474*7c478bd9Sstevel@tonic-gate int snfq_req_cnt; /* Number of requests */ 475*7c478bd9Sstevel@tonic-gate }; 476*7c478bd9Sstevel@tonic-gate 477*7c478bd9Sstevel@tonic-gate #define READ_OP 1 478*7c478bd9Sstevel@tonic-gate #define SNFQ_TIMEOUT (60 * 5 * hz) /* 5 minutes */ 479*7c478bd9Sstevel@tonic-gate 480*7c478bd9Sstevel@tonic-gate /* Socket network operations switch */ 481*7c478bd9Sstevel@tonic-gate struct sonodeops { 482*7c478bd9Sstevel@tonic-gate int (*sop_accept)(struct sonode *, int, struct sonode **); 483*7c478bd9Sstevel@tonic-gate int (*sop_bind)(struct sonode *, struct sockaddr *, socklen_t, 484*7c478bd9Sstevel@tonic-gate int); 485*7c478bd9Sstevel@tonic-gate int (*sop_listen)(struct sonode *, int); 486*7c478bd9Sstevel@tonic-gate int (*sop_connect)(struct sonode *, const struct sockaddr *, 487*7c478bd9Sstevel@tonic-gate socklen_t, int, int); 488*7c478bd9Sstevel@tonic-gate int (*sop_recvmsg)(struct sonode *, struct msghdr *, 489*7c478bd9Sstevel@tonic-gate struct uio *); 490*7c478bd9Sstevel@tonic-gate int (*sop_sendmsg)(struct sonode *, struct msghdr *, 491*7c478bd9Sstevel@tonic-gate struct uio *); 492*7c478bd9Sstevel@tonic-gate int (*sop_getpeername)(struct sonode *); 493*7c478bd9Sstevel@tonic-gate int (*sop_getsockname)(struct sonode *); 494*7c478bd9Sstevel@tonic-gate int (*sop_shutdown)(struct sonode *, int); 495*7c478bd9Sstevel@tonic-gate int (*sop_getsockopt)(struct sonode *, int, int, void *, 496*7c478bd9Sstevel@tonic-gate socklen_t *, int); 497*7c478bd9Sstevel@tonic-gate int (*sop_setsockopt)(struct sonode *, int, int, const void *, 498*7c478bd9Sstevel@tonic-gate socklen_t); 499*7c478bd9Sstevel@tonic-gate }; 500*7c478bd9Sstevel@tonic-gate 501*7c478bd9Sstevel@tonic-gate #define SOP_ACCEPT(so, fflag, nsop) \ 502*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_accept((so), (fflag), (nsop))) 503*7c478bd9Sstevel@tonic-gate #define SOP_BIND(so, name, namelen, flags) \ 504*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_bind((so), (name), (namelen), (flags))) 505*7c478bd9Sstevel@tonic-gate #define SOP_LISTEN(so, backlog) \ 506*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_listen((so), (backlog))) 507*7c478bd9Sstevel@tonic-gate #define SOP_CONNECT(so, name, namelen, fflag, flags) \ 508*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_connect((so), (name), (namelen), (fflag), (flags))) 509*7c478bd9Sstevel@tonic-gate #define SOP_RECVMSG(so, msg, uiop) \ 510*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_recvmsg((so), (msg), (uiop))) 511*7c478bd9Sstevel@tonic-gate #define SOP_SENDMSG(so, msg, uiop) \ 512*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_sendmsg((so), (msg), (uiop))) 513*7c478bd9Sstevel@tonic-gate #define SOP_GETPEERNAME(so) \ 514*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_getpeername((so))) 515*7c478bd9Sstevel@tonic-gate #define SOP_GETSOCKNAME(so) \ 516*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_getsockname((so))) 517*7c478bd9Sstevel@tonic-gate #define SOP_SHUTDOWN(so, how) \ 518*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_shutdown((so), (how))) 519*7c478bd9Sstevel@tonic-gate #define SOP_GETSOCKOPT(so, level, optionname, optval, optlenp, flags) \ 520*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_getsockopt((so), (level), (optionname), \ 521*7c478bd9Sstevel@tonic-gate (optval), (optlenp), (flags))) 522*7c478bd9Sstevel@tonic-gate #define SOP_SETSOCKOPT(so, level, optionname, optval, optlen) \ 523*7c478bd9Sstevel@tonic-gate ((so)->so_ops->sop_setsockopt((so), (level), (optionname), \ 524*7c478bd9Sstevel@tonic-gate (optval), (optlen))) 525*7c478bd9Sstevel@tonic-gate 526*7c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) || defined(_KMEMUSER) */ 527*7c478bd9Sstevel@tonic-gate 528*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 529*7c478bd9Sstevel@tonic-gate 530*7c478bd9Sstevel@tonic-gate #define ISALIGNED_cmsghdr(addr) \ 531*7c478bd9Sstevel@tonic-gate (((uintptr_t)(addr) & (_CMSG_HDR_ALIGNMENT - 1)) == 0) 532*7c478bd9Sstevel@tonic-gate 533*7c478bd9Sstevel@tonic-gate #define ROUNDUP_cmsglen(len) \ 534*7c478bd9Sstevel@tonic-gate (((len) + _CMSG_HDR_ALIGNMENT - 1) & ~(_CMSG_HDR_ALIGNMENT - 1)) 535*7c478bd9Sstevel@tonic-gate 536*7c478bd9Sstevel@tonic-gate /* 537*7c478bd9Sstevel@tonic-gate * Used in parsing msg_control 538*7c478bd9Sstevel@tonic-gate */ 539*7c478bd9Sstevel@tonic-gate #define CMSG_NEXT(cmsg) \ 540*7c478bd9Sstevel@tonic-gate (struct cmsghdr *)((uintptr_t)(cmsg) + \ 541*7c478bd9Sstevel@tonic-gate ROUNDUP_cmsglen((cmsg)->cmsg_len)) 542*7c478bd9Sstevel@tonic-gate 543*7c478bd9Sstevel@tonic-gate /* 544*7c478bd9Sstevel@tonic-gate * Maximum size of any argument that is copied in (addresses, options, 545*7c478bd9Sstevel@tonic-gate * access rights). MUST be at least MAXPATHLEN + 3. 546*7c478bd9Sstevel@tonic-gate * BSD and SunOS 4.X limited this to MLEN or MCLBYTES. 547*7c478bd9Sstevel@tonic-gate */ 548*7c478bd9Sstevel@tonic-gate #define SO_MAXARGSIZE 8192 549*7c478bd9Sstevel@tonic-gate 550*7c478bd9Sstevel@tonic-gate /* 551*7c478bd9Sstevel@tonic-gate * Convert between vnode and sonode 552*7c478bd9Sstevel@tonic-gate */ 553*7c478bd9Sstevel@tonic-gate #define VTOSO(vp) ((struct sonode *)((vp)->v_data)) 554*7c478bd9Sstevel@tonic-gate #define SOTOV(sp) ((sp)->so_vnode) 555*7c478bd9Sstevel@tonic-gate 556*7c478bd9Sstevel@tonic-gate /* 557*7c478bd9Sstevel@tonic-gate * Internal flags for sobind() 558*7c478bd9Sstevel@tonic-gate */ 559*7c478bd9Sstevel@tonic-gate #define _SOBIND_REBIND 0x01 /* Bind to existing local address */ 560*7c478bd9Sstevel@tonic-gate #define _SOBIND_UNSPEC 0x02 /* Bind to unspecified address */ 561*7c478bd9Sstevel@tonic-gate #define _SOBIND_LOCK_HELD 0x04 /* so_excl_lock held by caller */ 562*7c478bd9Sstevel@tonic-gate #define _SOBIND_NOXLATE 0x08 /* No addr translation for AF_UNIX */ 563*7c478bd9Sstevel@tonic-gate #define _SOBIND_XPG4_2 0x10 /* xpg4.2 semantics */ 564*7c478bd9Sstevel@tonic-gate #define _SOBIND_SOCKBSD 0x20 /* BSD semantics */ 565*7c478bd9Sstevel@tonic-gate #define _SOBIND_LISTEN 0x40 /* Make into SS_ACCEPTCONN */ 566*7c478bd9Sstevel@tonic-gate #define _SOBIND_SOCKETPAIR 0x80 /* Internal flag for so_socketpair() */ 567*7c478bd9Sstevel@tonic-gate /* to enable listen with backlog = 1 */ 568*7c478bd9Sstevel@tonic-gate 569*7c478bd9Sstevel@tonic-gate /* 570*7c478bd9Sstevel@tonic-gate * Internal flags for sounbind() 571*7c478bd9Sstevel@tonic-gate */ 572*7c478bd9Sstevel@tonic-gate #define _SOUNBIND_REBIND 0x01 /* Don't clear fields - will rebind */ 573*7c478bd9Sstevel@tonic-gate 574*7c478bd9Sstevel@tonic-gate /* 575*7c478bd9Sstevel@tonic-gate * Internal flags for soconnect() 576*7c478bd9Sstevel@tonic-gate */ 577*7c478bd9Sstevel@tonic-gate #define _SOCONNECT_NOXLATE 0x01 /* No addr translation for AF_UNIX */ 578*7c478bd9Sstevel@tonic-gate #define _SOCONNECT_DID_BIND 0x02 /* Unbind when connect fails */ 579*7c478bd9Sstevel@tonic-gate #define _SOCONNECT_XPG4_2 0x04 /* xpg4.2 semantics */ 580*7c478bd9Sstevel@tonic-gate 581*7c478bd9Sstevel@tonic-gate /* 582*7c478bd9Sstevel@tonic-gate * Internal flags for sodisconnect() 583*7c478bd9Sstevel@tonic-gate */ 584*7c478bd9Sstevel@tonic-gate #define _SODISCONNECT_LOCK_HELD 0x01 /* so_excl_lock held by caller */ 585*7c478bd9Sstevel@tonic-gate 586*7c478bd9Sstevel@tonic-gate /* 587*7c478bd9Sstevel@tonic-gate * Internal flags for sotpi_getsockopt(). 588*7c478bd9Sstevel@tonic-gate */ 589*7c478bd9Sstevel@tonic-gate #define _SOGETSOCKOPT_XPG4_2 0x01 /* xpg4.2 semantics */ 590*7c478bd9Sstevel@tonic-gate 591*7c478bd9Sstevel@tonic-gate /* 592*7c478bd9Sstevel@tonic-gate * Internal flags for soallocproto*() 593*7c478bd9Sstevel@tonic-gate */ 594*7c478bd9Sstevel@tonic-gate #define _ALLOC_NOSLEEP 0 /* Don't sleep for memory */ 595*7c478bd9Sstevel@tonic-gate #define _ALLOC_INTR 1 /* Sleep until interrupt */ 596*7c478bd9Sstevel@tonic-gate #define _ALLOC_SLEEP 2 /* Sleep forever */ 597*7c478bd9Sstevel@tonic-gate 598*7c478bd9Sstevel@tonic-gate /* 599*7c478bd9Sstevel@tonic-gate * Internal structure for handling AF_UNIX file descriptor passing 600*7c478bd9Sstevel@tonic-gate */ 601*7c478bd9Sstevel@tonic-gate struct fdbuf { 602*7c478bd9Sstevel@tonic-gate int fd_size; /* In bytes, for kmem_free */ 603*7c478bd9Sstevel@tonic-gate int fd_numfd; /* Number of elements below */ 604*7c478bd9Sstevel@tonic-gate char *fd_ebuf; /* Extra buffer to free */ 605*7c478bd9Sstevel@tonic-gate int fd_ebuflen; 606*7c478bd9Sstevel@tonic-gate frtn_t fd_frtn; 607*7c478bd9Sstevel@tonic-gate struct file *fd_fds[1]; /* One or more */ 608*7c478bd9Sstevel@tonic-gate }; 609*7c478bd9Sstevel@tonic-gate #define FDBUF_HDRSIZE (sizeof (struct fdbuf) - sizeof (struct file *)) 610*7c478bd9Sstevel@tonic-gate 611*7c478bd9Sstevel@tonic-gate /* 612*7c478bd9Sstevel@tonic-gate * Variable that can be patched to set what version of socket socket() 613*7c478bd9Sstevel@tonic-gate * will create. 614*7c478bd9Sstevel@tonic-gate */ 615*7c478bd9Sstevel@tonic-gate extern int so_default_version; 616*7c478bd9Sstevel@tonic-gate 617*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 618*7c478bd9Sstevel@tonic-gate /* Turn on extra testing capabilities */ 619*7c478bd9Sstevel@tonic-gate #define SOCK_TEST 620*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 621*7c478bd9Sstevel@tonic-gate 622*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 623*7c478bd9Sstevel@tonic-gate char *pr_state(uint_t, uint_t); 624*7c478bd9Sstevel@tonic-gate char *pr_addr(int, struct sockaddr *, t_uscalar_t); 625*7c478bd9Sstevel@tonic-gate int so_verify_oobstate(struct sonode *); 626*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 627*7c478bd9Sstevel@tonic-gate 628*7c478bd9Sstevel@tonic-gate /* 629*7c478bd9Sstevel@tonic-gate * DEBUG macros 630*7c478bd9Sstevel@tonic-gate */ 631*7c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(__lint) 632*7c478bd9Sstevel@tonic-gate #define SOCK_DEBUG 633*7c478bd9Sstevel@tonic-gate 634*7c478bd9Sstevel@tonic-gate extern int sockdebug; 635*7c478bd9Sstevel@tonic-gate extern int sockprinterr; 636*7c478bd9Sstevel@tonic-gate 637*7c478bd9Sstevel@tonic-gate #define eprint(args) printf args 638*7c478bd9Sstevel@tonic-gate #define eprintso(so, args) \ 639*7c478bd9Sstevel@tonic-gate { if (sockprinterr && ((so)->so_options & SO_DEBUG)) printf args; } 640*7c478bd9Sstevel@tonic-gate #define eprintline(error) \ 641*7c478bd9Sstevel@tonic-gate { \ 642*7c478bd9Sstevel@tonic-gate if (error != EINTR && (sockprinterr || sockdebug > 0)) \ 643*7c478bd9Sstevel@tonic-gate printf("socket error %d: line %d file %s\n", \ 644*7c478bd9Sstevel@tonic-gate (error), __LINE__, __FILE__); \ 645*7c478bd9Sstevel@tonic-gate } 646*7c478bd9Sstevel@tonic-gate 647*7c478bd9Sstevel@tonic-gate #define eprintsoline(so, error) \ 648*7c478bd9Sstevel@tonic-gate { if (sockprinterr && ((so)->so_options & SO_DEBUG)) \ 649*7c478bd9Sstevel@tonic-gate printf("socket(%p) error %d: line %d file %s\n", \ 650*7c478bd9Sstevel@tonic-gate (so), (error), __LINE__, __FILE__); \ 651*7c478bd9Sstevel@tonic-gate } 652*7c478bd9Sstevel@tonic-gate #define dprint(level, args) { if (sockdebug > (level)) printf args; } 653*7c478bd9Sstevel@tonic-gate #define dprintso(so, level, args) \ 654*7c478bd9Sstevel@tonic-gate { if (sockdebug > (level) && ((so)->so_options & SO_DEBUG)) printf args; } 655*7c478bd9Sstevel@tonic-gate 656*7c478bd9Sstevel@tonic-gate #else /* define(DEBUG) && !defined(__lint) */ 657*7c478bd9Sstevel@tonic-gate 658*7c478bd9Sstevel@tonic-gate #define eprint(args) {} 659*7c478bd9Sstevel@tonic-gate #define eprintso(so, args) {} 660*7c478bd9Sstevel@tonic-gate #define eprintline(error) {} 661*7c478bd9Sstevel@tonic-gate #define eprintsoline(so, error) {} 662*7c478bd9Sstevel@tonic-gate #define dprint(level, args) {} 663*7c478bd9Sstevel@tonic-gate #define dprintso(so, level, args) {} 664*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 665*7c478bd9Sstevel@tonic-gate #undef DEBUG 666*7c478bd9Sstevel@tonic-gate #endif 667*7c478bd9Sstevel@tonic-gate 668*7c478bd9Sstevel@tonic-gate #endif /* defined(DEBUG) && !defined(__lint) */ 669*7c478bd9Sstevel@tonic-gate 670*7c478bd9Sstevel@tonic-gate extern struct vfsops sock_vfsops; 671*7c478bd9Sstevel@tonic-gate extern struct vnodeops *socktpi_vnodeops; 672*7c478bd9Sstevel@tonic-gate extern const struct fs_operation_def socktpi_vnodeops_template[]; 673*7c478bd9Sstevel@tonic-gate 674*7c478bd9Sstevel@tonic-gate extern sonodeops_t sotpi_sonodeops; 675*7c478bd9Sstevel@tonic-gate 676*7c478bd9Sstevel@tonic-gate extern dev_t sockdev; 677*7c478bd9Sstevel@tonic-gate 678*7c478bd9Sstevel@tonic-gate /* NCAfs symbols */ 679*7c478bd9Sstevel@tonic-gate 680*7c478bd9Sstevel@tonic-gate extern int socknca_read(struct vnode *, struct uio *, int, struct cred *, 681*7c478bd9Sstevel@tonic-gate struct caller_context *); 682*7c478bd9Sstevel@tonic-gate extern int socknca_write(struct vnode *, struct uio *, int, struct cred *, 683*7c478bd9Sstevel@tonic-gate struct caller_context *); 684*7c478bd9Sstevel@tonic-gate extern int socknca_ioctl(struct vnode *, int, intptr_t, int, 685*7c478bd9Sstevel@tonic-gate struct cred *, int *); 686*7c478bd9Sstevel@tonic-gate extern int nca_poll(struct vnode *, short, int, short *, 687*7c478bd9Sstevel@tonic-gate struct pollhead **); 688*7c478bd9Sstevel@tonic-gate extern int socknca_close(struct vnode *, int, int, offset_t, 689*7c478bd9Sstevel@tonic-gate struct cred *); 690*7c478bd9Sstevel@tonic-gate extern void socknca_inactive(struct vnode *, struct cred *); 691*7c478bd9Sstevel@tonic-gate 692*7c478bd9Sstevel@tonic-gate extern const struct fs_operation_def socknca_vnodeops_template[]; 693*7c478bd9Sstevel@tonic-gate extern struct vnodeops *socknca_vnodeops; 694*7c478bd9Sstevel@tonic-gate 695*7c478bd9Sstevel@tonic-gate extern void sonca_init(void); 696*7c478bd9Sstevel@tonic-gate extern struct sonode *sonca_create(vnode_t *, int, int, int, int, 697*7c478bd9Sstevel@tonic-gate struct sonode *, int *); 698*7c478bd9Sstevel@tonic-gate 699*7c478bd9Sstevel@tonic-gate /* 700*7c478bd9Sstevel@tonic-gate * sockfs functions 701*7c478bd9Sstevel@tonic-gate */ 702*7c478bd9Sstevel@tonic-gate extern int sock_getmsg(vnode_t *, struct strbuf *, struct strbuf *, 703*7c478bd9Sstevel@tonic-gate uchar_t *, int *, int, rval_t *); 704*7c478bd9Sstevel@tonic-gate extern int sock_putmsg(vnode_t *, struct strbuf *, struct strbuf *, 705*7c478bd9Sstevel@tonic-gate uchar_t, int, int); 706*7c478bd9Sstevel@tonic-gate struct sonode *sotpi_create(vnode_t *, int, int, int, int, struct sonode *, 707*7c478bd9Sstevel@tonic-gate int *); 708*7c478bd9Sstevel@tonic-gate extern int socktpi_open(struct vnode **, int, struct cred *); 709*7c478bd9Sstevel@tonic-gate extern int so_sock2stream(struct sonode *); 710*7c478bd9Sstevel@tonic-gate extern void so_stream2sock(struct sonode *); 711*7c478bd9Sstevel@tonic-gate extern int sockinit(int, char *); 712*7c478bd9Sstevel@tonic-gate extern struct vnode 713*7c478bd9Sstevel@tonic-gate *makesockvp(struct vnode *, int, int, int); 714*7c478bd9Sstevel@tonic-gate extern void sockfree(struct sonode *); 715*7c478bd9Sstevel@tonic-gate extern void so_update_attrs(struct sonode *, int); 716*7c478bd9Sstevel@tonic-gate extern int soconfig(int, int, int, char *, int); 717*7c478bd9Sstevel@tonic-gate extern struct vnode 718*7c478bd9Sstevel@tonic-gate *solookup(int, int, int, char *, int *); 719*7c478bd9Sstevel@tonic-gate extern void so_lock_single(struct sonode *); 720*7c478bd9Sstevel@tonic-gate extern void so_unlock_single(struct sonode *, int); 721*7c478bd9Sstevel@tonic-gate extern int so_lock_read(struct sonode *, int); 722*7c478bd9Sstevel@tonic-gate extern int so_lock_read_intr(struct sonode *, int); 723*7c478bd9Sstevel@tonic-gate extern void so_unlock_read(struct sonode *); 724*7c478bd9Sstevel@tonic-gate extern void *sogetoff(mblk_t *, t_uscalar_t, t_uscalar_t, uint_t); 725*7c478bd9Sstevel@tonic-gate extern void so_getopt_srcaddr(void *, t_uscalar_t, 726*7c478bd9Sstevel@tonic-gate void **, t_uscalar_t *); 727*7c478bd9Sstevel@tonic-gate extern int so_getopt_unix_close(void *, t_uscalar_t); 728*7c478bd9Sstevel@tonic-gate extern int so_addr_verify(struct sonode *, const struct sockaddr *, 729*7c478bd9Sstevel@tonic-gate socklen_t); 730*7c478bd9Sstevel@tonic-gate extern int so_ux_addr_xlate(struct sonode *, struct sockaddr *, 731*7c478bd9Sstevel@tonic-gate socklen_t, int, void **, socklen_t *); 732*7c478bd9Sstevel@tonic-gate extern void fdbuf_free(struct fdbuf *); 733*7c478bd9Sstevel@tonic-gate extern mblk_t *fdbuf_allocmsg(int, struct fdbuf *); 734*7c478bd9Sstevel@tonic-gate extern int fdbuf_create(void *, int, struct fdbuf **); 735*7c478bd9Sstevel@tonic-gate extern void so_closefds(void *, t_uscalar_t, int, int); 736*7c478bd9Sstevel@tonic-gate extern int so_getfdopt(void *, t_uscalar_t, int, void **, int *); 737*7c478bd9Sstevel@tonic-gate t_uscalar_t so_optlen(void *, t_uscalar_t, int); 738*7c478bd9Sstevel@tonic-gate extern void so_cmsg2opt(void *, t_uscalar_t, int, mblk_t *); 739*7c478bd9Sstevel@tonic-gate extern t_uscalar_t 740*7c478bd9Sstevel@tonic-gate so_cmsglen(mblk_t *, void *, t_uscalar_t, int); 741*7c478bd9Sstevel@tonic-gate extern int so_opt2cmsg(mblk_t *, void *, t_uscalar_t, int, 742*7c478bd9Sstevel@tonic-gate void *, t_uscalar_t); 743*7c478bd9Sstevel@tonic-gate extern void soisconnecting(struct sonode *); 744*7c478bd9Sstevel@tonic-gate extern void soisconnected(struct sonode *); 745*7c478bd9Sstevel@tonic-gate extern void soisdisconnected(struct sonode *, int); 746*7c478bd9Sstevel@tonic-gate extern void socantsendmore(struct sonode *); 747*7c478bd9Sstevel@tonic-gate extern void socantrcvmore(struct sonode *); 748*7c478bd9Sstevel@tonic-gate extern void soseterror(struct sonode *, int); 749*7c478bd9Sstevel@tonic-gate extern int sogeterr(struct sonode *); 750*7c478bd9Sstevel@tonic-gate extern int sogetrderr(vnode_t *, int, int *); 751*7c478bd9Sstevel@tonic-gate extern int sogetwrerr(vnode_t *, int, int *); 752*7c478bd9Sstevel@tonic-gate extern void so_unix_close(struct sonode *); 753*7c478bd9Sstevel@tonic-gate extern mblk_t *soallocproto(size_t, int); 754*7c478bd9Sstevel@tonic-gate extern mblk_t *soallocproto1(const void *, ssize_t, ssize_t, int); 755*7c478bd9Sstevel@tonic-gate extern void soappendmsg(mblk_t *, const void *, ssize_t); 756*7c478bd9Sstevel@tonic-gate extern mblk_t *soallocproto2(const void *, ssize_t, const void *, ssize_t, 757*7c478bd9Sstevel@tonic-gate ssize_t, int); 758*7c478bd9Sstevel@tonic-gate extern mblk_t *soallocproto3(const void *, ssize_t, const void *, ssize_t, 759*7c478bd9Sstevel@tonic-gate const void *, ssize_t, ssize_t, int); 760*7c478bd9Sstevel@tonic-gate extern int sowaitprim(struct sonode *, t_scalar_t, t_scalar_t, 761*7c478bd9Sstevel@tonic-gate t_uscalar_t, mblk_t **, clock_t); 762*7c478bd9Sstevel@tonic-gate extern int sowaitokack(struct sonode *, t_scalar_t); 763*7c478bd9Sstevel@tonic-gate extern int sowaitack(struct sonode *, mblk_t **, clock_t); 764*7c478bd9Sstevel@tonic-gate extern void soqueueack(struct sonode *, mblk_t *); 765*7c478bd9Sstevel@tonic-gate extern int sowaitconnind(struct sonode *, int, mblk_t **); 766*7c478bd9Sstevel@tonic-gate extern void soqueueconnind(struct sonode *, mblk_t *); 767*7c478bd9Sstevel@tonic-gate extern int soflushconnind(struct sonode *, t_scalar_t); 768*7c478bd9Sstevel@tonic-gate extern void so_drain_discon_ind(struct sonode *); 769*7c478bd9Sstevel@tonic-gate extern void so_flush_discon_ind(struct sonode *); 770*7c478bd9Sstevel@tonic-gate extern int sowaitconnected(struct sonode *, int, int); 771*7c478bd9Sstevel@tonic-gate 772*7c478bd9Sstevel@tonic-gate extern int sosend_dgram(struct sonode *, struct sockaddr *, 773*7c478bd9Sstevel@tonic-gate socklen_t, struct uio *, int); 774*7c478bd9Sstevel@tonic-gate extern int sosend_svc(struct sonode *, struct uio *, t_scalar_t, int, int); 775*7c478bd9Sstevel@tonic-gate extern void so_installhooks(struct sonode *); 776*7c478bd9Sstevel@tonic-gate extern int so_strinit(struct sonode *, struct sonode *); 777*7c478bd9Sstevel@tonic-gate extern int sotpi_recvmsg(struct sonode *, struct nmsghdr *, 778*7c478bd9Sstevel@tonic-gate struct uio *); 779*7c478bd9Sstevel@tonic-gate extern int sotpi_getpeername(struct sonode *); 780*7c478bd9Sstevel@tonic-gate extern int sotpi_getsockopt(struct sonode *, int, int, void *, 781*7c478bd9Sstevel@tonic-gate socklen_t *, int); 782*7c478bd9Sstevel@tonic-gate extern int sotpi_setsockopt(struct sonode *, int, int, const void *, 783*7c478bd9Sstevel@tonic-gate socklen_t); 784*7c478bd9Sstevel@tonic-gate extern int socktpi_ioctl(struct vnode *, int, intptr_t, int, 785*7c478bd9Sstevel@tonic-gate struct cred *, int *); 786*7c478bd9Sstevel@tonic-gate extern int sodisconnect(struct sonode *, t_scalar_t, int); 787*7c478bd9Sstevel@tonic-gate extern ssize_t soreadfile(file_t *, uchar_t *, u_offset_t, int *, size_t); 788*7c478bd9Sstevel@tonic-gate extern int so_set_asyncsigs(vnode_t *, pid_t, int, int, cred_t *); 789*7c478bd9Sstevel@tonic-gate extern int so_set_events(struct sonode *, vnode_t *, cred_t *); 790*7c478bd9Sstevel@tonic-gate extern int so_flip_async(struct sonode *, vnode_t *, int, cred_t *); 791*7c478bd9Sstevel@tonic-gate extern int so_set_siggrp(struct sonode *, vnode_t *, pid_t, int, cred_t *); 792*7c478bd9Sstevel@tonic-gate extern void *sock_kstat_init(zoneid_t); 793*7c478bd9Sstevel@tonic-gate extern void sock_kstat_fini(zoneid_t, void *); 794*7c478bd9Sstevel@tonic-gate 795*7c478bd9Sstevel@tonic-gate /* 796*7c478bd9Sstevel@tonic-gate * Function wrappers (mostly arround the sonode switch) for 797*7c478bd9Sstevel@tonic-gate * backward compatibility. 798*7c478bd9Sstevel@tonic-gate */ 799*7c478bd9Sstevel@tonic-gate extern int soaccept(struct sonode *, int, struct sonode **); 800*7c478bd9Sstevel@tonic-gate extern int sobind(struct sonode *, struct sockaddr *, socklen_t, 801*7c478bd9Sstevel@tonic-gate int, int); 802*7c478bd9Sstevel@tonic-gate extern int solisten(struct sonode *, int); 803*7c478bd9Sstevel@tonic-gate extern int soconnect(struct sonode *, const struct sockaddr *, socklen_t, 804*7c478bd9Sstevel@tonic-gate int, int); 805*7c478bd9Sstevel@tonic-gate extern int sorecvmsg(struct sonode *, struct nmsghdr *, struct uio *); 806*7c478bd9Sstevel@tonic-gate extern int sosendmsg(struct sonode *, struct nmsghdr *, struct uio *); 807*7c478bd9Sstevel@tonic-gate extern int sogetpeername(struct sonode *); 808*7c478bd9Sstevel@tonic-gate extern int sogetsockname(struct sonode *); 809*7c478bd9Sstevel@tonic-gate extern int soshutdown(struct sonode *, int); 810*7c478bd9Sstevel@tonic-gate extern int sogetsockopt(struct sonode *, int, int, void *, socklen_t *, 811*7c478bd9Sstevel@tonic-gate int); 812*7c478bd9Sstevel@tonic-gate extern int sosetsockopt(struct sonode *, int, int, const void *, 813*7c478bd9Sstevel@tonic-gate t_uscalar_t); 814*7c478bd9Sstevel@tonic-gate 815*7c478bd9Sstevel@tonic-gate extern struct sonode *socreate(vnode_t *, int, int, int, int, 816*7c478bd9Sstevel@tonic-gate struct sonode *, int *); 817*7c478bd9Sstevel@tonic-gate 818*7c478bd9Sstevel@tonic-gate extern int so_copyin(const void *, void *, size_t, int); 819*7c478bd9Sstevel@tonic-gate extern int so_copyout(const void *, void *, size_t, int); 820*7c478bd9Sstevel@tonic-gate 821*7c478bd9Sstevel@tonic-gate extern int socktpi_access(struct vnode *, int, int, struct cred *); 822*7c478bd9Sstevel@tonic-gate extern int socktpi_fid(struct vnode *, struct fid *); 823*7c478bd9Sstevel@tonic-gate extern int socktpi_fsync(struct vnode *, int, struct cred *); 824*7c478bd9Sstevel@tonic-gate extern int socktpi_getattr(struct vnode *, struct vattr *, int, 825*7c478bd9Sstevel@tonic-gate struct cred *); 826*7c478bd9Sstevel@tonic-gate extern int socktpi_seek(struct vnode *, offset_t, offset_t *); 827*7c478bd9Sstevel@tonic-gate extern int socktpi_setattr(struct vnode *, struct vattr *, int, 828*7c478bd9Sstevel@tonic-gate struct cred *, caller_context_t *); 829*7c478bd9Sstevel@tonic-gate extern int socktpi_setfl(vnode_t *, int, int, cred_t *); 830*7c478bd9Sstevel@tonic-gate 831*7c478bd9Sstevel@tonic-gate /* SCTP sockfs */ 832*7c478bd9Sstevel@tonic-gate extern struct sonode *sosctp_create(vnode_t *, int, int, int, int, 833*7c478bd9Sstevel@tonic-gate struct sonode *, int *); 834*7c478bd9Sstevel@tonic-gate extern int sosctp_init(void); 835*7c478bd9Sstevel@tonic-gate 836*7c478bd9Sstevel@tonic-gate #endif 837*7c478bd9Sstevel@tonic-gate 838*7c478bd9Sstevel@tonic-gate /* 839*7c478bd9Sstevel@tonic-gate * Internal structure for obtaining sonode information from the socklist. 840*7c478bd9Sstevel@tonic-gate * These types match those corresponding in the sonode structure. 841*7c478bd9Sstevel@tonic-gate * This is not a published interface, and may change at any time. 842*7c478bd9Sstevel@tonic-gate */ 843*7c478bd9Sstevel@tonic-gate struct sockinfo { 844*7c478bd9Sstevel@tonic-gate uint_t si_size; /* real length of this struct */ 845*7c478bd9Sstevel@tonic-gate short si_family; 846*7c478bd9Sstevel@tonic-gate short si_type; 847*7c478bd9Sstevel@tonic-gate ushort_t si_flag; 848*7c478bd9Sstevel@tonic-gate uint_t si_state; 849*7c478bd9Sstevel@tonic-gate uint_t si_ux_laddr_sou_magic; 850*7c478bd9Sstevel@tonic-gate uint_t si_ux_faddr_sou_magic; 851*7c478bd9Sstevel@tonic-gate t_scalar_t si_serv_type; 852*7c478bd9Sstevel@tonic-gate t_uscalar_t si_laddr_soa_len; 853*7c478bd9Sstevel@tonic-gate t_uscalar_t si_faddr_soa_len; 854*7c478bd9Sstevel@tonic-gate uint16_t si_laddr_family; 855*7c478bd9Sstevel@tonic-gate uint16_t si_faddr_family; 856*7c478bd9Sstevel@tonic-gate char si_laddr_sun_path[MAXPATHLEN + 1]; /* NULL terminated */ 857*7c478bd9Sstevel@tonic-gate char si_faddr_sun_path[MAXPATHLEN + 1]; 858*7c478bd9Sstevel@tonic-gate zoneid_t si_szoneid; 859*7c478bd9Sstevel@tonic-gate }; 860*7c478bd9Sstevel@tonic-gate 861*7c478bd9Sstevel@tonic-gate 862*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 863*7c478bd9Sstevel@tonic-gate } 864*7c478bd9Sstevel@tonic-gate #endif 865*7c478bd9Sstevel@tonic-gate 866*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SOCKETVAR_H */ 867