fsm: Add osmo_fsm_inst_broadcast_children()

This is a helper function to broadcast an event to all of the
siblings of a specified FSM instance.

Change-Id: I2ce398741a8672d7b7c4058d056f46e2fe7353c1
diff --git a/src/fsm.c b/src/fsm.c
index 1e8909e..f1dbb41 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -1016,6 +1016,26 @@
 	}
 }
 
+/*! Broadcast an event to all the FSMs children.
+ *
+ *  Iterate over all children and send them the specified event.
+ *
+ *  \param[in] fi FSM instance of the parent
+ *  \param[in] event Event to send to children of FSM instance
+ *  \param[in] data Data to pass along with the event
+ *  \param[in] file Calling source file (from osmo_fsm_inst_dispatch macro)
+ *  \param[in] line Calling source line (from osmo_fsm_inst_dispatch macro)
+ */
+void _osmo_fsm_inst_broadcast_children(struct osmo_fsm_inst *fi,
+					uint32_t event, void *data,
+					const char *file, int line)
+{
+	struct osmo_fsm_inst *child, *tmp;
+	llist_for_each_entry_safe(child, tmp, &fi->proc.children, proc.child) {
+		_osmo_fsm_inst_dispatch(child, event, data, file, line);
+	}
+}
+
 const struct value_string osmo_fsm_term_cause_names[] = {
 	OSMO_VALUE_STRING(OSMO_FSM_TERM_PARENT),
 	OSMO_VALUE_STRING(OSMO_FSM_TERM_REQUEST),