blob: 0aef19d570534bdd6caa81875419c37681207d51 [file] [log] [blame]
Harald Welte1fa60c82009-02-09 18:13:26 +00001#include <string.h>
2#include <errno.h>
3
4#include <openbsc/gsm_data.h>
5#include <openbsc/e1_input.h>
Harald Welte39a1b712009-02-10 17:17:09 +00006#include <openbsc/trau_mux.h>
Holger Freytherff9592f2009-03-09 16:17:14 +00007#include <openbsc/misdn.h>
Harald Welte1fa60c82009-02-09 18:13:26 +00008
9#define SAPI_L2ML 0
10#define SAPI_OML 62
11#define SAPI_RSL 0 /* 63 ? */
12
13#define TEI_L2ML 127
14#define TEI_OML 25
15#define TEI_RSL 1
16
17/* do some compiled-in configuration for our BTS/E1 setup */
18int e1_config(struct gsm_bts *bts)
19{
20 struct e1inp_line *line;
21 struct e1inp_ts *sign_ts;
22 struct e1inp_sign_link *oml_link, *rsl_link;
23
24 line = malloc(sizeof(*line));
25 if (!line)
26 return -ENOMEM;
27 memset(line, 0, sizeof(*line));
28
29 /* create E1 timeslots for signalling and TRAU frames */
30 e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
31 e1inp_ts_config(&line->ts[2-1], line, E1INP_TS_TYPE_TRAU);
Harald Welte93d3f372009-02-18 03:27:14 +000032 //e1inp_ts_config(&line->ts[3-1], line, E1INP_TS_TYPE_TRAU);
Harald Welte1fa60c82009-02-09 18:13:26 +000033
34 /* create signalling links for TS1 */
35 sign_ts = &line->ts[1-1];
36 oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
37 bts->c0, TEI_OML, SAPI_OML);
38 rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
39 bts->c0, TEI_RSL, SAPI_RSL);
40
41 /* create back-links from bts/trx */
42 bts->oml_link = oml_link;
43 bts->c0->rsl_link = rsl_link;
44
Harald Welte11fa29c2009-02-19 17:24:39 +000045 /* enable subchannel demuxer on TS2 */
46 subch_demux_activate(&line->ts[2-1].trau.demux, 1);
47 subch_demux_activate(&line->ts[2-1].trau.demux, 2);
48 subch_demux_activate(&line->ts[2-1].trau.demux, 3);
Harald Welte93d3f372009-02-18 03:27:14 +000049
Harald Welte11fa29c2009-02-19 17:24:39 +000050#if 0
51 /* enable subchannel demuxer on TS3 */
52 subch_demux_activate(&line->ts[3-1].trau.demux, 0);
53 subch_demux_activate(&line->ts[3-1].trau.demux, 1);
54 subch_demux_activate(&line->ts[3-1].trau.demux, 2);
55 subch_demux_activate(&line->ts[3-1].trau.demux, 3);
56#endif
57
Harald Welte39a1b712009-02-10 17:17:09 +000058#ifdef HAVE_TRX1
59 /* create E1 timeslots for TRAU frames of TRX1 */
Harald Welte1fa60c82009-02-09 18:13:26 +000060 e1inp_ts_config(&line->ts[4-1], line, E1INP_TS_TYPE_TRAU);
61 e1inp_ts_config(&line->ts[5-1], line, E1INP_TS_TYPE_TRAU);
62
Harald Welte39a1b712009-02-10 17:17:09 +000063 /* create RSL signalling link for TRX1 */
Harald Welte1fa60c82009-02-09 18:13:26 +000064 sign_ts = &line->ts[1-1];
65 rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
66 &bts->trx[1], TEI_RSL+1, SAPI_RSL);
67 /* create back-links from trx */
68 bts->trx[1].rsl_link = rsl_link;
69#endif
70
Holger Freytherff9592f2009-03-09 16:17:14 +000071 return mi_setup(0, line);
Harald Welte1fa60c82009-02-09 18:13:26 +000072}
Harald Welte5fd8a542009-02-13 02:43:36 +000073
74/* do some compiled-in configuration for our BTS/E1 setup */
75int ia_config(struct gsm_bts *bts)
76{
77 struct e1inp_line *line;
Harald Welte5c1e4582009-02-15 11:57:29 +000078 struct e1inp_ts *sign_ts, *rsl_ts;
Harald Welte5fd8a542009-02-13 02:43:36 +000079 struct e1inp_sign_link *oml_link, *rsl_link;
80
81 line = malloc(sizeof(*line));
82 if (!line)
83 return -ENOMEM;
84 memset(line, 0, sizeof(*line));
85
86 /* create E1 timeslots for signalling and TRAU frames */
87 e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
Harald Welte5c1e4582009-02-15 11:57:29 +000088 e1inp_ts_config(&line->ts[2-1], line, E1INP_TS_TYPE_SIGN);
Harald Welte5fd8a542009-02-13 02:43:36 +000089
90 /* create signalling links for TS1 */
91 sign_ts = &line->ts[1-1];
Harald Welte5c1e4582009-02-15 11:57:29 +000092 rsl_ts = &line->ts[2-1];
Harald Welte5fd8a542009-02-13 02:43:36 +000093 oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
94 bts->c0, 0, 0xff);
Harald Welte5c1e4582009-02-15 11:57:29 +000095 rsl_link = e1inp_sign_link_create(rsl_ts, E1INP_SIGN_RSL,
Harald Welte5fd8a542009-02-13 02:43:36 +000096 bts->c0, 0, 0);
97
98 /* create back-links from bts/trx */
99 bts->oml_link = oml_link;
100 bts->c0->rsl_link = rsl_link;
101
102 return ipaccess_setup(line);
103}