[PATCH] libosmo-sccp[master]: Add xua_msg_part_get_u32() to get U32 value from xua_msg_part

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Feb 13 14:03:46 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1811

to look at the new patch set (#2).

Add xua_msg_part_get_u32() to get U32 value from xua_msg_part

Sometimes one already has the xua_msg_part and thus can avoid the
lookup that's done by xua_msg_get_u32().

Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f
---
M include/osmocom/sigtran/xua_msg.h
M src/xua_msg.c
2 files changed, 11 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/11/1811/2

diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h
index 5dc3894..2a6e3ae 100644
--- a/include/osmocom/sigtran/xua_msg.h
+++ b/include/osmocom/sigtran/xua_msg.h
@@ -60,5 +60,6 @@
 int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data);
 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(struct xua_msg_part *part);
 uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei);
 int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr);
diff --git a/src/xua_msg.c b/src/xua_msg.c
index 3d335d9..4a3e013 100644
--- a/src/xua_msg.c
+++ b/src/xua_msg.c
@@ -20,6 +20,7 @@
 #include <osmocom/sigtran/protocol/sua.h>
 #include <osmocom/sigtran/sccp_sap.h>
 
+#include <osmocom/core/utils.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/logging.h>
 #include <osmocom/core/talloc.h>
@@ -230,13 +231,18 @@
 	return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n);
 }
 
+uint32_t xua_msg_part_get_u32(struct xua_msg_part *part)
+{
+	OSMO_ASSERT(part->len >= 4);
+	return ntohl(*(uint32_t *)part->dat);
+}
+
 uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei)
 {
 	struct xua_msg_part *part = xua_msg_find_tag(xua, iei);
-	uint32_t rc = 0;
-	if (part)
-		rc = ntohl(*(uint32_t *)part->dat);
-	return rc;
+	if (!part)
+		return 0;
+	return xua_msg_part_get_u32(part);
 }
 
 int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f
Gerrit-PatchSet: 2
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder


More information about the gerrit-log mailing list