diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-03-11 23:56:58 +0100 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-03-12 01:00:26 +0100 |
commit | b271be3dc009cfe6c17d4e9fdd389e147975b77a (patch) | |
tree | 95ee770c8bdea5a9db14a505bb14a862ae12302b | |
parent | 4ae7c4907604426dff60b819ec1bedd7dd70569e (diff) |
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
-rw-r--r-- | pySim/utils.py | 6 |
1 files changed, 3 insertions, 3 deletions
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_mcc_from_plmn(plmn): 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) |