blob: 96ecec9c62a4b30918aa7ec8abb044648e69eae0 [file] [log] [blame]
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +02001#include <stdio.h>
Pablo Neira Ayuso54b49792011-06-07 12:15:26 +02002#include <talloc.h>
3#include <osmocom/abis/abis.h>
Pablo Neira Ayuso177094b2011-06-07 12:21:51 +02004#include <osmocom/abis/e1_input.h>
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +02005
Pablo Neira Ayuso54b49792011-06-07 12:15:26 +02006static void *tall_test;
7
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +02008static int rx_cb(struct msgb *msg, struct e1inp_ts *ts)
9{
10 printf("received data\n");
11
12 /* For ISDN: from the timeslot type, we can get if it's:
13 * - E1INP_TS_TYPE_SIGN: in this case, check if we have a signal
14 * link in this timeslot, then, check if it's OML or RSL and pass
15 * it to the upper layer.
16 * - E1INP_TS_TYPE_TRAU.
17 *
18 * For INET: we have to check if this is a control message, if it's
19 * a response to previous request id, we enable the signal links for
20 * OML and RSL. Otherwise, look up for the existing signal link and
21 * pass it to the upper layer. We don't receive TRAU frames, we use
22 * RTP.
23 */
24 return 0;
25}
26
27static int rx_err_cb(int error)
28{
29 printf("error, malformed message\n");
30 return 0;
31}
32
33int main(void)
34{
35 struct e1inp_line *line;
36 struct e1inp_ts *sign_ts;
37
Pablo Neira Ayuso54b49792011-06-07 12:15:26 +020038 tall_test = talloc_named_const(NULL, 1, "e1inp_test");
39 libosmo_abis_init(tall_test);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020040
41#define LINENR 0
42
43 line = e1inp_line_create(LINENR, "ipa", rx_cb, rx_err_cb);
44 if (line == NULL) {
45 fprintf(stderr, "problem creating E1 line\n");
46 exit(EXIT_FAILURE);
47 }
48 sign_ts = &line->ts[0];
49 if (e1inp_ts_config_sign(sign_ts, line) < 0) {
50 fprintf(stderr, "problem setting timeslot in E1 line\n");
51 exit(EXIT_FAILURE);
52 }
53
54 /*
55 * Depending if this is a real or virtual E1 lines:
56 * - real (ISDN): create signal link for OML and RSL before line up.
57 * - vitual (INET): we create it once we have seen response to REQ_ID.
58 *
59 * The signal link is created via e1inp_sign_link_create(...)
60 *
61 * See e1_reconfig_trx and e1_reconfig_bts in libbsc/e1_config.c,
62 * it explains how this is done with ISDN.
63 */
64
65 if (e1inp_line_update(line, E1INP_LINE_R_BSC) < 0) {
66 fprintf(stderr, "problem enabling E1 line\n");
67 exit(EXIT_FAILURE);
68 }
69
70 while (1) {
71 osmo_select_main(0);
72 }
73 return 0;
74}