135 #define LOGPFSMSL(fi, subsys, level, fmt, args...) \ 136 LOGPFSMSLSRC(fi, subsys, level, __FILE__, __LINE__, fmt, ## args) 148 #define LOGPFSMSLSRC(fi, subsys, level, caller_file, caller_line, fmt, args...) \ 149 LOGPSRC(subsys, level, \ 150 caller_file, caller_line, \ 152 osmo_fsm_inst_name(fi), \ 153 (fi) ? osmo_fsm_state_name((fi)->fsm, (fi)->state) : "fi=NULL", ## args) 162 #define LOGPFSML(fi, level, fmt, args...) \ 163 LOGPFSMLSRC(fi, level, __FILE__, __LINE__, fmt, ## args) 174 #define LOGPFSMLSRC(fi, level, caller_file, caller_line, fmt, args...) \ 175 LOGPFSMSLSRC(fi, (fi) ? (fi)->fsm->log_subsys : DLGLOBAL, level, \ 176 caller_file, caller_line, fmt, ## args) 185 #define LOGPFSM(fi, fmt, args...) \ 186 LOGPFSML(fi, (fi) ? (fi)->log_level : LOGL_ERROR, fmt, ## args) 197 #define LOGPFSMSRC(fi, caller_file, caller_line, fmt, args...) \ 198 LOGPFSMLSRC(fi, (fi) ? (fi)->log_level : LOGL_ERROR, \ 199 caller_file, caller_line, \ 202 #define OSMO_T_FMT "%c%u" 203 #define OSMO_T_FMT_ARGS(T) ((T) >= 0 ? 'T' : 'X'), ((T) >= 0 ? (T) : -(T)) 220 uint32_t new_parent_term_event);
241 #define osmo_fsm_inst_state_chg(fi, new_state, timeout_secs, T) \ 242 _osmo_fsm_inst_state_chg(fi, new_state, timeout_secs, T, \ 245 unsigned long timeout_secs,
int T,
246 const char *
file,
int line);
248 #define osmo_fsm_inst_state_chg_ms(fi, new_state, timeout_ms, T) \ 249 _osmo_fsm_inst_state_chg_ms(fi, new_state, timeout_ms, T, \ 252 unsigned long timeout_ms,
int T,
253 const char *
file,
int line);
264 #define osmo_fsm_inst_state_chg_keep_timer(fi, new_state) \ 265 _osmo_fsm_inst_state_chg_keep_timer(fi, new_state, \ 268 const char *
file,
int line);
278 #define osmo_fsm_inst_state_chg_keep_or_start_timer(fi, new_state, timeout_secs, T) \ 279 _osmo_fsm_inst_state_chg_keep_or_start_timer(fi, new_state, timeout_secs, T, \ 282 unsigned long timeout_secs,
int T,
283 const char *
file,
int line);
285 #define osmo_fsm_inst_state_chg_keep_or_start_timer_ms(fi, new_state, timeout_ms, T) \ 286 _osmo_fsm_inst_state_chg_keep_or_start_timer_ms(fi, new_state, timeout_ms, T, \ 289 unsigned long timeout_ms,
int T,
290 const char *
file,
int line);
299 #define osmo_fsm_inst_dispatch(fi, event, data) \ 300 _osmo_fsm_inst_dispatch(fi, event, data, __FILE__, __LINE__) 302 const char *
file,
int line);
310 #define osmo_fsm_inst_term(fi, cause, data) \ 311 _osmo_fsm_inst_term(fi, cause, data, __FILE__, __LINE__) 314 const char *
file,
int line);
322 #define osmo_fsm_inst_term_children(fi, cause, data) \ 323 _osmo_fsm_inst_term_children(fi, cause, data, __FILE__, __LINE__) 327 const char *
file,
int line);
335 #define osmo_fsm_inst_broadcast_children(fi, cause, data) \ 336 _osmo_fsm_inst_broadcast_children(fi, cause, data, __FILE__, __LINE__) 338 void *
data,
const char *
file,
int line);
int _osmo_fsm_inst_state_chg_keep_or_start_timer(struct osmo_fsm_inst *fi, uint32_t new_state, unsigned long timeout_secs, int T, const char *file, int line)
perform a state change while keeping the current timer if running, or starting a timer otherwise...
Definition: fsm.c:802
uint32_t state
current state of the FSM
Definition: fsm.h:101
struct osmo_fsm_inst * parent
the parent FSM that has created us
Definition: fsm.h:111
int log_subsys
logging sub-system for this FSM
Definition: fsm.h:79
uint32_t out_state_mask
bit-mask to which other states this state may transiton
Definition: fsm.h:46
const char * name
human-readable name of this state
Definition: fsm.h:48
const char * osmo_fsm_state_name(const struct osmo_fsm *fsm, uint32_t state)
get human-readable name of FSM state
Definition: fsm.c:609
struct osmo_fsm_inst * osmo_fsm_inst_find_by_name(const struct osmo_fsm *fsm, const char *name)
Definition: fsm.c:245
int _osmo_fsm_inst_dispatch(struct osmo_fsm_inst *fi, uint32_t event, void *data, const char *file, int line)
dispatch an event to an osmocom finite state machine instance
Definition: fsm.c:833
const char * name
human readable fully-qualified name
Definition: fsm.h:95
const char * osmo_fsm_inst_name(const struct osmo_fsm_inst *fi)
get human-readable name of FSM instance
Definition: fsm.c:593
int _osmo_fsm_inst_state_chg(struct osmo_fsm_inst *fi, uint32_t new_state, unsigned long timeout_secs, int T, const char *file, int line)
perform a state change of the given FSM instance
Definition: fsm.c:742
void osmo_fsm_term_safely(bool term_safely)
Enable safer way to deallocate cascades of terminating FSM instances.
Definition: fsm.c:168
uint32_t allstate_event_mask
bit-mask of events permitted in all states
Definition: fsm.h:70
const char * get_value_string(const struct value_string *vs, uint32_t val)
get human-readable string for given value
Definition: utils.c:62
void osmo_fsm_inst_free(struct osmo_fsm_inst *fi)
delete a given instance of a FSM
Definition: fsm.c:536
void osmo_fsm_log_addr(bool log_addr)
specify if FSM instance addresses should be logged or not
Definition: fsm.c:122
osmo_fsm_term_cause
Definition: fsm.h:21
const struct value_string osmo_fsm_term_cause_names[]
Definition: fsm.c:1037
int T
timer number for states with time-out
Definition: fsm.h:104
void osmo_fsm_unregister(struct osmo_fsm *fsm)
unregister a FSM from the core
Definition: fsm.c:305
struct osmo_fsm * fsm
back-pointer to the FSM of which we are an instance
Definition: fsm.h:91
struct osmo_fsm_inst * osmo_fsm_inst_find_by_id(const struct osmo_fsm *fsm, const char *id)
Definition: fsm.c:262
int _osmo_fsm_inst_state_chg_keep_timer(struct osmo_fsm_inst *fi, uint32_t new_state, const char *file, int line)
perform a state change while keeping the current timer running.
Definition: fsm.c:774
static const char * osmo_fsm_inst_state_name(struct osmo_fsm_inst *fi)
return the name of the state the FSM instance is currently in.
Definition: fsm.h:232
void _osmo_fsm_inst_term(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause, void *data, const char *file, int line)
Terminate FSM instance with given cause.
Definition: fsm.c:896
struct osmo_fsm * osmo_fsm_find_by_name(const char *name)
Definition: fsm.c:235
const char * id
human readable identifier
Definition: fsm.h:93
A mapping between human-readable string and numeric value.
Definition: utils.h:51
uint32_t parent_term_event
the event we should send upon termination
Definition: fsm.h:113
void(* onleave)(struct osmo_fsm_inst *fi, uint32_t next_state)
function to be called just before leaving the state
Definition: fsm.h:54
void _osmo_fsm_inst_term_children(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause, void *data, const char *file, int line)
Terminate all child FSM instances of an FSM instance.
Definition: fsm.c:986
erroneous termination of process
Definition: fsm.h:29
unsigned int num_states
number of entries in states
Definition: fsm.h:68
write Write running configuration to or terminal n Write configuration to the file(same as write file)\n") ALIAS(config_write_file
struct osmo_fsm_inst * osmo_fsm_inst_alloc(struct osmo_fsm *fsm, void *ctx, void *priv, int log_level, const char *id)
allocate a new instance of a specified FSM
Definition: fsm.c:437
Osmocom timer handling routines.
const char * name
human readable name
Definition: fsm.h:64
static const char * osmo_fsm_term_cause_name(enum osmo_fsm_term_cause cause)
Definition: fsm.h:35
void * priv
some private data of this instance
Definition: fsm.h:97
void osmo_fsm_inst_change_parent(struct osmo_fsm_inst *fi, struct osmo_fsm_inst *new_parent, uint32_t new_parent_term_event)
change parent instance of an FSM.
Definition: fsm.c:517
a single instanceof an osmocom finite state machine
Definition: fsm.h:87
int log_level
logging level for this FSM
Definition: fsm.h:99
Simple doubly linked list implementation.
void osmo_fsm_log_timeouts(bool log_timeouts)
Enable or disable logging of timeout values for FSM instance state changes.
Definition: fsm.c:142
(double) linked list header structure
Definition: linuxlist.h:46
a description of an osmocom finite state machine
Definition: fsm.h:58
int _osmo_fsm_inst_state_chg_keep_or_start_timer_ms(struct osmo_fsm_inst *fi, uint32_t new_state, unsigned long timeout_ms, int T, const char *file, int line)
Definition: fsm.c:808
void(* action)(struct osmo_fsm_inst *fi, uint32_t event, void *data)
function to be called for events arriving in this state
Definition: fsm.h:50
int osmo_fsm_inst_update_id_f_sanitize(struct osmo_fsm_inst *fi, char replace_with, const char *fmt,...)
Change id of the FSM instance using a string format, and ensuring a valid id.
Definition: fsm.c:409
description of a rule in the FSM
Definition: fsm.h:42
const struct osmo_fsm_state * states
table of state transition rules
Definition: fsm.h:66
void(* onenter)(struct osmo_fsm_inst *fi, uint32_t prev_state)
function to be called just after entering the state
Definition: fsm.h:52
void _osmo_fsm_inst_broadcast_children(struct osmo_fsm_inst *fi, uint32_t event, void *data, const char *file, int line)
Broadcast an event to all the FSMs children.
Definition: fsm.c:1027
const char * osmo_fsm_event_name(const struct osmo_fsm *fsm, uint32_t event)
get human-readable name of FSM event
Definition: fsm.c:579
const struct value_string * event_names
human-readable names of events
Definition: fsm.h:81
void osmo_fsm_set_dealloc_ctx(void *ctx)
Instead of deallocating FSM instances, move them to the given talloc context.
Definition: fsm.c:193
void osmo_fsm_inst_unlink_parent(struct osmo_fsm_inst *fi, void *ctx)
unlink child FSM from its parent FSM.
Definition: fsm.c:500
bool terminating
Indicator whether osmo_fsm_inst_term() was already invoked on this instance.
Definition: fsm.h:119
terminate because parent terminated
Definition: fsm.h:23
int osmo_fsm_inst_update_id_f(struct osmo_fsm_inst *fi, const char *fmt,...)
Change id of the FSM instance using a string format.
Definition: fsm.c:372
int _osmo_fsm_inst_state_chg_ms(struct osmo_fsm_inst *fi, uint32_t new_state, unsigned long timeout_ms, int T, const char *file, int line)
Definition: fsm.c:748
A structure representing a single instance of a timer.
Definition: timer.h:52
int osmo_fsm_register(struct osmo_fsm *fsm)
register a FSM with the core
Definition: fsm.c:282
int osmo_fsm_inst_update_id(struct osmo_fsm_inst *fi, const char *id)
Change id of the FSM instance.
Definition: fsm.c:340
uint32_t in_event_mask
bit-mask of permitted input events for this state
Definition: fsm.h:44
struct osmo_fsm_inst * osmo_fsm_inst_alloc_child(struct osmo_fsm *fsm, struct osmo_fsm_inst *parent, uint32_t parent_term_event)
allocate a new instance of a specified FSM as child of other FSM instance
Definition: fsm.c:472
regular termination of process
Definition: fsm.h:27
termination due to time-out
Definition: fsm.h:31
terminate on explicit user request
Definition: fsm.h:25