aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-24 22:00:43 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-26 21:00:51 +0100
commite9b1ebba9d720374700d3cb2537fcd2725c50a84 (patch)
treec9cd8640798f39723cc60d62b8953f576904499e
parent270f7fce1d5558f66277cbb4c08e3e7cfc4d9c4c (diff)
rlc: Test the basic of the gprs_rlc_v_n code for remembering the state
-rw-r--r--src/encoding.cpp2
-rw-r--r--src/rlc.cpp5
-rw-r--r--src/rlc.h7
-rw-r--r--tests/types/TypesTest.cpp20
4 files changed, 31 insertions, 3 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp
index 27c3ecd..13390b9 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -386,8 +386,6 @@ void Encoding::write_packet_uplink_ack(struct gprs_rlcmac_bts *bts,
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.state(bbn);
- if (bit == 0)
- bit = ' ';
show_v_n[i] = bit;
if (bit == 'R')
rbb = (rbb << 1)|1;
diff --git a/src/rlc.cpp b/src/rlc.cpp
index fda743f..f29af62 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -138,3 +138,8 @@ void gprs_rlc_v_b::state(char *show_v_b, const gprs_rlc_dl_window &w)
}
show_v_b[i] = '\0';
}
+
+void gprs_rlc_v_n::reset()
+{
+ memset(m_v_n, 0x0, sizeof(m_v_n));
+}
diff --git a/src/rlc.h b/src/rlc.h
index d9e0e6c..e1974e4 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -130,6 +130,8 @@ private:
};
struct gprs_rlc_v_n {
+ void reset();
+
void mark_received(int index);
void mark_missing(int index);
@@ -357,5 +359,8 @@ inline bool gprs_rlc_v_n::is_received(int index) const
inline char gprs_rlc_v_n::state(int index) const
{
- return m_v_n[index];
+ char bit = m_v_n[index];
+ if (bit == '\0')
+ return ' ';
+ return bit;
}
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index 517f8ea..8f6aec2 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -115,12 +115,32 @@ static void test_rlc_v_b()
}
}
+static void test_rlc_v_n()
+{
+ {
+ gprs_rlc_v_n vn;
+ vn.reset();
+
+ OSMO_ASSERT(!vn.is_received(0x23));
+ OSMO_ASSERT(vn.state(0x23) == ' ');
+
+ vn.mark_received(0x23);
+ OSMO_ASSERT(vn.is_received(0x23));
+ OSMO_ASSERT(vn.state(0x23) == 'R');
+
+ vn.mark_missing(0x23);
+ OSMO_ASSERT(!vn.is_received(0x23));
+ OSMO_ASSERT(vn.state(0x23) == 'N');
+ }
+}
+
int main(int argc, char **argv)
{
printf("Making some basic type testing.\n");
test_llc();
test_rlc();
test_rlc_v_b();
+ test_rlc_v_n();
return EXIT_SUCCESS;
}