From 6058220d2a05bada0a656809f9011fc86a1e22a5 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 21 Nov 2013 21:30:23 +0100 Subject: types: Add a simple testcase for basic types and fix the LLC code * Make append_data, remaining_space and fits_in_current.. work on m_length and not the index. This ways things can't overflow. * The current API consumer was moving the m_index so it should have worked okay. --- src/llc.cpp | 3 ++- src/llc.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/llc.cpp b/src/llc.cpp index c0c517f3..ae190b7f 100644 --- a/src/llc.cpp +++ b/src/llc.cpp @@ -55,7 +55,7 @@ void gprs_llc::put_frame(const uint8_t *data, size_t len) void gprs_llc::append_frame(const uint8_t *data, size_t len) { /* TODO: bounds check */ - memcpy(frame + m_index, data, len); + memcpy(frame + m_length, data, len); m_length += len; } @@ -72,6 +72,7 @@ void gprs_llc::clear(BTS *bts) void gprs_llc::init() { INIT_LLIST_HEAD(&queue); + reset(); } struct msgb *gprs_llc::dequeue() diff --git a/src/llc.h b/src/llc.h index f1692f4b..f50419c8 100644 --- a/src/llc.h +++ b/src/llc.h @@ -63,7 +63,7 @@ inline uint16_t gprs_llc::chunk_size() const inline uint16_t gprs_llc::remaining_space() const { - return LLC_MAX_LEN - m_index; + return LLC_MAX_LEN - m_length; } inline uint16_t gprs_llc::frame_length() const @@ -85,5 +85,5 @@ inline void gprs_llc::consume(uint8_t *data, size_t len) inline bool gprs_llc::fits_in_current_frame(uint8_t chunk_size) const { - return m_index + chunk_size <= LLC_MAX_LEN; + return m_length + chunk_size <= LLC_MAX_LEN; } -- cgit v1.2.3