aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2013-12-11 14:35:29 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-12-12 11:03:13 +0100
commit5241c1a018a27b1372f3d02c564acb5188b73ee2 (patch)
tree644c9076c98a565aa979a106b96e7aa096ff7d1a /src
parent52ea8a0d87e695ba3cafedc53498ee53a72ffaf9 (diff)
encoding: Factor out encode_rbb to help testing
Diffstat (limited to 'src')
-rw-r--r--src/encoding.cpp35
-rw-r--r--src/encoding.h2
2 files changed, 24 insertions, 13 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp
index fa2a0996..94799868 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -352,6 +352,27 @@ int Encoding::write_paging_request(bitvec * dest, uint8_t *ptmsi, uint16_t ptmsi
return plen;
}
+/**
+ * The index of the array show_rbb is the bit position inside the rbb
+ * (show_rbb[63] relates to BSN ssn-1)
+ */
+void Encoding::encode_rbb(const char *show_rbb, uint8_t *rbb)
+{
+ uint8_t rbb_byte = 0;
+
+ // RECEIVE_BLOCK_BITMAP
+ for (int i = 0; i < 64; i++) {
+ /* Set bit at the appropriate position (see 3GPP TS 04.60 9.1.8.1) */
+ if (show_rbb[i] == 'R')
+ rbb_byte |= 1<< (7-(i%8));
+
+ if((i%8) == 7) {
+ rbb[i/8] = rbb_byte;
+ rbb_byte = 0;
+ }
+ }
+}
+
/* generate uplink ack */
void Encoding::write_packet_uplink_ack(struct gprs_rlcmac_bts *bts,
RlcMacDownlink_t * block, struct gprs_rlcmac_tbf *tbf,
@@ -360,7 +381,6 @@ void Encoding::write_packet_uplink_ack(struct gprs_rlcmac_bts *bts,
// Packet Uplink Ack/Nack TS 44.060 11.2.28
char rbb[65];
- uint8_t i, rbb_byte;
tbf->dir.ul.window.update_rbb(&tbf->dir.ul.v_n, rbb);
@@ -381,18 +401,7 @@ void Encoding::write_packet_uplink_ack(struct gprs_rlcmac_bts *bts,
block->u.Packet_Uplink_Ack_Nack.u.PU_AckNack_GPRS_Struct.Ack_Nack_Description.FINAL_ACK_INDICATION = final; // FINAL ACK INDICATION
block->u.Packet_Uplink_Ack_Nack.u.PU_AckNack_GPRS_Struct.Ack_Nack_Description.STARTING_SEQUENCE_NUMBER = tbf->dir.ul.window.ssn(); // STARTING_SEQUENCE_NUMBER
- rbb_byte = 0;
- // RECEIVE_BLOCK_BITMAP
- for (i = 0; i < 64; i++) {
- /* Set bit at the appropriate position (see 3GPP TS 04.60 9.1.8.1) */
- if (rbb[i] == 'R')
- rbb_byte |= 1<< (7-(i%8));
-
- if((i%8) == 7) {
- block->u.Packet_Uplink_Ack_Nack.u.PU_AckNack_GPRS_Struct.Ack_Nack_Description.RECEIVED_BLOCK_BITMAP[i/8] = rbb_byte;
- rbb_byte = 0;
- }
- }
+ encode_rbb(rbb, block->u.Packet_Uplink_Ack_Nack.u.PU_AckNack_GPRS_Struct.Ack_Nack_Description.RECEIVED_BLOCK_BITMAP);
/* rbb is not NULL terminated */
rbb[64] = 0;
diff --git a/src/encoding.h b/src/encoding.h
index d0f8f0ab..e62c2c8f 100644
--- a/src/encoding.h
+++ b/src/encoding.h
@@ -54,6 +54,8 @@ public:
uint8_t old_downlink, struct gprs_rlcmac_tbf *tbf, uint8_t poll,
uint8_t alpha, uint8_t gamma, int8_t ta_idx, uint8_t ta_ts);
+ static void encode_rbb(const char *show_rbb, uint8_t *rbb);
+
static void write_packet_uplink_ack(struct gprs_rlcmac_bts *bts, RlcMacDownlink_t * block, struct gprs_rlcmac_tbf *tbf,
uint8_t final);