aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2021-04-23 19:37:36 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2021-04-30 17:04:52 +0200
commitf9cbe090e47cce88f8ffd9a46fe4eaff87d9ac85 (patch)
tree2f72d60aba676e071cc50d4e32b122a400847d09
parent0f1862799f3f79b09df465f01089776b4f1edbc6 (diff)
ts_51_011: fix encoding of EF.MSISDN
The json input that is used with EF.MSISDN seems to be somewhat ambigious. The original code accepts {"msisdn": "+4916012345678"} only while the output is {"msisdn": [1, 1, "+4916012345678"]}. Lets add a check and also accept the latter version. Change-Id: I8f8dd68aac25d3fa3bc1aab06b855f8ec6640258 Related: OS#4963
-rw-r--r--pySim/ts_51_011.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py
index 9123330..15a7907 100644
--- a/pySim/ts_51_011.py
+++ b/pySim/ts_51_011.py
@@ -381,7 +381,11 @@ class EF_MSISDN(LinFixedEF):
def _decode_record_hex(self, raw_hex_data):
return {'msisdn': dec_msisdn(raw_hex_data)}
def _encode_record_hex(self, abstract):
- encoded_msisdn = enc_msisdn(abstract['msisdn'])
+ msisdn = abstract['msisdn']
+ if type(msisdn) == str:
+ encoded_msisdn = enc_msisdn(msisdn)
+ else:
+ encoded_msisdn = enc_msisdn(msisdn[2],msisdn[0],msisdn[1])
alpha_identifier = (list(self.rec_len)[0] - len(encoded_msisdn) // 2) * "ff"
return alpha_identifier + encoded_msisdn