filesystem: pass total_len to construct of when encoding file contents

In our construct models we frequently use a context parameter "total_len",
we also pass this parameter to construct when we decode files, but we
do not pass it when we generate files. This is a problem, because when
total_len is used in the construct model, this parameter must be known
also when decoding the file.

Let's make sure that the total_len is properly determined and and passed
to construct (via pyosmocom).

Related: OS#5714
Change-Id: I1b7a51594fbc5d9fe01132c39354a2fa88d53f9b
This commit is contained in:
Philipp Maier
2024-09-17 18:28:43 +02:00
parent 78c22a7d63
commit efddffe015
9 changed files with 348 additions and 41 deletions

View File

@@ -358,7 +358,7 @@ class EF_IMSI(TransparentEF):
def _decode_hex(self, raw_hex):
return {'imsi': dec_imsi(raw_hex)}
def _encode_hex(self, abstract):
def _encode_hex(self, abstract, **kwargs):
return enc_imsi(abstract['imsi'])
@with_default_category('File-Specific Commands')
@@ -446,7 +446,7 @@ class EF_ServiceTable(TransparentEF):
}
return ret
def _encode_bin(self, in_json):
def _encode_bin(self, in_json, **kwargs):
# compute the required binary size
bin_len = 0
for srv in in_json.keys():
@@ -969,7 +969,7 @@ class EF_ICCID(TransparentEF):
def _decode_hex(self, raw_hex):
return {'iccid': dec_iccid(raw_hex)}
def _encode_hex(self, abstract):
def _encode_hex(self, abstract, **kwargs):
return enc_iccid(abstract['iccid'])
# TS 102 221 Section 13.3 / TS 31.101 Secction 13 / TS 51.011 Section 10.1.2