From 8006f5393e21750558a01c780641831d925382ee Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 13 Feb 2019 22:23:13 +0100 Subject: TLV: Add one-shot TLV encoder So far, the TLV code contained two types of functions * tlp_parse() to parse all TLVs according to definition into tlvp_parsed * various helper functions to encode individual TLVs during message generation This patch implements the inverse of tlv_parse(): tlv_encode(), which takes a full 'struct tlv_pared' and encodes all IEs found in it. The order of IEs is in numerically ascending order of the tag. As many protocols have different IE/TLV ordering requirements, let's add a tlv_encode_ordered() function where the caller can specify the TLV ordering during the one-shot encode. Change-Id: I761a30bf20355a9f80a4a8e0c60b0b0f78515efe --- tests/tlv/tlv_test.ok | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/tlv/tlv_test.ok') diff --git a/tests/tlv/tlv_test.ok b/tests/tlv/tlv_test.ok index de159bfb..f3f0fd41 100644 --- a/tests/tlv/tlv_test.ok +++ b/tests/tlv/tlv_test.ok @@ -1,2 +1,4 @@ Test shift functions +Testing TLV encoder by decoding + re-encoding binary +Testing TLV encoder with IE ordering Done. -- cgit v1.2.3