summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-19 17:50:53 +0300
committerGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-19 17:50:53 +0300
commit031caaf9b7745bfc552cc86fb475de1f18d0fd6d (patch)
treec58ce9782d781f2984fefc587c59ea37cf75a73d /include
parentb4165ee0b257aaa9064c5ac82200ff2569a02955 (diff)
downloadusurpation-031caaf9b7745bfc552cc86fb475de1f18d0fd6d.tar.gz
usurpation-031caaf9b7745bfc552cc86fb475de1f18d0fd6d.tar.bz2
usurpation-031caaf9b7745bfc552cc86fb475de1f18d0fd6d.zip
Protocol: Implemented protocol error reporting.
Now public functions of the protocol can return an error code. More work is done on actual logic. Protocol code has bare-bones doxygen documentation. Signed-off-by: Ramūnas Mažeikis <ramunasnezinomas@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/protocol.h32
-rw-r--r--include/utils.h7
2 files changed, 17 insertions, 22 deletions
diff --git a/include/protocol.h b/include/protocol.h
index 5872fa3..9d5b518 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -23,8 +23,8 @@
#include <errno.h>
-#define SUCCESS (0)
-#define TLV_OVERFLOW (1 << 0)
+#define E_TLV_OVERFLOW (1 << 0)
+#define E_UNKNOWN_TYPE (1 << 1)
enum packet_type {
REGURAL,
@@ -33,27 +33,27 @@ enum packet_type {
};
enum tlv_type {
- /* NULL-terminated string. */
+ /** NULL-terminated string. */
TEXT,
-
- /* Fixed point. 1 decimal digit of precision. */
+
+ /** Fixed point. 1 decimal digit of precision. */
FPI1,
-
- /* Literally time_t*/
+
+ /** Literally time_t*/
TIMESTAMP,
-
- /* Represents a request for lost message. Data is unsigned integer
- * that uniquely identifies the message.
+
+ /** Represents a request for lost message. Data is unsigned integer
+ * that uniquely identifies the message.
*/
REQUEST,
-
- /* Response to request. Begins with unsigned integer that represents
- * which message is begin repeated and the actual null-terminated
+
+ /** Response to request. Begins with unsigned integer that represents
+ * which message is being repeated and the actual null-terminated
* message after that.
*/
REPLY,
-
- /* UUID that represents a particular device.
+
+ /** UUID that represents a particular device.
*/
UUID
};
@@ -88,7 +88,7 @@ void clear_data(void);
/* Appends data to the next packet to be sent. Type of data is determined by
* enum tlv_type.
* */
-void push_data(char *data, enum tlv_type);
+int push_data(const char *data, enum tlv_type);
/* Sends packet towards the other end.
* */
diff --git a/include/utils.h b/include/utils.h
index daea864..e4feb9a 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -4,16 +4,11 @@
#include <stdint.h>
typedef struct uuid_s {
- uint64_t low;
- uint64_t hi;
+ char bytes[16];
} uuid_t;
int cmp_uuid(uuid_t *first, uuid_t *second);
-/* Prints uuid in cannonical format.
- */
-void uuid_to_str(uuid_t *to_print, char *buf);
-
typedef int fpi1_t;
fpi1_t add(fpi1_t a, fpi1_t b);