From 3397ca1e68f69259cca56751af73f3f0706b6831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Wed, 22 May 2019 21:46:23 +0300 Subject: Protocol: updated get_tlv and more docs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramūnas Mažeikis --- include/protocol.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/protocol.h b/include/protocol.h index cd28e2d..598b8e3 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -26,6 +26,7 @@ #define E_TLV_OVERFLOW (1 << 0) #define E_UNKNOWN_TYPE (1 << 1) #define E_IVALID_DESCRIPTOR (1 << 2) +#define END_OF_PACKET (1 << 3) /** * Regular packets contain tlv's defined by tlv_type. @@ -114,13 +115,23 @@ int get_tlv(struct tlv_parser *parser, struct tlv *ret); * * In case of overflow return E_TLV_OVERFLOW. * + * On next call after retreiving last packet returns END_OF_PACKET. + * * Overflow can be detected after forming tlv header. This means that the * packet may have changes. * */ int push_data(struct tlv_packet *packet, enum tlv_type type, char *data); + +/** + * Resets offset to 0 and set entire buffer to 0. + */ void clear_data(struct tlv_packet *packet); + +/** + * Tells what size of buffer is needed for next tlv. + */ size_t tlv_data_size(struct tlv_parser *parser); #endif /* PROTOCOL_H_INCLUDED */ -- cgit v1.2.3