blob: 6f4ceaa8684937c18fab90cee48516ccc46aed76 [file] [log] [blame]
Pablo Neira Ayuso96e81282011-06-09 15:06:11 +02001#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
8static void *tall_test;
9
10static 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
16static int sign_link(struct msgb *msg, struct e1inp_sign_link *link)
17{
18 printf("OML/RSL data received\n");
19 return 0;
20}
21
22static 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
30struct 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
39const 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
45int 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
Pablo Neira Ayusoc00ee732011-06-21 12:22:49 +020079 if (e1inp_line_update(line, E1INP_LINE_R_BTS, "127.0.0.1") < 0) {
Pablo Neira Ayuso96e81282011-06-09 15:06:11 +020080 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}