src/connection_state_machine.h file

Classes

struct state_machine_ctx_t
state_machine_ctx_t - Struct represents connection state machine.

Enums

enum LdapConnectionState { LDAP_CONNECTION_STATE_INIT = 1, LDAP_CONNECTION_STATE_TLS_NEGOTIATION = 2, LDAP_CONNECTION_STATE_TRANSPORT_READY = 3, LDAP_CONNECTION_STATE_BIND_IN_PROGRESS = 4, LDAP_CONNECTION_STATE_BOUND = 5, LDAP_CONNECTION_STATE_DETECT_DIRECTORY = 6, LDAP_CONNECTION_STATE_RUN = 7, LDAP_CONNECTION_STATE_ERROR = 8, LDAP_CONNECTION_STATE_REQUEST_SCHEMA = 9, LDAP_CONNECTION_STATE_CHECK_SCHEMA = 10 }

Typedefs

using state_machine_ctx_t = struct state_machine_ctx_t
state_machine_ctx_t - Struct represents connection state machine.

Functions

auto csm_init(struct state_machine_ctx_t* ctx, struct ldap_connection_ctx_t* connection) -> enum OperationReturnCode
csm_init Initializes state machine, sets machine state to LDAP_CONNECTION_STATE_INIT.
auto csm_next_state(struct state_machine_ctx_t* ctx) -> enum OperationReturnCode
csm_next_state Advances state based on a current machine state.
auto csm_set_state(struct state_machine_ctx_t* ctx, enum LdapConnectionState state) -> enum OperationReturnCode
csm_set_state Sets new state, prints transition between states.
auto csm_is_in_state(struct state_machine_ctx_t* ctx, enum LdapConnectionState state) -> bool
csm_is_in_state Checks if state macheine is in desired state.

Enum documentation

enum LdapConnectionState

Enumerators
LDAP_CONNECTION_STATE_INIT

Initial state of the LDAP connection.

LDAP_CONNECTION_STATE_TLS_NEGOTIATION

The connection is in the process of negotiating TLS encryption.

LDAP_CONNECTION_STATE_TRANSPORT_READY

The underlying transport layer is ready for communication.

LDAP_CONNECTION_STATE_BIND_IN_PROGRESS

The connection is in the process of binding.

LDAP_CONNECTION_STATE_BOUND

The connection has successfully performed LDAP bound.

LDAP_CONNECTION_STATE_DETECT_DIRECTORY

The connection is in the process of detecting type of the LDAP directory service.

LDAP_CONNECTION_STATE_RUN

The LDAP connection is active and ready for operations.

LDAP_CONNECTION_STATE_ERROR

The LDAP connection is in an error state.

LDAP_CONNECTION_STATE_REQUEST_SCHEMA

The LDAP connection is in the process of loading schema.

LDAP_CONNECTION_STATE_CHECK_SCHEMA

The LDAP connection is in the process of checking schema readiness.

Function documentation

enum OperationReturnCode csm_init(struct state_machine_ctx_t* ctx, struct ldap_connection_ctx_t* connection)

csm_init Initializes state machine, sets machine state to LDAP_CONNECTION_STATE_INIT.

Parameters
ctx in state machine to initialize
connection in connection to use
Returns RETURN_CODE_SUCCESS.

enum OperationReturnCode csm_next_state(struct state_machine_ctx_t* ctx)

csm_next_state Advances state based on a current machine state.

Parameters
ctx in state machine to use
Returns
  • RETURN_CODE_SUCCESS on success.
  • RETURN_CODE_OPERATION_IN_PROGRESS is operation is still running.
  • RETURN_CODE_FAILURE on failure.

enum OperationReturnCode csm_set_state(struct state_machine_ctx_t* ctx, enum LdapConnectionState state)

csm_set_state Sets new state, prints transition between states.

Parameters
ctx in state machine to use
state in state to set
Returns RETURN_CODE_SUCCESS.

bool csm_is_in_state(struct state_machine_ctx_t* ctx, enum LdapConnectionState state)

csm_is_in_state Checks if state macheine is in desired state.

Parameters
ctx in state machine to use
state in state to set
Returns
  • true - if machine current state matches
    • {state}
  • false - if not