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/device/protocol_device_private.h | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 src/device/protocol_device_private.h (limited to 'src/device/protocol_device_private.h') diff --git a/src/device/protocol_device_private.h b/src/device/protocol_device_private.h new file mode 100755 index 0000000..0fb46c7 --- /dev/null +++ b/src/device/protocol_device_private.h @@ -0,0 +1,37 @@ +#ifndef PROTOCOL_DEVICE_PRIVATE_H +#define PROTOCOL_DEVICE_PRIVATE_H + +#define MAX_PACKET_SIZE_OUT (64) +#define MAX_PACKET_SIZE_IN (512) +#define MAX_CONNECTIONS (1UL) + +/** + * Device's view of connection to daemon. + */ +struct connection_t { + /** + * Initially 0, non-zero when connection is open, 0 when connection + * is closed again. + */ + int is_live; + + /** Daemon IP adress */ + IPAddress address; + + /** Time last packet was reveived */ + time_t last_packet_sec; + + /** Incoming packet buffer */ + char inp_buf[MAX_PACKET_SIZE_IN]; + + /** Incoming packet cursor */ + size_t inp_crs; + + /** Outgoing packet buffer */ + char outp_buf[MAX_PACKET_SIZE_OUT]; + + /** Outgoing packet cursor */ + size_t outp_crs; +}; + +#endif /* PROTOCOL_DEVICE_PRIVATE_H */ \ No newline at end of file -- cgit v1.2.3