tbf/rlc: Move the marking of frames for resend into the v_b
diff --git a/src/rlc.cpp b/src/rlc.cpp
index 1a05546..f6b1362 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -50,3 +50,21 @@
 
 	return -1;
 }
+
+int gprs_rlc_v_b::mark_for_resend(const uint16_t v_a, const uint16_t v_s,
+				const uint16_t mod_sns,
+				const uint16_t mod_sns_half)
+{
+	int resend = 0;
+
+	for (uint8_t bsn = v_a; bsn != v_s; bsn = (bsn + 1) & mod_sns) {
+		uint16_t index = (bsn & mod_sns_half);
+		if (is_unacked(index)) {
+			/* mark to be re-send */
+			mark_resend(index);
+			resend += 1;
+		}
+	}
+
+	return resend;
+}
diff --git a/src/rlc.h b/src/rlc.h
index 3f65a2c..6edfb92 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -46,6 +46,8 @@
 struct gprs_rlc_v_b {
 	int resend_needed(const uint16_t acked, const uint16_t sent,
 			const uint16_t mod_sns, const uint16_t mod_sns_half);
+	int mark_for_resend(const uint16_t acked, const uint16_t sent,
+			const uint16_t mod_sns, const uint16_t mod_sns_half);
 
 	/* Check for an individual frame */
 	bool is_unacked(int index) const;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index a279fcc..3dc4146 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -907,8 +907,6 @@
 	/* if the window has stalled, or transfer is complete,
 	 * send an unacknowledged block */
 	if (state_is(GPRS_RLCMAC_FINISHED) || dl_window_stalled()) {
-	 	int resend = 0;
-
 		if (state_is(GPRS_RLCMAC_FINISHED)) {
 			LOGP(DRLCMACDL, LOGL_DEBUG, "- Restarting at BSN %d, "
 				"because all blocks have been transmitted.\n",
@@ -936,16 +934,10 @@
 		}
 		
 		/* cycle through all unacked blocks */
-		for (bsn = dir.dl.v_a; bsn != dir.dl.v_s;
-		     bsn = (bsn + 1) & mod_sns) {
-			index = (bsn & mod_sns_half);
-			if (dir.dl.v_b.is_unacked(index)) {
-				/* mark to be re-send */
-				dir.dl.v_b.mark_resend(index);
-				resend++;
-			}
-		}
-		/* At this point there should be at leasst one unacked block
+		int resend = dir.dl.v_b.mark_for_resend(dir.dl.v_a, dir.dl.v_s,
+							mod_sns, mod_sns_half);
+
+		/* At this point there should be at least one unacked block
 		 * to be resent. If not, this is an software error. */
 		if (resend == 0) {
 			LOGP(DRLCMACDL, LOGL_ERROR, "Software error: "