Protocol Control APIs

The server provides some client-visible ways to control client protocol sessions.

SIL Protocol Control

The internal APIs that support these mechanisms are available to SIL code:

agt_protocol_enabled

Returns true if:

  • Server compileed with correct compiler flags

  • Server configured to start this protocol

  • Sessions enabled for this protocol

boolean agt_protocol_enabled(const xmlChar *proto)

Check if protocol sessions are enabled.

Parameters:

proto -- protocol name that matches bit names in the "--disabled-protocols" field

Returns:

TRUE if named protocol is anabled and sessions enabled

agt_enable_protocol

Only enables sessions for the protocol.

  • The server must be built with correct flags and configured for sessions to actually be allowed.

status_t agt_enable_protocol(const xmlChar *proto)

Enable the named protocol.

Has no effect if "--with-foo" flag for protocol not true Does not check if already enabled.

Parameters:

proto -- protocol name that matches bit names in the "--disabled-protocols" field

Returns:

status

agt_disable_protocol

Warning

The server does not check if all protocols are disabled, since not all protocols can be controlled at run-time. Use with extreme caution or server can become unreachable by clients

Only disables sessions for the protocol.

  • The server must be built with correct flags and configured for sessions to actually be allowed.

status_t agt_disable_protocol(const xmlChar *proto)

Disable the named protocol.

Has no effect if "--with-foo" flag for protocol not true Does not check if protocol already disabled.

Parameters:

proto -- protocol name that matches bit names in the "--disabled-protocols" field

Returns:

status

DB-API Protocol Control

The DB-API library provides an external function that accepts the same parameters as the <protocol-control> operation.

db_api_send_protocol_control

This function is defined in the 'db-api/db_api.h' file.

status_t db_api_send_protocol_control(const xmlChar *action, const xmlChar *protocol)

Create a <protocol-control> request and send it to the main server.

Refer to the <protocol-control> operation in yumaworks-system.yang

Parameters:
  • action -- protocol action

  • protocol -- protocol name

Returns:

status

This function is used in the 'db-api-app' example program to support the 'protocol-control' operation.

/********************************************************************
* FUNCTION send_test_protocol_control
*
* Send a <protocol-controll> request
*********************************************************************/
static status_t
    send_test_protocol_control (const char *action,
                                const char *protocol)
{
    status_t res =
        db_api_send_protocol_control((const xmlChar *)action,
                                     (const xmlChar *)protocol);
    if (res != NO_ERR) {
        log_error("\nSend test protocol-control action='%s' protocol='%s' "
                  " failed (%s)\n",
                  action,
                  protocol,
                  get_error_string(res));
    } else if (LOGDEBUG) {
        log_debug("\nSend test protocol-control action='%s' "
                  "protocol='%s' OK\n",
                  action,
                  protocol);
    }
    return res;

} /* send_test_protocol_control */