From 2b5d3ce7c69e1149bb2af815ab8b8534026063ca Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 6 Nov 2011 20:47:08 +0100 Subject: src: add generic channel infrastructure and A-bis IPA server support This patch adds the generic channel infrastructure that allows to create channel of different types. Each channel has their own configuration functions. struct osmo_chan *chan; chan = osmo_chan_create(tall_example, CHAN_ABIS_IPA_SERVER); ... /* specific configuration functions per supported channel. */ osmo_chan_abis_ipa_server_set_cb_signalmsg(chan, signal_msg_cb); osmo_chan_abis_ipa_unit_add(chan, 1801, 0); /* open channel. */ osmo_chan_open(chan); The input path requires a callback to be registered. The output path is handled through: int osmo_chan_enqueue(struct osmo_chan *c, struct msgb *msg); The msg->dst must be set (it can be taken from the original message to route one reply). This patch also adds A-bis IPA server support. It has been tested with e1inp_ipa_bsc_test available in libosmo-abis. --- examples/Makefile.am | 2 + examples/channel/Makefile.am | 9 +++++ examples/channel/abis_ipa_server.c | 76 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 examples/channel/Makefile.am create mode 100644 examples/channel/abis_ipa_server.c (limited to 'examples') diff --git a/examples/Makefile.am b/examples/Makefile.am index be4ecde..173b620 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include AM_CFLAGS=-Wall -g $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) AM_LDFLAGS = $(COVERAGE_LDFLAGS) +SUBDIRS = channel + noinst_PROGRAMS = ipa-stream-client \ ipa-stream-server \ lapd-over-datagram-user \ diff --git a/examples/channel/Makefile.am b/examples/channel/Makefile.am new file mode 100644 index 0000000..1906465 --- /dev/null +++ b/examples/channel/Makefile.am @@ -0,0 +1,9 @@ +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS=-Wall -g $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) +AM_LDFLAGS = $(COVERAGE_LDFLAGS) + +noinst_PROGRAMS = abis_ipa_server + +abis_ipa_server_SOURCES = abis_ipa_server.c +abis_ipa_server_LDADD = $(top_builddir)/src/libosmonetif.la \ + $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) diff --git a/examples/channel/abis_ipa_server.c b/examples/channel/abis_ipa_server.c new file mode 100644 index 0000000..014975d --- /dev/null +++ b/examples/channel/abis_ipa_server.c @@ -0,0 +1,76 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +static void *tall_example; + +#define DEXAMPLE 0 + +struct log_info_cat example_cat[] = { + [DEXAMPLE] = { + .name = "DEXAMPLE", + .description = "example", + .color = "\033[1;35m", + .enabled = 1, .loglevel = LOGL_DEBUG, + }, +}; + +const struct log_info example_log_info = { + .filter_fn = NULL, + .cat = example_cat, + .num_cat = ARRAY_SIZE(example_cat), +}; + +void sighandler(int foo) +{ + LOGP(DEXAMPLE, LOGL_NOTICE, "closing test.\n"); + exit(EXIT_SUCCESS); +} + +static void signal_msg_cb(struct msgb *msg, int type) +{ + LOGP(DEXAMPLE, LOGL_NOTICE, "received signal message\n"); +} + +static struct osmo_chan *chan; + +int main(void) +{ + tall_example = talloc_named_const(NULL, 1, "example"); + + osmo_init_logging(&example_log_info); + log_set_log_level(osmo_stderr_target, LOGL_DEBUG); + + /* create channel. */ + chan = osmo_chan_create(tall_example, CHAN_ABIS_IPA_SERVER); + if (chan == NULL) { + LOGP(DEXAMPLE, LOGL_ERROR, "Cannot create A-bis IPA server\n"); + exit(EXIT_FAILURE); + } + + /* set specific parameters (depends on channel type). */ + osmo_chan_abis_ipa_server_set_cb_signalmsg(chan, signal_msg_cb); + osmo_chan_abis_ipa_unit_add(chan, 1801, 0); + + /* open channel. */ + if (osmo_chan_open(chan) < 0) { + LOGP(DEXAMPLE, LOGL_ERROR, "Cannot create A-bis IPA server\n"); + exit(EXIT_FAILURE); + } + + LOGP(DEXAMPLE, LOGL_NOTICE, "Entering main loop\n"); + + while(1) { + osmo_select_main(0); + } +} -- cgit v1.2.3