t_optmgmt(3xti_spx)


t_optmgmt -- manage protocol-specific options

Synopsis

#include "spx_app.h" 

int t_optmgmt ( int spxFd, struct t_optmgmt *req, struct t_optmgmt *ret )

Parameters

(IN) spxFd
Passes the file descriptor of the local transport endpoint.

(IN) req
Passes the address of the t_optmgmt structure that contains the requested values for each option.

(IN) ret
Passes the address of a t_optmgmt structure that will contain the granted values for each option.

(OUT) ret
Receives the granted values in the t_optmgmt structure.

Return values

0
Successful

-1
Unsuccessful
If t_optmgmt returns an error, t_errno may be set to one of the following:

TBADOPT
The size of the structure was less than the size of the SPX or SPXII option structure, or there has been an internal SPX/TLI error.

TBADFLAG
The flag specified is invalid.

TOUTSTATE
This request was issued in some state other than T_IDLE.

Remarks

The t_optmgmt function enables the user to get, verify, or negotiate protocol options with the transport provider.

SPXII supports two different option structures: one for SPXII and the other for SPX. The available options depend on whether you use ``nspx2'' or ``nspx''. The nspx2 set of options is an expanded set, while the ``nspx'' set of options is compatible with older versions of SPX.

This function works as specified in ``Programming with the X/Open Transport Interface (XTI)''. This call has one negotiable option that enables the SPX/SPXII user to set the maximum number of retries when the SPXII driver tries to deliver data reliably to the opposite transport endpoint.

The t_optmgmt structure has the following format:

   struct t_optmgmt { 
      struct netbuf  opt; 
      long           flags; 
   }; 
The netbuf structure has the following format:
   struct netbuf { 
      unsigned int   maxlen; 
      unsigned int   len; 
      char           *buf; 
   }; 
The t_optmgmt call uses two t_optmgmt structures: a request(req) structure and a return(ret) structure. The same structure can be passed as both the request structure and the return structure.

Although the SPX structure (SPX_OPTMGMT) is the same as in previous releases of SPX, it should not be used for newly written applications. SPX_OPTMGMT is available only for compatibility reasons and has the following format:

   typedef struct spx_optmgmt { 
      uint8   spxo_retry_count; 
      uint8   spxo_watchdog_flag; 
      uint16  spxo_min_retry_delay; 
   } SPX_OPTMGMT; 
The SPXII structure (SPX2_OPTIONS) is shown on the following page. It is used for calls t_listen, t_accept, t_connect and t_optmgmt. Because this structure is expandable in future versions of SPXII, a variable should never be declared directly (such as ``struct SPX2_OPTIONS spxoptions;''). Likewise, the size of the structure should never be taken (for example, ``sizeof(SPX2_OPTIONS);'').

The t_alloc function should always be used to allocate the t_optmgmt structure. The size of the opt.buf in the t_optmgmt structure can be determined by either checking the value of the options field in the t_info structure used during t_open, or by checking opt.maxlen after the t_alloc call.


NOTE: If the TLI calls are not used to allocate and determine the size, a TBUFOVFLW error could be generated when an application is run with a newer version of SPXII.

Only some of the SPXII structure elements are valid with the t_optmgmt call. The others are used for t_listen, t_accept, and t_connect.

The SPXII structure (SPX2_OPTIONS) has the following format.

The SPX2_OPTIONS Structure

Type Field Description
uint32 versionNumber * Must be set to OPTION_VERSION
uint32 spxIIOptionNegotiate * Exchange options and negotiate packet size with other endpoint
uint32 spxIIRetryCount * Number of transmit retries on data packets
uint32 spxIIMinimumRetryDelay * Minimum retry timeout, in milliseconds
uint32 spxIIMaximumRetryDelta * Maximum retry delta, in milliseconds
uint32 spxIIWatchdogTimeout This is a SYSTEM parameter for UNIX SPXII
uint32 spxIIConnectionTimeout * Number of milliseconds to wait for full connection setup
uint32 spxIILocalWindowSize * Number of data packets in receive window
uint32 spxIIRemoteWindowSize Remote endpoints initial receive window size
uint32 spxIIConnectionID Valid only after connection is established
uint32 spxIIInboundPacketSize Maximum receive packet size
uint32 spxIIOutboundPacketSize Maximum transmit packet size
uint32 spxIISessionFlags Session characteristic options

 
 --------------------------------------------------------------------------- 
