Pablo Neira Ayuso | 130c4fb | 2011-06-23 21:15:53 +0200 | [diff] [blame] | 1 | #include <stdio.h> |
Harald Welte | 71d87b2 | 2011-07-18 14:49:56 +0200 | [diff] [blame] | 2 | #include <osmocom/core/talloc.h> |
Pablo Neira Ayuso | 130c4fb | 2011-06-23 21:15:53 +0200 | [diff] [blame] | 3 | #include <osmocom/abis/abis.h> |
| 4 | #include <osmocom/abis/e1_input.h> |
| 5 | #include <osmocom/abis/ipa_proxy.h> |
| 6 | #include <osmocom/core/logging.h> |
| 7 | #include <osmocom/core/application.h> |
| 8 | #include <osmocom/vty/vty.h> |
| 9 | #include <osmocom/vty/command.h> |
| 10 | #include <osmocom/vty/telnet_interface.h> |
| 11 | #include "internal.h" |
| 12 | #include "config.h" |
| 13 | |
| 14 | static void *tall_test; |
| 15 | |
Pablo Neira Ayuso | fe8ab0a | 2011-07-02 18:48:45 +0200 | [diff] [blame] | 16 | #define DIPA_PROXY_TEST 0 |
Pablo Neira Ayuso | 130c4fb | 2011-06-23 21:15:53 +0200 | [diff] [blame] | 17 | |
| 18 | struct log_info_cat ipa_proxy_test_cat[] = { |
| 19 | [DIPA_PROXY_TEST] = { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 20 | .name = "DLINP_IPA_PROXY_TEST", |
Pablo Neira Ayuso | 130c4fb | 2011-06-23 21:15:53 +0200 | [diff] [blame] | 21 | .description = "IPA proxy test", |
| 22 | .color = "\033[1;35m", |
| 23 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 24 | }, |
| 25 | }; |
| 26 | |
| 27 | const struct log_info ipa_proxy_test_log_info = { |
| 28 | .filter_fn = NULL, |
| 29 | .cat = ipa_proxy_test_cat, |
| 30 | .num_cat = ARRAY_SIZE(ipa_proxy_test_cat), |
| 31 | }; |
| 32 | |
| 33 | static int bsc_vty_is_config_node(struct vty *vty, int node) |
| 34 | { |
| 35 | switch(node) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 36 | case L_IPA_NODE: |
Pablo Neira Ayuso | 130c4fb | 2011-06-23 21:15:53 +0200 | [diff] [blame] | 37 | return 1; |
| 38 | break; |
| 39 | } |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | static enum node_type bsc_vty_go_parent(struct vty *vty) |
| 44 | { |
| 45 | switch (vty->node) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 46 | case L_IPA_NODE: |
Pablo Neira Ayuso | 130c4fb | 2011-06-23 21:15:53 +0200 | [diff] [blame] | 47 | vty->node = VIEW_NODE; |
| 48 | break; |
| 49 | } |
| 50 | return vty->node; |
| 51 | } |
| 52 | |
| 53 | static struct vty_app_info vty_info = { |
| 54 | .name = "ipa-proxy-test", |
| 55 | .version = PACKAGE_VERSION, |
| 56 | .go_parent_cb = bsc_vty_go_parent, |
| 57 | .is_config_node = bsc_vty_is_config_node, |
| 58 | }; |
| 59 | |
| 60 | #define IPA_PROXY_TEST_TELNET_PORT 4260 |
| 61 | |
| 62 | int main(void) |
| 63 | { |
| 64 | tall_test = talloc_named_const(NULL, 1, "ipa proxy test"); |
| 65 | libosmo_abis_init(tall_test); |
| 66 | |
| 67 | osmo_init_logging(&ipa_proxy_test_log_info); |
| 68 | |
| 69 | vty_init(&vty_info); |
| 70 | ipa_proxy_vty_init(); |
| 71 | |
| 72 | telnet_init(tall_test, NULL, IPA_PROXY_TEST_TELNET_PORT); |
| 73 | |
| 74 | LOGP(DIPA_PROXY_TEST, LOGL_NOTICE, "entering main loop\n"); |
| 75 | |
| 76 | while (1) { |
| 77 | osmo_select_main(0); |
| 78 | } |
| 79 | } |