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
diff --git a/openbsc/src/ipaccess/ipaccess-config.c b/openbsc/src/ipaccess/ipaccess-config.c
index 31da056..9e3a471 100644
--- a/openbsc/src/ipaccess/ipaccess-config.c
+++ b/openbsc/src/ipaccess/ipaccess-config.c
@@ -983,7 +983,7 @@
 	}
 	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)
 		exit(1);
 
diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c
index 371ddee..06f4121 100644
--- a/openbsc/src/libbsc/bsc_init.c
+++ b/openbsc/src/libbsc/bsc_init.c
@@ -477,7 +477,7 @@
 	int rc;
 
 	/* 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)
 		return -ENOMEM;
 
diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c
index e01ba80..e53b466 100644
--- a/openbsc/src/libbsc/net_init.c
+++ b/openbsc/src/libbsc/net_init.c
@@ -23,13 +23,15 @@
 
 #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 *))
 {
 	struct gsm_network *net;
 	const char *default_regexp = ".*";
 
-	net = talloc_zero(tall_bsc_ctx, struct gsm_network);
+	net = talloc_zero(ctx, struct gsm_network);
 	if (!net)
 		return NULL;
 
diff --git a/openbsc/src/utils/bs11_config.c b/openbsc/src/utils/bs11_config.c
index 3fb74bf..227b9f8 100644
--- a/openbsc/src/utils/bs11_config.c
+++ b/openbsc/src/utils/bs11_config.c
@@ -894,7 +894,7 @@
 	handle_options(argc, argv);
 	bts_model_bs11_init();
 
-	gsmnet = gsm_network_init(1, 1, NULL);
+	gsmnet = gsm_network_init(tall_bs11cfg_ctx, 1, 1, NULL);
 	if (!gsmnet) {
 		fprintf(stderr, "Unable to allocate gsm network\n");
 		exit(1);