Change in osmo-ttcn3-hacks[master]: fix f_enc_IMEI_L3() oddevenIndicator

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

neels gerrit-no-reply at lists.osmocom.org
Wed Jun 10 15:56:42 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18758 )


Change subject: fix f_enc_IMEI_L3() oddevenIndicator
......................................................................

fix f_enc_IMEI_L3() oddevenIndicator

f_gen_imei() calls f_enc_IMEI_L3() with a 14 digits argument, but the IMEI_L3
template used is hardcoded to 15 digits. So the oddevenIndicator must always
indicate odd, not depend on the digits argument.

f_gen_imei() should probably also compose a Luhn checksum, leaving that to
another patch.

Found by using the new osmo_mobile_identity API in osmo-msc, which is stricter
about odd/even and filler digits than our previous implementations.
See osmo-msc Idfc8e576e10756aeaacf5569f6178068313eb7ea .

Change-Id: Iaa9ba1214c4c15fd9620e68fe2e842fdf52912c0
---
M library/L3_Templates.ttcn
1 file changed, 14 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/58/18758/1

diff --git a/library/L3_Templates.ttcn b/library/L3_Templates.ttcn
index 3032503..ba91180 100644
--- a/library/L3_Templates.ttcn
+++ b/library/L3_Templates.ttcn
@@ -184,11 +184,20 @@
 private function f_enc_IMEI_L3(hexstring digits) return IMEI_L3 {
 	var IMEI_L3 l3;
 	var integer len := lengthof(digits);
-	if (len rem 2 == 1) {	/* modulo remainder */
-		l3.oddevenIndicator := '1'B;
-	} else {
-		l3.oddevenIndicator := '0'B;
-	}
+	/* IMEI_L3 is always 15 digits. That is actually a 14 digit IMEI + a Luhn checksum digit (see
+	 * libosmocore/include/osmocom/gsm/protocol/gsm_23_003.h)
+	 *
+	 * Here, we must not make the oddevenIndicator depend on the 'digits' parameter, because:
+	 * - The IMEI_L3 template assumes always 15 digits.
+	 * - The 'digits' parameter, however, may also contain less digits, 14 in the case of
+	 *   f_gen_imei().
+	 * - The IMEI_L3 template will then fill up with zeros to make 15 digits.
+	 * Hence oddevenIndicator must always indicate 'odd' == '1'B.
+	 *
+	 * FIXME: if the caller passes less than 15 digits, the Luhn checksum digit then ends up zero == most probably
+	 * wrong.
+	 */
+	l3.oddevenIndicator := '1'B;
 	l3.digits := digits;
 	return l3;
 }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18758
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Iaa9ba1214c4c15fd9620e68fe2e842fdf52912c0
Gerrit-Change-Number: 18758
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200610/a4c891b0/attachment.htm>


More information about the gerrit-log mailing list