Change in libosmocore[master]: gsm48_generate_mid(): mask out ODD flag from mi_type

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 Dec 10 17:06:31 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/12155 )

Change subject: gsm48_generate_mid(): mask out ODD flag from mi_type
......................................................................

gsm48_generate_mid(): mask out ODD flag from mi_type

For MI encoding, see 3GPP TS 24.008, 10.5.1.4 Mobile Identity. The 'odd' flag
indicates whether the last BCD nibble is used. Of course that flag should be
made sure to reflect the actual length.

Change-Id: Id6e695ebf9f86b295eaa7e2c6228989256f37e68
---
M src/gsm/gsm48.c
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
3 files changed, 6 insertions(+), 8 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Pau Espin Pedrol: Looks good to me, approved
  Stefan Sperling: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index 4558dfb..0f0889b 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -611,7 +611,7 @@
 	uint8_t length = strnlen(id, 255), i, off = 0, odd = (length & 1) == 1;
 
 	buf[0] = GSM48_IE_MOBILE_ID;
-	buf[2] = osmo_char2bcd(id[0]) << 4 | mi_type | (odd << 3);
+	buf[2] = osmo_char2bcd(id[0]) << 4 | (mi_type & GSM_MI_TYPE_MASK) | (odd << 3);
 
 	/* if the length is even we will fill half of the last octet */
 	buf[1] = (length + (odd ? 1 : 2)) >> 1;
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index c786d38..9bb320d 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -380,7 +380,7 @@
 	{
 		.mi_type = GSM_MI_TYPE_IMSI | GSM_MI_ODD,
 		.mi_str = "423423",
-		.expect_mi_tlv_hex = "1704493224f3", /* encodes "odd" for even number of digits! */
+		.expect_mi_tlv_hex = "1704413224f3",
 	},
 	{
 		.mi_type = GSM_MI_TYPE_IMSI,
@@ -464,7 +464,7 @@
 	{
 		.mi_type = GSM_MI_ODD,
 		.mi_str = "1234",
-		.expect_mi_tlv_hex = "17031832f4", /* encoding invalid MI type, and "odd" for an even number of digits */
+		.expect_mi_tlv_hex = "17031032f4", /* encoding invalid MI type */
 		.expect_str = "",
 	},
 };
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index 2db58de..6e99f5b 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -14,10 +14,8 @@
   -> MI-TLV-hex='1704413224f3'
   -> MI-str="423423" rc=7
 - unknown 0x9 423423
-  -> MI-TLV-hex='1704493224f3'
-  -> MI-str="423423F" rc=8
-     ERROR: expected MI-str="423423"
-     ERROR: expected rc=7
+  -> MI-TLV-hex='1704413224f3'
+  -> MI-str="423423" rc=7
 - IMSI 4234235
   -> MI-TLV-hex='170449322453'
   -> MI-str="4234235" rc=8
@@ -58,7 +56,7 @@
   -> MI-TLV-hex='17031032f4'
   -> MI-str="" rc=1
 - unknown 0x8 1234
-  -> MI-TLV-hex='17031832f4'
+  -> MI-TLV-hex='17031032f4'
   -> MI-str="" rc=1
 
 Decoding zero length Mobile Identities

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id6e695ebf9f86b295eaa7e2c6228989256f37e68
Gerrit-Change-Number: 12155
Gerrit-PatchSet: 7
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <stsp at stsp.name>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181210/79d067b5/attachment.htm>


More information about the gerrit-log mailing list