esim.saip.File: Suppress encoding attributes that are like template

The point of the SAIP template mechanism is to reduce the size of the
encoded profile.  Therefore, our encoder in the to_fileDescriptor()
method should suppress generating attributes if their value is identical
to that of the template (if any).

Change-Id: I337ee6c7e882ec711bece17b7a0def9da36b0ad7
This commit is contained in:
Harald Welte
2024-11-22 21:00:47 +01:00
parent 0f1ffd20ef
commit 9ac4ff3229

View File

@@ -216,13 +216,13 @@ class File:
fdb_dec = {} fdb_dec = {}
pefi = {} pefi = {}
spfi = 0 spfi = 0
if self.fid: if self.fid and self.fid != self.template.fid:
fileDescriptor['fileID'] = self.fid.to_bytes(2, 'big') fileDescriptor['fileID'] = self.fid.to_bytes(2, 'big')
if self.sfi: if self.sfi and self.sfi != self.template.sfi:
fileDescriptor['shortEFID'] = bytes([self.sfi]) fileDescriptor['shortEFID'] = bytes([self.sfi])
if self.df_name: if self.df_name:
fileDescriptor['dfName'] = self.df_name fileDescriptor['dfName'] = self.df_name
if self.arr: if self.arr and self.arr != self.template.arr.to_bytes(1):
fileDescriptor['securityAttributesReferenced'] = self.arr fileDescriptor['securityAttributesReferenced'] = self.arr
if self.file_type in ['LF', 'CY']: if self.file_type in ['LF', 'CY']:
fdb_dec['file_type'] = 'working_ef' fdb_dec['file_type'] = 'working_ef'