libosmocore
0.12.0
Osmocom core library
|
Go to the documentation of this file.
122 #define LOGPFSML(fi, level, fmt, args...) \
123 LOGP((fi)->fsm->log_subsys, OSMO_MAX(level, (fi)->log_level), \
125 osmo_fsm_inst_name(fi), \
126 osmo_fsm_state_name((fi)->fsm, (fi)->state), ## args)
128 #define LOGPFSM(fi, fmt, args...) \
129 LOGPFSML(fi, (fi)->log_level, fmt, ## args)
131 #define LOGPFSMLSRC(fi, level, caller_file, caller_line, fmt, args...) \
132 LOGPSRC((fi)->fsm->log_subsys, level, \
133 caller_file, caller_line, \
135 osmo_fsm_inst_name(fi), \
136 osmo_fsm_state_name((fi)->fsm, (fi)->state), \
139 #define LOGPFSMSRC(fi, caller_file, caller_line, fmt, args...) \
140 LOGPFSMLSRC(fi, (fi)->log_level, \
141 caller_file, caller_line, \
159 uint32_t new_parent_term_event);
179 #define osmo_fsm_inst_state_chg(fi, new_state, timeout_secs, T) \
180 _osmo_fsm_inst_state_chg(fi, new_state, timeout_secs, T, \
181 __BASE_FILE__, __LINE__)
183 unsigned long timeout_secs,
int T,
184 const char *file,
int line);
195 #define osmo_fsm_inst_state_chg_keep_timer(fi, new_state) \
196 _osmo_fsm_inst_state_chg_keep_timer(fi, new_state, \
197 __BASE_FILE__, __LINE__)
199 const char *file,
int line);
207 #define osmo_fsm_inst_dispatch(fi, event, data) \
208 _osmo_fsm_inst_dispatch(fi, event, data, __BASE_FILE__, __LINE__)
210 const char *file,
int line);
218 #define osmo_fsm_inst_term(fi, cause, data) \
219 _osmo_fsm_inst_term(fi, cause, data, __BASE_FILE__, __LINE__)
222 const char *file,
int line);
230 #define osmo_fsm_inst_term_children(fi, cause, data) \
231 _osmo_fsm_inst_term_children(fi, cause, data, __BASE_FILE__, __LINE__)
235 const char *file,
int line);
@ OSMO_FSM_TERM_ERROR
erroneous termination of process
Definition: fsm.h:28
A structure representing a single instance of a timer.
Definition: timer.h:55
void * priv
some private data of this instance
Definition: fsm.h:96
description of a rule in the FSM
Definition: fsm.h:41
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:546
@ OSMO_FSM_TERM_REGULAR
regular termination of process
Definition: fsm.h:26
const char * get_value_string(const struct value_string *vs, uint32_t val)
get human-readable string for given value
Definition: utils.c:55
const char * name
human readable name
Definition: fsm.h:63
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:244
struct llist_head children
a list of children processes
Definition: fsm.h:114
int log_subsys
logging sub-system for this FSM
Definition: fsm.h:78
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:280
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:497
struct osmo_fsm_inst::@0 proc
support for fsm-based procedures
struct llist_head child
llist_head linked to parent->proc.children
Definition: fsm.h:116
osmo_fsm_term_cause
Definition: fsm.h:20
const char * osmo_fsm_event_name(struct osmo_fsm *fsm, uint32_t event)
get human-readable name of FSM event
Definition: fsm.c:392
uint32_t allstate_event_mask
bit-mask of events permitted in all states
Definition: fsm.h:69
void osmo_fsm_log_addr(bool log_addr)
specify if FSM instance addresses should be logged or not
Definition: fsm.c:102
a single instanceof an osmocom finite state machine
Definition: fsm.h:86
void(* onleave)(struct osmo_fsm_inst *fi, uint32_t next_state)
function to be called just before leaving the state
Definition: fsm.h:53
a description of an osmocom finite state machine
Definition: fsm.h:57
void(* allstate_action)(struct osmo_fsm_inst *fi, uint32_t event, void *data)
function pointer to be called for allstate events
Definition: fsm.h:71
char name[32]
source file name
Definition: gsmtap.h:13
void osmo_fsm_inst_free(struct osmo_fsm_inst *fi)
delete a given instance of a FSM
Definition: fsm.c:379
struct osmo_fsm * osmo_fsm_find_by_name(const char *name)
Definition: fsm.c:107
void osmo_fsm_unregister(struct osmo_fsm *fsm)
unregister a FSM from the core
Definition: fsm.c:177
const struct osmo_fsm_state * states
table of state transition rules
Definition: fsm.h:65
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:653
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:523
@ OSMO_FSM_TERM_PARENT
terminate because parent terminated
Definition: fsm.h:22
struct osmo_fsm_inst * parent
the parent FSM that has created us
Definition: fsm.h:110
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:170
const struct value_string osmo_fsm_term_cause_names[]
Definition: fsm.c:684
void osmo_fsm_inst_unlink_parent(struct osmo_fsm_inst *fi, void *ctx)
unlink child FSM from its parent FSM.
Definition: fsm.c:343
void(* cleanup)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
clean-up function, called during termination
Definition: fsm.h:73
const char * name
human readable fully-qualified name
Definition: fsm.h:94
uint32_t state
current state of the FSM
Definition: fsm.h:100
int(* timer_cb)(struct osmo_fsm_inst *fi)
timer call-back for states with time-out.
Definition: fsm.h:76
(double) linked list header structure
Definition: linuxlist.h:46
int T
timer number for states with time-out
Definition: fsm.h:103
@ OSMO_FSM_TERM_REQUEST
terminate on explicit user request
Definition: fsm.h:24
unsigned int num_states
number of entries in states
Definition: fsm.h:67
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:49
const char * id
human readable identifier
Definition: fsm.h:92
static const char * osmo_fsm_term_cause_name(enum osmo_fsm_term_cause cause)
Definition: fsm.h:34
@ OSMO_FSM_TERM_TIMEOUT
termination due to time-out
Definition: fsm.h:30
A mapping between human-readable string and numeric value.
Definition: utils.h:38
const char * osmo_fsm_inst_name(struct osmo_fsm_inst *fi)
get human-readable name of FSM instance
Definition: fsm.c:406
struct osmo_fsm * fsm
back-pointer to the FSM of which we are an instance
Definition: fsm.h:90
void(* pre_term)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
graceful exit function, called at the beginning of termination
Definition: fsm.h:82
void(* onenter)(struct osmo_fsm_inst *fi, uint32_t prev_state)
function to be called just after entering the state
Definition: fsm.h:51
struct llist_head instances
list of instances of this FSM
Definition: fsm.h:61
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:360
int osmo_fsm_register(struct osmo_fsm *fsm)
register a FSM with the core
Definition: fsm.c:154
int osmo_fsm_inst_update_id(struct osmo_fsm_inst *fi, const char *id)
Change id of the FSM instance.
Definition: fsm.c:212
const char * osmo_fsm_state_name(struct osmo_fsm *fsm, uint32_t state)
get human-readable name of FSM instance
Definition: fsm.c:422
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:315
uint32_t parent_term_event
the event we should send upon termination
Definition: fsm.h:112
struct osmo_fsm_inst * osmo_fsm_inst_find_by_name(const struct osmo_fsm *fsm, const char *name)
Definition: fsm.c:117
uint32_t in_event_mask
bit-mask of permitted input events for this state
Definition: fsm.h:43
const struct value_string * event_names
human-readable names of events
Definition: fsm.h:80
uint32_t out_state_mask
bit-mask to which other states this state may transiton
Definition: fsm.h:45
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:601
const char * name
human-readable name of this state
Definition: fsm.h:47
struct osmo_timer_list timer
timer back-end for states with time-out
Definition: fsm.h:105
struct llist_head list
global list
Definition: fsm.h:59
struct osmo_fsm_inst * osmo_fsm_inst_find_by_id(const struct osmo_fsm *fsm, const char *id)
Definition: fsm.c:134
int log_level
logging level for this FSM
Definition: fsm.h:98
struct llist_head list
member in the fsm->instances list
Definition: fsm.h:88