DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 
(TLI/XTI)

t_alloc(NET)


t_alloc -- allocate a library structure

Syntax

TLI syntax

cc . . . -lnsl

#include <sys/tiuser.h>

char * t_alloc (fd, struct_type, fields) int fd, struct_type, fields;

XTI syntax

cc . . . -lxti

#include <xti.h>

char *t_alloc (fd, struct_type, fields) int fd, struct_type, fields;

Description

The t_alloc function dynamically allocates memory for the various transport function argument structures as specified below. This function allocates memory for the specified structure, and also allocates memory for buffers referenced by the structure.

The structure to allocate is specified by struct_type, and can be one of the following:

TLI struct_type XTI struct_type struct
T_BIND T_BIND_STR t_bind
T_CALL T_CALL_STR t_call
T_DIS T_DIS_STR t_discon
T_INFO T_INFO_STR t_info
T_OPTMGMT T_OPTMGMT_STR t_optmgmt
T_UDERROR T_UDERROR_STR t_uderr
T_UNITDATA T_UNITDATA_STR t_unitdata

 +----------------+-----------------+------------+
 |TLI struct_type | XTI struct_type | struct     |
 +----------------+-----------------+------------+
 |T_BIND          | T_BIND_STR      | t_bind     |
 +----------------+-----------------+------------+
 |T_CALL          | T_CALL_STR      | t_call     |
 +----------------+-----------------+------------+
 |T_DIS           | T_DIS_STR       | t_discon   |
 +----------------+-----------------+------------+
 |T_INFO          | T_INFO_STR      | t_info     |
 +----------------+-----------------+------------+
 |T_OPTMGMT       | T_OPTMGMT_STR   | t_optmgmt  |
 +----------------+-----------------+------------+
 |T_UDERROR       | T_UDERROR_STR   | t_uderr    |
 +----------------+-----------------+------------+
 |T_UNITDATA      | T_UNITDATA_STR  | t_unitdata |
 +----------------+-----------------+------------+
Each of these structures may subsequently be used as an argument to one or more transport functions.

Each of the previously listed structures, except T_INFO (TLI) or T_INFO_STR (XTI), contains at least one field of type struct netbuf. netbuf is described in netbuf(FP). For each field of this type, the user may specify that the buffer for that field should be allocated as well. The fields argument specifies this option, where the argument is the bitwise-OR of any of the following:


T_ALL
All relevant fields of the given structure.

T_ADDR
The addr field of the t_bind, t_call, t_unitdata, or t_uderr structures.

T_OPT
The opt field of the t_optmgmt, t_call, t_unitdata, or t_uderr structures.

T_UDATA
The udata field of the t_call, t_discon, or t_unitdata structures.

For each field specified in fields, t_alloc allocates memory for the buffer associated with the field, and initialize the buf pointer and maxlen (see netbuf in netbuf(FP) for a description of the buf and maxlen) fields accordingly. The length of the buffer allocated is based on the same size information that is returned to the user on t_open and t_getinfo. Thus, fd must refer to the transport endpoint through which the newly allocated structure is passed, so that the appropriate size information can be accessed. If the size value associated with any specified field is -1 or -2 (see t_open or t_getinfo), t_alloc is unable to determine the size of the buffer to allocate and fails, setting t_errno to TSYSERR and errno to EINVAL. For any field not specified in fields, buf is set to NULL and maxlen is set to zero.

Use of t_alloc to allocate structures helps ensure the compatibility of user programs with future releases of the transport interface.

Return values

On successful completion, t_alloc returns a pointer to the newly allocated structure. On failure, it returns NULL.

Diagnostics

On failure, t_errno may be set to one of the following:

[TBADF]
The specified file descriptor does not refer to a transport endpoint.

[TNOSTRUCTYPE]
For XTI, an incorrect value was specified in the struct_type argument.

[TSYSERR]
A system error has occurred during execution of this function. The following conditions accompany this error:

t_errno errno Cause of error
TSYSERR not set Device or system failure
TSYSERR EINVAL struct_type out of range, or internal error
TSYSERR ENOMEM Memory could not be allocated for specified struct_type request

 +--------+---------+-------------------------------+
 |t_errno | errno   | Cause of error                |
 +--------+---------+-------------------------------+
 |TSYSERR | not set | Device or system failure      |
 +--------+---------+-------------------------------+
 |TSYSERR | EINVAL  | struct_type out of range, or  |
 |        |         | internal error                |
 +--------+---------+-------------------------------+
 |TSYSERR | ENOMEM  | Memory could not be allocated |
 |        |         | for specified struct_type     |
 |        |         | request                       |
 +--------+---------+-------------------------------+

See also

Intro(NET), netbuf(FP), t_free(NET), t_info(FP), t_getinfo(NET), t_open(NET)

Standards conformance

t_alloc is conformant with:

AT&T SVID Issue 3 ;
X/Open CAE Specification, Networking Services, Issue 4, 1994. ;
and Intel386 Binary Compatibility Specification, Edition 2 (iBCSe2) .


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003