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