aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSupreeth Herle <herlesupreeth@gmail.com>2020-03-25 11:43:19 +0100
committerherlesupreeth <herlesupreeth@gmail.com>2021-01-05 11:46:41 +0100
commit79f43dda3d0700ef2cc4e3e06595a8f207a866bf (patch)
tree7267403541f0222e111c99485f8d7979e258b2d4
parent556b0fe262e8693fc6e14cee5b2fc4c6e47e7237 (diff)
sysmoISIM-SJA2: Add support for programming IMS Home Network Domain Name
As per 3GPP TS 31.103, this EF (DOMAIN) can found under ADF.ISIM at File Id 6f03. The Home Network Domain Name, i.e. FQDN shall be encoded to an octet string according to UTF-8 encoding rules as specified in IETF RFC 3629 [27]. The tag value of the Home Network Domain Name TLV data object shall be '80'. Example: ./pySim-prog.py -p 0 -x 001 -y 01 -s 8988211900000000004 -i 001011234567895 -k 8baf473f2f8fd09487cccbd7097c6862 --op 11111111111111111111111111111111 -o 8E27B6AF0E692E750F32667A3B14605D -a 85524953 -n isim.test --msisdn 0598765432100 --epdgid epdg.epc.mnc001.mcc001.pub.3gppnetwork.org --pcscf pcscf.testims.org --ims-hdomain testims.org Change-Id: I3c823203aee88734ae423e4ad73da1027a4eaeed
-rwxr-xr-xpySim-prog.py4
-rw-r--r--pySim/cards.py28
2 files changed, 32 insertions, 0 deletions
diff --git a/pySim-prog.py b/pySim-prog.py
index 7ad57e6..f278015 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -156,6 +156,9 @@ def parse_options():
parser.add_option("--pcscf", dest="pcscf",
help="Set Proxy Call Session Control Function (P-CSCF) Address. (Only FQDN format supported)",
)
+ parser.add_option("--ims-hdomain", dest="ims_hdomain",
+ help="Set IMS Home Network Domain Name in FQDN format",
+ )
parser.add_option("--read-imsi", dest="read_imsi", action="store_true",
help="Read the IMSI from the CARD", default=False
)
@@ -464,6 +467,7 @@ def gen_parameters(opts):
'epdgid' : opts.epdgid,
'epdgSelection' : opts.epdgSelection,
'pcscf' : opts.pcscf,
+ 'ims_hdomain': opts.ims_hdomain,
}
diff --git a/pySim/cards.py b/pySim/cards.py
index 42460fe..7e47916 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -28,6 +28,7 @@ from pySim.ts_31_102 import EF_USIM_ADF_map
from pySim.ts_31_103 import EF_ISIM_ADF_map
from pySim.utils import *
from smartcard.util import toBytes
+from pytlv.TLV import *
class Card(object):
@@ -346,6 +347,23 @@ class IsimCard(Card):
else:
return (None, sw)
+ def update_domain(self, domain=None, mcc=None, mnc=None):
+ hex_str = ""
+ if domain:
+ hex_str = s2h(domain)
+ elif mcc and mnc:
+ # MCC and MNC always has 3 digits in domain form
+ plmn_str = 'mnc' + lpad(mnc, 3, "0") + '.mcc' + lpad(mcc, 3, "0")
+ hex_str = s2h('ims.' + plmn_str + '.3gppnetwork.org')
+
+ # Build TLV
+ tlv = TLV(['80'])
+ content = tlv.build({'80': hex_str})
+
+ bin_size_bytes = self._scc.binary_size(EF_ISIM_ADF_map['DOMAIN'])
+ data, sw = self._scc.update_binary(EF_ISIM_ADF_map['DOMAIN'], rpad(content, bin_size_bytes*2))
+ return sw
+
class _MagicSimBase(Card):
"""
@@ -1238,6 +1256,16 @@ class SysmoISIMSJA2(UsimCard, IsimCard):
print("Programming P-CSCF failed with code %s"%sw)
+ # update EF.DOMAIN in ADF.ISIM
+ if self.file_exists(EF_ISIM_ADF_map['DOMAIN']):
+ if p.get('ims_hdomain'):
+ sw = self.update_domain(domain=p['ims_hdomain'])
+ else:
+ sw = self.update_domain()
+
+ if sw != '9000':
+ print("Programming Home Network Domain Name failed with code %s"%sw)
+
if '9000' == self.select_adf_by_aid():
# update EF-USIM_AUTH_KEY in ADF.USIM
if p.get('ki'):