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
diff --git a/include/osmocom/core/prim.h b/include/osmocom/core/prim.h
index 99a71d5..f04e15e 100644
--- a/include/osmocom/core/prim.h
+++ b/include/osmocom/core/prim.h
@@ -57,4 +57,18 @@
 /*! \brief primitive handler callback type */
 typedef int (*osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx);
 
+/*! \brief magic value to be used as final record of \ref
+ * osmo_prim_event_map */
+#define OSMO_NO_EVENT	0xFFFFFFFF
+
+/*! \brief single entry in a SAP/PRIM/OP -> EVENT map */
+struct osmo_prim_event_map {
+	unsigned int sap;	/*!< SAP to match */
+	unsigned int primitive;	/*!< primtiive to match */
+	enum osmo_prim_operation operation; /*!< operation to match */
+	uint32_t event;		/*!< event as result if above match */
+};
+
+uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph,
+			     const struct osmo_prim_event_map *maps);
 /*! @} */