Treat MCC and MNC as strings, not integers

A MNC of 02 and 002 are *not* equal.  The former is a two-digit MNC
and the latter is a three-digit MNC.  Hence, we shouldn't treat
MNCs as integer values as we have no clue how many leading zeroes
(if any) the user entered.

Change-Id: I9d1d07a64888c76703c3e430bbdd822080c05819
Closes: OS#4523
This commit is contained in:
Harald Welte
2020-05-12 21:12:44 +02:00
committed by Philipp Maier
parent ff84c23839
commit 7f1d3c496f
8 changed files with 33 additions and 22 deletions

View File

@@ -102,7 +102,9 @@ def enc_iccid(iccid):
def enc_plmn(mcc, mnc):
"""Converts integer MCC/MNC into 3 bytes for EF"""
return swap_nibbles(lpad('%d' % int(mcc), 3) + lpad('%d' % int(mnc), 3))
if len(mnc) == 2:
mnc = "F%s" % mnc
return swap_nibbles("%s%s" % (mcc, mnc))
def dec_spn(ef):
byte1 = int(ef[0:2])