aboutsummaryrefslogtreecommitdiffstats
path: root/pySim
diff options
context:
space:
mode:
authorSupreeth Herle <herlesupreeth@gmail.com>2020-03-23 11:59:33 +0100
committerSupreeth Herle <herlesupreeth@gmail.com>2020-06-23 13:54:21 +0200
commit3c0bd7a41e8b5d9ecb61e9eab5ea299966096d6d (patch)
tree22aaf164697e55bd4b7a62f83e86c1b7904ca93a /pySim
parentb1634db0b32fedd8088c3f69602b74bfcf5ef186 (diff)
utils.py: Add helper method to encode ePDG IdentifierHEADmaster
This method encodes ePDG Id so it can be stored to EF.ePDGId or EF.ePDGIdEm. See 3GPP TS 31.102 version 13.4.0 Release 13, section 4.2.102 and 4.2.104. Resulting hex string is made of tag value + length + address type + address. tag value for home ePDG identifier is 80 address type: 0x00 (FQDN), 0x01 (IPv4), 0x02 (IPv6), other (Reserved) ePDG FQDN example: epdg.mnc001.mcc001.3gppnetwork.org Note: Only FQDN format is supported for now Change-Id: I864bda5505e9061391a727add294a6e90c50f9ef
Diffstat (limited to 'pySim')
-rw-r--r--pySim/utils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/pySim/utils.py b/pySim/utils.py
index 79a1c1b..ac82774 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -476,6 +476,24 @@ def dec_epdgid(hexstr):
return s
+def enc_epdgid(epdg_addr, addr_type='00'):
+ """
+ Encode ePDG Id so it can be stored to EF.ePDGId or EF.ePDGIdEm.
+ See 3GPP TS 31.102 version 13.4.0 Release 13, section 4.2.102 and 4.2.104.
+
+ Default values:
+ - addr_type: 00 - FQDN format of ePDG Address
+ """
+
+ s = ""
+
+ # TODO: Encoding of IPv4 and IPv6 address
+ if addr_type == '00':
+ hex_str = s2h(epdg_addr)
+ s += '80' + ('%02x' % ((len(hex_str)//2)+1)) + '00' + hex_str
+
+ return s
+
def sanitize_pin_adm(opts):
"""
The ADM pin can be supplied either in its hexadecimal form or as