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

Change subject: euicc: Add get_profiles_info command
......................................................................

euicc: Add get_profiles_info command

Example output:

pySIM-shell (02:MF/ADF.ISD-R)> get_profiles_info
{
    "profile_info_seq": {
        "profile_info": {
            "iccid": "98940462222222222222",
            "isdp_aid": "a0000005591010ffffffff8900001200",
            "profile_state": "enabled",
            "service_provider_name": "foobar",
            "profile_name": "foobar",
            "profile_class": "provisioning"
        }
    }
}

Change-Id: I52d136f99dc0eb29905e7ca0cd0865486d3cf65b
---
M docs/shell.rst
M pySim/euicc.py
2 files changed, 70 insertions(+), 6 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/docs/shell.rst b/docs/shell.rst
index 31d73c0..610500f 100644
--- a/docs/shell.rst
+++ b/docs/shell.rst
@@ -883,6 +883,11 @@
    :module: pySim.euicc
    :func: ADF_ISDR.AddlShellCommands.rem_notif_parser

+get_profiles_info
+~~~~~~~~~~~~~~~~~
+
+Obtain information about the profiles present on the eUICC using the ES10c 
GetProfilesInfo() function.
+
 enable_profile
 ~~~~~~~~~~~~~~

diff --git a/pySim/euicc.py b/pySim/euicc.py
index d9b7b70..45ebf1c 100644
--- a/pySim/euicc.py
+++ b/pySim/euicc.py
@@ -167,11 +167,41 @@
 class LoadCRL(BER_TLV_IE, tag=0xbf35, nested=[]): # FIXME
     pass

+# SGP.22 Section 5.7.15: GetProfilesInfo
+class TagList(BER_TLV_IE, tag=0x5c):
+    _construct = GreedyRange(Int8ub) # FIXME: tags could be multi-byte
+class ProfileInfoListReq(BER_TLV_IE, tag=0xbf2d, nested=[TagList]): # FIXME: 
SearchCriteria
+    pass
+class IsdpAid(BER_TLV_IE, tag=0x4f):
+    _construct = HexAdapter(GreedyBytes)
+class ProfileState(BER_TLV_IE, tag=0x9f70):
+    _construct = Enum(Int8ub, disabled=0, enabled=1)
+class ProfileNickname(BER_TLV_IE, tag=0x90):
+    _construct = Utf8Adapter(GreedyBytes)
+class ServiceProviderName(BER_TLV_IE, tag=0x91):
+    _construct = Utf8Adapter(GreedyBytes)
+class ProfileName(BER_TLV_IE, tag=0x92):
+    _construct = Utf8Adapter(GreedyBytes)
+class IconType(BER_TLV_IE, tag=0x93):
+    _construct = Enum(Int8ub, jpg=0, png=1)
+class Icon(BER_TLV_IE, tag=0x94):
+    _construct = GreedyBytes
+class ProfileClass(BER_TLV_IE, tag=0x95):
+    _construct = Enum(Int8ub, test=0, provisioning=1, operational=2)
+class ProfileInfo(BER_TLV_IE, tag=0xe3, nested=[Iccid, IsdpAid, ProfileState, 
ProfileNickname,
+                                                ServiceProviderName, 
ProfileName, IconType, Icon,
+                                                ProfileClass]): # FIXME: more 
IEs
+    pass
+class ProfileInfoSeq(BER_TLV_IE, tag=0xa0, nested=[ProfileInfo]):
+    pass
+class ProfileInfoListError(BER_TLV_IE, tag=0x81):
+    _construct = Enum(Int8ub, incorrectInputValues=1, undefinedError=2)
+class ProfileInfoListResp(BER_TLV_IE, tag=0xbf2d, nested=[ProfileInfoSeq, 
ProfileInfoListError]):
+    pass
+
 # SGP.22 Section 5.7.16:: EnableProfile
 class RefreshFlag(BER_TLV_IE, tag=0x88): # FIXME
     _construct = Int8ub # FIXME
-class IsdpAid(BER_TLV_IE, tag=0x4f):
-    _construct = HexAdapter(GreedyBytes)
 class EnableResult(BER_TLV_IE, tag=0x80):
     _construct = Enum(Int8ub, ok=0, iccidOrAidNotFound=1, 
profileNotInDisabledState=2,
                       disallowedByPolicy=3, wrongProfileReenabling=4, 
catBusy=5, undefinedError=127)
@@ -199,17 +229,15 @@
     pass

 # SGP.22 Section 5.7.20 GetEID
-class TagList(BER_TLV_IE, tag=0x5c):
-    _construct = GreedyRange(Int8ub)
 class EidValue(BER_TLV_IE, tag=0x5a):
     _construct = HexAdapter(GreedyBytes)
 class GetEuiccData(BER_TLV_IE, tag=0xbf3e, nested=[TagList, EidValue]):
     pass

 # SGP.22 Section 5.7.21: ES10c SetNickname
-class ProfileNickname(BER_TLV_IE, tag=0x8f):
+class SnrProfileNickname(BER_TLV_IE, tag=0x8f):
     _construct = Utf8Adapter(GreedyBytes)
-class SetNicknameReq(BER_TLV_IE, tag=0xbf29, children=[Iccid, 
ProfileNickname]):
+class SetNicknameReq(BER_TLV_IE, tag=0xbf29, children=[Iccid, 
SnrProfileNickname]):
     pass
 class SetNicknameResult(BER_TLV_IE, tag=0x80):
     _construct = Enum(Int8ub, ok=0, iccidNotFound=1, undefinedError=127)
@@ -321,6 +349,12 @@
             d = rn.to_dict()
             
self._cmd.poutput_json(flatten_dict_lists(d['notification_sent_resp']))

+        def do_get_profiles_info(self, opts):
+            """Perform an ES10c GetProfilesInfo function."""
+            pi = ADF_ISDR.store_data_tlv(self._cmd.lchan.scc, 
ProfileInfoListReq(), ProfileInfoListResp)
+            d = pi.to_dict()
+            
self._cmd.poutput_json(flatten_dict_lists(d['profile_info_list_resp']))
+
         en_prof_parser = argparse.ArgumentParser()
         en_prof_grp = en_prof_parser.add_mutually_exclusive_group()
         en_prof_grp.add_argument('--isdp-aid', help='Profile identified by its 
ISD-P AID')

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I52d136f99dc0eb29905e7ca0cd0865486d3cf65b
Gerrit-Change-Number: 34880
Gerrit-PatchSet: 4
Gerrit-Owner: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to