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/poll_controller.cpp b/src/poll_controller.cpp
index ac79510..04ec4fd 100644
--- a/src/poll_controller.cpp
+++ b/src/poll_controller.cpp
@@ -24,6 +24,7 @@
 #include <bts.h>
 #include <tbf.h>
 #include <tbf_ul.h>
+#include <tbf_dl.h>
 #include <cxx_linuxlist.h>
 #include <sba.h>
 
@@ -32,7 +33,7 @@
 #include <osmocom/gsm/gsm_utils.h>
 }
 
-PollController::PollController(BTS& bts)
+PollController::PollController(struct gprs_rlcmac_bts& bts)
 	: m_bts(bts)
 {}
 
@@ -51,26 +52,26 @@
 	struct gprs_rlcmac_dl_tbf *dl_tbf;
 	struct gprs_rlcmac_ul_tbf *ul_tbf;
 	struct gprs_rlcmac_sba *sba, *sba2;
-	LListHead<gprs_rlcmac_tbf> *pos;
+	struct llist_item *pos;
 
-	llist_for_each(pos, &m_bts.ul_tbfs()) {
-		ul_tbf = as_ul_tbf(pos->entry());
+	llist_for_each_entry(pos, &m_bts.ul_tbfs, list) {
+		ul_tbf = as_ul_tbf((struct gprs_rlcmac_tbf *)pos->entry);
 		if (ul_tbf->poll_scheduled()) {
 			if (elapsed_fn_check(max_delay, frame_number, ul_tbf->poll_fn))
 				ul_tbf->poll_timeout();
 		}
 	}
-	llist_for_each(pos, &m_bts.dl_tbfs()) {
-		dl_tbf = as_dl_tbf(pos->entry());
+	llist_for_each_entry(pos, &m_bts.dl_tbfs, list) {
+		dl_tbf = as_dl_tbf((struct gprs_rlcmac_tbf *)pos->entry);
 		if (dl_tbf->poll_scheduled()) {
 			if (elapsed_fn_check(max_delay, frame_number, dl_tbf->poll_fn))
 				dl_tbf->poll_timeout();
 		}
 	}
-	llist_for_each_entry_safe(sba, sba2, &m_bts.sba()->m_sbas, list) {
+	llist_for_each_entry_safe(sba, sba2, &bts_sba(&m_bts)->m_sbas, list) {
 		if (elapsed_fn_check(max_delay, frame_number, sba->fn)) {
 			/* sba will be freed here */
-			m_bts.sba()->timeout(sba);
+			bts_sba(&m_bts)->timeout(sba);
 		}
 	}