blob: a1ffd30dcfbe193f1dca1bc2ba4d72fc9567118a [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file fsm.h
2 * Finite State Machine
3 */
4
Harald Welte136e7372016-05-29 10:53:17 +09005#pragma once
6
7#include <stdint.h>
8#include <stdbool.h>
9
10#include <osmocom/core/linuxlist.h>
11#include <osmocom/core/timer.h>
12#include <osmocom/core/utils.h>
Neels Hofmeyr344776d2019-11-09 06:41:10 +010013#include <osmocom/core/logging.h>
Harald Welte136e7372016-05-29 10:53:17 +090014
15/*! \defgroup fsm Finite State Machine abstraction
16 * @{
Neels Hofmeyr17518fe2017-06-20 04:35:06 +020017 * \file fsm.h */
Harald Welte136e7372016-05-29 10:53:17 +090018
19struct osmo_fsm_inst;
20
21enum osmo_fsm_term_cause {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020022 /*! terminate because parent terminated */
Harald Welte136e7372016-05-29 10:53:17 +090023 OSMO_FSM_TERM_PARENT,
Neels Hofmeyr87e45502017-06-20 00:17:59 +020024 /*! terminate on explicit user request */
Harald Welte136e7372016-05-29 10:53:17 +090025 OSMO_FSM_TERM_REQUEST,
Neels Hofmeyr87e45502017-06-20 00:17:59 +020026 /*! regular termination of process */
Harald Welte136e7372016-05-29 10:53:17 +090027 OSMO_FSM_TERM_REGULAR,
Neels Hofmeyr87e45502017-06-20 00:17:59 +020028 /*! erroneous termination of process */
Harald Welte136e7372016-05-29 10:53:17 +090029 OSMO_FSM_TERM_ERROR,
Neels Hofmeyr87e45502017-06-20 00:17:59 +020030 /*! termination due to time-out */
Harald Weltef627c0f2016-06-18 10:36:25 +020031 OSMO_FSM_TERM_TIMEOUT,
Harald Welte136e7372016-05-29 10:53:17 +090032};
33
Neels Hofmeyr5c5c78a2016-12-14 18:35:47 +010034extern const struct value_string osmo_fsm_term_cause_names[];
35static inline const char *osmo_fsm_term_cause_name(enum osmo_fsm_term_cause cause)
36{
37 return get_value_string(osmo_fsm_term_cause_names, cause);
38}
39
40
Neels Hofmeyr87e45502017-06-20 00:17:59 +020041/*! description of a rule in the FSM */
Harald Welte136e7372016-05-29 10:53:17 +090042struct osmo_fsm_state {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020043 /*! bit-mask of permitted input events for this state */
Harald Welte136e7372016-05-29 10:53:17 +090044 uint32_t in_event_mask;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020045 /*! bit-mask to which other states this state may transiton */
Harald Welte136e7372016-05-29 10:53:17 +090046 uint32_t out_state_mask;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020047 /*! human-readable name of this state */
Harald Welte136e7372016-05-29 10:53:17 +090048 const char *name;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020049 /*! function to be called for events arriving in this state */
Harald Welte136e7372016-05-29 10:53:17 +090050 void (*action)(struct osmo_fsm_inst *fi, uint32_t event, void *data);
Neels Hofmeyr87e45502017-06-20 00:17:59 +020051 /*! function to be called just after entering the state */
Harald Welte136e7372016-05-29 10:53:17 +090052 void (*onenter)(struct osmo_fsm_inst *fi, uint32_t prev_state);
Neels Hofmeyr87e45502017-06-20 00:17:59 +020053 /*! function to be called just before leaving the state */
Harald Welte136e7372016-05-29 10:53:17 +090054 void (*onleave)(struct osmo_fsm_inst *fi, uint32_t next_state);
55};
56
Neels Hofmeyr87e45502017-06-20 00:17:59 +020057/*! a description of an osmocom finite state machine */
Harald Welte136e7372016-05-29 10:53:17 +090058struct osmo_fsm {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020059 /*! global list */
Harald Welte136e7372016-05-29 10:53:17 +090060 struct llist_head list;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020061 /*! list of instances of this FSM */
Harald Welte136e7372016-05-29 10:53:17 +090062 struct llist_head instances;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020063 /*! human readable name */
Harald Welte136e7372016-05-29 10:53:17 +090064 const char *name;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020065 /*! table of state transition rules */
Harald Welte136e7372016-05-29 10:53:17 +090066 const struct osmo_fsm_state *states;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020067 /*! number of entries in \ref states */
Harald Welte136e7372016-05-29 10:53:17 +090068 unsigned int num_states;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020069 /*! bit-mask of events permitted in all states */
Harald Welte136e7372016-05-29 10:53:17 +090070 uint32_t allstate_event_mask;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020071 /*! function pointer to be called for allstate events */
Harald Welte136e7372016-05-29 10:53:17 +090072 void (*allstate_action)(struct osmo_fsm_inst *fi, uint32_t event, void *data);
Neels Hofmeyr87e45502017-06-20 00:17:59 +020073 /*! clean-up function, called during termination */
Harald Welte136e7372016-05-29 10:53:17 +090074 void (*cleanup)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause);
Neels Hofmeyr87e45502017-06-20 00:17:59 +020075 /*! timer call-back for states with time-out.
Neels Hofmeyrdda5e792016-12-09 16:10:34 +010076 * \returns 1 to request termination, 0 to keep running. */
Harald Weltef627c0f2016-06-18 10:36:25 +020077 int (*timer_cb)(struct osmo_fsm_inst *fi);
Neels Hofmeyr87e45502017-06-20 00:17:59 +020078 /*! logging sub-system for this FSM */
Harald Welte136e7372016-05-29 10:53:17 +090079 int log_subsys;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020080 /*! human-readable names of events */
Harald Welte136e7372016-05-29 10:53:17 +090081 const struct value_string *event_names;
Philipp Maierd1f57932018-02-14 18:20:07 +010082 /*! graceful exit function, called at the beginning of termination */
83 void (*pre_term)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause);
Harald Welte136e7372016-05-29 10:53:17 +090084};
85
Neels Hofmeyr87e45502017-06-20 00:17:59 +020086/*! a single instanceof an osmocom finite state machine */
Harald Welte136e7372016-05-29 10:53:17 +090087struct osmo_fsm_inst {
Neels Hofmeyr87e45502017-06-20 00:17:59 +020088 /*! member in the fsm->instances list */
Harald Welte136e7372016-05-29 10:53:17 +090089 struct llist_head list;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020090 /*! back-pointer to the FSM of which we are an instance */
Harald Welte136e7372016-05-29 10:53:17 +090091 struct osmo_fsm *fsm;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020092 /*! human readable identifier */
Harald Welte136e7372016-05-29 10:53:17 +090093 const char *id;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020094 /*! human readable fully-qualified name */
Harald Welte136e7372016-05-29 10:53:17 +090095 const char *name;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020096 /*! some private data of this instance */
Harald Welte136e7372016-05-29 10:53:17 +090097 void *priv;
Neels Hofmeyr87e45502017-06-20 00:17:59 +020098 /*! logging level for this FSM */
Harald Welte136e7372016-05-29 10:53:17 +090099 int log_level;
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200100 /*! current state of the FSM */
Harald Welte136e7372016-05-29 10:53:17 +0900101 uint32_t state;
102
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200103 /*! timer number for states with time-out */
Harald Welte136e7372016-05-29 10:53:17 +0900104 int T;
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200105 /*! timer back-end for states with time-out */
Harald Welte136e7372016-05-29 10:53:17 +0900106 struct osmo_timer_list timer;
107
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200108 /*! support for fsm-based procedures */
Harald Welte136e7372016-05-29 10:53:17 +0900109 struct {
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200110 /*! the parent FSM that has created us */
Harald Welte136e7372016-05-29 10:53:17 +0900111 struct osmo_fsm_inst *parent;
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200112 /*! the event we should send upon termination */
Harald Welte136e7372016-05-29 10:53:17 +0900113 uint32_t parent_term_event;
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200114 /*! a list of children processes */
Harald Welte136e7372016-05-29 10:53:17 +0900115 struct llist_head children;
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200116 /*! \ref llist_head linked to parent->proc.children */
Harald Welte136e7372016-05-29 10:53:17 +0900117 struct llist_head child;
Neels Hofmeyr3b414a42019-04-08 00:33:53 +0200118 /*! Indicator whether osmo_fsm_inst_term() was already invoked on this instance. */
119 bool terminating;
Harald Welte136e7372016-05-29 10:53:17 +0900120 } proc;
121};
122
123void osmo_fsm_log_addr(bool log_addr);
Neels Hofmeyr050f2d32018-05-31 15:30:15 +0200124void osmo_fsm_log_timeouts(bool log_timeouts);
Neels Hofmeyr1f9cc012019-03-24 05:56:21 +0100125void osmo_fsm_term_safely(bool term_safely);
Neels Hofmeyr988f6d72019-10-04 20:37:17 +0200126void osmo_fsm_set_dealloc_ctx(void *ctx);
Harald Welte136e7372016-05-29 10:53:17 +0900127
Neels Hofmeyr691ba522018-12-19 23:34:25 +0100128/*! Log using FSM instance's context, on explicit logging subsystem and level.
129 * \param fi An osmo_fsm_inst.
130 * \param subsys A logging subsystem, e.g. DLGLOBAL.
131 * \param level A logging level, e.g. LOGL_INFO.
132 * \param fmt printf-like format string.
133 * \param args Format string arguments.
134 */
135#define LOGPFSMSL(fi, subsys, level, fmt, args...) \
136 LOGPFSMSLSRC(fi, subsys, level, __FILE__, __LINE__, fmt, ## args)
137
138/*! Log using FSM instance's context, on explicit logging subsystem and level,
139 * and passing explicit source file and line information.
140 * \param fi An osmo_fsm_inst.
141 * \param subsys A logging subsystem, e.g. DLGLOBAL.
142 * \param level A logging level, e.g. LOGL_INFO.
143 * \param caller_file A string constant containing a source file path, like __FILE__.
144 * \param caller_line A number constant containing a source file line, like __LINE__.
145 * \param fmt printf-like format string.
146 * \param args Format string arguments.
147 */
148#define LOGPFSMSLSRC(fi, subsys, level, caller_file, caller_line, fmt, args...) \
149 LOGPSRC(subsys, level, \
150 caller_file, caller_line, \
151 "%s{%s}: " fmt, \
152 osmo_fsm_inst_name(fi), \
153 (fi) ? osmo_fsm_state_name((fi)->fsm, (fi)->state) : "fi=NULL", ## args)
154
155
Neels Hofmeyrb11ff7c2018-12-20 00:19:29 +0100156/*! Log using FSM instance's context, on explicit logging level.
157 * \param fi An osmo_fsm_inst.
158 * \param level A logging level, e.g. LOGL_INFO.
159 * \param fmt printf-like format string.
160 * \param args Format string arguments.
161 */
Neels Hofmeyr6a13e7f2016-12-14 17:37:34 +0100162#define LOGPFSML(fi, level, fmt, args...) \
Neels Hofmeyre5bde902018-12-20 00:00:11 +0100163 LOGPFSMLSRC(fi, level, __FILE__, __LINE__, fmt, ## args)
Neels Hofmeyr6a13e7f2016-12-14 17:37:34 +0100164
Neels Hofmeyrb11ff7c2018-12-20 00:19:29 +0100165/*! Log using FSM instance's context, on explicit logging level, and with explicit source file and line info.
166 * The log subsystem to log on is obtained from the underlying FSM definition.
167 * \param fi An osmo_fsm_inst.
168 * \param level A logging level, e.g. LOGL_INFO.
169 * \param caller_file A string constant containing a source file path, like __FILE__.
170 * \param caller_line A number constant containing a source file line, like __LINE__.
171 * \param fmt printf-like format string.
172 * \param args Format string arguments.
173 */
Neels Hofmeyreeacf902016-12-23 01:00:13 +0100174#define LOGPFSMLSRC(fi, level, caller_file, caller_line, fmt, args...) \
Neels Hofmeyr691ba522018-12-19 23:34:25 +0100175 LOGPFSMSLSRC(fi, (fi) ? (fi)->fsm->log_subsys : DLGLOBAL, level, \
176 caller_file, caller_line, fmt, ## args)
Neels Hofmeyreeacf902016-12-23 01:00:13 +0100177
Neels Hofmeyrb11ff7c2018-12-20 00:19:29 +0100178/*! Log using FSM instance's context.
179 * The log level to log on is obtained from the FSM instance.
180 * The log subsystem to log on is obtained from the underlying FSM definition.
181 * \param fi An osmo_fsm_inst.
182 * \param fmt printf-like format string.
183 * \param args Format string arguments.
184 */
Neels Hofmeyre5bde902018-12-20 00:00:11 +0100185#define LOGPFSM(fi, fmt, args...) \
Neels Hofmeyrb0b39af2018-12-20 00:03:59 +0100186 LOGPFSML(fi, (fi) ? (fi)->log_level : LOGL_ERROR, fmt, ## args)
Neels Hofmeyre5bde902018-12-20 00:00:11 +0100187
Neels Hofmeyrb11ff7c2018-12-20 00:19:29 +0100188/*! Log using FSM instance's context, with explicit source file and line info.
189 * The log level to log on is obtained from the FSM instance.
190 * The log subsystem to log on is obtained from the underlying FSM definition.
191 * \param fi An osmo_fsm_inst.
192 * \param caller_file A string constant containing a source file path, like __FILE__.
193 * \param caller_line A number constant containing a source file line, like __LINE__.
194 * \param fmt printf-like format string.
195 * \param args Format string arguments.
196 */
Neels Hofmeyreeacf902016-12-23 01:00:13 +0100197#define LOGPFSMSRC(fi, caller_file, caller_line, fmt, args...) \
Neels Hofmeyrb0b39af2018-12-20 00:03:59 +0100198 LOGPFSMLSRC(fi, (fi) ? (fi)->log_level : LOGL_ERROR, \
Neels Hofmeyreeacf902016-12-23 01:00:13 +0100199 caller_file, caller_line, \
200 fmt, ## args)
201
Neels Hofmeyr5734bff2019-02-21 02:27:48 +0100202#define OSMO_T_FMT "%c%u"
Vadim Yanitskiyb71f4612024-01-04 06:38:03 +0700203#define OSMO_T_FMT_ARGS(T) ((T) >= 0 ? 'T' : 'X'), ((T) >= 0 ? (T) : -(T))
Neels Hofmeyr5734bff2019-02-21 02:27:48 +0100204
Harald Welte136e7372016-05-29 10:53:17 +0900205int osmo_fsm_register(struct osmo_fsm *fsm);
Max8b25a3f2016-11-01 11:02:17 +0100206void osmo_fsm_unregister(struct osmo_fsm *fsm);
Harald Welte8808bb42017-01-07 11:11:03 +0100207struct osmo_fsm *osmo_fsm_find_by_name(const char *name);
Harald Welte4585e672017-04-16 17:23:56 +0200208struct osmo_fsm_inst *osmo_fsm_inst_find_by_name(const struct osmo_fsm *fsm,
209 const char *name);
210struct osmo_fsm_inst *osmo_fsm_inst_find_by_id(const struct osmo_fsm *fsm,
211 const char *id);
Harald Welte136e7372016-05-29 10:53:17 +0900212struct osmo_fsm_inst *osmo_fsm_inst_alloc(struct osmo_fsm *fsm, void *ctx, void *priv,
213 int log_level, const char *id);
214struct osmo_fsm_inst *osmo_fsm_inst_alloc_child(struct osmo_fsm *fsm,
215 struct osmo_fsm_inst *parent,
216 uint32_t parent_term_event);
Philipp Maier2a06a492018-01-16 18:45:56 +0100217void osmo_fsm_inst_unlink_parent(struct osmo_fsm_inst *fi, void *ctx);
218void osmo_fsm_inst_change_parent(struct osmo_fsm_inst *fi,
219 struct osmo_fsm_inst *new_parent,
220 uint32_t new_parent_term_event);
Harald Welte136e7372016-05-29 10:53:17 +0900221void osmo_fsm_inst_free(struct osmo_fsm_inst *fi);
222
Daniel Willmannb0c43a62018-02-08 18:00:37 +0100223int osmo_fsm_inst_update_id(struct osmo_fsm_inst *fi, const char *id);
Neels Hofmeyra64c45a2018-03-31 16:34:49 +0200224int osmo_fsm_inst_update_id_f(struct osmo_fsm_inst *fi, const char *fmt, ...);
Neels Hofmeyrb480b742019-04-11 06:58:44 +0200225int osmo_fsm_inst_update_id_f_sanitize(struct osmo_fsm_inst *fi, char replace_with, const char *fmt, ...);
Daniel Willmannb0c43a62018-02-08 18:00:37 +0100226
Vadim Yanitskiyb3e3a5d2022-07-29 00:06:48 +0700227const char *osmo_fsm_event_name(const struct osmo_fsm *fsm, uint32_t event);
228const char *osmo_fsm_inst_name(const struct osmo_fsm_inst *fi);
229const char *osmo_fsm_state_name(const struct osmo_fsm *fsm, uint32_t state);
Harald Welte136e7372016-05-29 10:53:17 +0900230
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200231/*! return the name of the state the FSM instance is currently in. */
Neels Hofmeyrfca04bb2017-02-28 03:38:38 +0100232static inline const char *osmo_fsm_inst_state_name(struct osmo_fsm_inst *fi)
Neels Hofmeyr56632b62019-01-22 00:22:17 +0100233{ return fi ? osmo_fsm_state_name(fi->fsm, fi->state) : "NULL"; }
Neels Hofmeyrfca04bb2017-02-28 03:38:38 +0100234
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200235/*! perform a state change of the given FSM instance
Neels Hofmeyr725698a2016-12-14 17:24:54 +0100236 *
237 * This is a macro that calls _osmo_fsm_inst_state_chg() with the given
238 * parameters as well as the caller's source file and line number for logging
239 * purposes. See there for documentation.
240 */
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, \
Neels Hofmeyr983dcb92018-08-20 12:33:22 +0200243 __FILE__, __LINE__)
Neels Hofmeyr725698a2016-12-14 17:24:54 +0100244int _osmo_fsm_inst_state_chg(struct osmo_fsm_inst *fi, uint32_t new_state,
245 unsigned long timeout_secs, int T,
246 const char *file, int line);
Harald Welte136e7372016-05-29 10:53:17 +0900247
Harald Welte7b745512019-05-18 21:03:55 +0200248#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, \
250 __FILE__, __LINE__)
251int _osmo_fsm_inst_state_chg_ms(struct osmo_fsm_inst *fi, uint32_t new_state,
252 unsigned long timeout_ms, int T,
253 const char *file, int line);
254
Neels Hofmeyr407df022018-05-25 18:20:06 +0200255/*! perform a state change while keeping the current timer running.
256 *
257 * This is useful to keep a timeout across several states (without having to round the
258 * remaining time to seconds).
259 *
260 * This is a macro that calls _osmo_fsm_inst_state_chg_keep_timer() with the given
261 * parameters as well as the caller's source file and line number for logging
262 * purposes. See there for documentation.
263 */
264#define osmo_fsm_inst_state_chg_keep_timer(fi, new_state) \
265 _osmo_fsm_inst_state_chg_keep_timer(fi, new_state, \
Neels Hofmeyr983dcb92018-08-20 12:33:22 +0200266 __FILE__, __LINE__)
Neels Hofmeyr407df022018-05-25 18:20:06 +0200267int _osmo_fsm_inst_state_chg_keep_timer(struct osmo_fsm_inst *fi, uint32_t new_state,
268 const char *file, int line);
269
Neels Hofmeyrd4b79c82019-03-06 05:43:23 +0100270/*! perform a state change while keeping the current timer if running, or starting a timer otherwise.
271 *
272 * This is useful to keep a timeout across several states, but to make sure that some timeout is actually running.
273 *
274 * This is a macro that calls _osmo_fsm_inst_state_chg_keep_or_start_timer() with the given
275 * parameters as well as the caller's source file and line number for logging
276 * purposes. See there for documentation.
277 */
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, \
280 __FILE__, __LINE__)
281int _osmo_fsm_inst_state_chg_keep_or_start_timer(struct osmo_fsm_inst *fi, uint32_t new_state,
282 unsigned long timeout_secs, int T,
283 const char *file, int line);
284
Harald Welte7b745512019-05-18 21:03:55 +0200285#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, \
287 __FILE__, __LINE__)
288int _osmo_fsm_inst_state_chg_keep_or_start_timer_ms(struct osmo_fsm_inst *fi, uint32_t new_state,
289 unsigned long timeout_ms, int T,
290 const char *file, int line);
291
292
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200293/*! dispatch an event to an osmocom finite state machine instance
Neels Hofmeyr725698a2016-12-14 17:24:54 +0100294 *
295 * This is a macro that calls _osmo_fsm_inst_dispatch() with the given
296 * parameters as well as the caller's source file and line number for logging
297 * purposes. See there for documentation.
298 */
299#define osmo_fsm_inst_dispatch(fi, event, data) \
Neels Hofmeyr983dcb92018-08-20 12:33:22 +0200300 _osmo_fsm_inst_dispatch(fi, event, data, __FILE__, __LINE__)
Neels Hofmeyr725698a2016-12-14 17:24:54 +0100301int _osmo_fsm_inst_dispatch(struct osmo_fsm_inst *fi, uint32_t event, void *data,
302 const char *file, int line);
303
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200304/*! Terminate FSM instance with given cause
Neels Hofmeyr725698a2016-12-14 17:24:54 +0100305 *
306 * This is a macro that calls _osmo_fsm_inst_term() with the given parameters
307 * as well as the caller's source file and line number for logging purposes.
308 * See there for documentation.
309 */
310#define osmo_fsm_inst_term(fi, cause, data) \
Neels Hofmeyr983dcb92018-08-20 12:33:22 +0200311 _osmo_fsm_inst_term(fi, cause, data, __FILE__, __LINE__)
Neels Hofmeyr725698a2016-12-14 17:24:54 +0100312void _osmo_fsm_inst_term(struct osmo_fsm_inst *fi,
313 enum osmo_fsm_term_cause cause, void *data,
314 const char *file, int line);
Harald Welte136e7372016-05-29 10:53:17 +0900315
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200316/*! Terminate all child FSM instances of an FSM instance.
Neels Hofmeyrc014f602016-12-23 04:26:39 +0100317 *
318 * This is a macro that calls _osmo_fsm_inst_term_children() with the given
319 * parameters as well as the caller's source file and line number for logging
320 * purposes. See there for documentation.
321 */
322#define osmo_fsm_inst_term_children(fi, cause, data) \
Neels Hofmeyr983dcb92018-08-20 12:33:22 +0200323 _osmo_fsm_inst_term_children(fi, cause, data, __FILE__, __LINE__)
Neels Hofmeyrc014f602016-12-23 04:26:39 +0100324void _osmo_fsm_inst_term_children(struct osmo_fsm_inst *fi,
325 enum osmo_fsm_term_cause cause,
326 void *data,
327 const char *file, int line);
328
Harald Welte4eb0f162020-12-21 12:34:46 +0100329/*! dispatch an event to all children of an osmocom finite state machine instance
330 *
331 * This is a macro that calls _osmo_fsm_inst_broadcast_children() with the given
332 * parameters as well as the caller's source file and line number for logging
333 * purposes. See there for documentation.
334 */
335#define osmo_fsm_inst_broadcast_children(fi, cause, data) \
336 _osmo_fsm_inst_broadcast_children(fi, cause, data, __FILE__, __LINE__)
337void _osmo_fsm_inst_broadcast_children(struct osmo_fsm_inst *fi, uint32_t event,
338 void *data, const char *file, int line);
339
Harald Welte136e7372016-05-29 10:53:17 +0900340/*! @} */