blob: 9c6bd4c266091225e2cd30d65b3e395509198b4c [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
Pablo Neira Ayusof163d232011-06-25 18:42:55 +020010static int sign_link_up(struct msgb *msg, struct e1inp_line *line,
11 enum e1inp_sign_type type)
Pablo Neira Ayuso96e81282011-06-09 15:06:11 +020012{
13 printf("ID_RESP received, create sign link.\n");
14 return 0;
15}
16
Pablo Neira Ayusof163d232011-06-25 18:42:55 +020017static int sign_link(struct msgb *msg, struct e1inp_line *line,
18 struct e1inp_sign_link *link)
Pablo Neira Ayuso96e81282011-06-09 15:06:11 +020019{
20 printf("OML/RSL data received\n");
21 return 0;
22}
23
Pablo Neira Ayusof163d232011-06-25 18:42:55 +020024static int error(struct msgb *msg, struct e1inp_line *line,
25 enum e1inp_sign_type type, int error)
Pablo Neira Ayuso96e81282011-06-09 15:06:11 +020026{
27 printf("error, malformed message\n");
28 return 0;
29}
30
31#define DBTSTEST OSMO_LOG_SS_APPS
32
33struct 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
42const 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
48int 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 Ayusof163d232011-06-25 18:42:55 +020058 .role = E1INP_LINE_R_BTS,
59 .addr = "127.0.0.1",
Pablo Neira Ayuso96e81282011-06-09 15:06:11 +020060 .sign_link_up = sign_link_up,
61 .sign_link = sign_link,
62 .error = error,
63 };
64
65#define LINENR 0
66
Pablo Neira Ayusof163d232011-06-25 18:42:55 +020067 line = e1inp_line_create(LINENR, "ipa");
Pablo Neira Ayuso96e81282011-06-09 15:06:11 +020068 if (line == NULL) {
69 LOGP(DBTSTEST, LOGL_ERROR, "problem enabling E1 line\n");
70 exit(EXIT_FAILURE);
71 }
Pablo Neira Ayusof163d232011-06-25 18:42:55 +020072 e1inp_line_bind_ops(line, &ops);
Pablo Neira Ayuso96e81282011-06-09 15:06:11 +020073
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 Ayusof163d232011-06-25 18:42:55 +020085 if (e1inp_line_update(line) < 0) {
Pablo Neira Ayuso96e81282011-06-09 15:06:11 +020086 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}