Change in libosmocore[master]: gsm0808: gsm0808_create_ass2(): use osmo_store{16, 32}be()

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/.

fixeria gerrit-no-reply at lists.osmocom.org
Fri Feb 5 02:59:17 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22717 )


Change subject: gsm0808: gsm0808_create_ass2(): use osmo_store{16,32}be()
......................................................................

gsm0808: gsm0808_create_ass2(): use osmo_store{16,32}be()

This API makes the code simpler and easier to read.

Change-Id: Ibe9eaaa2a9344ba798631b8f115ad248f0a2f76b
---
M src/gsm/gsm0808.c
1 file changed, 5 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/17/22717/1

diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 971d962..bd3afeb 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -494,8 +494,6 @@
 {
 	/* See also: 3GPP TS 48.008 3.2.1.1 ASSIGNMENT REQUEST */
 	struct msgb *msg;
-	uint16_t cic_sw;
-	uint32_t ci_sw;
 
 	/* Mandatory emelent! */
 	OSMO_ASSERT(ct);
@@ -514,9 +512,8 @@
 
 	/* Circuit Identity Code 3.2.2.2  */
 	if (cic) {
-		cic_sw = osmo_htons(*cic);
-		msgb_tv_fixed_put(msg, GSM0808_IE_CIRCUIT_IDENTITY_CODE,
-				  sizeof(cic_sw), (uint8_t *) & cic_sw);
+		msgb_v_put(msg, GSM0808_IE_CIRCUIT_IDENTITY_CODE);
+		osmo_store16be(*cic, msgb_put(msg, sizeof(*cic)));
 	}
 
 	/* AoIP: AoIP Transport Layer Address (MGW) 3.2.2.102 */
@@ -531,17 +528,9 @@
 	/* AoIP: Call Identifier 3.2.2.105 */
 	if (ci) {
 		/* NOTE: 3GPP TS 48.008, section 3.2.2.105 specifies that
-		   the least significant byte should be transmitted first.
-		   On x86, this would mean that the endieness is already
-		   correct, however a platform independed implementation
-		   is required: */
-#ifndef OSMO_IS_LITTLE_ENDIAN
-		ci_sw = osmo_swab32(*ci);
-#else
-		ci_sw = *ci;
-#endif
-		msgb_tv_fixed_put(msg, GSM0808_IE_CALL_ID, sizeof(ci_sw),
-				  (uint8_t *) & ci_sw);
+		 * the least significant byte shall be transmitted first. */
+		msgb_v_put(msg, GSM0808_IE_CALL_ID);
+		osmo_store32le(*ci, msgb_put(msg, sizeof(*ci)));
 	}
 
 	if (kc)

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22717
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ibe9eaaa2a9344ba798631b8f115ad248f0a2f76b
Gerrit-Change-Number: 22717
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210205/2f2d7828/attachment.htm>


More information about the gerrit-log mailing list