From 95ec772b61c9f8c7514d92a8f434706759bfb787 Mon Sep 17 00:00:00 2001 From: Supreeth Herle Date: Tue, 24 Mar 2020 13:09:03 +0100 Subject: [PATCH] utils.py: Add helper method to encode ePDGSelection info TLV Encodes ePDGSelection info TLV so it can be stored at EF.ePDGSelection or EF.ePDGSelectionEm. See 3GPP TS 31.102 version 15.2.0 Release 15, section 4.2.104 and 4.2.106. Take original hex string of EF.ePDGSelection or EF.ePDGSelectionEm, MCC, MNC, ePDG priority for PLMN and ePDG FQDN Format to use for PLMNas input and outputs the encoded hex string. Change-Id: Ia7292d33783c770a3bb91b081c671af36bbb907f --- pySim/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pySim/utils.py b/pySim/utils.py index a3e4cb14..ebc2a956 100644 --- a/pySim/utils.py +++ b/pySim/utils.py @@ -610,6 +610,22 @@ def init_reader(opts): return sl +def enc_ePDGSelection(hexstr, mcc, mnc, epdg_priority='0001', epdg_fqdn_format='00'): + """ + Encode ePDGSelection so it can be stored at EF.ePDGSelection or EF.ePDGSelectionEm. + See 3GPP TS 31.102 version 15.2.0 Release 15, section 4.2.104 and 4.2.106. + + Default values: + - epdg_priority: '0001' - 1st Priority + - epdg_fqdn_format: '00' - Operator Identifier FQDN + """ + + plmn1 = enc_plmn(mcc, mnc) + epdg_priority + epdg_fqdn_format + # TODO: Handle encoding of Length field for length more than 127 Bytes + content = '80' + ('%02x' % (len(plmn1)//2)) + plmn1 + content = rpad(content, len(hexstr)) + return content + def dec_ePDGSelection(sixhexbytes): """ Decode ePDGSelection to get EF.ePDGSelection or EF.ePDGSelectionEm.