laforge has submitted this change. (
https://gerrit.osmocom.org/c/pysim/+/43979?usp=email )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted
one.
)Change subject: esim.saip: expand a fill or repeat pattern per record
......................................................................
esim.saip: expand a fill or repeat pattern per record
File.expand_fill_pattern() expanded the Fcp pattern once across the
whole file. TS 102 222 applies both patterns record by record in a
record oriented EF, so only the first record received the leading
bytes of the pattern and every later record started with 'FF'.
For a linear fixed or cyclic EF, expand the pattern to one record and
repeat it for every record.
The folder osmocom-pysim-saip-fill-file-offset-erased-state of
hampushellsberg-dev/PySIM-upstream-patches on GitHub has the analysis
and a repro.
Change-Id: Ia49cf751673b5811aac32215f4f6f7a2aee9daba
---
M pySim/esim/saip/__init__.py
1 file changed, 14 insertions(+), 2 deletions(-)
Approvals:
laforge: Looks good to me, approved
jolly: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py
index 8b81c9c..55811a8 100644
--- a/pySim/esim/saip/__init__.py
+++ b/pySim/esim/saip/__init__.py
@@ -437,8 +437,20 @@
return ret
def expand_fill_pattern(self) -> bytes:
- """Expand the fill/repeat pattern as per TS 102 222 Section
6.3.2.2.2"""
- return ts_102_222.expand_pattern(self.fill_pattern,
self.fill_pattern_repeat, self.file_size)
+ """Expand the fill/repeat pattern as per TS 102 222 Section 6.3.2.2.2
+
+ TS 102 222 defines both patterns record-wise for a record oriented EF:
tag 'C1'
+ initialises "the first W-1 bytes of each record", and tag 'C2' repeats
within a record and
+ truncates "at the end of each record". Expanding once across file_size
instead puts the
+ leading bytes of the pattern only in the first record, which for
EF.EXT* or EF.SMS means
+ every later record claims a record type or status of 'FF'.
+ """
+ if self.file_type in ['LF', 'CY'] and self.rec_len and self.nb_rec:
+ record = ts_102_222.expand_pattern(self.fill_pattern,
self.fill_pattern_repeat,
+ self.rec_len)[:self.rec_len]
+ return record * self.nb_rec
+ return ts_102_222.expand_pattern(self.fill_pattern,
self.fill_pattern_repeat,
+ self.file_size)[:self.file_size]
def file_content_from_tuples(self, l: List[Tuple]) -> Optional[bytes]:
"""linearize a list of fillFileContent / fillFileOffset tuples into a
stream of bytes."""
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/43979?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: Ia49cf751673b5811aac32215f4f6f7a2aee9daba
Gerrit-Change-Number: 43979
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <[email protected]>
Gerrit-Reviewer: jolly <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-CC: hampushellsberg <[email protected]>