aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-12-14 11:54:29 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-12-16 19:37:08 +0100
commit784a0bd0001e4e81167eda6e3bb4a2001d24d1f6 (patch)
treee6d706f5d17c8d3a96db89d8eddec13e953fc55d
parentd87e1d6ab747423d3668c74d16201a5d967accf0 (diff)
edge: Add is_received and invalidate_bsn to gprs_rlc_ul_window
These methods will be needed for EGPRS decoding. The is_received method returns true iff a block with the given BSN has already been received in the current window. A call to invalidate_bsn marks the block as not received. Sponsored-by: On-Waves ehf
-rw-r--r--src/rlc.cpp7
-rw-r--r--src/rlc.h11
2 files changed, 18 insertions, 0 deletions
diff --git a/src/rlc.cpp b/src/rlc.cpp
index bafc56e7..227fa362 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -224,5 +224,12 @@ void gprs_rlc_ul_window::receive_bsn(const uint16_t bsn)
{
m_v_n.mark_received(bsn);
raise_v_r(bsn);
+}
+
+bool gprs_rlc_ul_window::invalidate_bsn(const uint16_t bsn)
+{
+ bool was_valid = m_v_n.is_received(bsn);
+ m_v_n.mark_missing(bsn);
+ return was_valid;
}
diff --git a/src/rlc.h b/src/rlc.h
index 081ba40e..81689945 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -194,6 +194,7 @@ struct gprs_rlc_ul_window {
const uint16_t ssn() const;
bool is_in_window(uint8_t bsn) const;
+ bool is_received(uint8_t bsn) const;
void update_rbb(char *rbb);
void raise_v_r_to(int moves);
@@ -203,6 +204,7 @@ struct gprs_rlc_ul_window {
void raise_v_q(int);
void receive_bsn(const uint16_t bsn);
+ bool invalidate_bsn(const uint16_t bsn);
uint16_t m_v_r; /* receive state */
uint16_t m_v_q; /* receive window state */
@@ -401,6 +403,15 @@ inline bool gprs_rlc_ul_window::is_in_window(uint8_t bsn) const
return offset_v_q < ws();
}
+inline bool gprs_rlc_ul_window::is_received(uint8_t bsn) const
+{
+ uint16_t offset_v_r;
+
+ /* Offset to the end of the received window */
+ offset_v_r = (m_v_r - 1 - bsn) & mod_sns();
+ return is_in_window(bsn) && m_v_n.is_received(bsn) && offset_v_r < ws();
+}
+
inline const uint16_t gprs_rlc_ul_window::sns() const
{
return RLC_MAX_SNS;