diff options
author | 2019-05-19 17:50:53 +0300 | |
---|---|---|
committer | 2019-05-19 17:50:53 +0300 | |
commit | 031caaf9b7745bfc552cc86fb475de1f18d0fd6d (patch) | |
tree | c58ce9782d781f2984fefc587c59ea37cf75a73d /include/protocol.h | |
parent | b4165ee0b257aaa9064c5ac82200ff2569a02955 (diff) | |
download | usurpation-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/protocol.h')
-rw-r--r-- | include/protocol.h | 32 |
1 files changed, 16 insertions, 16 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. * */ |