<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 6:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">P.S: I have verified the MSISDN programmed on the SIM represented in the same way as it was programmed</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Sorry, i swallowed some of my words :P. I meant, I verified the MSISDN number programmed on the SIM by putting it in a UE and it represented in the same way as it was programmed</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Ok, thanks for explanation. I also checked the specs, and here is what I propose:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  # Make sure mandatory fields are present<br>  if len(res) < 14:<br>    raise ValueError("EF-MSISDN length is too short")</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  # Skip optional Alpha Identifier<br>  xlen = len(res) - 14<br>  msisdn_lhv = res[xlen:][:12]</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  # Parse the length (in bytes) of BCD encoded number<br>  # FIXME: it seems the length of ToN/NPI is also included<br>  bcd_len = int(msisdn_lhv[0])<br>  if bcd_len > 11: # "This means that the maximum value is 11"<br>    raise ValueError("EF-MSISDN contains odd BCD length")</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  # Parse ToN / NPI<br>  ton = (int(msisdn_lhv[1]) >> 4) & 0x07<br>  npi = int(msisdn_lhv[1]) & 0x0f<br>  bcd_len -= 1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  # Parse MSISDN<br>  msisdn = swap_nibbles(msisdn_lhv[2:][:bcd_len]).rstrip('f')</pre><p style="white-space: pre-wrap; word-wrap: break-word;">I did not test this code though...</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/16947">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/16947">change 16947</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/pysim/+/16947"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ie914ae83d787e3f1a90f9f305bffd45053b8c863 </div>
<div style="display:none"> Gerrit-Change-Number: 16947 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: herlesupreeth <herlesupreeth@gmail.com> </div>
<div style="display:none"> Gerrit-Assignee: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: herlesupreeth <herlesupreeth@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-CC: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Wed, 22 Jan 2020 15:48:01 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>