socktpi.h revision 3e95bd4ab92abca814bd28e854607d1975c7dc88
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#ifndef _SOCKFS_SOCKTPI_H
#define _SOCKFS_SOCKTPI_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Internal representation used for addresses.
*/
struct soaddr {
};
/* Maximum size address for transports that have ADDR_size == 1 */
#define SOA_DEFSIZE 128
struct sonode;
/*
* TPI Sockets
* ======================
*
* A TPI socket can be created by the TPI socket module, or as a
* result of fallback. In either case, the TPI related information is
* stored in a sotpi_info_t. Sockets that are TPI based from the
* beginning will use a sotpi_sonode_t, but fallback case the
* sotpi_info_t will be allocated when needed. However, the so_priv
* field in the sonode will always point to the sotpi_info_t, and the
* structure should only be accessed via so_priv. Use SOTOTPI().
*
* A TPI socket always corresponds to a VCHR stream representing the
* from the kernel socket configuration table and accessible via
* so_sockparams->sp_sdev_info. sockfs uses this to perform
* VOP_ACCESS checks before allowing an open of the transport
* provider.
*
* AF_UNIX Sockets
* -------------------------
*
* When an AF_UNIX socket is bound to a pathname the sockfs creates a
* VSOCK vnode in the underlying file system. However, the vnodeops
* etc in this VNODE remain those of the underlying file system.
* Sockfs uses the v_stream pointer in the underlying file system
* VSOCK node to find the sonode bound to the pathname. The bound
* pathname vnode is accessed through sti_ux_vp.
*
* Out of Band Data Handling
* -------------------------
*
* The counts (sti_oobcnt and sti_oobsigcnt) track the number of
* urgent indicates that are (logically) queued on the stream head
* read queue. The urgent data is queued on the stream head
* as follows.
*
* In the normal case the SIGURG is not generated until
* the T_EXDATA_IND arrives at the stream head. However, transports
* that have an early indication that urgent data is pending
* (e.g. TCP receiving a "new" urgent pointer value) can send up
*
* The mark is indicated by either:
* - a T_EXDATA_IND (with no M_DATA b_cont) with MSGMARK set.
* When this message is consumed by sorecvmsg the socket layer
* sets SS_RCVATMARK until data has been consumed past the mark.
* - a message with MSGMARKNEXT set (indicating that the
* first byte of the next message constitutes the mark). When
* the last byte of the MSGMARKNEXT message is consumed in
* the stream head the stream head sets STRATMARK. This flag
* is cleared when at least one byte is read. (Note that
* the MSGMARKNEXT messages can be of zero length when there
* is no previous data to which the marknext can be attached.)
*
* While the T_EXDATA_IND method is the common case which is used
* with all TPI transports, the MSGMARKNEXT method is needed to
* indicate the mark when e.g. the TCP urgent byte has not been
* received yet but the TCP urgent pointer has made TCP generate
*
* The signal (the M_PCSIG carrying the SIGURG) and the mark
* indication can not be delivered as a single message, since
* the signal should be delivered as high priority and any mark
* indication must flow with the data. This implies that immediately
* when the SIGURG has been delivered if the stream head queue is
* empty it is impossible to determine if this will be the position
* of the mark. This race condition is resolved by using MSGNOTMARKNEXT
* messages and the STRNOTATMARK flag in the stream head. The
* SIOCATMARK code calls the stream head to wait for either a
* non-empty queue or one of the STR*ATMARK flags being set.
* This implies that any transport that is sending M_PCSIG(SIGURG)
* should send the appropriate MSGNOTMARKNEXT message (which can be
* zero length) after sending an M_PCSIG to prevent SIOCATMARK
* from sleeping unnecessarily.
*/
#define SOTPI_INFO_MAGIC 0x12345678
/*
*/
typedef struct sotpi_info {
/*
* These fields are initialized once.
*/
/* so_pushcnt */
short sti_pushcnt; /* Number of modules above "sockmod" */
sti_pad_to_bit7 : 4;
/* put here for delayed processing */
/* From T_info_ack */
/* From T_capability_ack */
/* Internal provider information */
struct tpi_provinfo *sti_provinfo;
/*
* The local and remote addresses have multiple purposes
* but one of the key reasons for their existence and careful
* tracking in sockfs is to support getsockname and getpeername
* when the transport does not handle the TI_GET*NAME ioctls
* and caching when it does (signalled by valid bits in so_state).
* When all transports support the new TPI (with T_ADDR_REQ)
* we can revisit this code.
*
* The other usage of sti_faddr is to keep the "connected to"
* address for datagram sockets.
*
* Finally, for AF_UNIX both local and remote addresses are used
* to record the sockaddr_un since we use a separate namespace
* in the loopback transport.
*/
/*
* For AF_UNIX sockets:
*
* sti_ux_laddr/faddr records the internal addresses used with the
* transport. sti_ux_vp and v_stream->sd_vnode form the
* cross-linkage between the underlying fs vnode corresponding
* to the bound sockaddr_un and the socket node.
*/
/*
* For NL7C sockets:
*
* sti_nl7c_flags the NL7C state of URL processing.
*
* sti_nl7c_rcv_mp mblk_t chain of already received data to be
* passed up to the app after NL7C gives up on
* a socket.
*
* sti_nl7c_rcv_rval returned rval for last mblk_t from above.
*
* sti_nl7c_uri the URI currently being processed.
*
* sti_nl7c_rtime URI request gethrestime_sec().
*
* sti_nl7c_addr pointer returned by nl7c_addr_lookup().
*/
void *sti_nl7c_uri;
void *sti_nl7c_addr;
/* For sockets acting as an in-kernel SSL proxy */
} sotpi_info_t;
struct T_capability_ack;
extern sonodeops_t sotpi_sonodeops;
extern int socktpi_init(void);
short);
#ifdef DEBUG
#else
#endif
/* for consumers outside sockfs */
#ifdef __cplusplus
}
#endif
#endif /* _SOCKFS_SOCKTPI_H */