Change in pysim[master]: filesystem: add new command add_ef

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Mon Mar 29 19:07:39 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/23533 )


Change subject: filesystem: add new command add_ef
......................................................................

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963
---
M pySim/filesystem.py
1 file changed, 31 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/33/23533/1

diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 04fa250..2c1fe8b 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -130,12 +130,43 @@
 
 class CardDF(CardFile):
     """DF (Dedicated File) in the smart card filesystem.  Those are basically sub-directories."""
+
+    @with_default_category('DF/ADF Commands')
+    class ShellCommands(CommandSet):
+        def __init__(self):
+            super().__init__()
+
+        add_ef_parser = argparse.ArgumentParser()
+        add_ef_parser.add_argument('fid', type=str, default=None, help='file identifier (hexadecimal)')
+        add_ef_parser.add_argument('--name', type=str, default=None, help='human readable name')
+        add_ef_parser.add_argument('--desc', type=str, default=None, help='human readable description')
+        add_ef_parser.add_argument('--struct', type=str, default="TransparentEF", help='file structure (TransparentEF|LinFixedEF)')
+        @cmd2.with_argparser(add_ef_parser)
+
+        def do_add_ef(self, opts):
+            """Add an EF representation at the current position in the file system"""
+            selected_file = self._cmd.rs.selected_file
+
+            if not opts.name:
+                opts.name = "EF." + opts.fid
+            if not opts.desc:
+                opts.desc = "manually added at runtime"
+
+            if opts.struct == "TransparentEF":
+                ef = TransparentEF(fid=opts.fid, sfid=None, name=opts.name, desc=opts.desc)
+            elif opts.struct == "LinFixedEF":
+                ef = LinFixedEF(fid=opts.fid, sfid=None, name=opts.name, desc=opts.desc)
+            else:
+                self._cmd.poutput("add_ef: error: invalid file type specified")
+            selected_file.add_files([ef])
+
     def __init__(self, **kwargs):
         if not isinstance(self, CardADF):
             if not 'fid' in kwargs:
                 raise TypeError('fid is mandatory for all DF')
         super().__init__(**kwargs)
         self.children = dict()
+        self.shell_commands = [self.ShellCommands()]
 
     def __str__(self):
         return "DF(%s)" % (super().__str__())

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23533
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Gerrit-Change-Number: 23533
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210329/000b00d0/attachment.htm>


More information about the gerrit-log mailing list