mscsplit: gsm_network_init(): add explicit root talloc ctx
Decouple the root talloc context from libbsc's global talloc_bsc_ctx. This allows to define the root talloc ctx from a main() scope, which in turn helps decouple libmsc from libbsc. Change-Id: I92f6b47b1eeea2e8f3fba66f25d7e708e5659f8a
This commit is contained in:
parent
d90fa42dc9
commit
77c8d5ffb5
|
@ -394,8 +394,11 @@ struct gsm_sms {
|
||||||
char text[SMS_TEXT_SIZE];
|
char text[SMS_TEXT_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_code,
|
struct gsm_network *gsm_network_init(void *ctx,
|
||||||
|
uint16_t country_code,
|
||||||
|
uint16_t network_code,
|
||||||
int (*mncc_recv)(struct gsm_network *, struct msgb *));
|
int (*mncc_recv)(struct gsm_network *, struct msgb *));
|
||||||
|
|
||||||
int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
|
int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
|
||||||
|
|
||||||
/* Get reference to a neighbor cell on a given BCCH ARFCN */
|
/* Get reference to a neighbor cell on a given BCCH ARFCN */
|
||||||
|
|
|
@ -983,7 +983,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
libosmo_abis_init(tall_ctx_config);
|
libosmo_abis_init(tall_ctx_config);
|
||||||
|
|
||||||
bsc_gsmnet = gsm_network_init(1, 1, NULL);
|
bsc_gsmnet = gsm_network_init(tall_bsc_ctx, 1, 1, NULL);
|
||||||
if (!bsc_gsmnet)
|
if (!bsc_gsmnet)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
|
|
|
@ -477,7 +477,7 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *),
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* initialize our data structures */
|
/* initialize our data structures */
|
||||||
bsc_gsmnet = gsm_network_init(1, 1, mncc_recv);
|
bsc_gsmnet = gsm_network_init(tall_bsc_ctx, 1, 1, mncc_recv);
|
||||||
if (!bsc_gsmnet)
|
if (!bsc_gsmnet)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,15 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_code,
|
struct gsm_network *gsm_network_init(void *ctx,
|
||||||
|
uint16_t country_code,
|
||||||
|
uint16_t network_code,
|
||||||
int (*mncc_recv)(struct gsm_network *, struct msgb *))
|
int (*mncc_recv)(struct gsm_network *, struct msgb *))
|
||||||
{
|
{
|
||||||
struct gsm_network *net;
|
struct gsm_network *net;
|
||||||
const char *default_regexp = ".*";
|
const char *default_regexp = ".*";
|
||||||
|
|
||||||
net = talloc_zero(tall_bsc_ctx, struct gsm_network);
|
net = talloc_zero(ctx, struct gsm_network);
|
||||||
if (!net)
|
if (!net)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -894,7 +894,7 @@ int main(int argc, char **argv)
|
||||||
handle_options(argc, argv);
|
handle_options(argc, argv);
|
||||||
bts_model_bs11_init();
|
bts_model_bs11_init();
|
||||||
|
|
||||||
gsmnet = gsm_network_init(1, 1, NULL);
|
gsmnet = gsm_network_init(tall_bs11cfg_ctx, 1, 1, NULL);
|
||||||
if (!gsmnet) {
|
if (!gsmnet) {
|
||||||
fprintf(stderr, "Unable to allocate gsm network\n");
|
fprintf(stderr, "Unable to allocate gsm network\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char **argv)
|
||||||
printf("Testing the gsm_subscriber chan logic\n");
|
printf("Testing the gsm_subscriber chan logic\n");
|
||||||
|
|
||||||
/* Create a dummy network */
|
/* Create a dummy network */
|
||||||
network = gsm_network_init(1, 1, NULL);
|
network = gsm_network_init(tall_bsc_ctx, 1, 1, NULL);
|
||||||
if (!network)
|
if (!network)
|
||||||
exit(1);
|
exit(1);
|
||||||
bts = gsm_bts_alloc(network);
|
bts = gsm_bts_alloc(network);
|
||||||
|
|
|
@ -122,7 +122,7 @@ static inline void _bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn,
|
||||||
static inline void test_si2q_u(void)
|
static inline void test_si2q_u(void)
|
||||||
{
|
{
|
||||||
struct gsm_bts *bts;
|
struct gsm_bts *bts;
|
||||||
struct gsm_network *network = gsm_network_init(1, 1, NULL);
|
struct gsm_network *network = gsm_network_init(tall_bsc_ctx, 1, 1, NULL);
|
||||||
printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n");
|
printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n");
|
||||||
|
|
||||||
if (!network)
|
if (!network)
|
||||||
|
@ -149,7 +149,7 @@ static inline void test_si2q_u(void)
|
||||||
static inline void test_si2q_e(void)
|
static inline void test_si2q_e(void)
|
||||||
{
|
{
|
||||||
struct gsm_bts *bts;
|
struct gsm_bts *bts;
|
||||||
struct gsm_network *network = gsm_network_init(1, 1, NULL);
|
struct gsm_network *network = gsm_network_init(tall_bsc_ctx, 1, 1, NULL);
|
||||||
printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n");
|
printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n");
|
||||||
|
|
||||||
if (!network)
|
if (!network)
|
||||||
|
|
Loading…
Reference in New Issue