TBF: make UL ack state internal

* add functions/macros for setting TBF's UL ack state
* add functions for checking TBF's UL ack state

N. B: this should not be confused with TBF-UL state.

Change-Id: I144483447d4b0b93e775da0e926ee45eb8ab39f3
Related: OS#1539
diff --git a/src/tbf.h b/src/tbf.h
index 2d51945..2828772 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -87,6 +87,8 @@
 	GPRS_RLCMAC_UL_ACK_WAIT_ACK, /* wait for PACKET CONTROL ACK */
 };
 
+extern const struct value_string gprs_rlcmac_tbf_ul_ack_state_names[];
+
 enum gprs_rlcmac_tbf_direction {
 	GPRS_RLCMAC_DL_TBF,
 	GPRS_RLCMAC_UL_TBF
@@ -183,6 +185,7 @@
 #define TBF_SET_STATE(t, st) do { t->set_state(st, __FILE__, __LINE__); } while(0)
 #define TBF_SET_ASS_STATE_DL(t, st) do { t->set_ass_state_dl(st, __FILE__, __LINE__); } while(0)
 #define TBF_SET_ASS_STATE_UL(t, st) do { t->set_ass_state_ul(st, __FILE__, __LINE__); } while(0)
+#define TBF_SET_ACK_STATE(t, st) do { t->set_ack_state(st, __FILE__, __LINE__); } while(0)
 #define TBF_SET_ASS_ON(t, fl, chk) do { t->set_assigned_on(fl, chk, __FILE__, __LINE__); } while(0)
 
 struct gprs_rlcmac_tbf {
@@ -195,9 +198,11 @@
 	bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const;
 	bool dl_ass_state_is(enum gprs_rlcmac_tbf_dl_ass_state rhs) const;
 	bool ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const;
+	bool ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const;
 	void set_state(enum gprs_rlcmac_tbf_state new_state, const char *file, int line);
 	void set_ass_state_dl(enum gprs_rlcmac_tbf_dl_ass_state new_state, const char *file, int line);
 	void set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state new_state, const char *file, int line);
+	void set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line);
 	void check_pending_ass();
 	bool check_n_clear(uint8_t state_flag);
 	void set_assigned_on(uint8_t state_flag, bool check_ccch, const char *file, int line);
@@ -279,8 +284,6 @@
 
 	gprs_llc m_llc;
 
-	enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
-
 	enum gprs_rlcmac_tbf_poll_state poll_state;
 	uint32_t poll_fn; /* frame number to poll */
 	uint8_t poll_ts; /* TS to poll */
@@ -343,6 +346,7 @@
 	enum gprs_rlcmac_tbf_state state;
 	enum gprs_rlcmac_tbf_dl_ass_state dl_ass_state;
 	enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state;
+	enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
 	LListHead<gprs_rlcmac_tbf> m_list;
 	LListHead<gprs_rlcmac_tbf> m_ms_list;
 	bool m_egprs_enabled;
@@ -385,6 +389,11 @@
 	return ul_ass_state == rhs;
 }
 
+inline bool gprs_rlcmac_tbf::ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const
+{
+	return ul_ack_state == rhs;
+}
+
 inline bool gprs_rlcmac_tbf::state_is_not(enum gprs_rlcmac_tbf_state rhs) const
 {
 	return state != rhs;
@@ -434,6 +443,15 @@
 	ul_ass_state = new_state;
 }
 
+inline void gprs_rlcmac_tbf::set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line)
+{
+	LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes UL ACK state from %s to %s\n",
+		tbf_name(this),
+		get_value_string(gprs_rlcmac_tbf_ul_ack_state_names, ul_ack_state),
+		get_value_string(gprs_rlcmac_tbf_ul_ack_state_names, new_state));
+	ul_ack_state = new_state;
+}
+
 inline void gprs_rlcmac_tbf::check_pending_ass()
 {
 	if (ul_ass_state != GPRS_RLCMAC_UL_ASS_NONE)