t_optmgmt() — Manage options for a transport endpoint

Standards

Standards / Extensions C or C++ Dependencies
XPG4.2 both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <xti.h>

int t_optmgmt(int fd, struct t_optmgmt *req, struct t_optmgmt *ret);

General description

Enables a transport user to retrieve, verify or negotiate protocol options with the transport provider. The argument fd identifies a transport endpoint. The req and ret arguments point to a t_optmgmt structure containing the following members:
struct netbuf   opt;
long            flags;
The opt field identifies protocol options and the flags field is used to specify the action to take with those options.
The options are represented by a netbuf structure in a manner similar to the address in t_bind(). The netbuf structure contains the following members:
unsigned int     maxlen      maximum buffer value length
unsigned int     len         actual buffer value length
char *           buf         pointer to buffer
The argument req is used to request a specific action of the provider and to send options to the provider. The argument len specifies the number of bytes in the options, buf points to the options buffer, and maxlen has no meaning for the req argument. The transport provider may return options and flag values to the user through ret. For ret, maxlen specifies the maximum size of the options buffer, and buf points to the buffer where the options are to be placed. On return, len specifies the number of bytes of options returned. The value in maxlen has no meaning for the req argument, but must be set in the ret argument to specify the maximum number of bytes the options buffer can hold.

Each option in the options buffer is of the form struct t_opthdr possibly followed by an option value. The t_opthdr structure contains the following members:

AMODE(31):
unsigned long    len         sizeof(t_opthdr)+optval len
unsigned long    level       protocol affected
unsigned long    name        option value
unsigned long    status      status value
AMODE(64):
unsigned int    len         sizeof(t_opthdr)+optval len
unsigned int    level       protocol affected
unsigned int    name        option value
unsigned int    status      status value

The level field of struct t_opthdr identifies the XTI level or a protocol of the transport provider. The name field identifies the option within the level, and len contains its total length. The total length is the length of the option header t_opthdr plus the length of the option value. If t_optmgmt() is called with the action T_NEGOTIATE set, the status field of the returned options contains information about the success or failure of a negotiation.

Each option in the input or output option buffer must start at a long-word boundary. The macro OPT_NEXTHDR(pbuf, buflen, poption) can be used for that purpose. The parameter pbuf denotes a pointer to an option buffer opt.buf, and buflen is its length. The parameter poption points to the current option in the option buffer. OPT_NEXTHDR returns a pointer to the position of the next option, or returns a NULL pointer if the option buffer is exhausted. The macro is helpful for writing and reading. See xti.h for the exact definition.

If the transport user specifies several options on input, all options must address the same level.

If any option in the options buffer does not indicate the same level as the first option, or the level specified is unsupported, then the t_optmgmt() request will fail with TBADOPT. If the error is detected, some options have possibly been successfully negotiated. The transport user can check the current status by calling t_optmgmt() with the T_CURRENT flag set.

Before using this function, you should read topic, “Use of Options in XTI”, in X/Open CAE Specification, Networking Services, Issue 4

The flags field of req must specify one of the following actions:
T_NEGOTIATE
This action enables the transport user to negotiate option values.

The user specifies the options of interest and their values in the buffer specified by req->opt.buf and req->opt.len. The negotiated option values are returned in the buffer pointed to by ret->opt.buf. The status field of each returned option is set to indicate the result of the negotiation. The value is T_SUCCESS if the proposed value was negotiated, T_PARTSUCCESS if a degraded value was negotiated, T_FAILURE if the negotiation failed (according to the negotiation rules), T_NOTSUPPORT if the transport provider does not support this option or illegally requests negotiation of a privileged option, and T_READONLY if modification of a read-only option was requested. If the status is T_SUCCESS, T_FAILURE, T_NOTSUPPORT or T_READONLY, the returned option value is the same as the one requested on input.

The overall result of the negotiation is returned in ret->flags.

This field contains the worst single result, whereby the rating is done according to the order T_NOTSUPPORT, T_READONLY, T_FAILURE, T_PARTSUCCESS, T_SUCCESS. The value T_NOTSUPPORT is the worst result and T_SUCCESS is the best.

