Add compression support in EGPRS PUAN

This adds compression of bitmap in PUAN. The compressed bitmap
is used only if the number of bits in the bitmap does not fit in
the message and there is a gain after compression.
The algorithm is part of libosmocore and so there is dependency
on the libosmocore for compilation.
The algorithm is tested on integration setup by forcing compression.

Change-Id: Id2eec4b5eb6da0ebd24054b541b09b700b9b40ba
diff --git a/src/rlc.cpp b/src/rlc.cpp
index 2bffccb..d13045e 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -83,6 +83,32 @@
 	return resend;
 }
 
+/* Update the receive block bitmap */
+uint16_t gprs_rlc_ul_window::update_egprs_rbb(uint8_t *rbb)
+{
+	int i;
+	uint16_t bsn;
+	uint16_t bitmask = 0x80;
+	int8_t pos = 0;
+	int8_t bit_pos = 0;
+	for (i = 0, bsn = (v_q()+1); ((bsn < (v_r())) && (i < ws())); i++,
+					bsn = this->mod_sns(bsn + 1)) {
+		if (m_v_n.is_received(bsn)) {
+			rbb[pos] = rbb[pos] | bitmask;
+		} else {
+			rbb[pos] = rbb[pos] & (~bitmask);
+		}
+		bitmask = bitmask >> 1;
+		bit_pos++;
+		bit_pos = bit_pos % 8;
+		if (bit_pos == 0) {
+			pos++;
+			bitmask = 0x80;
+		}
+	}
+	return i;
+}
+
 int gprs_rlc_dl_window::count_unacked()
 {
 	uint16_t unacked = 0;
@@ -219,6 +245,8 @@
 
 void gprs_rlc_window::set_ws(uint16_t ws)
 {
+	LOGP(DRLCMAC, LOGL_INFO, "ws(%d)\n",
+		ws);
 	OSMO_ASSERT(ws >= RLC_GPRS_SNS/2);
 	OSMO_ASSERT(ws <= RLC_MAX_SNS/2);
 	m_ws = ws;