dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/39863?usp=email )
Change subject: saip-tool: add commandline option to edit mandatory services list ......................................................................
saip-tool: add commandline option to edit mandatory services list
Change-Id: I120b98d4b0942c26674bc1365c5711101ec95235 --- M contrib/saip-tool.py M pySim/esim/saip/__init__.py 2 files changed, 30 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/63/39863/1
diff --git a/contrib/saip-tool.py b/contrib/saip-tool.py index 1ffc0e2..889d35f 100755 --- a/contrib/saip-tool.py +++ b/contrib/saip-tool.py @@ -102,6 +102,11 @@ parser_rappi.add_argument('--aid', required=True, help='Load package AID') parser_rappi.add_argument('--inst-aid', required=True, help='Instance AID')
+parser_ssrv = subparsers.add_parser('set-service', help='Add/Remove service flag from/to mandatory services list') +parser_ssrv.add_argument('--output-file', required=True, help='Output file name') +parser_ssrv.add_argument('--add-flag', default=[], action='append', help='Add flag to mandatory services list') +parser_ssrv.add_argument('--remove-flag', default=[], action='append', help='Remove flag from mandatory services list') + parser_info = subparsers.add_parser('tree', help='Display the filesystem tree')
def write_pes(pes: ProfileElementSequence, output_file:str): @@ -451,6 +456,22 @@
print("Load Package AID: %s not found in PE Sequence" % opts.aid)
+def do_set_service(pes: ProfileElementSequence, opts): + header = pes.pe_by_type.get('header', [])[0] + + for s in opts.add_flag: + print("Adding service '%s' from mandatory services list..." % s) + header.mandatory_service_add(s) + for s in opts.remove_flag: + print("Removing service '%s' from mandatory services list..." % s) + header.mandatory_service_remove(s) + + print("The following services are set mandatory:") + for s in header.decoded['eUICC-Mandatory-services'].keys(): + print("\t%s" % s) + + write_pes(pes, opts.output_file) + def do_tree(pes:ProfileElementSequence, opts): pes.mf.print_tree()
@@ -493,5 +514,7 @@ do_add_app_inst(pes, opts) elif opts.command == 'remove-app-inst': do_remove_app_inst(pes, opts) + elif opts.command == 'set-service': + do_set_service(pes, opts) elif opts.command == 'tree': do_tree(pes, opts) diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 752df74..2f9ae10 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -1349,6 +1349,13 @@ if profile_type: self.decoded['profileType'] = profile_type
+ def mandatory_service_add(self, service_name): + self.decoded['eUICC-Mandatory-services'][service_name] = None + + def mandatory_service_remove(self, service_name): + if service_name in self.decoded['eUICC-Mandatory-services'].keys(): + del self.decoded['eUICC-Mandatory-services'][service_name] + class ProfileElementEnd(ProfileElement): type = 'end' def __init__(self, decoded: Optional[dict] = None, **kwargs):