neels has uploaded this change for review.
comprehensiontlv: encode_len, encode_one akin to bertlv
Change-Id: I5fa2b3388c9d3f6ce96f01572e3d022a5d5ee758
---
M src/osmocom/tlv.py
1 file changed, 6 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/python/pyosmocom refs/changes/25/44225/1
diff --git a/src/osmocom/tlv.py b/src/osmocom/tlv.py
index ef43c0f..3bd294e 100644
--- a/src/osmocom/tlv.py
+++ b/src/osmocom/tlv.py
@@ -79,7 +79,12 @@
ret |= 0x80
return ret.to_bytes(1, 'big')
-# length value coding is equal to BER-TLV
+def comprehensiontlv_encode_len(length: int) -> bytes:
+ # length value coding is equal to BER-TLV
+ return bertlv_encode_len(length)
+
+def comprehensiontlv_encode_one(t: int, v: bytes):
+ return comprehensiontlv_encode_tag(t) + bertlv_encode_len(len(v)) + v
def comprehensiontlv_parse_one(binary: bytes) -> Tuple[dict, int, bytes, bytes]:
"""Parse a single TLV IE at the start of the given binary data.
To view, visit change 44225. To unsubscribe, or for help writing mail filters, visit settings.