diff options
author | 2019-05-22 21:46:23 +0300 | |
---|---|---|
committer | 2019-05-22 21:46:23 +0300 | |
commit | 3397ca1e68f69259cca56751af73f3f0706b6831 (patch) | |
tree | f05b1228d6435f426cf1bbdbda282e28177efc86 /include | |
parent | 5e22764d79e42345d512216f07880fdd8db2edf2 (diff) | |
download | usurpation-3397ca1e68f69259cca56751af73f3f0706b6831.tar.gz usurpation-3397ca1e68f69259cca56751af73f3f0706b6831.tar.bz2 usurpation-3397ca1e68f69259cca56751af73f3f0706b6831.zip |
Protocol: updated get_tlv and more docs.
Signed-off-by: Ramūnas Mažeikis <ramunasnezinomas@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/protocol.h | 11 |
1 files changed, 11 insertions, 0 deletions
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 */ |