t_alloc(3)
NAME
t_alloc − allocate a library structure
SYNOPSIS
#include <xti.h> (for XTI)
or
#include <tiuser.h> (for TLI)
char *t_alloc (fd, struct_type, fields)
int fd;
int struct_type;
int fields;
DESCRIPTION
The t_alloc function dynamically allocates memory for the various transport function argument structures as specified below. This function will allocate memory for the specified structure, and will also allocate memory for buffers referenced by the structure.
The structure to allocate is specified by struct_type, and must be one of the following:
For XTI:
| T_BIND_STR | struct | t_bind |
| T_CALL_STR | struct | t_call |
| T_OPTMGMT_STR | struct | t_optmgmt |
| T_DIS_STR | struct | t_discon |
| T_UNITDATA_STR | struct | t_unitdata |
| T_UDERROR_STR | struct | t_uderr |
| T_INFO_STR | struct | t_info |
For TLI:
| T_BIND | struct | t_bind |
| T_CALL | struct | t_call |
| T_OPTMGMT | struct | t_optmgmt |
| T_DIS | struct | t_discon |
| T_UNITDATA | struct | t_unitdata |
| T_UDERROR | struct | t_uderr |
| T_INFO | struct | t_info |
where each of these structures may subsequently be used as an argument to one or more transport functions.
Each of the above structures, except T_INFO_STR (for XTI) or T_INFO (for TLI), contains at least one field of type struct netbuf. For each field of this type, the user may specify that the buffer for that field should be allocated as well. The length of the buffer allocated will be based on the size information returned in the info argument of t_open(3) or t_getinfo(3). The relevant fields of the info argument are described in the following list. The fields argument specifies which buffer to allocate, where the argument is the bitwise-OR of any of the following:
T_ADDR The addr field of the t_bind, t_call, t_unitdata, or t_uderr structure (size obtained from info->addr ).
T_OPT The opt field of the t_optmgmt, t_call, t_unitdata, or t_uderr structure (size obtained from info->options ).
T_UDATA The udata field of the t_call, t_discon, or t_unitdata structure (for T_CALL_STR (XTI only), size is the maximum value of info->connect and info->discon; for T_CALL (TLI only), size is the value of info->connect; for T_DIS_STR (XTI only) and T_DIS (TLI only), size is the value of info->discon; for T_UNITDATA_STR (XTI only) and T_UNITDATA (TLI only), size is the value of info->tsdu ).
T_ALL All relevant fields of the given structure. Fields which are not supported by the transport provider specified by fd will not be allocated ( info values are <= 0).
For each field specified in fields, t_alloc will allocate memory for the buffer associated with the field, and initialize the len field to zero and the buf pointer and maxlen field accordingly. Since the length of the buffer allocated will be based on the same size information that is returned to the user on t_open(3) or t_getinfo(3), fd must refer to the transport endpoint through which the newly allocated structure will be passed. In this way the appropriate size information can be accessed. If the size value associated with any specified field is -1 or -2 ( see t_open(3) or t_getinfo(3) ), t_alloc will be unable to determine the size of the buffer to allocate and will fail, setting t_errno to [TSYSERR] and errno to [EINVAL]. For any field not specified in fields, buf will be set to a null pointer and maxlen will be set to zero.
Use of t_alloc to allocate structures will help ensure the compatibility of user programs with future releases of the transport interface functions.
ERRORS
On failure, t_errno is set to one of the following:
[TBADF] fd The specified endpoint identifier does not refer to a transport endpoint
[TSYSERR] A system error has occurred during execution of this function.
[TNOSTRUCTYPE] (XTI only) Unsupported struct_type requested. This can include a request for a structure type which is inconsistent with the transport provider type specified, i.e., connection-oriented or connectionless.
RETURN VALUE
Upon successful completion, t_alloc returns a pointer to the newly allocated structure. On failure, a null pointer is returned.
NOTE
In HP-UX 9.0, XTI (X/Open Transport Interface) supports only OSI as a transport provider, and is available only as part of the OSI Transport Services 9000 product. Users of this product can access XTI versions of the t_* routines by linking with /usr/lib/libxti.a. For more information on XTI, see "HP-UX/9000 XTI Programmer’s Guide".
In HP-UX 9.0, TLI (Transport Layer Interface) supports any transport provider which is compliant with TPI (Transport Provider Interface). TLI is available only as part of the STREAMS product. Users of this product can access TLI versions of the t_* routines by linking with /usr/lib/libnsl_s.a. For more information on TLI, see the TLI section of "STREAMS/UX for HP 9000 Reference Manual".
SEE ALSO
t_free(3), t_getinfo(3), t_open(3).
Hewlett-Packard Company — HP-UX Release 9.0: October 1992