laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/37835?usp=email )


Change subject: pySim.esim.saip: Improve File.from_template feature support
......................................................................

pySim.esim.saip: Improve File.from_template feature support

When populating a File from a FileTemplate, let's make sure we
* correctly treat the maximum file size for BER-TLV files
* respect the default value pattern / repeat pattern
* respect the high_update flag.

Change-Id: I3ba092e0893f53a18264dff5fa37b12ccd9bd47e
---
M pySim/esim/saip/__init__.py
1 file changed, 20 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/35/37835/1

diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py
index b63b95a..0bf805d 100644
--- a/pySim/esim/saip/__init__.py
+++ b/pySim/esim/saip/__init__.py
@@ -107,6 +107,7 @@
     def from_template(self, template: templates.FileTemplate):
         """Determine defaults for file based on given FileTemplate."""
         fdb_dec = {}
+        pefi = {}
         self.rec_len = None
         if template.fid:
             self.fileDescriptor['fileID'] = template.fid.to_bytes(2, 'big')
@@ -126,14 +127,16 @@
                 fdb_dec['structure'] = 'linear_fixed'
             elif template.file_type == 'CY':
                 fdb_dec['structure'] = 'cyclic'
-        elif template.file_type in ['TR', 'BT']:
+        elif template.file_type == 'BT':
             fdb_dec['file_type'] = 'working_ef'
+            fdb_dec['structure'] = 'ber_tlv'
+            if template.file_size:
+                pefi['maximumFileSize'] = template.file_size.to_bytes(2, 
'big') # FIXME
+        elif template.file_type == 'TR':
+            fdb_dec['file_type'] = 'working_ef'
+            fdb_dec['structure'] = 'transparent'
             if template.file_size:
                 self.fileDescriptor['efFileSize'] = 
template.file_size.to_bytes(2, 'big') # FIXME
-            if template.file_type == 'BT':
-                fdb_dec['structure'] = 'ber_tlv'
-            elif template.file_type == 'TR':
-                fdb_dec['structure'] = 'transparent'
         elif template.file_type in ['MF', 'DF', 'ADF']:
             fdb_dec['file_type'] = 'df'
             fdb_dec['structure'] = 'no_info_given'
@@ -142,9 +145,18 @@
         if self.rec_len:
             fd_dict['record_len'] = self.rec_len
         self.fileDescriptor['fileDescriptor'] = 
build_construct(FileDescriptor._construct, fd_dict)
-        # FIXME: default_val
-        # FIXME: high_update
-        # FIXME: params?
+        if template.high_update:
+            pefi['specialFileInformation'] = b'\x80' # TS 102 222 Table 5
+        try:
+            if template.default_val_repeat:
+                pefi['repeatPattern'] = template.expand_default_value_pattern()
+            elif template.default_val:
+                pefi['fillPattern'] = template.expand_default_value_pattern()
+        except ValueError:
+            # ignore this here as without a file or record length we cannot do 
this
+            continue
+        if len(pefi.keys()):
+            self.fileDescriptor['proprietaryEFInfo'] = pefi

     def from_tuples(self, l:List[Tuple]):
         """Parse a list of fileDescriptor, fillFileContent, fillFileOffset 
tuples into this instance."""

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

Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I3ba092e0893f53a18264dff5fa37b12ccd9bd47e
Gerrit-Change-Number: 37835
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>

Reply via email to