neels has uploaded this change for review.

View Change

add bertlv_encode()

trivial convenience function that does "len(v), v" in one step.

Change-Id: Idc9412f8f9ad4ae9a6babd28031234046a8e9516
---
M src/osmocom/tlv.py
1 file changed, 3 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/python/pyosmocom refs/changes/89/44189/1
diff --git a/src/osmocom/tlv.py b/src/osmocom/tlv.py
index 1aa0103..b822e59 100644
--- a/src/osmocom/tlv.py
+++ b/src/osmocom/tlv.py
@@ -240,6 +240,9 @@
else:
raise ValueError("Length > 32bits not supported")

+def bertlv_encode(t: int, v: bytes):
+ return bertlv_encode_tag(t) + bertlv_encode_len(len(v)) + v
+
def bertlv_parse_one(binary: bytes) -> Tuple[dict, int, bytes, bytes]:
"""Parse a single TLV IE at the start of the given binary data.
Args:

To view, visit change 44189. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: Idc9412f8f9ad4ae9a6babd28031234046a8e9516
Gerrit-Change-Number: 44189
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr@sysmocom.de>