Change in pysim[master]: Revert "utils.py: Fix for parsing MNC"

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

fixeria gerrit-no-reply at lists.osmocom.org
Fri Mar 12 00:13:31 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/23328 )


Change subject: Revert "utils.py: Fix for parsing MNC"
......................................................................

Revert "utils.py: Fix for parsing MNC"

This reverts commit bdf3d3597b5d8e4260f80a00ada78e9ad612b00b, which
broke pySim.utils.dec_mnc_from_plmn().  According to 3GPP TS 31.102,
which points to TS 24.008, the three-digit EHPLMN shall be encoded
as shown below (ASCII-art interpretation):

    0   1   2   3   4   5   6   7
  +---+---+---+---+---+---+---+---+
  |  MCC Digit 2  |  MCC Digit 1  |
  +---+---+---+---+---+---+---+---+
  |  MNC Digit 3  |  MCC Digit 3  |
  +---+---+---+---+---+---+---+---+
  |  MNC Digit 2  |  MNC Digit 1  |
  +---+---+---+---+---+---+---+---+

So the original implementation was correct, and we even had a unit
test for it.  Most likely, the SIM card itself was programmed
incorrectly?

Makes 'testDecMNCfromPLMN_threeDigitMNC' pass again.

Change-Id: If6bf5383988ad442e275efc7c5a159327d104879
---
M pySim/utils.py
1 file changed, 3 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/28/23328/1

diff --git a/pySim/utils.py b/pySim/utils.py
index 6dbd980..b49a437 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -140,9 +140,9 @@
 
 def dec_mnc_from_plmn(plmn):
 	ia = h2i(plmn)
-	digit1 = (ia[1] & 0xF0)	>>4		# 2nd byte, MSB
-	digit2 = ia[2] & 0x0F			# 3rd byte, LSB
-	digit3 = (ia[2] & 0xF0) >> 4	# 3nd byte, MSB
+	digit1 = ia[2] & 0x0F		# 3rd byte, LSB
+	digit2 = (ia[2] & 0xF0) >> 4	# 3rd byte, MSB
+	digit3 = (ia[1] & 0xF0) >> 4	# 2nd byte, MSB
 	if digit3 == 0xF and digit2 == 0xF and digit1 == 0xF:
 		return 0xFFF # 4095
 	return derive_mnc(digit1, digit2, digit3)

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: If6bf5383988ad442e275efc7c5a159327d104879
Gerrit-Change-Number: 23328
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210312/d8bc40dd/attachment.htm>


More information about the gerrit-log mailing list