tbf/rlc: Move the parsing of RBB to Decoding, move window marking out

Move the parsing of the bitbmap out of the TBF code into Decoding.
Move the updating of the V_B into the V_B class. Add some comments
about handling the mod_sns, mod_sns_half parameters by using template
code.
diff --git a/src/rlc.cpp b/src/rlc.cpp
index f6b1362..d33e206 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -17,6 +17,8 @@
  */
 
 #include "tbf.h"
+#include "bts.h"
+#include "gprs_debug.h"
 
 extern "C" {
 #include <osmocom/core/utils.h>
@@ -68,3 +70,30 @@
 
 	return resend;
 }
+
+void gprs_rlc_v_b::update(BTS *bts, char *show_rbb, uint8_t ssn,
+			const uint16_t v_a,
+			const uint16_t mod_sns, const uint16_t mod_sns_half,
+			uint16_t *lost, uint16_t *received)
+{
+	uint16_t bsn;
+	int i;
+
+	/* SSN - 1 is in range V(A)..V(S)-1 */
+	for (i = 63, bsn = (ssn - 1) & mod_sns;
+	     i >= 0 && bsn != ((v_a - 1) & mod_sns);
+	     i--, bsn = (bsn - 1) & mod_sns) {
+
+		if (show_rbb[i] == '1') {
+			LOGP(DRLCMACDL, LOGL_DEBUG, "- got ack for BSN=%d\n", bsn);
+			if (!is_acked(bsn & mod_sns_half))
+				*received += 1;
+			mark_acked(bsn & mod_sns_half);
+		} else {
+			LOGP(DRLCMACDL, LOGL_DEBUG, "- got NACK for BSN=%d\n", bsn);
+			mark_nacked(bsn & mod_sns_half);
+			bts->rlc_nacked();
+			*lost += 1;
+		}
+	}
+}