From 446157d793c30386f994743f5a8e6ab64e66507f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Wed, 22 May 2019 21:35:46 +0300 Subject: Protocol: updated docs for functions that survived redesign. 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 | 5 +++++ src/common/protocol_private.h | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/protocol.h b/include/protocol.h index 1f941a4..cd28e2d 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -111,6 +111,11 @@ int get_tlv(struct tlv_parser *parser, struct tlv *ret); /** * Appends data to the next packet to be sent. Type of data is determined by * enum tlv_type. + * + * In case of overflow return E_TLV_OVERFLOW. + * + * 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); diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index de086cd..fe28aa0 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -3,7 +3,20 @@ #include "protocol_private.h" +/** + * Convenience function that pushes bytes to the end of a packet and reports + * potential overflow. + * + * In case of detected overflow nothing is done to the packet. + */ int push_bytes(struct tlv_packet *packet, char *data, size_t size); + +/** + * Convenience function that forms a tlv header at the end of a packet. Reports + * potential overflow. + * + * In case of detected overflow nothing is done to the packet. + */ int push_tlv_header(struct tlv_packet *packet, enum tlv_type type, size_t size); #endif /* PROTOCOL_PRIVATE_H */ \ No newline at end of file -- cgit v1.2.3