For each level, the option T_ALLOPT (see below) can be requested on input. No value is given with this option; only the t_opthdr part is specified. This input requests to negotiate all supported options of this level to their default values. The result is returned option by option in ret->opt.buf. (Note that depending on the state of the transport endpoint, not all requests to negotiate the default value may be successful.)

T_CHECK
This action enables the user to verify whether the options specified in req are supported by the transport provider.

If an option is specified with no option value (it consists only of a t_opthdr structure), the option is returned with its status field set to T_SUCCESS if it is supported, T_NOTSUPPORT if it is not or needs additional user privileges, and T_READONLY if it is read-only (in the current XTI state). No option value is returned.

If an option is specified with an option value, the status field of the returned option has the same value, as if the user had tried to negotiate this value with T_NEGOTIATE. If the status is T_SUCCESS, T_FAILURE, T_NOTSUPPORT or T_READONLY, the returned option value is the same as the one requested on input.

The overall result of the option checks is returned in ret->flags. This field contains the worst single result of the option checks, whereby the rating is the same as for T_NEGOTIATE.

Note that no negotiation takes place. All currently effective option values remain unchanged.

T_DEFAULT
This action enables the transport user to retrieve the default option values. The user specifies the options of interest in req->opt.buf. The option values are irrelevant and will be ignored. It is sufficient to specify the t_opthdr part of an option only. The default values are then returned in ret->opt.buf.

The status field returned is T_NOTSUPPORT if the protocol level does not support this option or the transport user illegally requested a privileged option, T_READONLY if the option is read-only, and set to T_SUCCESS in all other cases. The overall result of the request is returned in ret->flags. This field contains the worst single result, whereby the rating is the same as for T_NEGOTIATE.

For each level, the option T_ALLOPT (see below) can be requested on input. All supported options of this level with their default values are then returned. In this case, ret->opt.maxlen must be given at least the value info->options (see t_getinfo(), t_open() ) before the call.

T_CURRENT
This action enables the transport user to retrieve the currently effective option values. The user specifies the options of interest in req->opt.buf. The option values are irrelevant and will be ignored. It is sufficient to specify the t_opthdr part of an option only. The currently effective values are then returned in ret->opt.buf.

The status field returned is T_NOTSUPPORT if the protocol level does not support this option, or the transport user illegally requested a privileged option, T_READONLY if the option is read-only, and set to T_SUCCESS in all other cases. The overall result of the request is returned in ret->flags. This field contains the worst single result, whereby the rating is the same as for T_NEGOTIATE.

For each level, the option T_ALLOPT (see below) can be requested on input. All supported options of this level with their currently effective values are then returned.

The option T_ALLOPT can only be used with t_optmgmt() and the actions T_NEGOTIATE, T_DEFAULT and T_CURRENT. It can be used with any supported level and addresses all supported options of this level. The option has no value; it consists of a t_opthdr only. Since in a t_optmgmt() call only options of one level may be addressed, this option should not be requested together with other options. The function returns as soon as this option has been processed.

Options are independently processed in the order they appear in the input option buffer. If an option is multiply input, it depends on the implementation whether it is multiply output or whether it is returned only once.

The function t_optmgmt() may block under various circumstances and depending on the implementation. The function will block, for instance, if the protocol addressed by the call resides on a separate controller. It may also block due to flow control constraints. For example, if data sent previously across this transport endpoint has not yet been fully processed. If the function is interrupted by a signal, the option negotiations that have been done so far may remain valid. The behavior of the function is not changed if O_NONBLOCK is set.

Valid states: All - except for T_UNINIT

XTI-level options: XTI-level options are not specific for a particular transport provider. An XTI implementation supports none, all or any subset of the options defined below. An implementation may restrict the use of any of these options by offering them only in the privileged or read-only mode, or if fd relates to specific transport providers.

The subsequent options are not association-related They may be negotiated in all XTI states except T_UNINIT. See topic, “Use of Options in XTI”, in X/Open CAE Specification, Networking Services, Issue 4 for more information.

The protocol level is XTI_GENERIC. For this level, the following options are defined:
XTI_DEBUG
This option enables debugging. The valid values of this option are:
  • None (option header only) - indicating that debug is to be turned off.
  • -1 - indicating that debug output is to go to stderr.
  • A file descriptor - indicating the destination file for debug output.
