bts: Detect FN jumps

Change-Id: I29fb27981597edc69abb976049ba41aa840488cb
diff --git a/src/bts.cpp b/src/bts.cpp
index 9f78c8b..c1cee17 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -244,7 +244,7 @@
 
 	bts->ms_store = new GprsMsStorage(bts);
 
-	bts->cur_fn = 0;
+	bts->cur_fn = FN_UNSET;
 	bts->cur_blk_fn = -1;
 	bts->max_cs_dl = MAX_GPRS_CS;
 	bts->max_cs_ul = MAX_GPRS_CS;
@@ -287,13 +287,16 @@
 	return bts;
 }
 
-void bts_set_current_frame_number(struct gprs_rlcmac_bts *bts, int fn)
+void bts_set_current_frame_number(struct gprs_rlcmac_bts *bts, uint32_t fn)
 {
 	/* The UL frame numbers lag 3 behind the DL frames and the data
 	 * indication is only sent after all 4 frames of the block have been
 	 * received. Sometimes there is an idle frame between the end of one
 	 * and start of another frame (every 3 blocks). */
-
+	if (fn != bts->cur_fn && bts->cur_fn != FN_UNSET && fn != fn_next_block(bts->cur_fn)) {
+		LOGP(DRLCMAC, LOGL_NOTICE,
+			"Detected FN jump! %u -> %u\n", bts->cur_fn, fn);
+	}
 	bts->cur_fn = fn;
 }
 
@@ -329,8 +332,8 @@
 
 	bts->cur_blk_fn = fn;
 	if (delay < fn_update_ok_min_delay || delay > fn_update_ok_max_delay ||
-		bts_current_frame_number(bts) == 0)
-		bts->cur_fn = fn;
+	    bts_current_frame_number(bts) == FN_UNSET)
+		bts_set_current_frame_number(bts, fn);
 }
 
 int bts_add_paging(struct gprs_rlcmac_bts *bts, uint8_t chan_needed, const struct osmo_mobile_identity *mi)