aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2012-08-15 23:22:50 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2012-08-16 00:31:00 +0200
commit0f4626377732dd2f52fd0ded4f8e976c1a461d30 (patch)
tree1c3f029b51d1a26438f8a8b793cc5d1864edb206 /examples
parent3dc28ec6a3d2fe2a500d4a7ee330613cf1af9d89 (diff)
add ABIS IPA example as client (BTS)
Diffstat (limited to 'examples')
-rw-r--r--examples/channel/Makefile.am7
-rw-r--r--examples/channel/abis_ipa_client.c89
2 files changed, 95 insertions, 1 deletions
diff --git a/examples/channel/Makefile.am b/examples/channel/Makefile.am
index 1906465..eb53c41 100644
--- a/examples/channel/Makefile.am
+++ b/examples/channel/Makefile.am
@@ -2,8 +2,13 @@ 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
+noinst_PROGRAMS = abis_ipa_server \
+ abis_ipa_client
abis_ipa_server_SOURCES = abis_ipa_server.c
abis_ipa_server_LDADD = $(top_builddir)/src/libosmonetif.la \
$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
+
+abis_ipa_client_SOURCES = abis_ipa_client.c
+abis_ipa_client_LDADD = $(top_builddir)/src/libosmonetif.la \
+ $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
diff --git a/examples/channel/abis_ipa_client.c b/examples/channel/abis_ipa_client.c
new file mode 100644
index 0000000..8ff0c11
--- /dev/null
+++ b/examples/channel/abis_ipa_client.c
@@ -0,0 +1,89 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <osmocom/core/select.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/core/application.h>
+
+#include <osmocom/netif/channel.h>
+#include <osmocom/netif/channel/abis_ipa_client.h>
+#include <osmocom/netif/ipa_unit.h>
+
+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)
+{
+ struct ipaccess_unit *unit;
+
+ 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_CLI);
+ if (chan == NULL) {
+ LOGP(DEXAMPLE, LOGL_ERROR, "Cannot create A-bis IPA client\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* set specific parameters (depends on channel type). */
+ osmo_abis_ipa_cli_set_oml_addr(chan, "127.0.0.1");
+ osmo_abis_ipa_cli_set_rsl_addr(chan, "127.0.0.1");
+
+ unit = osmo_ipa_unit_alloc();
+ if (unit == NULL) {
+ LOGP(DEXAMPLE, LOGL_ERROR, "Cannot create IPA unit\n");
+ exit(EXIT_FAILURE);
+ }
+ osmo_ipa_unit_set_site_id(unit, 1801);
+
+ osmo_abis_ipa_cli_set_unit(chan, unit);
+ osmo_abis_ipa_cli_set_cb_signalmsg(chan, signal_msg_cb);
+
+ /* open channel. */
+ if (osmo_chan_open(chan) < 0) {
+ LOGP(DEXAMPLE, LOGL_ERROR, "Cannot create A-bis IPA client\n");
+ exit(EXIT_FAILURE);
+ }
+
+ LOGP(DEXAMPLE, LOGL_NOTICE, "Entering main loop\n");
+
+ while(1) {
+ osmo_select_main(0);
+ }
+}