[PATCH] libosmo-sccp[master]: xua_msg: Add support for msg_event_maps

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Apr 3 20:22:07 UTC 2017


Review at  https://gerrit.osmocom.org/2208

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
---
M include/osmocom/sigtran/xua_msg.h
M src/xua_msg.c
2 files changed, 30 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/08/2208/1

diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h
index 60dd693..320da6a 100644
--- a/include/osmocom/sigtran/xua_msg.h
+++ b/include/osmocom/sigtran/xua_msg.h
@@ -60,6 +60,12 @@
 	const struct xua_msg_class *class[256];
 };
 
+struct xua_msg_event_map {
+	uint8_t msg_class;
+	uint8_t msg_type;
+	int event;
+};
+
 extern const struct xua_dialect xua_dialect_sua;
 extern const struct xua_dialect xua_dialect_m3ua;
 
@@ -94,3 +100,6 @@
 char *xua_msg_dump(struct xua_msg *xua, const struct xua_dialect *dialect);
 int xua_dialect_check_all_mand_ies(const struct xua_dialect *dialect, struct xua_msg *xua);
 
+int xua_msg_event_map(const struct xua_msg *xua,
+		      const struct xua_msg_event_map *maps,
+		      unsigned int num_maps);
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 @@
 	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];

-- 
To view, visit https://gerrit.osmocom.org/2208
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee1c7fc2bf64219ebb71a0dbe6fd210749332413
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list