diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h index 5e5b091c4..dcd6935e7 100644 --- a/include/osmocom/core/fsm.h +++ b/include/osmocom/core/fsm.h @@ -81,6 +81,16 @@ struct osmo_fsm { const struct value_string *event_names; /*! graceful exit function, called at the beginning of termination */ void (*pre_term)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause); + /*! bit-mask of events which will be ignored if they are not valid in the current fsm state. + * + * An invalid event is an event which is neither part of the allstat_event_mask nor state->in_event_mask. + * If an invalid event is dispatched to an fsm, the fsm core will log it (error) and + * osmo_fsm_inst_dispatch() will return != 0. + * + * To silence those log lines and change the return code of osmo_fsm_inst_dispatch, add the + * event to ignore_invalid_event_mask. + */ + uint32_t ignore_invalid_event_mask; }; /*! a single instanceof an osmocom finite state machine */ diff --git a/src/fsm.c b/src/fsm.c index 9333cac5e..e90d1851c 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -865,6 +865,9 @@ int _osmo_fsm_inst_dispatch(struct osmo_fsm_inst *fi, uint32_t event, void *data } if (!((1 << event) & fs->in_event_mask)) { + if ((1 << event) & fsm->ignore_invalid_event_mask) + return 0; + LOGPFSMLSRC(fi, LOGL_ERROR, file, line, "Event %s not permitted\n", osmo_fsm_event_name(fsm, event));