Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 1 | /* OpenBSC E1 Input code */ |
| 2 | |
| 3 | /* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> |
| 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Affero General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU Affero General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Affero General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | */ |
| 20 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 21 | #include <string.h> |
| 22 | #include <errno.h> |
| 23 | |
Harald Welte | 25de991 | 2009-04-30 15:53:07 +0000 | [diff] [blame] | 24 | #include <netinet/in.h> |
| 25 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 26 | #include <openbsc/gsm_data.h> |
| 27 | #include <openbsc/e1_input.h> |
Harald Welte | 45b407a | 2009-05-23 15:51:12 +0000 | [diff] [blame] | 28 | #include <openbsc/trau_frame.h> |
Harald Welte | 39a1b71 | 2009-02-10 17:17:09 +0000 | [diff] [blame] | 29 | #include <openbsc/trau_mux.h> |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 30 | #include <openbsc/misdn.h> |
Holger Hans Peter Freyther | 34e9749 | 2009-08-10 07:54:02 +0200 | [diff] [blame] | 31 | #include <openbsc/ipaccess.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 32 | #include <osmocom/core/talloc.h> |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 33 | #include <openbsc/debug.h> |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 34 | |
| 35 | #define SAPI_L2ML 0 |
| 36 | #define SAPI_OML 62 |
| 37 | #define SAPI_RSL 0 /* 63 ? */ |
| 38 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 39 | /* The e1_reconfig_*() functions below tale the configuration present in the |
| 40 | * bts/trx/ts data structures and ensure the E1 configuration reflects the |
| 41 | * timeslot/subslot/TEI configuration */ |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 42 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 43 | int e1_reconfig_ts(struct gsm_bts_trx_ts *ts) |
| 44 | { |
| 45 | struct gsm_e1_subslot *e1_link = &ts->e1_link; |
| 46 | struct e1inp_line *line; |
| 47 | struct e1inp_ts *e1_ts; |
| 48 | |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 49 | DEBUGP(DMI, "e1_reconfig_ts(%u,%u,%u)\n", ts->trx->bts->nr, ts->trx->nr, ts->nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 50 | |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 51 | if (!e1_link->e1_ts) { |
| 52 | LOGP(DINP, LOGL_ERROR, "TS (%u/%u/%u) without E1 timeslot?\n", |
| 53 | ts->nr, ts->trx->nr, ts->trx->bts->nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 54 | return 0; |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 55 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 56 | |
Harald Welte | 3016d9f | 2011-02-05 13:54:41 +0100 | [diff] [blame] | 57 | line = e1inp_line_get(e1_link->e1_nr); |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 58 | if (!line) { |
| 59 | LOGP(DINP, LOGL_ERROR, "TS (%u/%u/%u) referring to " |
| 60 | "non-existing E1 line %u\n", ts->nr, ts->trx->nr, |
| 61 | ts->trx->bts->nr, e1_link->e1_nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 62 | return -ENOMEM; |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 63 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 64 | |
| 65 | switch (ts->pchan) { |
| 66 | case GSM_PCHAN_TCH_F: |
| 67 | case GSM_PCHAN_TCH_H: |
| 68 | e1_ts = &line->ts[e1_link->e1_ts-1]; |
| 69 | e1inp_ts_config(e1_ts, line, E1INP_TS_TYPE_TRAU); |
| 70 | subch_demux_activate(&e1_ts->trau.demux, e1_link->e1_ts_ss); |
| 71 | break; |
| 72 | default: |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | int e1_reconfig_trx(struct gsm_bts_trx *trx) |
| 80 | { |
| 81 | struct gsm_e1_subslot *e1_link = &trx->rsl_e1_link; |
| 82 | struct e1inp_ts *sign_ts; |
| 83 | struct e1inp_line *line; |
| 84 | struct e1inp_sign_link *rsl_link; |
| 85 | int i; |
| 86 | |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 87 | if (!e1_link->e1_ts) { |
| 88 | LOGP(DINP, LOGL_ERROR, "TRX (%u/%u) RSL link without " |
| 89 | "timeslot?\n", trx->bts->nr, trx->nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 90 | return -EINVAL; |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 91 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 92 | |
| 93 | /* RSL Link */ |
Harald Welte | 3016d9f | 2011-02-05 13:54:41 +0100 | [diff] [blame] | 94 | line = e1inp_line_get(e1_link->e1_nr); |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 95 | if (!line) { |
| 96 | LOGP(DINP, LOGL_ERROR, "TRX (%u/%u) RSL link referring " |
| 97 | "to non-existing E1 line %u\n", trx->bts->nr, |
| 98 | trx->nr, e1_link->e1_nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 99 | return -ENOMEM; |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 100 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 101 | sign_ts = &line->ts[e1_link->e1_ts-1]; |
| 102 | e1inp_ts_config(sign_ts, line, E1INP_TS_TYPE_SIGN); |
Harald Welte | 15ccc77 | 2011-02-13 19:36:18 +0100 | [diff] [blame] | 103 | /* Ericsson RBS have a per-TRX OML link in parallel to RSL */ |
Harald Welte | c834b70 | 2011-02-13 15:41:09 +0100 | [diff] [blame] | 104 | if (trx->bts->type == GSM_BTS_TYPE_RBS2000) { |
Harald Welte | 15ccc77 | 2011-02-13 19:36:18 +0100 | [diff] [blame] | 105 | struct e1inp_sign_link *oml_link; |
| 106 | oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML, trx, |
| 107 | trx->rsl_tei, SAPI_OML); |
| 108 | if (!oml_link) { |
Harald Welte | 4d54d0b | 2011-02-19 16:48:17 +0100 | [diff] [blame] | 109 | LOGP(DINP, LOGL_ERROR, "TRX (%u/%u) OML link creation " |
Harald Welte | 15ccc77 | 2011-02-13 19:36:18 +0100 | [diff] [blame] | 110 | "failed\n", trx->bts->nr, trx->nr); |
| 111 | return -ENOMEM; |
| 112 | } |
| 113 | if (trx->oml_link) |
| 114 | e1inp_sign_link_destroy(trx->oml_link); |
| 115 | trx->oml_link = oml_link; |
Harald Welte | c834b70 | 2011-02-13 15:41:09 +0100 | [diff] [blame] | 116 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 117 | rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL, |
| 118 | trx, trx->rsl_tei, SAPI_RSL); |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 119 | if (!rsl_link) { |
| 120 | LOGP(DINP, LOGL_ERROR, "TRX (%u/%u) RSL link creation " |
| 121 | "failed\n", trx->bts->nr, trx->nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 122 | return -ENOMEM; |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 123 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 124 | if (trx->rsl_link) |
| 125 | e1inp_sign_link_destroy(trx->rsl_link); |
| 126 | trx->rsl_link = rsl_link; |
| 127 | |
| 128 | for (i = 0; i < TRX_NR_TS; i++) |
| 129 | e1_reconfig_ts(&trx->ts[i]); |
| 130 | |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | int e1_reconfig_bts(struct gsm_bts *bts) |
| 135 | { |
| 136 | struct gsm_e1_subslot *e1_link = &bts->oml_e1_link; |
| 137 | struct e1inp_ts *sign_ts; |
| 138 | struct e1inp_line *line; |
| 139 | struct e1inp_sign_link *oml_link; |
| 140 | struct gsm_bts_trx *trx; |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 141 | |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 142 | DEBUGP(DMI, "e1_reconfig_bts(%u)\n", bts->nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 143 | |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 144 | if (!e1_link->e1_ts) { |
| 145 | LOGP(DINP, LOGL_ERROR, "BTS %u OML link without timeslot?\n", |
| 146 | bts->nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 147 | return -EINVAL; |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 148 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 149 | |
| 150 | /* OML link */ |
Harald Welte | 3016d9f | 2011-02-05 13:54:41 +0100 | [diff] [blame] | 151 | line = e1inp_line_get(e1_link->e1_nr); |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 152 | if (!line) { |
| 153 | LOGP(DINP, LOGL_ERROR, "BTS %u OML link referring to " |
| 154 | "non-existing E1 line %u\n", bts->nr, e1_link->e1_nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 155 | return -ENOMEM; |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 156 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 157 | sign_ts = &line->ts[e1_link->e1_ts-1]; |
| 158 | e1inp_ts_config(sign_ts, line, E1INP_TS_TYPE_SIGN); |
| 159 | oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML, |
| 160 | bts->c0, bts->oml_tei, SAPI_OML); |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 161 | if (!oml_link) { |
| 162 | LOGP(DINP, LOGL_ERROR, "BTS %u OML link creation failed\n", |
| 163 | bts->nr); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 164 | return -ENOMEM; |
Harald Welte | 889f16e | 2011-02-05 15:41:24 +0100 | [diff] [blame] | 165 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 166 | if (bts->oml_link) |
| 167 | e1inp_sign_link_destroy(bts->oml_link); |
| 168 | bts->oml_link = oml_link; |
| 169 | |
| 170 | llist_for_each_entry(trx, &bts->trx_list, list) |
| 171 | e1_reconfig_trx(trx); |
| 172 | |
| 173 | /* notify E1 input something has changed */ |
| 174 | return e1inp_line_update(line); |
| 175 | } |
| 176 | |
| 177 | #if 0 |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 178 | /* do some compiled-in configuration for our BTS/E1 setup */ |
Holger Freyther | b5c00f5 | 2009-04-22 22:08:07 +0000 | [diff] [blame] | 179 | int e1_config(struct gsm_bts *bts, int cardnr, int release_l2) |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 180 | { |
| 181 | struct e1inp_line *line; |
| 182 | struct e1inp_ts *sign_ts; |
| 183 | struct e1inp_sign_link *oml_link, *rsl_link; |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 184 | struct gsm_bts_trx *trx = bts->c0; |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 185 | int base_ts; |
| 186 | |
| 187 | switch (bts->nr) { |
| 188 | case 0: |
| 189 | /* First BTS uses E1 TS 01,02,03,04,05 */ |
Harald Welte | 63589be | 2009-08-06 17:38:10 +0200 | [diff] [blame] | 190 | base_ts = HARDCODED_BTS0_TS - 1; |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 191 | break; |
| 192 | case 1: |
Harald Welte | 63589be | 2009-08-06 17:38:10 +0200 | [diff] [blame] | 193 | /* Second BTS uses E1 TS 06,07,08,09,10 */ |
| 194 | base_ts = HARDCODED_BTS1_TS - 1; |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 195 | break; |
| 196 | case 2: |
Harald Welte | 63589be | 2009-08-06 17:38:10 +0200 | [diff] [blame] | 197 | /* Third BTS uses E1 TS 11,12,13,14,15 */ |
| 198 | base_ts = HARDCODED_BTS2_TS - 1; |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 199 | default: |
| 200 | return -EINVAL; |
| 201 | } |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 202 | |
Harald Welte | 470ec29 | 2009-06-26 20:25:23 +0200 | [diff] [blame] | 203 | line = talloc_zero(tall_bsc_ctx, struct e1inp_line); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 204 | if (!line) |
| 205 | return -ENOMEM; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 206 | |
| 207 | /* create E1 timeslots for signalling and TRAU frames */ |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 208 | e1inp_ts_config(&line->ts[base_ts+1-1], line, E1INP_TS_TYPE_SIGN); |
| 209 | e1inp_ts_config(&line->ts[base_ts+2-1], line, E1INP_TS_TYPE_TRAU); |
| 210 | e1inp_ts_config(&line->ts[base_ts+3-1], line, E1INP_TS_TYPE_TRAU); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 211 | |
| 212 | /* create signalling links for TS1 */ |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 213 | sign_ts = &line->ts[base_ts+1-1]; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 214 | oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML, |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 215 | trx, TEI_OML, SAPI_OML); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 216 | rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL, |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 217 | trx, TEI_RSL, SAPI_RSL); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 218 | |
| 219 | /* create back-links from bts/trx */ |
| 220 | bts->oml_link = oml_link; |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 221 | trx->rsl_link = rsl_link; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 222 | |
Harald Welte | 11fa29c | 2009-02-19 17:24:39 +0000 | [diff] [blame] | 223 | /* enable subchannel demuxer on TS2 */ |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 224 | subch_demux_activate(&line->ts[base_ts+2-1].trau.demux, 1); |
| 225 | subch_demux_activate(&line->ts[base_ts+2-1].trau.demux, 2); |
| 226 | subch_demux_activate(&line->ts[base_ts+2-1].trau.demux, 3); |
Harald Welte | 93d3f37 | 2009-02-18 03:27:14 +0000 | [diff] [blame] | 227 | |
Harald Welte | 11fa29c | 2009-02-19 17:24:39 +0000 | [diff] [blame] | 228 | /* enable subchannel demuxer on TS3 */ |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 229 | subch_demux_activate(&line->ts[base_ts+3-1].trau.demux, 0); |
| 230 | subch_demux_activate(&line->ts[base_ts+3-1].trau.demux, 1); |
| 231 | subch_demux_activate(&line->ts[base_ts+3-1].trau.demux, 2); |
| 232 | subch_demux_activate(&line->ts[base_ts+3-1].trau.demux, 3); |
Harald Welte | 11fa29c | 2009-02-19 17:24:39 +0000 | [diff] [blame] | 233 | |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 234 | trx = gsm_bts_trx_num(bts, 1); |
| 235 | if (trx) { |
| 236 | /* create E1 timeslots for TRAU frames of TRX1 */ |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 237 | e1inp_ts_config(&line->ts[base_ts+4-1], line, E1INP_TS_TYPE_TRAU); |
| 238 | e1inp_ts_config(&line->ts[base_ts+5-1], line, E1INP_TS_TYPE_TRAU); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 239 | |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 240 | /* create RSL signalling link for TRX1 */ |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 241 | sign_ts = &line->ts[base_ts+1-1]; |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 242 | rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL, |
| 243 | trx, TEI_RSL+1, SAPI_RSL); |
| 244 | /* create back-links from trx */ |
| 245 | trx->rsl_link = rsl_link; |
| 246 | |
| 247 | /* enable subchannel demuxer on TS2 */ |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 248 | subch_demux_activate(&line->ts[base_ts+4-1].trau.demux, 0); |
| 249 | subch_demux_activate(&line->ts[base_ts+4-1].trau.demux, 1); |
| 250 | subch_demux_activate(&line->ts[base_ts+4-1].trau.demux, 2); |
| 251 | subch_demux_activate(&line->ts[base_ts+4-1].trau.demux, 3); |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 252 | |
| 253 | /* enable subchannel demuxer on TS3 */ |
Harald Welte | 4e55d68 | 2009-08-04 14:13:35 +0200 | [diff] [blame] | 254 | subch_demux_activate(&line->ts[base_ts+5-1].trau.demux, 0); |
| 255 | subch_demux_activate(&line->ts[base_ts+5-1].trau.demux, 1); |
| 256 | subch_demux_activate(&line->ts[base_ts+5-1].trau.demux, 2); |
| 257 | subch_demux_activate(&line->ts[base_ts+5-1].trau.demux, 3); |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 258 | } |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 259 | |
Holger Freyther | b5c00f5 | 2009-04-22 22:08:07 +0000 | [diff] [blame] | 260 | return mi_setup(cardnr, line, release_l2); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 261 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 262 | #endif |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 263 | |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 264 | /* configure pseudo E1 line in ip.access style and connect to BTS */ |
| 265 | int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin) |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 266 | { |
| 267 | struct e1inp_line *line; |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 268 | struct e1inp_ts *sign_ts, *rsl_ts; |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 269 | struct e1inp_sign_link *oml_link, *rsl_link; |
| 270 | |
Harald Welte | 470ec29 | 2009-06-26 20:25:23 +0200 | [diff] [blame] | 271 | line = talloc_zero(tall_bsc_ctx, struct e1inp_line); |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 272 | if (!line) |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 273 | return -ENOMEM; |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 274 | |
| 275 | /* create E1 timeslots for signalling and TRAU frames */ |
| 276 | e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN); |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 277 | e1inp_ts_config(&line->ts[2-1], line, E1INP_TS_TYPE_SIGN); |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 278 | |
| 279 | /* create signalling links for TS1 */ |
| 280 | sign_ts = &line->ts[1-1]; |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 281 | rsl_ts = &line->ts[2-1]; |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 282 | oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML, |
Harald Welte | d99fb99 | 2009-10-20 21:54:06 +0200 | [diff] [blame] | 283 | bts->c0, 0xff, 0); |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 284 | rsl_link = e1inp_sign_link_create(rsl_ts, E1INP_SIGN_RSL, |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 285 | bts->c0, 0, 0); |
| 286 | |
| 287 | /* create back-links from bts/trx */ |
| 288 | bts->oml_link = oml_link; |
| 289 | bts->c0->rsl_link = rsl_link; |
| 290 | |
Harald Welte | 25de991 | 2009-04-30 15:53:07 +0000 | [diff] [blame] | 291 | /* default port at BTS for incoming connections is 3006 */ |
| 292 | if (sin->sin_port == 0) |
| 293 | sin->sin_port = htons(3006); |
| 294 | |
| 295 | return ipaccess_connect(line, sin); |
| 296 | } |