The debug output contains varying information depending on the XTI services invoked. It is meant to be used by customer support personnel.
XTI_LINGER
This option is used to linger the execution of a t_close() or close() if send data is still queued in the send buffer. The option value specifies the linger period. If a close() or t_close() is issued and the send buffer is not empty, the system attempts to send the pending data within the linger period before closing the endpoint. Data still pending after the linger period has elapsed is discarded.

Depending on the implementation, t_close() or close() either block for at maximum the linger period, or immediately return, whereupon the system holds the connection in existence for at most the linger period.

The option value consists of a structure t_linger declared as:
struct t_linger {
        long l_onoff;   /* switch option on/off     */
        long l_linger;  /* linger period in seconds */
}
Legal values for the field l_onoff are:
T_NO
switch option off
T_YES
activate option
The value l_onoff is an absolute requirement.

The field l_linger determines the linger period in seconds. The transport user can request the default value by setting the field to T_UNSPEC. The default timeout value depends on the underlying transport provider (it is often T_INFINITE). Legal values for this field are T_UNSPEC, T_INFINITE and all nonnegative numbers.

The l_linger value is not an absolute requirement. The implementation may place upper and lower limits to this value. Requests that fall short of the lower limit are negotiated to the lower limit.

Note that this option does not linger the execution of t_snddis().

XTI_RCVBUF
This option is used to adjust the internal buffer size allocated for the receive buffer. The buffer size may be increased for high-volume connections, or decreased to limit the possible backlog of incoming data.

This request is not an absolute requirement. The implementation may place upper and lower limits on the option value. Requests that fall short of the lower limit are negotiated to the lower limit.

Legal values are all positive numbers.

XTI_SNDBUF
This option is used to adjust the internal buffer size allocated for the send buffer.

This request is not an absolute requirement. The implementation may place upper and lower limits on the option value. Requests that fall short of the lower limit are negotiated to the lower limit.

Legal values are all positive numbers.

TCP-level options: The protocol level is INET_TCP. The following TCP-level options are supported. They are not association-related.
TCP_KEEPALIVE
If this option is set, a keep-alive timer is activated to monitor idle connections that might no longer exist. If a connection has been idle since the last keep-alive timeout, a keep-alive packet is sent to check if the connection is still alive or broken.
The option value consists of a structure t_kpalive declared as:
struct t_kpalive {
     long    kp_onoff;       /* switch option on/off */
     long    kp_timeout;     /* keep-alive timeout in minutes */
 }
Legal values fot the field kp_onoff are:
T_NO
switch keep-alive timer off
T_YES
activate keep-alive timer
The field kp_timeout determines the frequency of keep-alive packets being sent, in minutes. The transport user can request the default value by setting the field to T_UNSPEC. The default is 120 minutes. Legal values for this field are T_UNSPEC and all positive numbers.

The timeout value is not an absolute requirement. However, no limits are currently specified by the TCP transport provider.

IP-level options: The protocol level is INET_IP. The following IP-level options are supported. The are not association-related.
IP_REUSEADDR
Generally, users are not allowed to bind more than one transport endpoint to addresses with identical port numbers, If IP_REUSEADDR is set to T_YES this restriction is relaxed in the sense that it is now permissible to bind a transport endpoint to an address with a port number and an under-specified internet address and further endpoints to addresses with the same port number and (mutually exclusive) fully specified internet addresses.

Returned value

If successful, t_optmgmt() returns 0.

If unsuccessful, t_optmgmt() returns -1 and sets errno to one of the following values:
Error Code
Description
TACCES
The user does not have permission to negotiate the specified options.
TBADF
The specified file descriptor does not refer to a transport endpoint.
TBADFLAG
An invalid flag was specified.
TBADOPT
The specified options were in an incorrect format or contained illegal information.
TBUFOVFLW
The number of bytes allowed for an incoming argument (maxlen) is greater than 0 but not sufficient to store the value of that argument. The information to be returned in ret will be discarded.
TNOTSUPPORT
This action is not supported by the transport provider.
TOUTSTATE
The function was issued in the wrong sequence.
TPROTO
This error indicates that a communication problem has been detected between XTI and the transport provider for which there is no other suitable XTI (t_errno).
TSYSERR
A system error has occurred during execution of this function.

Related information