#include "spx_app.h"int t_optmgmt ( int spxFd, struct t_optmgmt *req, struct t_optmgmt *ret )
spxFd
req
ret
ret
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.
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 |
/* ** 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); ... }