aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-02-08 13:17:23 +0100
committerHarald Welte <laforge@osmocom.org>2021-02-08 18:11:12 +0100
commitbf85d6f433e5d1d24a3cb7f212f6bfb65988d609 (patch)
treeda1cff2f386c5d2ce50b2f1a6351f8551c70cc76
parentd2dc5ed987a218254f8bd4aced8a1e1e613bedd7 (diff)
xua: introduce xua_msg_get_u32p() helper
-rw-r--r--include/osmocom/sigtran/xua_msg.h1
-rw-r--r--src/xua_msg.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h
index 329ba96..11bce6f 100644
--- a/include/osmocom/sigtran/xua_msg.h
+++ b/include/osmocom/sigtran/xua_msg.h
@@ -91,6 +91,7 @@ int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val);
int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val);
uint32_t xua_msg_part_get_u32(const struct xua_msg_part *part);
uint32_t xua_msg_get_u32(const struct xua_msg *xua, uint16_t iei);
+const uint32_t *xua_msg_get_u32p(const struct xua_msg *xua, uint16_t iei, uint32_t *out);
const char *xua_msg_part_get_str(const struct xua_msg_part *part);
const char *xua_msg_get_str(const struct xua_msg *xua, uint16_t iei);
void xua_part_add_gt(struct msgb *msg, const struct osmo_sccp_gt *gt);
diff --git a/src/xua_msg.c b/src/xua_msg.c
index 42c580d..1df9abd 100644
--- a/src/xua_msg.c
+++ b/src/xua_msg.c
@@ -297,6 +297,16 @@ uint32_t xua_msg_get_u32(const struct xua_msg *xua, uint16_t iei)
return xua_msg_part_get_u32(part);
}
+/* get a U32 IE in host-byte-order, returning whether it exists (!= NULL) or not (== NULL) */
+const uint32_t *xua_msg_get_u32p(const struct xua_msg *xua, uint16_t iei, uint32_t *out)
+{
+ struct xua_msg_part *part = xua_msg_find_tag(xua, iei);
+ if (!part)
+ return NULL;
+ *out = xua_msg_part_get_u32(part);
+ return out;
+}
+
const char *xua_msg_part_get_str(const struct xua_msg_part *part)
{
static char __thread buf[256];