diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-11-24 22:00:43 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-11-26 21:00:51 +0100 |
commit | e9b1ebba9d720374700d3cb2537fcd2725c50a84 (patch) | |
tree | c9cd8640798f39723cc60d62b8953f576904499e | |
parent | 270f7fce1d5558f66277cbb4c08e3e7cfc4d9c4c (diff) |
rlc: Test the basic of the gprs_rlc_v_n code for remembering the state
-rw-r--r-- | src/encoding.cpp | 2 | ||||
-rw-r--r-- | src/rlc.cpp | 5 | ||||
-rw-r--r-- | src/rlc.h | 7 | ||||
-rw-r--r-- | tests/types/TypesTest.cpp | 20 |
4 files changed, 31 insertions, 3 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp index 27c3ecd5..13390b90 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 fda743f0..f29af62d 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)); +} @@ -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 517f8ea3..8f6aec23 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; } |