src: add libosmo_abis_init(void *ctx) to set the talloc context
This function is called during initialization, so we can set what's the talloc context for the application and the library.
This commit is contained in:
parent
177094b4c9
commit
54b4979de6
|
@ -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. */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef _OSMO_ABIS_H_
|
||||
#define _OSMO_ABIS_H_
|
||||
|
||||
void libosmo_abis_init(void *ctx);
|
||||
|
||||
#endif
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue