summaryrefslogtreecommitdiffstats
path: root/src/common/protocol_private.h
diff options
context:
space:
mode:
authorGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-19 13:52:43 +0300
committerGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-19 13:52:43 +0300
commitb4165ee0b257aaa9064c5ac82200ff2569a02955 (patch)
tree5f56cb813bace9b885c0528b7b23342d4e625f6c /src/common/protocol_private.h
parent9c8ece1538d31dba9a416c9f29f88e18510f4c75 (diff)
downloadusurpation-b4165ee0b257aaa9064c5ac82200ff2569a02955.tar.gz
usurpation-b4165ee0b257aaa9064c5ac82200ff2569a02955.tar.bz2
usurpation-b4165ee0b257aaa9064c5ac82200ff2569a02955.zip
Protocol: more work on protocol implementation.
Additional functions implemented for protocol and basic functions to work with uuid. Source is buildable but actual build files are not edited to accomodate the changes. Signed-off-by: Ramūnas Mažeikis <ramunasnezinomas@gmail.com>
Diffstat (limited to 'src/common/protocol_private.h')
-rw-r--r--src/common/protocol_private.h40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h
index 3a4b1b2..653d19c 100644
--- a/src/common/protocol_private.h
+++ b/src/common/protocol_private.h
@@ -18,10 +18,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#ifdef PROTOCOL_H_PRIVATE
+#ifndef PROTOCOL_H_PRIVATE
#define PROTOCOL_H_PRIVATE
-#define TLV_ARR_SIZE (16)
+#include "utils.h"
+
+#define TLV_BUF_SIZE (16)
/* Pease don't rape the buffer with long messages, daemon-kun. */
#define MSG_BUF_SIZE (257)
@@ -38,10 +40,22 @@
* */
size_t tlv_count(const struct packet_data * const packet);
-/* Parses a data packet, fills buffer of tlv's of size `buf_size` and returns
- * the number of tlv's actually parsed.
+
+/**
+ * Parses tlv's from packet data and writes them to a buffer of given size.
+ *
+ * Returns how many tlv's were actually parsed.
*
* To check for errors, set errno to 0 and check after calling.
+ *
+ * Not yet implemented.
+ *
+ * @param data Data from network packet
+ * @param buf Buffer to store parsed tlv's
+ * @param buf_size Size of buffer used to store tlv's
+ *
+ * @return Number of tlv's actually parsed. Greter than or equal to buffer
+ * size, if an error occurs.
* */
size_t get_tlvs( const struct packet_data * const data,
const struct tlv *buf,
@@ -51,16 +65,30 @@ size_t get_tlvs( const struct packet_data * const data,
* */
void push_string(char *str);
-void push_fpi1(fpi1_t num);
+/* Reinterprets char * as fpi1_t * and appends it to the outgoing packet as a
+ * tlv.
+ */
+void push_fpi1(char *num);
+/* Reinterprets char * as time_t * and appends it to the outgoing packet as a
+ * tlv.
+ */
void push_timestamp(char *data);
+/* Not implemented yet. */
void push_request(char *data);
+/* Not implemented yet. */
void push_reply(char *data);
+/* Reinterprets char * as uuid_t * and appends it to the outgoing packet as a
+ * tlv.
+ */
void push_uuid(char *data);
-
+/* Appends tlv_type and size of data to a packet effectively creating a tlv
+ * header.
+ */
+void push_tlv_header(enum tlv_type type, size_t size);
#endif /* PROTOCOL_H_PRIVATE */