diff options
author | 2019-05-21 19:16:22 +0300 | |
---|---|---|
committer | 2019-05-21 19:16:22 +0300 | |
commit | 36b3e7f310c624b7b4e31829090dd02131c528d5 (patch) | |
tree | 492df5090f64e298cad3f8995ef9d6a611b45c9d /include | |
parent | cabb90c1240015ee5cd17d91573588527bcc2482 (diff) | |
download | usurpation-36b3e7f310c624b7b4e31829090dd02131c528d5.tar.gz usurpation-36b3e7f310c624b7b4e31829090dd02131c528d5.tar.bz2 usurpation-36b3e7f310c624b7b4e31829090dd02131c528d5.zip |
Protocol: implementation of device-side protocol.
Parts of protocol specific for device are implementepd to reflect the
fact that the device is a client. This effectively means that device
gets a single connection only and severe memory restrictions about
which the daemon might get informed about in the future.
Signed-off-by: Ramūnas Mažeikis <ramunasnezinomas@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/net.h | 14 | ||||
-rw-r--r-- | include/protocol.h | 6 |
2 files changed, 17 insertions, 3 deletions
diff --git a/include/net.h b/include/net.h index 34f557a..6860455 100644 --- a/include/net.h +++ b/include/net.h @@ -33,9 +33,21 @@ enum response { TMPFILE, }; - +/** + * Initialises connection with daemon and returns a network descriptor. + */ int net_init(const unsigned short int port); + +/** + * Closes connection associated with network descriptor. + */ int net_close(int nd); + +/** + * Get last data received from connection associated with network descriptor. + * Function mallocates a buffer for data received from packet. Don't forget to + * free the buffer. + */ int net_getlastdata(int nd, char * const data); #endif /* NET_H_INCLUDED */ diff --git a/include/protocol.h b/include/protocol.h index 60d31ea..c5e657b 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -106,12 +106,12 @@ struct tlv { * Reads last packets received, parses and stores them to be later retreived * via get_tlv. * */ -void get_last_data(cd_t connection); +int get_last_data(cd_t connection); /** Returns tlv's parsed by get_last_data. Returned tlv is only valid until * next call to get_tlv. * */ -struct tlv * get_tlv(void); +struct tlv * get_tlv(cd_t cd); /** * Any modifications made to the pending outgoing packet are nullified. @@ -129,4 +129,6 @@ int push_data(cd_t connection, const char *data, enum tlv_type); * */ void flush_data(cd_t connection); +cd_t protocol_init(void); + #endif /* PROTOCOL_H_INCLUDED */ |