summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--library/L3_Templates.ttcn19
1 files changed, 14 insertions, 5 deletions
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_IMSI_L3(hexstring digits) return IMSI_L3 {
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;
}