Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <talloc.h> |
| 3 | #include <osmocom/abis/abis.h> |
| 4 | #include <osmocom/abis/e1_input.h> |
| 5 | #include <osmocom/core/logging.h> |
| 6 | #include <osmocom/core/application.h> |
| 7 | |
| 8 | static void *tall_test; |
| 9 | |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 10 | static int sign_link_up(struct msgb *msg, struct e1inp_line *line, |
| 11 | enum e1inp_sign_type type) |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 12 | { |
| 13 | printf("ID_RESP received, create sign link.\n"); |
| 14 | return 0; |
| 15 | } |
| 16 | |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 17 | static int sign_link(struct msgb *msg, struct e1inp_line *line, |
| 18 | struct e1inp_sign_link *link) |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 19 | { |
| 20 | printf("OML/RSL data received\n"); |
| 21 | return 0; |
| 22 | } |
| 23 | |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 24 | static int error(struct msgb *msg, struct e1inp_line *line, |
| 25 | enum e1inp_sign_type type, int error) |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 26 | { |
| 27 | printf("error, malformed message\n"); |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | #define DBTSTEST OSMO_LOG_SS_APPS |
| 32 | |
| 33 | struct log_info_cat bts_test_cat[] = { |
| 34 | [DBTSTEST] = { |
| 35 | .name = "DBTSTEST", |
| 36 | .description = "BTS-mode test", |
| 37 | .color = "\033[1;35m", |
| 38 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 39 | }, |
| 40 | }; |
| 41 | |
| 42 | const struct log_info bts_test_log_info = { |
| 43 | .filter_fn = NULL, |
| 44 | .cat = bts_test_cat, |
| 45 | .num_cat = ARRAY_SIZE(bts_test_cat), |
| 46 | }; |
| 47 | |
| 48 | int main(void) |
| 49 | { |
| 50 | struct e1inp_line *line; |
| 51 | |
| 52 | tall_test = talloc_named_const(NULL, 1, "e1inp_test"); |
| 53 | libosmo_abis_init(tall_test); |
| 54 | |
| 55 | osmo_init_logging(&bts_test_log_info); |
| 56 | |
| 57 | struct e1inp_line_ops ops = { |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 58 | .role = E1INP_LINE_R_BTS, |
| 59 | .addr = "127.0.0.1", |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 60 | .sign_link_up = sign_link_up, |
| 61 | .sign_link = sign_link, |
| 62 | .error = error, |
| 63 | }; |
| 64 | |
| 65 | #define LINENR 0 |
| 66 | |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 67 | line = e1inp_line_create(LINENR, "ipa"); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 68 | if (line == NULL) { |
| 69 | LOGP(DBTSTEST, LOGL_ERROR, "problem enabling E1 line\n"); |
| 70 | exit(EXIT_FAILURE); |
| 71 | } |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 72 | e1inp_line_bind_ops(line, &ops); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 73 | |
| 74 | /* |
| 75 | * Depending if this is a real or virtual E1 lines: |
| 76 | * - real (ISDN): create signal link for OML and RSL before line up. |
| 77 | * - vitual (INET): we create it in signal_link_up(...) callback. |
| 78 | * |
| 79 | * The signal link is created via e1inp_sign_link_create(...) |
| 80 | * |
| 81 | * See e1_reconfig_trx and e1_reconfig_bts in libbsc/e1_config.c, |
| 82 | * it explains how this is done with ISDN. |
| 83 | */ |
| 84 | |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 85 | if (e1inp_line_update(line) < 0) { |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 86 | LOGP(DBTSTEST, LOGL_ERROR, "problem enabling E1 line\n"); |
| 87 | exit(EXIT_FAILURE); |
| 88 | } |
| 89 | |
| 90 | LOGP(DBTSTEST, LOGL_NOTICE, "entering main loop\n"); |
| 91 | |
| 92 | while (1) { |
| 93 | osmo_select_main(0); |
| 94 | } |
| 95 | return 0; |
| 96 | } |