| Type    |  Field                   |  Description                        | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  versionNumber *         |  Must be set to OPTION_VERSION      | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIOptionNegotiate *  |  Exchange options and negotiate     | 
|         |                          |  packet size with other endpoint    | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIRetryCount *       |  Number of transmit retries on data | 
|         |                          |  packets                            | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIMinimumRetryDelay *|  Minimum retry timeout, in          | 
|         |                          |  milliseconds                       | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIMaximumRetryDelta *|  Maximum retry delta, in            | 
|         |                          |  milliseconds                       | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIWatchdogTimeout    |  This is a SYSTEM parameter for UNIX| 
|         |                          |  SPXII                              | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIConnectionTimeout *|  Number of milliseconds to wait for | 
|         |                          |  full connection setup              | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIILocalWindowSize *  |  Number of data packets in receive  | 
|         |                          |  window                             | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIRemoteWindowSize   |  Remote endpoints initial receive   | 
|         |                          |  window size                        | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIConnectionID       |  Valid only after connection is     | 
|         |                          |  established                        | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIInboundPacketSize  |  Maximum receive packet size        | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIIOutboundPacketSize |  Maximum transmit packet size       | 
|---------|--------------------------|-------------------------------------| 
| uint32  |  spxIISessionFlags       |  Session characteristic options     | 
|---------|--------------------------|-------------------------------------| 
A ``*'' indicates structure elements valid for t_optmgmt. The flags field in the t_optmgmt structure must be initialized to the appropriate value. The t_optmgmt call supports the following flags: T_NEGOTIATE, T_CHECK, and T_DEFAULT.

Examples

    /* 
    ** Change SPXII local window size and retry count. 
    ** If SPX device, change retry count only. 
    */ 

{ struct t_optmgmt *req_opts; struct t_optmgmt *ret_opts; SPX2_OPTIONS *retIIOpts; SPX2_OPTIONS *reqIIOpts; SPX_OPTIONS *retOpts; SPX_OPTIONS *reqOpts; int len; ...

/* Get proper size structure for request values t_optmgmt */ if ((req_opts = (struct t_optmgmt *) t_alloc (spxFd, T_OPTMGMT, T_ALL)) == NULL ) { t_error( "t_alloc failed"); exit(-1); } /* Get proper size structure for return values from t_optmgmt */ if ((ret_opts = (struct t_optmgmt *) t_alloc (spxFd, T_OPTMGMT, T_ALL)) == NULL ) { t_error( "t_alloc failed"); exit(-1); } len = req_opts->opt.maxlen; /* ** Get the DEFAULT options. Have defaults returned in request structure **/ req_opts->flags = T_DEFAULT; req_opts->opt.len = len; if ((t_optmgmt(spxFd, req_opts, req_opts))<0) { fprintf (stderr, "t_optmgmt failed to %s failed t_errno= %d errno= %d\n", spxDev, t_errno, errno); t_error ("t_optmgmt failed"); exit(-1); }

if (len == sizeof(SPX_OPTMGMT)) { /* ** SPX: Change retry count to 5. */ reqOpts = (SPX_OPTMGMT *)req_opts->opt.buf; reqOpts->spxo_retry-count = 5; } else { /* ** SPXII: Change retry count to 5 and window size to 12. */ reqIIOpts = (SPX2_OPTIONS *)req_opts->opt.buf; reqIIOpts->spxIIRetryCount = 5; reqIIOpts->spxIILocalWindowSize = 12; } req_opts->flags = T_NEGOTIATE; req_opts->opt.len = len; if ((t_optmgmt(spxFd, req_opts, ret_opts))<0) { fprintf (stderr, "t_optmgmt failed to %s failed t_errno= %d errno= %d\n", spxDev, t_errno, errno); t_error ("t_optmgmt failed"); exit(-1); } t_free((char *)req_opts, T_OPTMGMT); t_free((char *)ret_opts, T_OPTMGMT); ... }

State

The t_optmgmt call must be issued with the endpoint in the T_IDLE state. The state does not change on the successful completion of the call.

References

t_accept(3xti_spx), t_connect(3xti_spx), t_listen(3xti_spx), t_open(3xti_spx), t_optmgmt(3xti)
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.