src/connection_state_machine.c file

Classes

struct csm_state_value_t

Typedefs

using csm_state_value_t = struct csm_state_value_t

Functions

auto csm_state2str(int state) -> const char*
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(state_machine_ctx_t* ctx, enum LdapConnectionState state) -> bool
csm_is_in_state Checks if state macheine is in desired state.

Variables

const csm_state_value_t state_strings
const int state_strings_size
static const int MAX_RECONNECT_ATTEMPTS

Defines

#define number_of_elements(x)

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(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