Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h
index db9ce9f..080893f 100644
--- a/src/gprs_bssgp_pcu.h
+++ b/src/gprs_bssgp_pcu.h
@@ -22,7 +22,9 @@
#define GPRS_BSSGP_PCU_H
+#ifdef __cplusplus
extern "C" {
+#endif
#include <osmocom/core/talloc.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/logging.h>
@@ -34,7 +36,7 @@
#include <osmocom/gprs/gprs_msgb.h>
struct bssgp_bvc_ctx *btsctx_alloc(uint16_t bvci, uint16_t nsei);
-}
+
#include <gprs_debug.h>
#include <time.h>
@@ -75,6 +77,14 @@
struct tlv_parsed *tp);
};
+int gprs_gp_send_cb(void *ctx, struct msgb *msg);
+struct bssgp_bvc_ctx *gprs_bssgp_pcu_current_bctx(void);
+int gprs_ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx);
+void gprs_bssgp_update_queue_delay(const struct timespec *tv_recv,
+ const struct timespec *tv_now);
+void gprs_bssgp_update_frames_sent();
+void gprs_bssgp_update_bytes_received(unsigned bytes_recv, unsigned frames_recv);
+
struct gprs_bssgp_pcu *gprs_bssgp_init(
struct gprs_rlcmac_bts *bts,
uint16_t nsei, uint16_t bvci,
@@ -86,16 +96,10 @@
const struct osmo_sockaddr *remote,
uint16_t *nsvci, uint16_t valid);
-int gprs_ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx);
-int gprs_gp_send_cb(void *ctx, struct msgb *msg);
-
void gprs_bssgp_destroy(struct gprs_rlcmac_bts *bts);
-struct bssgp_bvc_ctx *gprs_bssgp_pcu_current_bctx(void);
-
-void gprs_bssgp_update_queue_delay(const struct timespec *tv_recv,
- const struct timespec *tv_now);
-void gprs_bssgp_update_frames_sent();
-void gprs_bssgp_update_bytes_received(unsigned bytes_recv, unsigned frames_recv);
+#ifdef __cplusplus
+}
+#endif
#endif // GPRS_BSSGP_PCU_H