diff options
-rw-r--r-- | src/common/protocol.c | 41 | ||||
-rw-r--r-- | src/common/protocol_private.h | 14 | ||||
-rwxr-xr-x | src/device/protocol_device.c | 5 |
3 files changed, 5 insertions, 55 deletions
diff --git a/src/common/protocol.c b/src/common/protocol.c index 3d63771..dc0f532 100644 --- a/src/common/protocol.c +++ b/src/common/protocol.c @@ -33,47 +33,6 @@ #define READ_AS(from, type) (*(type*)(from)) -#define GET_MSG_CHAR(i) (msg_buf[(i) % MSG_BUF_SIZE]) -#define SET_MSG_CHAR(i, ch) msg_buf[(i) % MSG_BUF_SIZE] = (ch) - -/* Increment message cursor */ -#define IMC(x) ((msg_cursor + (x)) % MSG_BUF_SIZE) - -/* Begins at 2 because this way we'll have two null's at the beggining - * indicating that going back is not possible. - * */ -static int msg_cursor = 2; - -/** - * Message buffer. - * - * Two consecutive null's indicate that going back is not possible. - * */ -static char msg_buf[MSG_BUF_SIZE] = {0}; - -static int tlv_cursor = 0; -static struct tlv tlv_buf[TLV_BUF_SIZE] = {0}; - -static size_t packet_cursor = 0; -/* Outgoing packet. - * */ -static char packet_buf[PACKET_MAX_SIZE] = {0}; - -static int push_bytes(cd_t connection, const void * const data, const size_t size) -{ - if (packet_cursor + size >= PACKET_MAX_SIZE) { - return E_PACKET_OVERFLOW; - } - memcpy(packet_buf + packet_cursor, data, size); - packet_cursor += size; - return 0; -} - -void clear_data(cd_t connection) -{ - packet_cursor = 0; -} - int push_data(cd_t connection, const char *data, enum tlv_type type) { int ret = E_UNKNOWN_TYPE; 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. * diff --git a/src/device/protocol_device.c b/src/device/protocol_device.c index 3b3d8c8..3e38e19 100755 --- a/src/device/protocol_device.c +++ b/src/device/protocol_device.c @@ -18,6 +18,11 @@ cd_t protocol_init(void) return 0; } +void clear_data(void) +{ + connection.inp_crs = 0; +} + static int push_bytes(cd_t cd, char *data, size_t size) { int ret = 0; |