From 9c8ece1538d31dba9a416c9f29f88e18510f4c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Sat, 18 May 2019 16:32:20 +0300 Subject: Whole-project: partial implementation of protocol. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit is part of ticket #31. Branch is not in a compiling state. Work is being done on utility functions and protocol implementation. To be completed later. Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 66 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/common/protocol_private.h (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h new file mode 100644 index 0000000..3a4b1b2 --- /dev/null +++ b/src/common/protocol_private.h @@ -0,0 +1,66 @@ +/* + * Usurpataion --- server-client protocol private interface. + * + * Copyright (C) 2019 Ramūnas Mažeikis + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef PROTOCOL_H_PRIVATE +#define PROTOCOL_H_PRIVATE + +#define TLV_ARR_SIZE (16) + +/* Pease don't rape the buffer with long messages, daemon-kun. */ +#define MSG_BUF_SIZE (257) + +/* UDP can carry bigger packets but memory is hard to come by and more won't be + * needed anyway. + * */ +#define PACKET_MAX_SIZE (512) + +/* Returns the amount of tlv's int a packet. + * + * If a tlv reports length that goes beyond the end of a packet, errno is set + * to TLV_OVERFLOW. To check this, set errno to 0 first. + * */ +size_t tlv_count(const struct packet_data * const packet); + +/* Parses a data packet, fills buffer of tlv's of size `buf_size` and returns + * the number of tlv's actually parsed. + * + * To check for errors, set errno to 0 and check after calling. + * */ +size_t get_tlvs( const struct packet_data * const data, + const struct tlv *buf, + size_t buf_size); + +/* Takes a null-terminated string and appends it to the next outgoing packet. + * */ +void push_string(char *str); + +void push_fpi1(fpi1_t num); + +void push_timestamp(char *data); + +void push_request(char *data); + +void push_reply(char *data); + +void push_uuid(char *data); + + + +#endif /* PROTOCOL_H_PRIVATE */ -- cgit v1.2.3 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 --- src/common/protocol_private.h | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index 3a4b1b2..653d19c 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -18,10 +18,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifdef PROTOCOL_H_PRIVATE +#ifndef PROTOCOL_H_PRIVATE #define PROTOCOL_H_PRIVATE -#define TLV_ARR_SIZE (16) +#include "utils.h" + +#define TLV_BUF_SIZE (16) /* Pease don't rape the buffer with long messages, daemon-kun. */ #define MSG_BUF_SIZE (257) @@ -38,10 +40,22 @@ * */ size_t tlv_count(const struct packet_data * const packet); -/* Parses a data packet, fills buffer of tlv's of size `buf_size` and returns - * the number of tlv's actually parsed. + +/** + * Parses tlv's from packet data and writes them to a buffer of given size. + * + * Returns how many tlv's were actually parsed. * * To check for errors, set errno to 0 and check after calling. + * + * Not yet implemented. + * + * @param data Data from network packet + * @param buf Buffer to store parsed tlv's + * @param buf_size Size of buffer used to store tlv's + * + * @return Number of tlv's actually parsed. Greter than or equal to buffer + * size, if an error occurs. * */ size_t get_tlvs( const struct packet_data * const data, const struct tlv *buf, @@ -51,16 +65,30 @@ size_t get_tlvs( const struct packet_data * const data, * */ void push_string(char *str); -void push_fpi1(fpi1_t num); +/* Reinterprets char * as fpi1_t * and appends it to the outgoing packet as a + * tlv. + */ +void push_fpi1(char *num); +/* Reinterprets char * as time_t * and appends it to the outgoing packet as a + * tlv. + */ void push_timestamp(char *data); +/* Not implemented yet. */ void push_request(char *data); +/* Not implemented yet. */ void push_reply(char *data); +/* Reinterprets char * as uuid_t * and appends it to the outgoing packet as a + * tlv. + */ void push_uuid(char *data); - +/* Appends tlv_type and size of data to a packet effectively creating a tlv + * header. + */ +void push_tlv_header(enum tlv_type type, size_t size); #endif /* PROTOCOL_H_PRIVATE */ -- cgit v1.2.3 From 031caaf9b7745bfc552cc86fb475de1f18d0fd6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Sun, 19 May 2019 17:50:53 +0300 Subject: Protocol: Implemented protocol error reporting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/common/protocol_private.h | 44 ++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index 653d19c..0c0b7f9 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -23,37 +23,44 @@ #include "utils.h" +#define E_PACKET_OVERFLOW (1 << 0) + +/** Read as "A maximum of 16 tlv's per packet". */ #define TLV_BUF_SIZE (16) /* Pease don't rape the buffer with long messages, daemon-kun. */ #define MSG_BUF_SIZE (257) -/* UDP can carry bigger packets but memory is hard to come by and more won't be - * needed anyway. +/* Maximum size of packet that can fit into the packet buffer. UDP can carry + * bigger packets but memory is hard to come by and more won't be needed + * anyway. * */ #define PACKET_MAX_SIZE (512) -/* Returns the amount of tlv's int a packet. +/** Returns the amount of tlv's int a packet. * * If a tlv reports length that goes beyond the end of a packet, errno is set * to TLV_OVERFLOW. To check this, set errno to 0 first. + * + * @param packet data parsed from a packet. Function cannot use raw packets. + * + * @return Amount of tlv's in a packet. * */ -size_t tlv_count(const struct packet_data * const packet); - +size_t tlv_count(const struct packet_data * const packet_data); /** * Parses tlv's from packet data and writes them to a buffer of given size. - * + * * Returns how many tlv's were actually parsed. * * To check for errors, set errno to 0 and check after calling. - * + * * Not yet implemented. - * + * * @param data Data from network packet * @param buf Buffer to store parsed tlv's * @param buf_size Size of buffer used to store tlv's - * + * * @return Number of tlv's actually parsed. Greter than or equal to buffer * size, if an error occurs. * */ @@ -61,34 +68,37 @@ size_t get_tlvs( const struct packet_data * const data, const struct tlv *buf, size_t buf_size); -/* Takes a null-terminated string and appends it to the next outgoing packet. +/** Takes a null-terminated string and appends it to the next outgoing packet. + * + * @return Returns 0 on success. Otherwise: E_PACKET_OVERFLOW. + * * */ -void push_string(char *str); +int push_string(char *str); /* Reinterprets char * as fpi1_t * and appends it to the outgoing packet as a * tlv. */ -void push_fpi1(char *num); +int push_fpi1(char *num); /* Reinterprets char * as time_t * and appends it to the outgoing packet as a * tlv. */ -void push_timestamp(char *data); +int push_timestamp(char *data); /* Not implemented yet. */ -void push_request(char *data); +int push_request(char *data); /* Not implemented yet. */ -void push_reply(char *data); +int push_reply(char *data); /* Reinterprets char * as uuid_t * and appends it to the outgoing packet as a * tlv. */ -void push_uuid(char *data); +int push_uuid(char *data); /* Appends tlv_type and size of data to a packet effectively creating a tlv * header. */ -void push_tlv_header(enum tlv_type type, size_t size); +int push_tlv_header(enum tlv_type type, size_t size); #endif /* PROTOCOL_H_PRIVATE */ -- cgit v1.2.3 From bb70fccb66f55e9cc2b9ed0bf366479828f41346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Mon, 20 May 2019 21:50:19 +0300 Subject: Protocol: implemented request and reply pushing to packet. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First implementation of complete protocol interface. While the first implementation does compile, the interface might change due to demands from other parts of the project. For now reqest is a tlv that is an unsigned int which represents what message to repeat from daemon. A reply is also a tlv made of two parts --- message sequence number of type msg_ixd_t and the actual null terminated string. All of the above is subject to change. More docs. Doxygen is on the way. Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index 0c0b7f9..b74c0eb 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -75,23 +75,39 @@ size_t get_tlvs( const struct packet_data * const data, * */ int push_string(char *str); -/* Reinterprets char * as fpi1_t * and appends it to the outgoing packet as a +/** Reinterprets char * as fpi1_t * and appends it to the outgoing packet as a * tlv. */ int push_fpi1(char *num); -/* Reinterprets char * as time_t * and appends it to the outgoing packet as a +/** Reinterprets char * as time_t * and appends it to the outgoing packet as a * tlv. */ int push_timestamp(char *data); -/* Not implemented yet. */ +/** + * Pushes a request for daemon to repeat a message identified by a msg_index_t. + * + * @param data Pointer to a msg_index_t. + * + * @return 0 on success or E_PACKET_OVERFLOW, if not enough space is available + * to push all the data. + */ int push_request(char *data); -/* Not implemented yet. */ +/** + * Pushes a message to the outgoing packet buffer as a reply. A reply is just + * a null terminated string. + * + * @param data msg_idx_t representing sequence number since beggining of + * connection and a null-terminated string. + * + * @return On success --- 0 or E_PACKET_OVERFLOW, if not enough buffer is + * available. + */ int push_reply(char *data); -/* Reinterprets char * as uuid_t * and appends it to the outgoing packet as a +/** Reinterprets char * as uuid_t * and appends it to the outgoing packet as a * tlv. */ int push_uuid(char *data); -- cgit v1.2.3 From cabb90c1240015ee5cd17d91573588527bcc2482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Tue, 21 May 2019 17:41:21 +0300 Subject: Protocol: changes to interface and some re-implementation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most functions exposed in protocol.h take a connection descriptor (cd_t) as first argument. This allows for multiple connections. Device gets only one connection which means that cd_t is effectively 0 all the time. Additionaly, any function that actually does anything with a connection descriptor instead of just passing it to another function must be implemented separately in device and daemon. Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index b74c0eb..eecbc15 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -37,7 +37,8 @@ * */ #define PACKET_MAX_SIZE (512) -/** Returns the amount of tlv's int a packet. +/** + * Returns the amount of tlv's int a packet. * * If a tlv reports length that goes beyond the end of a packet, errno is set * to TLV_OVERFLOW. To check this, set errno to 0 first. @@ -73,17 +74,17 @@ size_t get_tlvs( const struct packet_data * const data, * @return Returns 0 on success. Otherwise: E_PACKET_OVERFLOW. * * */ -int push_string(char *str); +int push_string(cd_t connection, char *str); /** Reinterprets char * as fpi1_t * and appends it to the outgoing packet as a * tlv. */ -int push_fpi1(char *num); +int push_fpi1(cd_t connection, char *num); /** Reinterprets char * as time_t * and appends it to the outgoing packet as a * tlv. */ -int push_timestamp(char *data); +int push_timestamp(cd_t connection, char *data); /** * Pushes a request for daemon to repeat a message identified by a msg_index_t. @@ -93,7 +94,7 @@ int push_timestamp(char *data); * @return 0 on success or E_PACKET_OVERFLOW, if not enough space is available * to push all the data. */ -int push_request(char *data); +int push_request(cd_t connection, char *data); /** * Pushes a message to the outgoing packet buffer as a reply. A reply is just @@ -105,16 +106,16 @@ int push_request(char *data); * @return On success --- 0 or E_PACKET_OVERFLOW, if not enough buffer is * available. */ -int push_reply(char *data); +int push_reply(cd_t connection, char *data); /** Reinterprets char * as uuid_t * and appends it to the outgoing packet as a * tlv. */ -int push_uuid(char *data); +int push_uuid(cd_t connection, char *data); /* Appends tlv_type and size of data to a packet effectively creating a tlv * header. */ -int push_tlv_header(enum tlv_type type, size_t size); +int push_tlv_header(cd_t connection, enum tlv_type type, size_t size); #endif /* PROTOCOL_H_PRIVATE */ -- cgit v1.2.3 From 5ca7e24e58f6bd657787b9235247149ffff420ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Tue, 21 May 2019 19:28:23 +0300 Subject: Protocol: common no longer has device-specific implementations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forgot to remove device-specific code from common protocol code. Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index eecbc15..7433ff0 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -23,20 +23,6 @@ #include "utils.h" -#define E_PACKET_OVERFLOW (1 << 0) - -/** Read as "A maximum of 16 tlv's per packet". */ -#define TLV_BUF_SIZE (16) - -/* Pease don't rape the buffer with long messages, daemon-kun. */ -#define MSG_BUF_SIZE (257) - -/* Maximum size of packet that can fit into the packet buffer. UDP can carry - * bigger packets but memory is hard to come by and more won't be needed - * anyway. - * */ -#define PACKET_MAX_SIZE (512) - /** * Returns the amount of tlv's int a packet. * -- cgit v1.2.3 From 3fa7dd642af57b8b138e9a0d674c2d9960ebedf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Wed, 22 May 2019 11:33:51 +0300 Subject: Protocol: fixed type errors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added const where appropriate to satisfy stricter type checking of C++. Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index 7433ff0..d50a314 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -35,6 +35,14 @@ * */ size_t tlv_count(const struct packet_data * const packet_data); +/** + * Pushes bytes to outgoing packet and adjusts the offset accordingly. + * + * Returns E_PACKET_OVERFLOW, if no more bytes can fit into the packet. + */ + +int push_bytes(cd_t cd, const char *data, size_t size); + /** * Parses tlv's from packet data and writes them to a buffer of given size. * -- cgit v1.2.3 From 28b26ca86cf18947d6d9543ad753ef112ff4da89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Wed, 22 May 2019 20:33:08 +0300 Subject: Protocol: interface redesign. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every function is a stub now. Reimplementaion coming up. Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 122 ++++-------------------------------------- 1 file changed, 9 insertions(+), 113 deletions(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index d50a314..5228afd 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -1,115 +1,11 @@ -/* - * Usurpataion --- server-client protocol private interface. - * - * Copyright (C) 2019 Ramūnas Mažeikis - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; version 2.1 - * of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ +#ifndef PROTOCOL_PRIVATE_H +#define PROTOCOL_PRIVATE_H -#ifndef PROTOCOL_H_PRIVATE -#define PROTOCOL_H_PRIVATE +static int push_string(const char *str); +static int push_fpi1(const char *num); +static int push_timestamp(const char *data); +static int push_request(const char *data); +static int push_reply(const char *data); +static int push_uuid(const char *data); -#include "utils.h" - -/** - * Returns the amount of tlv's int a packet. - * - * If a tlv reports length that goes beyond the end of a packet, errno is set - * to TLV_OVERFLOW. To check this, set errno to 0 first. - * - * @param packet data parsed from a packet. Function cannot use raw packets. - * - * @return Amount of tlv's in a packet. - * */ -size_t tlv_count(const struct packet_data * const packet_data); - -/** - * Pushes bytes to outgoing packet and adjusts the offset accordingly. - * - * Returns E_PACKET_OVERFLOW, if no more bytes can fit into the packet. - */ - -int push_bytes(cd_t cd, const char *data, size_t size); - -/** - * Parses tlv's from packet data and writes them to a buffer of given size. - * - * Returns how many tlv's were actually parsed. - * - * To check for errors, set errno to 0 and check after calling. - * - * Not yet implemented. - * - * @param data Data from network packet - * @param buf Buffer to store parsed tlv's - * @param buf_size Size of buffer used to store tlv's - * - * @return Number of tlv's actually parsed. Greter than or equal to buffer - * size, if an error occurs. - * */ -size_t get_tlvs( const struct packet_data * const data, - const struct tlv *buf, - size_t buf_size); - -/** Takes a null-terminated string and appends it to the next outgoing packet. - * - * @return Returns 0 on success. Otherwise: E_PACKET_OVERFLOW. - * - * */ -int push_string(cd_t connection, char *str); - -/** Reinterprets char * as fpi1_t * and appends it to the outgoing packet as a - * tlv. - */ -int push_fpi1(cd_t connection, char *num); - -/** Reinterprets char * as time_t * and appends it to the outgoing packet as a - * tlv. - */ -int push_timestamp(cd_t connection, char *data); - -/** - * Pushes a request for daemon to repeat a message identified by a msg_index_t. - * - * @param data Pointer to a msg_index_t. - * - * @return 0 on success or E_PACKET_OVERFLOW, if not enough space is available - * to push all the data. - */ -int push_request(cd_t connection, char *data); - -/** - * Pushes a message to the outgoing packet buffer as a reply. A reply is just - * a null terminated string. - * - * @param data msg_idx_t representing sequence number since beggining of - * connection and a null-terminated string. - * - * @return On success --- 0 or E_PACKET_OVERFLOW, if not enough buffer is - * available. - */ -int push_reply(cd_t connection, char *data); - -/** Reinterprets char * as uuid_t * and appends it to the outgoing packet as a - * tlv. - */ -int push_uuid(cd_t connection, char *data); - -/* Appends tlv_type and size of data to a packet effectively creating a tlv - * header. - */ -int push_tlv_header(cd_t connection, enum tlv_type type, size_t size); - -#endif /* PROTOCOL_H_PRIVATE */ +#endif /* PROTOCOL_PRIVATE_H */ \ No newline at end of file -- cgit v1.2.3 From ca9e0b1cc8084b66311705b0c79da16821eb275d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Wed, 22 May 2019 20:38:29 +0300 Subject: Protocol: amendments to interface functions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index 5228afd..a31103a 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -1,11 +1,15 @@ #ifndef PROTOCOL_PRIVATE_H #define PROTOCOL_PRIVATE_H -static int push_string(const char *str); -static int push_fpi1(const char *num); -static int push_timestamp(const char *data); -static int push_request(const char *data); -static int push_reply(const char *data); -static int push_uuid(const char *data); +#include "protocol_private.h" + +int push_string(struct tlv_packet *packet, const char *str); +int push_fpi1(struct tlv_packet *packet, const char *num); +int push_timestamp(struct tlv_packet *packet, const char *data); +int push_request(struct tlv_packet *packet, const char *data); +int push_reply(struct tlv_packet *packet, const char *data); +int push_uuid(struct tlv_packet *packet, const char *data); +int push_bytes(struct tlv_packet *packet, size_t size); +int push_tlv_header(struct tlv_packet *packet, enum tlv_type type, size_t size); #endif /* PROTOCOL_PRIVATE_H */ \ No newline at end of file -- cgit v1.2.3 From 54f0ba9d41b446b83090dc0f3b220db9c82491d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Wed, 22 May 2019 20:52:26 +0300 Subject: Protocol: tossed a bunch of function out the window. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index a31103a..206046f 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -3,12 +3,6 @@ #include "protocol_private.h" -int push_string(struct tlv_packet *packet, const char *str); -int push_fpi1(struct tlv_packet *packet, const char *num); -int push_timestamp(struct tlv_packet *packet, const char *data); -int push_request(struct tlv_packet *packet, const char *data); -int push_reply(struct tlv_packet *packet, const char *data); -int push_uuid(struct tlv_packet *packet, const char *data); int push_bytes(struct tlv_packet *packet, size_t size); int push_tlv_header(struct tlv_packet *packet, enum tlv_type type, size_t size); -- cgit v1.2.3 From 5fee4a9996158479fe5503c9acace5733660f9e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Wed, 22 May 2019 21:21:25 +0300 Subject: Protocol: reimplemented push_bytes and push_tlv_header. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index 206046f..de086cd 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -3,7 +3,7 @@ #include "protocol_private.h" -int push_bytes(struct tlv_packet *packet, size_t size); +int push_bytes(struct tlv_packet *packet, char *data, size_t size); int push_tlv_header(struct tlv_packet *packet, enum tlv_type type, size_t size); #endif /* PROTOCOL_PRIVATE_H */ \ No newline at end of file -- cgit v1.2.3 From 446157d793c30386f994743f5a8e6ab64e66507f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Wed, 22 May 2019 21:35:46 +0300 Subject: Protocol: updated docs for functions that survived redesign. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ramūnas Mažeikis --- src/common/protocol_private.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index de086cd..fe28aa0 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -3,7 +3,20 @@ #include "protocol_private.h" +/** + * Convenience function that pushes bytes to the end of a packet and reports + * potential overflow. + * + * In case of detected overflow nothing is done to the packet. + */ int push_bytes(struct tlv_packet *packet, char *data, size_t size); + +/** + * Convenience function that forms a tlv header at the end of a packet. Reports + * potential overflow. + * + * In case of detected overflow nothing is done to the packet. + */ int push_tlv_header(struct tlv_packet *packet, enum tlv_type type, size_t size); #endif /* PROTOCOL_PRIVATE_H */ \ No newline at end of file -- cgit v1.2.3 From b25865cc827f4a6a9c31f3d92a4e443485fd5d93 Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Sun, 26 May 2019 14:46:36 +0300 Subject: common: cosmetic changes. Signed-off-by: Gediminas Jakutis --- src/common/protocol_private.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/common/protocol_private.h') diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h index fe28aa0..51d5431 100644 --- a/src/common/protocol_private.h +++ b/src/common/protocol_private.h @@ -1,3 +1,29 @@ +/* + * Usurpataion --- clinet-server protocol implementation. + * + * Copyright (C) 2019 Ramūnas Mažeikis + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * Common parts of protocol implementation. Handling of anything that actually + * deals with connection descriptor has to be implemented by device and daemon + * separately. + */ + #ifndef PROTOCOL_PRIVATE_H #define PROTOCOL_PRIVATE_H @@ -19,4 +45,4 @@ int push_bytes(struct tlv_packet *packet, char *data, size_t size); */ int push_tlv_header(struct tlv_packet *packet, enum tlv_type type, size_t size); -#endif /* PROTOCOL_PRIVATE_H */ \ No newline at end of file +#endif /* PROTOCOL_PRIVATE_H */ -- cgit v1.2.3