23 RCSID(
"$Id: bd8fcd446cc0672e44e5ae1173274360eaee6685 $")
81 hook->
func(m, state1, state2, hook->
uctx);
204 for (j = 0; j < 2; j++) {
219 #ifdef STATIC_ANALYZER
398 if (m->
dead)
return -1;
403 if ((state <= 0) || (state > m->
def->
max_state))
return -1;
414 if (
current->def->number == state)
return 0;
419 if (!
current->def->allowed[state])
return -1;
438 if (!defer)
return -1;
440 defer->
state = state;
487 if ((state < 0) || (state > m->
def->
max_state))
return "<INVALID>";
546 if (!hook)
return NULL;
584 if (m->
paused > 0)
return;
597 int state = defer->
state;
624 if (m->
dead)
return -1;
629 if ((signal <= 0) || (signal > m->
def->
max_signal))
return -1;
655 if (state == 0)
return 0;
fr_dcursor_eval_t void const * uctx
fr_dcursor_iter_t void * current
#define fr_dlist_init(_head, _type, _field)
Initialise the head structure of a doubly linked list.
static void * fr_dlist_next(fr_dlist_head_t const *list_head, void const *ptr)
Get the next item in a list.
static unsigned int fr_dlist_num_elements(fr_dlist_head_t const *head)
Return the number of elements in the dlist.
static void * fr_dlist_head(fr_dlist_head_t const *list_head)
Return the HEAD item of a list or NULL if the list is empty.
static int fr_dlist_insert_tail(fr_dlist_head_t *list_head, void *ptr)
Insert an item into the tail of a list.
static void * fr_dlist_remove(fr_dlist_head_t *list_head, void *ptr)
Remove an item from the list.
Head of a doubly linked list.
Entry in a doubly linked list.
static void call_hook(fr_machine_t *m, fr_dlist_head_t *head, int state1, int state2)
Call the hook with the current state machine, and the hooks context.
fr_dlist_t dlist
linked list of deferred signals
fr_dlist_head_t signal[2]
pre/post signal hooks
int fr_machine_signal(fr_machine_t *m, int signal)
Send an async signal to the state machine.
fr_dlist_head_t * head
where the hook is stored
static int _machine_free(fr_machine_t *m)
Free a state machine.
fr_dlist_t dlist
linked list of hooks
fr_machine_state_t const * def
static definition of names, callbacks for this particular state
fr_dlist_head_t enter[2]
pre/post enter hooks
static int _machine_hook_free(fr_machine_hook_t *hook)
bool dead
we were asked to exit, but aren't yet done cleaning up
int fr_machine_process(fr_machine_t *m)
Process the state machine.
fr_machine_hook_func_t func
function to call for the hook
static void state_transition(fr_machine_t *m, int state, void *in_handler)
Transition from one state to another.
void * uctx
to pass to the various handlers
fr_machine_state_inst_t state[]
all of the state transitions
int state
state transition to defer
bool oneshot
is this a one-shot callback?
char const * fr_machine_state_name(fr_machine_t *m, int state)
Get the name of a particular state.
fr_machine_def_t const * def
static definition of states, names, callbacks for the state machine
fr_dlist_head_t process[2]
pre/post process hooks
fr_dlist_head_t deferred
list of deferred entries
void fr_machine_resume(fr_machine_t *m)
Resume transitions.
int fr_machine_transition(fr_machine_t *m, int state)
Transition to a new state.
void * fr_machine_hook(fr_machine_t *m, TALLOC_CTX *ctx, int state_to_hook, fr_machine_hook_type_t type, fr_machine_hook_sense_t sense, bool oneshot, fr_machine_hook_func_t func, void *uctx)
Add a hook to a state, with an optional talloc_ctx.
fr_dlist_head_t exit[2]
pre/post exit hooks
void fr_machine_pause(fr_machine_t *m)
Pause any transitions.
int fr_machine_current(fr_machine_t *m)
Get the current state.
fr_machine_t * fr_machine_alloc(TALLOC_CTX *ctx, fr_machine_def_t const *def, void *uctx)
Instantiate a state machine.
int paused
are transitions paused?
void const * in_handler
which handler we are in
void * uctx
to pass back to the function
static int state_post(fr_machine_t *m, int state)
Post the new state to the state machine.
fr_machine_state_inst_t * current
current state we are in
int max_signal
1..max signals are permitted
struct fr_machine_s fr_machine_t
int free
state to run on free
fr_machine_process_t process
run this to process the current state
fr_machine_func_t exit
run this when exiting the state
int number
enum for this state machine
char const * name
state name
void(* fr_machine_hook_func_t)(fr_machine_t *m, int, int, void *uctx)
fr_machine_state_t state[]
states
int init
state to run on init
int max_state
1..max states are permitted
fr_machine_func_t enter
run this when entering the state
fr_aka_sim_id_type_t type