laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/39409?usp=email )

Change subject: euicc: Add euicc_memory_reset shell command
......................................................................

euicc: Add euicc_memory_reset shell command

This implements the ES10c eUICC Memory Reset procedure

Change-Id: Ib462f5b7de3e500e51c0f3d6e2b9b0c2d3ba7e20
---
M docs/shell.rst
M pySim/euicc.py
2 files changed, 42 insertions(+), 0 deletions(-)

Approvals:
  dexter: Looks good to me, but someone else must approve
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/docs/shell.rst b/docs/shell.rst
index 026f5c8..564f162 100644
--- a/docs/shell.rst
+++ b/docs/shell.rst
@@ -1393,6 +1393,13 @@
       "delete_result": "ok"
   }

+euicc_memory_reset
+~~~~~~~~~~~~~~~~~~
+
+.. argparse::
+   :module: pySim.euicc
+   :func: CardApplicationISDR.AddlShellCommands.mem_res_parser
+

 get_eid
 ~~~~~~~
diff --git a/pySim/euicc.py b/pySim/euicc.py
index e9321d6..64eb29c 100644
--- a/pySim/euicc.py
+++ b/pySim/euicc.py
@@ -268,6 +268,17 @@
 class DeleteProfileResp(BER_TLV_IE, tag=0xbf33, nested=[DeleteResult]):
     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
 class EidValue(BER_TLV_IE, tag=0x5a):
     _construct = HexAdapter(GreedyBytes)
@@ -504,6 +515,30 @@
             d = dp.to_dict()
             
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):
             """Perform an ES10c GetEID function."""

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39409?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib462f5b7de3e500e51c0f3d6e2b9b0c2d3ba7e20
Gerrit-Change-Number: 39409
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <[email protected]>
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>

Reply via email to