aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/encoding.cpp2
-rw-r--r--src/rlc.h30
-rw-r--r--src/tbf.cpp9
-rw-r--r--src/tbf.h2
4 files changed, 36 insertions, 7 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp
index b45657a..27c3ecd 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -385,7 +385,7 @@ void Encoding::write_packet_uplink_ack(struct gprs_rlcmac_bts *bts,
// RECEIVE_BLOCK_BITMAP
for (i = 0, bbn = (tbf->dir.ul.window.v_r() - 64) & mod_sns_half; i < 64;
i++, bbn = (bbn + 1) & mod_sns_half) {
- bit = tbf->dir.ul.v_n[bbn];
+ bit = tbf->dir.ul.v_n.state(bbn);
if (bit == 0)
bit = ' ';
show_v_n[i] = bit;
diff --git a/src/rlc.h b/src/rlc.h
index e08a5d7..d9e0e6c 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -129,6 +129,16 @@ private:
char m_v_b[RLC_MAX_SNS/2]; /* acknowledge state array */
};
+struct gprs_rlc_v_n {
+ void mark_received(int index);
+ void mark_missing(int index);
+
+ bool is_received(int index) const;
+
+ char state(int index) const;
+private:
+ char m_v_n[RLC_MAX_SNS/2]; /* receive state array */
+};
extern "C" {
/* TS 04.60 10.2.2 */
@@ -329,3 +339,23 @@ inline void gprs_rlc_ul_window::increment_q(int incr)
{
m_v_q = (m_v_q + incr) & mod_sns();
}
+
+inline void gprs_rlc_v_n::mark_received(int index)
+{
+ m_v_n[index] = 'R';
+}
+
+inline void gprs_rlc_v_n::mark_missing(int index)
+{
+ m_v_n[index] = 'N';
+}
+
+inline bool gprs_rlc_v_n::is_received(int index) const
+{
+ return m_v_n[index] == 'R';
+}
+
+inline char gprs_rlc_v_n::state(int index) const
+{
+ return m_v_n[index];
+}
diff --git a/src/tbf.cpp b/src/tbf.cpp
index eca7229..694a41c 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -1616,7 +1616,7 @@ int gprs_rlcmac_tbf::rcv_data_block_acknowledged(const uint8_t *data, size_t len
index = rh->bsn & mod_sns_half; /* memory index of block */
memcpy(m_rlc.blocks[index].block, data, len); /* Copy block. */
m_rlc.blocks[index].len = len;
- this->dir.ul.v_n[index] = 'R'; /* Mark received block. */
+ dir.ul.v_n.mark_received(index);
LOGP(DRLCMACUL, LOGL_DEBUG, "- BSN %d storing in window (%d..%d)\n",
rh->bsn, dir.ul.window.v_q(),
(dir.ul.window.v_q() + ws - 1) & mod_sns);
@@ -1625,8 +1625,7 @@ int gprs_rlcmac_tbf::rcv_data_block_acknowledged(const uint8_t *data, size_t len
if (offset_v_r < (sns() >> 1)) { /* Positive offset, so raise. */
while (offset_v_r--) {
if (offset_v_r) /* all except the received block */
- dir.ul.v_n[dir.ul.window.v_r() & mod_sns_half]
- = 'N'; /* Mark block as not received */
+ dir.ul.v_n.mark_missing(dir.ul.window.v_r() & mod_sns_half);
this->dir.ul.window.raise(1);
/* Inc V(R). */
}
@@ -1638,8 +1637,8 @@ int gprs_rlcmac_tbf::rcv_data_block_acknowledged(const uint8_t *data, size_t len
/* Raise V(Q) if possible, and retrieve LLC frames from blocks.
* This is looped until there is a gap (non received block) or
* the window is empty.*/
- while (this->dir.ul.window.v_q() != this->dir.ul.window.v_r() && this->dir.ul.v_n[
- (index = this->dir.ul.window.v_q() & mod_sns_half)] == 'R') {
+ while (this->dir.ul.window.v_q() != this->dir.ul.window.v_r() && this->dir.ul.v_n.
+ is_received(index = this->dir.ul.window.v_q() & mod_sns_half)) {
LOGP(DRLCMACUL, LOGL_DEBUG, "- Taking block %d out, raising "
"V(Q) to %d\n", this->dir.ul.window.v_q(),
(this->dir.ul.window.v_q() + 1) & mod_sns);
diff --git a/src/tbf.h b/src/tbf.h
index 9560e3c..4718707 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -171,7 +171,7 @@ struct gprs_rlcmac_tbf {
} dl;
struct {
gprs_rlc_ul_window window;
- char v_n[RLC_MAX_SNS/2]; /* receive state array */
+ gprs_rlc_v_n v_n;
int32_t rx_counter; /* count all received blocks */
uint8_t n3103; /* N3103 counter */
uint8_t usf[8]; /* list USFs per PDCH (timeslot) */