summaryrefslogtreecommitdiffstats
path: root/include/osmocom/core/fsm.h
Commit message (Collapse)AuthorAgeFilesLines
* fsm: convenience: add inline osmo_fsm_inst_state_name()Neels Hofmeyr2017-03-011-0/+4
| | | | Change-Id: If9a6ecc4d6e2beaf716569e9a6053d73488e860b
* Add osmo_fsm_find_by_name() and avoid registering FSM with same nameHarald Welte2017-01-071-0/+1
| | | | | | | This addresses a FIXME in the fsm.c code: osmo_fsm_register() should fail in case a FSM with the given name already exists. Change-Id: I5fd882939859c79581eba70c14cbafd64560b583
* fsm: factor out osmo_fsm_inst_term_children() from osmo_fsm_inst_term()Neels Hofmeyr2016-12-241-0/+13
| | | | | | | | | | | | | | | | | | | | osmo_fsm_inst_term() has code for safe child removal, publish that part as osmo_fsm_inst_term_children(); also use from osmo_fsm_inst_term(). As with osmo_fsm_inst_term(), add osmo_fsm_inst_term_children() macro to pass the caller's source file and line to new _osmo_fsm_inst_term_children(). Rationale: in openbsc's VLR, I want to discard child FSMs when certain events are handled. I could keep a pointer to each one, or simply iterate all children, making the code a lot simpler in some places. (Unfortunately, the patch may be displayed subobtimally. This really only moves the children-loop to a new function, replaces it with a call to _osmo_fsm_inst_term_children(fi, OSMO_FSM_TERM_PARENT, NULL, file, line) and drops two local iterator variables. No other code changes are made, even though the diff may show large removal + addition chunks) Change-Id: I8dac1206259cbd251660f793ad023aaa1dc705a2
* fsm: move LOGPFSMSRC and LOGPFSMLSRC to .hNeels Hofmeyr2016-12-241-0/+13
| | | | | | | | | | | LOGPFSM and LOGPFSML are in the header file, put the *SRC variants also there so users of the osmo_fsm_inst API may conveniently create own functions that log the caller's source file and line. Very useful if many action functions call the same event dispatching function, like foo_fsm_done(), and one needs to know which of the callers to debug. Change-Id: I39447b1d15237b28f88d8c5f08d82c764679dc80
* fsm api doc: fix typo in doxygen marker '\breif'Neels Hofmeyr2016-12-201-1/+1
| | | | Change-Id: I5c57e35b29d50cb409becada6b9b120ce5210ae0
* add value strings for enum osmo_fsm_term_cause and use for loggingNeels Hofmeyr2016-12-151-0/+7
| | | | Change-Id: Iaf63d3cadb0d46bf454e3314ebb439240cafd834
* fsm: log caller's source for events and state changes, not fsm.c linesNeels Hofmeyr2016-12-141-6/+35
| | | | | | | | | | | | | | | | | | | | | | | When looking at log output, it is not interesting to see that a state transition's petty details are implemented in fsm.c. Rather log the *caller's* source file and line that caused an event, state change and cascading events. To that end, introduce LOGPSRC() absorbing the guts of LOGP(), to be able to explicitly pass the source file and line information. Prepend an underscore to the function names of osmo_fsm_inst_state_chg(), osmo_fsm_inst_dispatch() and osmo_fsm_inst_term(), and add file and line arguments to them. Provide the previous names as macros that insert the caller's __BASE_FILE__ and __LINE__ constants for the new arguments. Hence no calling code needs to be changed. In fsm.c, add LOGPFSMSRC to call LOGPSRC, and add LOGPFSMLSRC, and use them in above _osmo_fsm_inst_* functions. In addition, in _osmo_fsm_inst_term(), pass the caller's source file and line on to nested event dispatches, so showing where a cascade originated from. Change-Id: Iae72aba7bbf99e19dd584ccabea5867210650dcd
* fsm: add LOGPFSML to pass explicit logging levelNeels Hofmeyr2016-12-141-2/+5
| | | | | | | | | | | | | | Provide one central LOGPFSML to print FSM information, take the FSM logging subsystem from the FSM instance but use an explicitly provided log level instead of the FSM's default level. Use to replace some, essentially, duplications of the LOGPFSM macro. In effect, the fsm_test's expected error changes, since the previous code dup for logging events used round braces to indicate the fi's state, while the central macro uses curly braces. Change-Id: If295fdabb3f31a0fd9490d1e0df57794c75ae547
* doc: fsm timer_cb: explain return valueNeels Hofmeyr2016-12-091-1/+2
| | | | Change-Id: Ic6fbe95737862ed8b8de78058989c8b2ae330006
* Add osmo_fsm_unregister() to headerMax2016-11-021-1/+1
| | | | | | | Previously function was defined but not exposed so there were a way to register FSM but no way to unregister it. Change-Id: I2e749d896009784b77d6d5952fcc38e1c131db2b
* fsm: Introduce default time-out handlingHarald Welte2016-06-271-1/+3
| | | | | | | | | | | If a FSM doesn't specify any timer_cb, simply terminate the FSM by default on time-out. This is a reasonable default for most cases, and avoids copy+pasting a one-line timer_cb function in every FSM. Also, even if there is a timer_cb, let it have a return value to decide if the core should terminate after return from timer_cb or not. Change-Id: I0461a9593bfb729c82b7d1d1cf9f30b1079d0212
* Add Finite State Machine abstraction codeHarald Welte2016-06-161-0/+135
This code is supposed to formalize some of the state machine handling in Osmocom code. Change-Id: I0b0965a912598c1f6b84042a99fea9d522642466 Reviewed-on: https://gerrit.osmocom.org/163 Tested-by: Jenkins Builder Reviewed-by: Harald Welte <laforge@gnumonks.org>