aboutsummaryrefslogtreecommitdiffstats
path: root/src/xua_msg.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-04-03 18:24:23 +0200
committerHarald Welte <laforge@gnumonks.org>2017-04-10 10:41:16 +0200
commitc96db7fa585d169eff600ebc291d45b427a6cb16 (patch)
treee8078a5fad55544c8a79993d09a76b503d842340 /src/xua_msg.c
parentd75e8967ef9e117d54c3cd87082f8de7c840c9f5 (diff)
xua_msg: Add support for msg_event_maps
msg_event_maps facilitate the mapping from a xUA message (class + type) to an integer event. This is useful when passing xUA messages to a osmo_fsm. Change-Id: Iee1c7fc2bf64219ebb71a0dbe6fd210749332413
Diffstat (limited to 'src/xua_msg.c')
-rw-r--r--src/xua_msg.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/xua_msg.c b/src/xua_msg.c
index e094cb6..27279ce 100644
--- a/src/xua_msg.c
+++ b/src/xua_msg.c
@@ -361,6 +361,27 @@ int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_s
return rc;
}
+/*! \brief Map from a xua_msg (class+type) to an event
+ * \param[in] xua xUA message which is to be mapped
+ * \param[in] maps Table containing msg type+class -> event maps
+ * \[aram[in] num_maps number of entries in \ref maps
+ * \returns event >= 0; negative on error (no map found) */
+int xua_msg_event_map(const struct xua_msg *xua,
+ const struct xua_msg_event_map *maps,
+ unsigned int num_maps)
+{
+ int i;
+
+ for (i= 0; i < num_maps; i++) {
+ const struct xua_msg_event_map *map = &maps[i];
+ if (xua->hdr.msg_class == map->msg_class &&
+ xua->hdr.msg_type == map->msg_type) {
+ return map->event;
+ }
+ }
+ return -1;
+}
+
const char *xua_class_msg_name(const struct xua_msg_class *xmc, uint16_t msg_type)
{
static char class_buf[64];