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