summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-28 20:58:44 +0300
committerGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-28 20:58:44 +0300
commit2b2eb7556424c2b85668f44c49602370bb6014ec (patch)
tree9b247114b4185ba463d4d3e9fbbdc8ac9be2616e
parentafef44b519153463838ed54327f1b7fca184d97d (diff)
downloadusurpation-2b2eb7556424c2b85668f44c49602370bb6014ec.tar.gz
usurpation-2b2eb7556424c2b85668f44c49602370bb6014ec.tar.bz2
usurpation-2b2eb7556424c2b85668f44c49602370bb6014ec.zip
Protocol: renamed functions to fit the "namespace".
Signed-off-by: Ramūnas Mažeikis <ramunasnezinomas@gmail.com>
-rw-r--r--include/protocol.h9
-rw-r--r--src/common/protocol.c13
2 files changed, 12 insertions, 10 deletions
diff --git a/include/protocol.h b/include/protocol.h
index 6d8bbd9..e15ef6a 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -113,14 +113,13 @@ struct tlv_parser {
size_t size;
};
-
/**
* Fills tlv structure to represent the next tlv in the packet.
*
* Returns END_OF_PACKET if all tlv's were read of E_TLV_OVERFLOW, if the last
* tlv, according to its declared size should not fit in a packet.
*/
-int get_tlv(struct tlv_parser *parser, struct tlv *ret);
+int tlv_get(struct tlv_parser *parser, struct tlv *ret);
/**
* Appends data to the next packet to be sent. Type of data is determined by
@@ -133,17 +132,17 @@ int get_tlv(struct tlv_parser *parser, struct tlv *ret);
* 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);
+int tlv_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);
+void tlv_clear_data(struct tlv_packet *packet);
/**
* Initialises tlv to sane values.
*/
-void tlv_init(struct tlv *t);
+void tlv_init(struct tlv *t, enum tlv_type type);
/**
* Frees data held in the tlv structure. The structure itself shall be freed as
diff --git a/src/common/protocol.c b/src/common/protocol.c
index edaf491..3f7bd24 100644
--- a/src/common/protocol.c
+++ b/src/common/protocol.c
@@ -32,7 +32,8 @@
#include "net.h"
#include "utils.h"
-int push_tlv(struct tlv_packet *packet, enum tlv_type type, char *data)
+#if 0
+int tlv_push(struct tlv_packet *packet, enum tlv_type type, char *data)
{
int ret = 0;
size_t size;
@@ -64,7 +65,9 @@ int push_tlv(struct tlv_packet *packet, enum tlv_type type, char *data)
return ret;
}
-void clear_data(struct tlv_packet *packet)
+#endif
+
+void tlv_clear_data(struct tlv_packet *packet)
{
packet->offset = 0;
packet->type = 0;
@@ -98,7 +101,7 @@ static int push_tlv_header(struct tlv_packet *packet, enum tlv_type type, size_t
return ret;
}
-int get_tlv(struct tlv_parser *parser, struct tlv *ret)
+int tlv_get(struct tlv_parser *parser, struct tlv *ret)
{
int ret = 0;
@@ -157,9 +160,9 @@ int tlv_push(struct tlv *t, const char *data, size_t size)
return ret;
}
-void tlv_init(struct tlv *t)
+void tlv_init(struct tlv *t, enum tlv_type type)
{
- t->type = TEXT;
+ t->type = type;
t->length = 0;
t->data = NULL;
} \ No newline at end of file