tihdr.h revision c28749e97052f09388969427adf7df641cdcdc22
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_TIHDR_H
#define _SYS_TIHDR_H
#pragma ident "%Z%%M% %I% %E% SMI" /* from SVr4.0 11.4 */
/*
* Include declarations implicit to TPI and shared with user level code
*/
#include <sys/tpicommon.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* The feature test macro, _SUN_TPI_VERSION makes some of additional
* declarations available and changes some existing ones. There was
* some changes done to this interface and this feature test macro
* enables transitioning to those changes while maintaining retaining
* backward compatibility.
*
* The following is all the information
* needed by the Transport Service Interface.
*/
/*
* The following are the definitions of the Transport
* Service Interface primitives.
*/
/*
* Primitives that are initiated by the transport user.
*/
#define T_CONN_REQ 0 /* connection request */
#if _SUN_TPI_VERSION > 1
#else
#endif /* _SUN_TPI_VERSION > 1 */
/*
* Bind Request primitive (TLI inspired
* address binding semantics). If requested address is
* found to be busy, an alternative free address is
* returned. (Requires comparison of requested address to
* returned address to verify if the requested address was
* bound)
*
*/
#if _SUN_TPI_VERSION > 0
#define O_T_BIND_REQ 6
#else
#define T_BIND_REQ 6
#endif /* _SUN_TPI_VERSION > 0 */
/*
* Option management request (with TLI inspired semantics )
* The preferred name for this primitive in new code is T_SVR4_OPTMGMT_REQ.
* This primitive had the name T_OPTMGMT_REQ in old SVR4 derived TPI.
* This primitive is used for TLI and Socket API support.
* The packing of options in option buffer is private contract
* between transport provider and its users and can differ
* between different transports.
* (The name O_T_OPTMGMT_REQ continues to exist for Solaris 2.6
* compilation environment compatibility only)
*
*/
#define T_SVR4_OPTMGMT_REQ 9
#if _SUN_TPI_VERSION > 0
#define O_T_OPTMGMT_REQ T_SVR4_OPTMGMT_REQ
#else
#define T_OPTMGMT_REQ T_SVR4_OPTMGMT_REQ
#endif /* _SUN_TPI_VERSION > 0 */
/*
* Primitives that are initiated by the transport provider.
*/
/*
* Primitives added to namespace and contain a mix of ones
* initiated by transport user or provider.
*/
#if _SUN_TPI_VERSION > 0
/*
* Bind request primitive with better address
* binding semantics. (XTI inspired)
* If the requested address is found to be busy,
* an error is returned. (No need to compare addresses on successful
* bind acknowledgement).
*/
/*
* Option management request (with XTI inspired semantics)
* The packing of options in option buffer is required to
* be with 'struct T_opthdr' data structure defined later in
* this header.
*/
#endif /* _SUN_TPI_VERSION > 0 */
#if _SUN_TPI_VERSION > 1
/*
* The connection response that expects its ACCEPTOR_id to have been
* filled in from the value supplied via a T_CAPABILITY_ACK.
*/
/*
* Capability request and ack. These primitives are optional and
* subsume the functionality of T_INFO_{REQ,ACK}.
*/
#define T_CAPABILITY_REQ 30
#define T_CAPABILITY_ACK 31
#endif /* _SUN_TPI_VERSION > 1 */
#ifdef _KERNEL
/*
* Sun private TPI extensions. They are currently used for transparently
* passing options through the connection-oriented loopback transport,
* and for setting the kernel SSL proxy.
* Values assigned to them may change.
*
* T_EXTCONN_IND (extended T_CONN_IND) is used to return dst as well as
*/
/* kssl_entry_t to the transport. */
/* endpoint, carrying a kssl_ctx_t */
#endif /* _KERNEL */
/*
* The following are the events that drive the state machine
*/
/* Initialization events */
#define TE_BIND_REQ 0 /* bind request */
/* Connection oriented events */
/* Unit data events */
#define TE_NOEVENTS 28
/*
* The following are the possible states of the Transport
* Service Interface
*/
#define TS_UNBND 0 /* unbound */
#define TS_NOSTATES 17
/*
* The following structure definitions define the format of the
* stream message block of the above primitives.
* (everything is declared t_scalar_t to ensure proper alignment
* across different machines)
*/
/* connection request */
struct T_conn_req {
};
/* connect response */
/*
* Historical compatibility note for "struct T_conn_res" usage.
* "QUEUE_ptr" field of type "queue_t" is obsolete to support
* code portability and application binary compatibility
* between ILP32(32-bit) and LP64 (64-bit) environments.
* Use field "ACCEPTOR_id" instead.
* For compatibility, drivers using (_SUN_TPI_VERSION >= 2) interface
* can support treating ACCEPTOR_id content as queue pointer
* only when PRIM_type is O_T_CONN_RES.
*/
struct T_conn_res {
};
/* disconnect request */
struct T_discon_req {
};
/* data request */
struct T_data_req {
};
/* expedited data request */
struct T_exdata_req {
};
/* information request */
struct T_info_req {
};
/* bind request */
struct T_bind_req {
};
/* unbind request */
struct T_unbind_req {
};
/* unitdata request */
struct T_unitdata_req {
};
/* manage options request */
struct T_optmgmt_req {
/* T_SVR4_OPTMGMT_REQ */
};
/* orderly release request */
struct T_ordrel_req {
};
/* protocol address request */
struct T_addr_req {
};
/* connect indication */
struct T_conn_ind {
};
/* connect confirmation */
struct T_conn_con {
};
/* disconnect indication */
struct T_discon_ind {
};
/* data indication */
struct T_data_ind {
};
/* expedited data indication */
struct T_exdata_ind {
};
/* information acknowledgment */
struct T_info_ack {
};
/*
* The following are definitions of flags available to the transport
* provider to set in the PROVIDER_flag field of the T_info_ack
* structure.
*/
#if _SUN_TPI_VERSION > 0
/* old providers- old value of */
#else
#endif /* _SUN_TPI_VERSION > 0 */
/*
* Flag XPG4_1:
* transport provider supports TPI modifications motivated by and
* in conjunction with XTI inspired TPI support and all the
* compatibility baggage that implies.
* It implies, - primitives T_ADDR_REQ & T_ADDR_ACK supported
* - primitives O_T_BIND_REQ & T_BIND_REQ separately supported
* - primitives T_SVR4_OPTMGMT_REQ & T_OPTMGMT_REQ separately
* supported.
*/
#define XPG4_1 0x0004
/* bind acknowledgment */
struct T_bind_ack {
};
/* error acknowledgment */
struct T_error_ack {
};
/* ok acknowledgment */
struct T_ok_ack {
};
/* unitdata indication */
struct T_unitdata_ind {
};
/* unitdata error indication */
struct T_uderror_ind {
};
/* manage options ack */
struct T_optmgmt_ack {
};
/* orderly release indication */
struct T_ordrel_ind {
};
/* protocol address acknowledgment */
struct T_addr_ack {
};
#if _SUN_TPI_VERSION > 1
/*
* Capability request and ack. These primitives are optional and
* subsume the functionality of T_INFO_{REQ,ACK}.
*/
struct T_capability_req {
};
struct T_capability_ack {
struct T_info_ack
INFO_ack; /* info acknowledgement */
};
#endif /* _SUN_TPI_VERSION > 1 */
#ifdef _KERNEL
/*
* Private Sun TPI extensions.
*/
/* data (with options) request */
struct T_optdata_req {
};
/* data (with options) indication */
struct T_optdata_ind {
};
struct T_extconn_ind {
};
#endif /* _KERNEL */
/*
* The following is a union of the primitives
*/
union T_primitives {
#if _SUN_TPI_VERSION > 1
#endif /* _SUN_TPI_VERSION > 1 */
#ifdef _KERNEL
#endif /* _KERNEL */
};
/*
* TPI specification is not clear on how to pack options in option
* buffers. What follows is the Solaris TPI interpretation of it.
*
* struct T_opthdr data structure is used to pack options in T_OPTMGMT_{REQ,ACK}
* message primitives in buffer delimited by [OPT_offset, OPT_length] fields in
* struct T_optmgmt_req/T_optmgmt_ack data structures.
*
* It is also used to pack options in similar buffers for data structures in
* T_CONN_{REQ,IND,RES,CONN} primitives and T_UNITDATA_{REQ,IND} primitives
* Needs to be on t_uscalar_t (32-bit word) aligned boundary.
*
* Note: T_SVR4_OPTMGMT_REQ primitive can, but need not, use this data
* structure for packing options. The format of option buffer for
* T_SVR4_OPTMGMT_REQ primitive is undefined and is a private contract
* between transport provider and its users.
*
* |<--------------first option---------------->| |<--second option--...
* ______________________________________ _ _ _ ____________________________
* | len | level | name | status | value.......| / / | len ...
* -------------------------------------- - - - ----------------------------
* |32bit| 32bit |32bit | 32bit | ^ | 32bit...
* |
* |
* alignment characters
*/
struct T_opthdr {
/* option value aligned on t_uscalar_t (32-bit) alignment boundary */
};
/*
* ------------------------------------------------------------------------
* Common experimental private TPI alignment related macros. Not for
* use outside Solaris bundled code and can change in any release.
* The alignment boundary _TPI_ALIGN_SIZE represents an implementation
* choice for aligning many data objects which are directly or indirectly
* associated with Solaris TPI implementation.
* ------------------------------------------------------------------------
*/
#define __TPI_ALIGN_SIZE (sizeof (t_scalar_t))
#define __TPI_ALIGN(x) \
#define __TPI_SIZE_ISALIGNED(x) \
/*
* TPI primitive in message must be aligned at _TPI_ALIGN_SIZE boundary
*/
#define __TPI_PRIM_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x)
/*
* TPI option header "struct opthdr" objects must be aligned
* at __TPI_ALIGN_SIZE boundary.
*/
#define __TPI_OPT_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x)
#define _TPI_ALIGN_OPT(x) __TPI_ALIGN(x)
/*
* TPI option header "struct T_opthdr" objects must be aligned
* at __TPI_ALIGN_SIZE boundary.
*/
#define __TPI_TOPT_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x)
#define _TPI_ALIGN_TOPT(x) __TPI_ALIGN(x)
/*
* --------------------------------------------------------------------
* Private experimental macros. Not for use outside Solaris bundled
* source code and can change in any release.
* Macros that operate on struct T_opthdr. These are roughly modelled
* after the corresponding Socket CMSG_*() and XTI T_OPT_*() macros, but
* are applied to TPI option buffers.
* --------------------------------------------------------------------
*
* unsigned char *
* _TPI_TOPT_DATA(struct T_opthdr *tohp):
* Get start of data part after option header
*/
#define _TPI_TOPT_DATA(tohp) \
/*
* t_uscalar_t
* _TPI_TOPT_DATALEN(tohp)
* Get length of contents of option data excluding header (and
* padding etc if any).
*/
/*
* struct T_opthdr *
* _TPI_TOPT_FIRSTHDR(char *pbuf, t_scalar_t buflen):
* Get pointer to the first option header in buffer 'pbuf'
* Return NULL if there is not enough room for the header
*
* struct T_opthdr *
* _TPI_TOPT_NEXTHDR(char *pbuf, t_scalar_t buflen,
* struct T_opthdr *popt):
* Skip to next option header
*
* Notes: _TPI_TOPT_NEXTHDR performs the roundup of the length.
*
* If _TPI_TOPT_{FIRST,NEXT}HDR returns a non-null value, the user of
* _TPI_TOPT_{FIRST,NEXT}HDR must still verify that the resulting pointer
* is valid, by making a call to _TPI_TOPT_VALID. The _TPI_TOPT_VALID
* macro does not assume that the last option buffer is padded.
*/
__TPI_TOPT_ISALIGNED(pbuf)) ? \
(struct T_opthdr *)0)
/*
* bool_t
* _TPI_TOPT_VALID(struct T_opthdr *tohp, char *start, char *end)
* Validate the option header at tohp, for its alignment and length.
* 1. check that tohp is aligned at t_scalar_t boundary
* 2. check that start <= tohp < end
* 3. validate the length, should be >= sizeof(T_opthdr) and
* check that there is no pointer arithmetic overflow.
* (could be caused by a very large value for tohp->len)
*/
(__TPI_TOPT_ISALIGNED(tohp) && \
sizeof (struct T_opthdr)))
#ifdef __cplusplus
}
#endif
#endif /* _SYS_TIHDR_H */