summaryrefslogtreecommitdiffstats
path: root/include/protocol.h
diff options
context:
space:
mode:
authorGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-22 20:33:08 +0300
committerGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-22 20:33:08 +0300
commit28b26ca86cf18947d6d9543ad753ef112ff4da89 (patch)
tree00a9205e36efe91e4229ad1c17750aa6aaf0fa68 /include/protocol.h
parentf810b277752fc42f3a0e951c7501670a596eb387 (diff)
downloadusurpation-28b26ca86cf18947d6d9543ad753ef112ff4da89.tar.gz
usurpation-28b26ca86cf18947d6d9543ad753ef112ff4da89.tar.bz2
usurpation-28b26ca86cf18947d6d9543ad753ef112ff4da89.zip
Protocol: interface redesign.
Every function is a stub now. Reimplementaion coming up. Signed-off-by: Ramūnas Mažeikis <ramunasnezinomas@gmail.com>
Diffstat (limited to 'include/protocol.h')
-rw-r--r--include/protocol.h45
1 files changed, 14 insertions, 31 deletions
diff --git a/include/protocol.h b/include/protocol.h
index 8d5c535..d8f395d 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -23,9 +23,9 @@
#include <errno.h>
-#define E_TLV_OVERFLOW (1 << 0)
-#define E_UNKNOWN_TYPE (1 << 1)
-#define E_IVALID_DESCRIPTOR (1 << 2)
+#define E_TLV_OVERFLOW (1 << 0)
+#define E_UNKNOWN_TYPE (1 << 1)
+#define E_IVALID_DESCRIPTOR (1 << 2)
/**
* Regular packets contain tlv's defined by tlv_type.
@@ -41,11 +41,6 @@ enum packet_type {
};
/**
- * Connection descriptor.
- */
-typedef unsigned int cd_t;
-
-/**
* Message sequence number since beggining of sesssion.
*
* Mainly used for identifying lost messages.
@@ -86,10 +81,13 @@ enum tlv_type {
/**
* Packet data itself is a special type of tlv. A packet is either regular,
* hearbeat or discovery.
+ *
+ * May be used to send data.
*/
-struct packet_data {
+struct tlv_packet {
enum packet_type type;
size_t packet_size;
+ size_t offset;
char *data; /* Bytes representing tlv's */
};
@@ -102,33 +100,18 @@ struct tlv {
void *data;
};
-/**
- * Reads last packets received, parses and stores them to be later retreived
- * via get_tlv.
- * */
-int get_last_data(cd_t connection);
-
-/** Returns tlv's parsed by get_last_data. Returned tlv is only valid until
- * next call to get_tlv.
- * */
-struct tlv * get_tlv(cd_t cd);
+struct tlv_parser {
+ char *data;
+ size_t offset;
+ size_t size;
+};
-/**
- * Any modifications made to the pending outgoing packet are nullified.
- * */
-int clear_data(cd_t connection);
+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.
* */
-int push_data(cd_t connection, const char *data, enum tlv_type);
-
-/**
- * Sends packet towards the other end.
- * */
-int flush_data(cd_t connection);
-
-cd_t protocol_init(void);
+int push_tlv(struct tlv_packet *packet, const char *data, enum tlv_type);
#endif /* PROTOCOL_H_INCLUDED */