summaryrefslogtreecommitdiffstats
path: root/src/prim.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-04-08 23:35:24 +0200
committerHarald Welte <laforge@gnumonks.org>2017-04-09 17:54:28 +0000
commitacd08feb8f75827555a9ef38b890870fed3388ea (patch)
tree1f0827f7c04df6f572679153d62c9fb8d731128d /src/prim.c
parent18a62b04887d8c6f6d338404330391a66c337b69 (diff)
Add struct osmo_prim_event_map and osmo_event_for_prim()
This can be used to map from an osmo_prim to an osmo_fsm event. Change-Id: I52350f4ebe97811b2a692e5a69a2cd39a853583c
Diffstat (limited to 'src/prim.c')
-rw-r--r--src/prim.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/prim.c b/src/prim.c
index 3f41c416..5851f6f5 100644
--- a/src/prim.c
+++ b/src/prim.c
@@ -10,3 +10,21 @@ const struct value_string osmo_prim_op_names[5] = {
{ PRIM_OP_CONFIRM, "confirm" },
{ 0, NULL }
};
+
+/*! \brief resolve the (fsm) event for a given primitive using a map
+ * \param[in] oph primitive header used as key for match
+ * \param[in] maps list of mappings from primitive to event
+ * \returns event determined by map; \ref OSMO_NO_EVENT if no match */
+uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph,
+ const struct osmo_prim_event_map *maps)
+{
+ const struct osmo_prim_event_map *map;
+
+ for (map = maps; map->event != OSMO_NO_EVENT; map++) {
+ if (map->sap == oph->sap &&
+ map->primitive == oph->primitive &&
+ map->operation == oph->operation)
+ return map->event;
+ }
+ return OSMO_NO_EVENT;
+}