Unify BTS into a C usable structure

Previous work on BTS class started to get stuff out of the C++ struct
 into a C struct (BTS -> struct gprs_glcmac_bts) so that some parts of
it were accessible from C code. Doing so, however, ended up being messy
too, since all code needs to be switching from one object to another,
which actually refer to the same logical component.

Let's instead rejoin the structures and make sure the struct is
accessible and usable from both C and C++ code by rewriting all methods
to be C compatible and converting 3 allocated suboject as pointers.
This way BTS can internally still use those C++ objects while providing
a clean APi to both C and C++ code.

Change-Id: I7d12c896c5ded659ca9d3bff4cf3a3fc857db9dd
diff --git a/src/tbf.h b/src/tbf.h
index d767547..cb4c9b9 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -196,6 +196,7 @@
 enum gprs_rlcmac_tbf_direction tbf_direction(const struct gprs_rlcmac_tbf *tbf);
 void tbf_set_ms(struct gprs_rlcmac_tbf *tbf, struct GprsMs *ms);
 struct llist_head *tbf_ms_list(struct gprs_rlcmac_tbf *tbf);
+struct llist_head *tbf_bts_list(struct gprs_rlcmac_tbf *tbf);
 struct GprsMs *tbf_ms(struct gprs_rlcmac_tbf *tbf);
 bool tbf_timers_pending(struct gprs_rlcmac_tbf *tbf, enum tbf_timers t);
 void tbf_free(struct gprs_rlcmac_tbf *tbf);
@@ -212,7 +213,7 @@
 #ifdef __cplusplus
 
 struct gprs_rlcmac_tbf {
-	gprs_rlcmac_tbf(BTS *bts_, GprsMs *ms, gprs_rlcmac_tbf_direction dir);
+	gprs_rlcmac_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms, gprs_rlcmac_tbf_direction dir);
 	virtual ~gprs_rlcmac_tbf() {}
 
 	static void free_all(struct gprs_rlcmac_trx *trx);
@@ -296,9 +297,6 @@
 	/* attempt to make things a bit more fair */
 	void rotate_in_list();
 
-	LListHead<gprs_rlcmac_tbf>& list();
-	const LListHead<gprs_rlcmac_tbf>& list() const;
-
 	uint32_t state_flags;
 	enum gprs_rlcmac_tbf_direction direction;
 	struct gprs_rlcmac_trx *trx;
@@ -335,7 +333,7 @@
 	uint8_t upgrade_to_multislot;
 
 	/* store the BTS this TBF belongs to */
-	BTS *bts;
+	struct gprs_rlcmac_bts *bts;
 
 	/*
 	 * private fields. We can't make it private as it is breaking the
@@ -347,6 +345,7 @@
 	struct rate_ctr_group *m_ctrs;
 	enum gprs_rlcmac_tbf_state state;
 	struct llist_item m_ms_list;
+	struct llist_item m_bts_list;
 
 protected:
 	gprs_rlcmac_bts *bts_data() const;
@@ -364,7 +363,6 @@
 	enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state;
 	enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
 	enum gprs_rlcmac_tbf_poll_state poll_state;
-	LListHead<gprs_rlcmac_tbf> m_list;
 	bool m_egprs_enabled;
 	struct osmo_timer_list Tarr[T_MAX];
 	uint8_t Narr[N_MAX];
@@ -522,16 +520,6 @@
 	return false;
 }
 
-inline LListHead<gprs_rlcmac_tbf>& gprs_rlcmac_tbf::list()
-{
-	return this->m_list;
-}
-
-inline const LListHead<gprs_rlcmac_tbf>& gprs_rlcmac_tbf::list() const
-{
-	return this->m_list;
-}
-
 inline GprsMs *gprs_rlcmac_tbf::ms() const
 {
 	return m_ms;