<p>neels <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18758">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">fix f_enc_IMEI_L3() oddevenIndicator<br><br>f_gen_imei() calls f_enc_IMEI_L3() with a 14 digits argument, but the IMEI_L3<br>template used is hardcoded to 15 digits. So the oddevenIndicator must always<br>indicate odd, not depend on the digits argument.<br><br>f_gen_imei() should probably also compose a Luhn checksum, leaving that to<br>another patch.<br><br>Found by using the new osmo_mobile_identity API in osmo-msc, which is stricter<br>about odd/even and filler digits than our previous implementations.<br>See osmo-msc Idfc8e576e10756aeaacf5569f6178068313eb7ea .<br><br>Change-Id: Iaa9ba1214c4c15fd9620e68fe2e842fdf52912c0<br>---<br>M library/L3_Templates.ttcn<br>1 file changed, 14 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/library/L3_Templates.ttcn b/library/L3_Templates.ttcn</span><br><span>index 3032503..ba91180 100644</span><br><span>--- a/library/L3_Templates.ttcn</span><br><span>+++ b/library/L3_Templates.ttcn</span><br><span>@@ -184,11 +184,20 @@</span><br><span> private function f_enc_IMEI_L3(hexstring digits) return IMEI_L3 {</span><br><span>      var IMEI_L3 l3;</span><br><span>      var integer len := lengthof(digits);</span><br><span style="color: hsl(0, 100%, 40%);">-    if (len rem 2 == 1) {   /* modulo remainder */</span><br><span style="color: hsl(0, 100%, 40%);">-          l3.oddevenIndicator := '1'B;</span><br><span style="color: hsl(0, 100%, 40%);">-    } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                l3.oddevenIndicator := '0'B;</span><br><span style="color: hsl(0, 100%, 40%);">-    }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* IMEI_L3 is always 15 digits. That is actually a 14 digit IMEI + a Luhn checksum digit (see</span><br><span style="color: hsl(120, 100%, 40%);">+  * libosmocore/include/osmocom/gsm/protocol/gsm_23_003.h)</span><br><span style="color: hsl(120, 100%, 40%);">+      *</span><br><span style="color: hsl(120, 100%, 40%);">+     * Here, we must not make the oddevenIndicator depend on the 'digits' parameter, because:</span><br><span style="color: hsl(120, 100%, 40%);">+      * - The IMEI_L3 template assumes always 15 digits.</span><br><span style="color: hsl(120, 100%, 40%);">+    * - The 'digits' parameter, however, may also contain less digits, 14 in the case of</span><br><span style="color: hsl(120, 100%, 40%);">+  *   f_gen_imei().</span><br><span style="color: hsl(120, 100%, 40%);">+     * - The IMEI_L3 template will then fill up with zeros to make 15 digits.</span><br><span style="color: hsl(120, 100%, 40%);">+      * Hence oddevenIndicator must always indicate 'odd' == '1'B.</span><br><span style="color: hsl(120, 100%, 40%);">+  *</span><br><span style="color: hsl(120, 100%, 40%);">+     * FIXME: if the caller passes less than 15 digits, the Luhn checksum digit then ends up zero == most probably</span><br><span style="color: hsl(120, 100%, 40%);">+         * wrong.</span><br><span style="color: hsl(120, 100%, 40%);">+      */</span><br><span style="color: hsl(120, 100%, 40%);">+   l3.oddevenIndicator := '1'B;</span><br><span>         l3.digits := digits;</span><br><span>         return l3;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18758">change 18758</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18758"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-ttcn3-hacks </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Iaa9ba1214c4c15fd9620e68fe2e842fdf52912c0 </div>
<div style="display:none"> Gerrit-Change-Number: 18758 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>