2009-02-09 18:13:26 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2009-04-30 15:53:07 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2009-02-09 18:13:26 +00:00
|
|
|
#include <openbsc/gsm_data.h>
|
|
|
|
#include <openbsc/e1_input.h>
|
2009-05-23 15:51:12 +00:00
|
|
|
#include <openbsc/trau_frame.h>
|
2009-02-10 17:17:09 +00:00
|
|
|
#include <openbsc/trau_mux.h>
|
2009-03-09 16:17:14 +00:00
|
|
|
#include <openbsc/misdn.h>
|
2009-02-09 18:13:26 +00:00
|
|
|
|
|
|
|
#define SAPI_L2ML 0
|
|
|
|
#define SAPI_OML 62
|
|
|
|
#define SAPI_RSL 0 /* 63 ? */
|
|
|
|
|
|
|
|
#define TEI_L2ML 127
|
|
|
|
#define TEI_OML 25
|
|
|
|
#define TEI_RSL 1
|
|
|
|
|
|
|
|
/* do some compiled-in configuration for our BTS/E1 setup */
|
2009-04-22 22:08:07 +00:00
|
|
|
int e1_config(struct gsm_bts *bts, int cardnr, int release_l2)
|
2009-02-09 18:13:26 +00:00
|
|
|
{
|
|
|
|
struct e1inp_line *line;
|
|
|
|
struct e1inp_ts *sign_ts;
|
|
|
|
struct e1inp_sign_link *oml_link, *rsl_link;
|
|
|
|
|
|
|
|
line = malloc(sizeof(*line));
|
|
|
|
if (!line)
|
|
|
|
return -ENOMEM;
|
|
|
|
memset(line, 0, sizeof(*line));
|
|
|
|
|
|
|
|
/* create E1 timeslots for signalling and TRAU frames */
|
|
|
|
e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
|
|
|
|
e1inp_ts_config(&line->ts[2-1], line, E1INP_TS_TYPE_TRAU);
|
2009-04-29 16:21:34 +00:00
|
|
|
e1inp_ts_config(&line->ts[3-1], line, E1INP_TS_TYPE_TRAU);
|
2009-02-09 18:13:26 +00:00
|
|
|
|
|
|
|
/* create signalling links for TS1 */
|
|
|
|
sign_ts = &line->ts[1-1];
|
|
|
|
oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
|
|
|
|
bts->c0, TEI_OML, SAPI_OML);
|
|
|
|
rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
|
|
|
|
bts->c0, TEI_RSL, SAPI_RSL);
|
|
|
|
|
|
|
|
/* create back-links from bts/trx */
|
|
|
|
bts->oml_link = oml_link;
|
|
|
|
bts->c0->rsl_link = rsl_link;
|
|
|
|
|
2009-02-19 17:24:39 +00:00
|
|
|
/* enable subchannel demuxer on TS2 */
|
|
|
|
subch_demux_activate(&line->ts[2-1].trau.demux, 1);
|
|
|
|
subch_demux_activate(&line->ts[2-1].trau.demux, 2);
|
|
|
|
subch_demux_activate(&line->ts[2-1].trau.demux, 3);
|
|
|
|
|
|
|
|
/* enable subchannel demuxer on TS3 */
|
|
|
|
subch_demux_activate(&line->ts[3-1].trau.demux, 0);
|
|
|
|
subch_demux_activate(&line->ts[3-1].trau.demux, 1);
|
|
|
|
subch_demux_activate(&line->ts[3-1].trau.demux, 2);
|
|
|
|
subch_demux_activate(&line->ts[3-1].trau.demux, 3);
|
2009-02-18 03:27:14 +00:00
|
|
|
|
2009-02-10 17:17:09 +00:00
|
|
|
#ifdef HAVE_TRX1
|
|
|
|
/* create E1 timeslots for TRAU frames of TRX1 */
|
2009-02-09 18:13:26 +00:00
|
|
|
e1inp_ts_config(&line->ts[4-1], line, E1INP_TS_TYPE_TRAU);
|
|
|
|
e1inp_ts_config(&line->ts[5-1], line, E1INP_TS_TYPE_TRAU);
|
|
|
|
|
2009-02-10 17:17:09 +00:00
|
|
|
/* create RSL signalling link for TRX1 */
|
2009-02-09 18:13:26 +00:00
|
|
|
sign_ts = &line->ts[1-1];
|
|
|
|
rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
|
|
|
|
&bts->trx[1], TEI_RSL+1, SAPI_RSL);
|
|
|
|
/* create back-links from trx */
|
|
|
|
bts->trx[1].rsl_link = rsl_link;
|
|
|
|
#endif
|
|
|
|
|
2009-04-22 22:08:07 +00:00
|
|
|
return mi_setup(cardnr, line, release_l2);
|
2009-02-09 18:13:26 +00:00
|
|
|
}
|
2009-02-13 02:43:36 +00:00
|
|
|
|
2009-05-01 14:59:07 +00:00
|
|
|
/* configure pseudo E1 line in ip.access style and connect to BTS */
|
|
|
|
int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin)
|
2009-02-13 02:43:36 +00:00
|
|
|
{
|
|
|
|
struct e1inp_line *line;
|
2009-02-15 11:57:29 +00:00
|
|
|
struct e1inp_ts *sign_ts, *rsl_ts;
|
2009-02-13 02:43:36 +00:00
|
|
|
struct e1inp_sign_link *oml_link, *rsl_link;
|
|
|
|
|
|
|
|
line = malloc(sizeof(*line));
|
|
|
|
if (!line)
|
2009-04-30 15:53:07 +00:00
|
|
|
return NULL;
|
2009-02-13 02:43:36 +00:00
|
|
|
memset(line, 0, sizeof(*line));
|
|
|
|
|
|
|
|
/* create E1 timeslots for signalling and TRAU frames */
|
|
|
|
e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
|
2009-02-15 11:57:29 +00:00
|
|
|
e1inp_ts_config(&line->ts[2-1], line, E1INP_TS_TYPE_SIGN);
|
2009-02-13 02:43:36 +00:00
|
|
|
|
|
|
|
/* create signalling links for TS1 */
|
|
|
|
sign_ts = &line->ts[1-1];
|
2009-02-15 11:57:29 +00:00
|
|
|
rsl_ts = &line->ts[2-1];
|
2009-02-13 02:43:36 +00:00
|
|
|
oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
|
|
|
|
bts->c0, 0, 0xff);
|
2009-02-15 11:57:29 +00:00
|
|
|
rsl_link = e1inp_sign_link_create(rsl_ts, E1INP_SIGN_RSL,
|
2009-02-13 02:43:36 +00:00
|
|
|
bts->c0, 0, 0);
|
|
|
|
|
|
|
|
/* create back-links from bts/trx */
|
|
|
|
bts->oml_link = oml_link;
|
|
|
|
bts->c0->rsl_link = rsl_link;
|
|
|
|
|
2009-04-30 15:53:07 +00:00
|
|
|
/* default port at BTS for incoming connections is 3006 */
|
|
|
|
if (sin->sin_port == 0)
|
|
|
|
sin->sin_port = htons(3006);
|
|
|
|
|
|
|
|
return ipaccess_connect(line, sin);
|
|
|
|
}
|