[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2

t_alloc Subroutine for Transport Layer Interface


Allocates a library structure.


Transport Layer Interface Library (libtli.a)


#include <tiuser.h>

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


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

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


fd Specifies the transport end point through which the newly allocated structure will be passed.
struct_type Specifies the structure to be allocated. The structure to allocate is specified by the struct_type parameter, and can be one of the following:

struct t_bind

struct t_call

struct t_optmgmt

struct t_discon

struct t_unitdata

struct t_uderr

struct t_info

Each of these structures may subsequently be used as a parameter to one or more transport functions.

Each of the above structures, except T_INFO, contains at least one field of the struct netbuf type. The netbuf structure is described in the tiuser.h file. For each field of this type, the user may specify that the buffer for that field should be allocated as well. The fields parameter specifies this option, where the parameter is the bitwise-OR of any of the following:

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

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

The udata field of the t_call, t_discon, or t_unitdata structure.

All relevant fields of the given structure.
fields Specifies whether the buffer should be allocated for each field type. For each field specified in the fields parameter, the t_alloc subroutine allocates memory for the buffer associated with the field, initializes the len field to zero, and initializes the buf pointer and the maxlen field accordingly. The length of the buffer allocated is based on the same size information returned to the user from the t_open and t_getinfo subroutines. Thus, the fd parameter must refer to the transport end point through which the newly allocated structure will be passed, so that the appropriate size information can be accessed. If the size value associated with any specified field is -1 or -2, the t_alloc subroutine will be unable to determine the size of the buffer to allocate; it then fails, setting the t_errno variable to TSYSERR and the errno global variable to EINVAL. For any field not specified in the fields parameter, the buf field is set to null and the maxlen field is set to 0.

Return Values

On successful completion, the t_alloc subroutine returns a pointer to the newly allocated structure. Otherwise, it returns a null pointer.

Error Codes

On failure, the t_errno variable is set to one of the following:

TBADF The specified file descriptor does not refer to a transport end point.
TNOSTRUCTYPE Unsupported structure type requested. This can include a request for a structure type which is inconsistent with the transport provider type specified, for example, connection-oriented or connectionless.
TSYSERR A system error has occurred during execution of this function.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The t_free subroutine, t_getinfo subroutine, t_open subroutine.

List of Streams Programming References and STREAMS Overview in AIX 5L Version 5.1 Communications Programming Concepts.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]