filesystem: Introduce support for TLV parser

This adds an easy way for files to make use of the pySim.tlv parser.

All a file has to do is to specify a _tlv member which points to
either a TLV_IE or a TLV_IE_Collection instance.

Change-Id: I59f456b4223ec88081e91cee168b654c69bcb5f4
This commit is contained in:
Harald Welte
2021-05-29 21:28:24 +02:00
parent bb3b5df8bf
commit fb50621570
2 changed files with 40 additions and 0 deletions

View File

@@ -338,6 +338,8 @@ class TLV_IE_Collection(metaclass=TlvCollectionMeta):
while len(remainder):
# obtain the tag at the start of the remainder
tag, r = first._parse_tag_raw(remainder)
if tag == None:
return res
if tag in self.members_by_tag:
cls = self.members_by_tag[tag]
# create an instance and parse accordingly