aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2011-06-23 21:15:53 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2011-06-23 22:15:45 +0200
commit130c4fbe2e815d94bcf4b6d13849bebbfbf0198d (patch)
tree1e526e4f0d2f46a2b28b84aa7dc87e46f054e90e /tests
parentaf3fed9213666c8fa68ba3a153aa17577df97649 (diff)
ipa-proxy: add A-bis over IP generic proxy commands for VTY
This patch adds VTY commands to route IPA flows. The following example allows to add a new route: $ tests/./ipa_proxy_test & <0000> ipa_proxy_test.c:74 entering main loop $ telnet localhost 4260 ipa-proxy-test> enable ipa-proxy-test# ipa instance input-oml bind 127.0.0.1 tcp port 8888 ipa-proxy-test# ipa instance output-oml connect 127.0.0.1 tcp port 3002 ipa-proxy-test# ipa route instance input-oml streamid 0xfe instance output-oml streamid 0xfe ipa-proxy-test# ipa instance input-rsl bind 127.0.0.1 tcp port 8889 ipa-proxy-test# ipa instance output-rsl connect 127.0.0.1 tcp port 3003 ipa-proxy-test# ipa route instance input-rsl streamid 0xfe instance output-rsl streamid 0xfe I'm using this to initially test this code [*]. [*] note that this requires a minor hackish patch for the src/input/ipaccess.c driver which changes the default OML and RSL ports to listen in 8888 and 8889 instead of the default ports, thus, I can initially test everything from the localhost.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/ipa_proxy_test.c79
2 files changed, 86 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c27342d..5cb6447 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,9 @@ 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_bts_test
+noinst_PROGRAMS = e1inp_ipa_bsc_test \
+ e1inp_ipa_bts_test \
+ ipa_proxy_test
e1inp_ipa_bsc_test_SOURCES = e1inp_ipa_bsc_test.c
e1inp_ipa_bsc_test_LDADD = $(top_builddir)/src/libosmoabis.la \
@@ -11,3 +13,7 @@ e1inp_ipa_bsc_test_LDADD = $(top_builddir)/src/libosmoabis.la \
e1inp_ipa_bts_test_SOURCES = e1inp_ipa_bts_test.c
e1inp_ipa_bts_test_LDADD = $(top_builddir)/src/libosmoabis.la \
$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
+
+ipa_proxy_test_SOURCES = ipa_proxy_test.c
+ipa_proxy_test_LDADD = $(top_builddir)/src/libosmoabis.la \
+ $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
diff --git a/tests/ipa_proxy_test.c b/tests/ipa_proxy_test.c
new file mode 100644
index 0000000..cea8e2b
--- /dev/null
+++ b/tests/ipa_proxy_test.c
@@ -0,0 +1,79 @@
+#include <stdio.h>
+#include <talloc.h>
+#include <osmocom/abis/abis.h>
+#include <osmocom/abis/e1_input.h>
+#include <osmocom/abis/ipa_proxy.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/core/application.h>
+#include <osmocom/vty/vty.h>
+#include <osmocom/vty/command.h>
+#include <osmocom/vty/telnet_interface.h>
+#include "internal.h"
+#include "config.h"
+
+static void *tall_test;
+
+#define DIPA_PROXY_TEST OSMO_LOG_SS_APPS
+
+struct log_info_cat ipa_proxy_test_cat[] = {
+ [DIPA_PROXY_TEST] = {
+ .name = "DINP_IPA_PROXY_TEST",
+ .description = "IPA proxy test",
+ .color = "\033[1;35m",
+ .enabled = 1, .loglevel = LOGL_NOTICE,
+ },
+};
+
+const struct log_info ipa_proxy_test_log_info = {
+ .filter_fn = NULL,
+ .cat = ipa_proxy_test_cat,
+ .num_cat = ARRAY_SIZE(ipa_proxy_test_cat),
+};
+
+static int bsc_vty_is_config_node(struct vty *vty, int node)
+{
+ switch(node) {
+ case IPA_NODE:
+ return 1;
+ break;
+ }
+ return 0;
+}
+
+static enum node_type bsc_vty_go_parent(struct vty *vty)
+{
+ switch (vty->node) {
+ case IPA_NODE:
+ vty->node = VIEW_NODE;
+ break;
+ }
+ return vty->node;
+}
+
+static struct vty_app_info vty_info = {
+ .name = "ipa-proxy-test",
+ .version = PACKAGE_VERSION,
+ .go_parent_cb = bsc_vty_go_parent,
+ .is_config_node = bsc_vty_is_config_node,
+};
+
+#define IPA_PROXY_TEST_TELNET_PORT 4260
+
+int main(void)
+{
+ tall_test = talloc_named_const(NULL, 1, "ipa proxy test");
+ libosmo_abis_init(tall_test);
+
+ osmo_init_logging(&ipa_proxy_test_log_info);
+
+ vty_init(&vty_info);
+ ipa_proxy_vty_init();
+
+ telnet_init(tall_test, NULL, IPA_PROXY_TEST_TELNET_PORT);
+
+ LOGP(DIPA_PROXY_TEST, LOGL_NOTICE, "entering main loop\n");
+
+ while (1) {
+ osmo_select_main(0);
+ }
+}