summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/internal.h6
-rw-r--r--include/osmocom/abis/Makefile.am2
-rw-r--r--include/osmocom/abis/abis.h6
-rw-r--r--include/osmocom/abis/e1_input.h3
-rw-r--r--src/Makefile.am3
-rw-r--r--src/e1_input.c1
-rw-r--r--src/init.c27
-rw-r--r--src/input/hsl.c6
-rw-r--r--src/input/ipaccess.c8
-rw-r--r--tests/e1inp_ipa_bsc_test.c7
10 files changed, 58 insertions, 11 deletions
diff --git a/include/internal.h b/include/internal.h
index 131e12b..24ec63e 100644
--- a/include/internal.h
+++ b/include/internal.h
@@ -1,6 +1,12 @@
#ifndef _INTERNAL_H_
#define _INTERNAL_H_
+/* talloc context for libosmo-abis. */
+extern void *libosmo_abis_ctx;
+
+/* use libosmo_abis_init, this is only for internal use. */
+void e1inp_init(void);
+
/* things I don't know what to do with yet. */
/* extracted from include/openbsc/debug.h. */
diff --git a/include/osmocom/abis/Makefile.am b/include/osmocom/abis/Makefile.am
index 8bdcc96..3093ee5 100644
--- a/include/osmocom/abis/Makefile.am
+++ b/include/osmocom/abis/Makefile.am
@@ -1,3 +1,3 @@
-osmoabis_HEADERS = e1_input.h subchan_demux.h ipaccess.h trau_frame.h
+osmoabis_HEADERS = abis.h e1_input.h subchan_demux.h ipaccess.h trau_frame.h
osmoabisdir = $(includedir)/osmocom/gsm/abis
diff --git a/include/osmocom/abis/abis.h b/include/osmocom/abis/abis.h
new file mode 100644
index 0000000..af8c64c
--- /dev/null
+++ b/include/osmocom/abis/abis.h
@@ -0,0 +1,6 @@
+#ifndef _OSMO_ABIS_H_
+#define _OSMO_ABIS_H_
+
+void libosmo_abis_init(void *ctx);
+
+#endif
diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h
index c5a4137..a7ac578 100644
--- a/include/osmocom/abis/e1_input.h
+++ b/include/osmocom/abis/e1_input.h
@@ -208,9 +208,6 @@ int hsl_setup(struct gsm_network *gsmnet);
extern struct llist_head e1inp_driver_list;
extern struct llist_head e1inp_line_list;
-int e1inp_vty_init(void);
-void e1inp_init(void);
-
int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml);
/* XXX */
diff --git a/src/Makefile.am b/src/Makefile.am
index ce053cf..d6f8340 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,7 @@ AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
lib_LTLIBRARIES = libosmoabis.la
libosmoabis_la_LIBADD = input/libosmoabis-input.la
-libosmoabis_la_SOURCES = e1_input.c \
+libosmoabis_la_SOURCES = init.c \
+ e1_input.c \
subchan_demux.c \
trau_frame.c
diff --git a/src/e1_input.c b/src/e1_input.c
index 8a4e1b9..fb3d9a6 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -605,6 +605,7 @@ void e1inp_hsl_init(void);
void e1inp_init(void)
{
+ tall_e1inp_ctx = talloc_named_const(libosmo_abis_ctx, 1, "e1inp");
tall_sigl_ctx = talloc_named_const(tall_e1inp_ctx, 1,
"e1inp_sign_link");
osmo_signal_register_handler(SS_GLOBAL, e1i_sig_cb, NULL);
diff --git a/src/init.c b/src/init.c
new file mode 100644
index 0000000..f461856
--- /dev/null
+++ b/src/init.c
@@ -0,0 +1,27 @@
+/* (C) 2011 by Harald Welte <laforge@gnumonks.org>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "internal.h"
+#include <talloc.h>
+
+void *libosmo_abis_ctx;
+
+void libosmo_abis_init(void *ctx)
+{
+ libosmo_abis_ctx = talloc_named_const(ctx, 0, "abis");
+ e1inp_init();
+}
diff --git a/src/input/hsl.c b/src/input/hsl.c
index 689698c..b7c7897 100644
--- a/src/input/hsl.c
+++ b/src/input/hsl.c
@@ -59,7 +59,7 @@
#define PRIV_OML 1
#define PRIV_RSL 2
-static void *tall_bsc_ctx;
+static void *tall_hsl_ctx;
/* data structure for one E1 interface with A-bis */
struct hsl_e1_handle {
@@ -292,7 +292,9 @@ int hsl_setup(struct gsm_network *gsmnet)
void e1inp_hsl_init(void)
{
- e1h = talloc_zero(tall_bsc_ctx, struct hsl_e1_handle);
+ tall_hsl_ctx = talloc_named_const(libosmo_abis_ctx, 1, "hsl");
+
+ e1h = talloc_zero(tall_hsl_ctx, struct hsl_e1_handle);
if (!e1h)
return;
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 40d69b6..ef773ba 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -46,7 +46,7 @@
#define PRIV_OML 1
#define PRIV_RSL 2
-static void *tall_bsc_ctx;
+static void *tall_ipa_ctx;
/* data structure for one E1 interface with A-bis */
struct ia_e1_handle {
@@ -378,7 +378,7 @@ static int rsl_listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
if (!(what & BSC_FD_READ))
return 0;
- bfd = talloc_zero(tall_bsc_ctx, struct osmo_fd);
+ bfd = talloc_zero(tall_ipa_ctx, struct osmo_fd);
if (!bfd)
return -ENOMEM;
@@ -502,7 +502,9 @@ int ipaccess_setup(struct gsm_network *gsmnet)
void e1inp_ipaccess_init(void)
{
- e1h = talloc_zero(tall_bsc_ctx, struct ia_e1_handle);
+ tall_ipa_ctx = talloc_named_const(libosmo_abis_ctx, 1, "ipa");
+
+ e1h = talloc_zero(tall_ipa_ctx, struct ia_e1_handle);
if (!e1h)
return;
diff --git a/tests/e1inp_ipa_bsc_test.c b/tests/e1inp_ipa_bsc_test.c
index 5ef725e..96ecec9 100644
--- a/tests/e1inp_ipa_bsc_test.c
+++ b/tests/e1inp_ipa_bsc_test.c
@@ -1,6 +1,10 @@
#include <stdio.h>
+#include <talloc.h>
+#include <osmocom/abis/abis.h>
#include <osmocom/abis/e1_input.h>
+static void *tall_test;
+
static int rx_cb(struct msgb *msg, struct e1inp_ts *ts)
{
printf("received data\n");
@@ -31,7 +35,8 @@ int main(void)
struct e1inp_line *line;
struct e1inp_ts *sign_ts;
- e1inp_init();
+ tall_test = talloc_named_const(NULL, 1, "e1inp_test");
+ libosmo_abis_init(tall_test);
#define LINENR 0