From 0ba77d53a97906ee70a262083fb30f67fe8801c5 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 5 Jun 2011 18:32:44 +0200 Subject: initial commit of libosmo-abis still many things to get fixed --- tests/Makefile.am | 10 +++++++ tests/e1inp_ipa_bsc_test.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/Makefile.am create mode 100644 tests/e1inp_ipa_bsc_test.c (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..c9986fd --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,10 @@ +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS=-Wall -g $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(COVERAGE_CFLAGS) +AM_LDFLAGS = $(COVERAGE_LDFLAGS) + +noinst_PROGRAMS = e1inp_ipa_bsc_test + +e1inp_ipa_bsc_test_SOURCES = e1inp_ipa_bsc_test.c + +e1inp_ipa_bsc_test_LDADD = $(top_builddir)/src/libosmoabis.la \ + $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) diff --git a/tests/e1inp_ipa_bsc_test.c b/tests/e1inp_ipa_bsc_test.c new file mode 100644 index 0000000..8985e98 --- /dev/null +++ b/tests/e1inp_ipa_bsc_test.c @@ -0,0 +1,69 @@ +#include +#include + +static int rx_cb(struct msgb *msg, struct e1inp_ts *ts) +{ + printf("received data\n"); + + /* For ISDN: from the timeslot type, we can get if it's: + * - E1INP_TS_TYPE_SIGN: in this case, check if we have a signal + * link in this timeslot, then, check if it's OML or RSL and pass + * it to the upper layer. + * - E1INP_TS_TYPE_TRAU. + * + * For INET: we have to check if this is a control message, if it's + * a response to previous request id, we enable the signal links for + * OML and RSL. Otherwise, look up for the existing signal link and + * pass it to the upper layer. We don't receive TRAU frames, we use + * RTP. + */ + return 0; +} + +static int rx_err_cb(int error) +{ + printf("error, malformed message\n"); + return 0; +} + +int main(void) +{ + struct e1inp_line *line; + struct e1inp_ts *sign_ts; + + e1inp_init(); + +#define LINENR 0 + + line = e1inp_line_create(LINENR, "ipa", rx_cb, rx_err_cb); + if (line == NULL) { + fprintf(stderr, "problem creating E1 line\n"); + exit(EXIT_FAILURE); + } + sign_ts = &line->ts[0]; + if (e1inp_ts_config_sign(sign_ts, line) < 0) { + fprintf(stderr, "problem setting timeslot in E1 line\n"); + exit(EXIT_FAILURE); + } + + /* + * Depending if this is a real or virtual E1 lines: + * - real (ISDN): create signal link for OML and RSL before line up. + * - vitual (INET): we create it once we have seen response to REQ_ID. + * + * The signal link is created via e1inp_sign_link_create(...) + * + * See e1_reconfig_trx and e1_reconfig_bts in libbsc/e1_config.c, + * it explains how this is done with ISDN. + */ + + if (e1inp_line_update(line, E1INP_LINE_R_BSC) < 0) { + fprintf(stderr, "problem enabling E1 line\n"); + exit(EXIT_FAILURE); + } + + while (1) { + osmo_select_main(0); + } + return 0; +} -- cgit v1.2.3-55-g7522