blob: 9863c9e470167b2b3a361786172e522bba9f8786 [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>
Harald Welte1fa60c82009-02-09 18:13:26 +00007
8#define SAPI_L2ML 0
9#define SAPI_OML 62
10#define SAPI_RSL 0 /* 63 ? */
11
12#define TEI_L2ML 127
13#define TEI_OML 25
14#define TEI_RSL 1
15
16/* do some compiled-in configuration for our BTS/E1 setup */
17int e1_config(struct gsm_bts *bts)
18{
19 struct e1inp_line *line;
20 struct e1inp_ts *sign_ts;
21 struct e1inp_sign_link *oml_link, *rsl_link;
22
23 line = malloc(sizeof(*line));
24 if (!line)
25 return -ENOMEM;
26 memset(line, 0, sizeof(*line));
27
28 /* create E1 timeslots for signalling and TRAU frames */
29 e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
30 e1inp_ts_config(&line->ts[2-1], line, E1INP_TS_TYPE_TRAU);
31 e1inp_ts_config(&line->ts[3-1], line, E1INP_TS_TYPE_TRAU);
32
33 /* create signalling links for TS1 */
34 sign_ts = &line->ts[1-1];
35 oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
36 bts->c0, TEI_OML, SAPI_OML);
37 rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
38 bts->c0, TEI_RSL, SAPI_RSL);
39
40 /* create back-links from bts/trx */
41 bts->oml_link = oml_link;
42 bts->c0->rsl_link = rsl_link;
43
Harald Welte39a1b712009-02-10 17:17:09 +000044 /* configure a static mapping between on-air TS1 and TS2
45 * since we don't yet have code to dynamically switch the
46 * voice channels */
47 {
48 struct gsm_e1_subslot src_ss, dst_ss;
49 src_ss.e1_nr = dst_ss.e1_nr = 0;
50 src_ss.e1_ts = dst_ss.e1_ts = 2;
51 src_ss.e1_ts_ss = 1; dst_ss.e1_ts_ss = 2;
52 trau_mux_map(&src_ss, &dst_ss);
53 }
54#ifdef HAVE_TRX1
55 /* create E1 timeslots for TRAU frames of TRX1 */
Harald Welte1fa60c82009-02-09 18:13:26 +000056 e1inp_ts_config(&line->ts[4-1], line, E1INP_TS_TYPE_TRAU);
57 e1inp_ts_config(&line->ts[5-1], line, E1INP_TS_TYPE_TRAU);
58
Harald Welte39a1b712009-02-10 17:17:09 +000059 /* create RSL signalling link for TRX1 */
Harald Welte1fa60c82009-02-09 18:13:26 +000060 sign_ts = &line->ts[1-1];
61 rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
62 &bts->trx[1], TEI_RSL+1, SAPI_RSL);
63 /* create back-links from trx */
64 bts->trx[1].rsl_link = rsl_link;
65#endif
66
67 return mi_setup(0, line, NULL);
68}
Harald Welte5fd8a542009-02-13 02:43:36 +000069
70/* do some compiled-in configuration for our BTS/E1 setup */
71int ia_config(struct gsm_bts *bts)
72{
73 struct e1inp_line *line;
74 struct e1inp_ts *sign_ts;
75 struct e1inp_sign_link *oml_link, *rsl_link;
76
77 line = malloc(sizeof(*line));
78 if (!line)
79 return -ENOMEM;
80 memset(line, 0, sizeof(*line));
81
82 /* create E1 timeslots for signalling and TRAU frames */
83 e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
84
85 /* create signalling links for TS1 */
86 sign_ts = &line->ts[1-1];
87 oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
88 bts->c0, 0, 0xff);
89 rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
90 bts->c0, 0, 0);
91
92 /* create back-links from bts/trx */
93 bts->oml_link = oml_link;
94 bts->c0->rsl_link = rsl_link;
95
96 return ipaccess_setup(line);
97}