From b4165ee0b257aaa9064c5ac82200ff2569a02955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Sun, 19 May 2019 13:52:43 +0300 Subject: Protocol: more work on protocol implementation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- include/protocol.h | 23 ++++++++++++++++++++--- include/utils.h | 15 ++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/protocol.h b/include/protocol.h index c1b786c..5872fa3 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifdef PROTOCOL_H_INCLUDED +#ifndef PROTOCOL_H_INCLUDED #define PROTOCOL_H_INCLUDED #include @@ -33,11 +33,28 @@ enum packet_type { }; enum tlv_type { - TEXT, /* NULL-terminated string. */ - FPI1, /* Fixed point. 1 decimal digit of precision. */ + /* NULL-terminated string. */ + TEXT, + + /* Fixed point. 1 decimal digit of precision. */ + FPI1, + + /* Literally time_t*/ TIMESTAMP, + + /* 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 + * message after that. + */ REPLY, + + /* UUID that represents a particular device. + */ UUID }; diff --git a/include/utils.h b/include/utils.h index ca2d2ee..daea864 100644 --- a/include/utils.h +++ b/include/utils.h @@ -1,6 +1,19 @@ -#ifdef PROJECT_UTILS_H +#ifndef PROJECT_UTILS_H #define PROJECT_UTILS_H +#include + +typedef struct uuid_s { + uint64_t low; + uint64_t hi; +} 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); -- cgit v1.2.3