mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-27 07:48:33 +03:00
euicc: Add euicc_memory_reset shell command
This implements the ES10c eUICC Memory Reset procedure Change-Id: Ib462f5b7de3e500e51c0f3d6e2b9b0c2d3ba7e20
This commit is contained in:
@@ -1393,6 +1393,13 @@ Example::
|
|||||||
"delete_result": "ok"
|
"delete_result": "ok"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
euicc_memory_reset
|
||||||
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. argparse::
|
||||||
|
:module: pySim.euicc
|
||||||
|
:func: CardApplicationISDR.AddlShellCommands.mem_res_parser
|
||||||
|
|
||||||
|
|
||||||
get_eid
|
get_eid
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|||||||
@@ -268,6 +268,17 @@ class DeleteProfileReq(BER_TLV_IE, tag=0xbf33, nested=[IsdpAid, Iccid]):
|
|||||||
class DeleteProfileResp(BER_TLV_IE, tag=0xbf33, nested=[DeleteResult]):
|
class DeleteProfileResp(BER_TLV_IE, tag=0xbf33, nested=[DeleteResult]):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# SGP.22 Section 5.7.19: EuiccMemoryReset
|
||||||
|
class ResetOptions(BER_TLV_IE, tag=0x82):
|
||||||
|
_construct = FlagsEnum(Byte, deleteOperationalProfiles=0x80, deleteFieldLoadedTestProfiles=0x40,
|
||||||
|
resetDefaultSmdpAddress=0x20)
|
||||||
|
class ResetResult(BER_TLV_IE, tag=0x80):
|
||||||
|
_construct = Enum(Int8ub, ok=0, nothingToDelete=1, undefinedError=127)
|
||||||
|
class EuiccMemoryResetReq(BER_TLV_IE, tag=0xbf34, nested=[ResetOptions]):
|
||||||
|
pass
|
||||||
|
class EuiccMemoryResetResp(BER_TLV_IE, tag=0xbf34, nested=[ResetResult]):
|
||||||
|
pass
|
||||||
|
|
||||||
# SGP.22 Section 5.7.20 GetEID
|
# SGP.22 Section 5.7.20 GetEID
|
||||||
class EidValue(BER_TLV_IE, tag=0x5a):
|
class EidValue(BER_TLV_IE, tag=0x5a):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = HexAdapter(GreedyBytes)
|
||||||
@@ -504,6 +515,30 @@ class CardApplicationISDR(pySim.global_platform.CardApplicationSD):
|
|||||||
d = dp.to_dict()
|
d = dp.to_dict()
|
||||||
self._cmd.poutput_json(flatten_dict_lists(d['delete_profile_resp']))
|
self._cmd.poutput_json(flatten_dict_lists(d['delete_profile_resp']))
|
||||||
|
|
||||||
|
mem_res_parser = argparse.ArgumentParser()
|
||||||
|
mem_res_parser.add_argument('--delete-operational', action='store_true',
|
||||||
|
help='Delete all operational profiles')
|
||||||
|
mem_res_parser.add_argument('--delete-test-field-installed', action='store_true',
|
||||||
|
help='Delete all test profiles, except pre-installed ones')
|
||||||
|
mem_res_parser.add_argument('--reset-smdp-address', action='store_true',
|
||||||
|
help='Reset the SM-DP+ address')
|
||||||
|
|
||||||
|
@cmd2.with_argparser(mem_res_parser)
|
||||||
|
def do_euicc_memory_reset(self, opts):
|
||||||
|
"""Perform an ES10c eUICCMemoryReset function. This will permanently delete the selected subset of
|
||||||
|
profiles from the eUICC."""
|
||||||
|
flags = {}
|
||||||
|
if opts.delete_operational:
|
||||||
|
flags['deleteOperationalProfiles'] = True
|
||||||
|
if opts.delete_test_field_installed:
|
||||||
|
flags['deleteFieldLoadedTestProfiles'] = True
|
||||||
|
if opts.reset_smdp_address:
|
||||||
|
flags['resetDefaultSmdpAddress'] = True
|
||||||
|
|
||||||
|
mr_cmd = EuiccMemoryResetReq(children=[ResetOptions(decoded=flags)])
|
||||||
|
mr = CardApplicationISDR.store_data_tlv(self._cmd.lchan.scc, mr_cmd, EuiccMemoryResetResp)
|
||||||
|
d = mr.to_dict()
|
||||||
|
self._cmd.poutput_json(flatten_dict_lists(d['euicc_memory_reset_resp']))
|
||||||
|
|
||||||
def do_get_eid(self, _opts):
|
def do_get_eid(self, _opts):
|
||||||
"""Perform an ES10c GetEID function."""
|
"""Perform an ES10c GetEID function."""
|
||||||
|
|||||||
Reference in New Issue
Block a user