Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1 | /* GSM 04.08 System Information (SI) encoding and decoding |
| 2 | * 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */ |
| 3 | |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 4 | /* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 5 | * (C) 2012 Holger Hans Peter Freyther |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 6 | * |
| 7 | * All Rights Reserved |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 10 | * it under the terms of the GNU Affero General Public License as published by |
| 11 | * the Free Software Foundation; either version 3 of the License, or |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 17 | * GNU Affero General Public License for more details. |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 18 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <errno.h> |
| 25 | #include <string.h> |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 26 | #include <stdio.h> |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 27 | #include <netinet/in.h> |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 28 | #include <stdbool.h> |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 29 | |
Harald Welte | 80cffaf | 2011-05-24 15:02:20 +0200 | [diff] [blame] | 30 | #include <osmocom/core/bitvec.h> |
| 31 | #include <osmocom/core/utils.h> |
| 32 | #include <osmocom/gsm/sysinfo.h> |
Neels Hofmeyr | 7b65688 | 2017-07-09 22:09:18 +0200 | [diff] [blame] | 33 | #include <osmocom/gsm/gsm48_ie.h> |
| 34 | #include <osmocom/gsm/gsm48.h> |
Harald Welte | 80cffaf | 2011-05-24 15:02:20 +0200 | [diff] [blame] | 35 | |
Neels Hofmeyr | c016479 | 2017-09-04 15:15:32 +0200 | [diff] [blame^] | 36 | #include <osmocom/bsc/debug.h> |
| 37 | #include <osmocom/bsc/gsm_data.h> |
| 38 | #include <osmocom/bsc/abis_rsl.h> |
| 39 | #include <osmocom/bsc/rest_octets.h> |
| 40 | #include <osmocom/bsc/arfcn_range_encode.h> |
| 41 | #include <osmocom/bsc/gsm_04_08_utils.h> |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 42 | |
Holger Hans Peter Freyther | d4d1d5e | 2013-01-17 13:49:39 +0100 | [diff] [blame] | 43 | /* |
| 44 | * DCS1800 and PCS1900 have overlapping ARFCNs. We would need to set the |
| 45 | * ARFCN_PCS flag on the 1900 ARFCNs but this would increase cell_alloc |
| 46 | * and other arrays to make sure (ARFCN_PCS + 1024)/8 ARFCNs fit into the |
| 47 | * array. DCS1800 and PCS1900 can not be used at the same time so conserve |
| 48 | * memory and do the below. |
| 49 | */ |
| 50 | static int band_compatible(const struct gsm_bts *bts, int arfcn) |
| 51 | { |
| 52 | enum gsm_band band = gsm_arfcn2band(arfcn); |
| 53 | |
| 54 | /* normal case */ |
| 55 | if (band == bts->band) |
| 56 | return 1; |
| 57 | /* deal with ARFCN_PCS not set */ |
| 58 | if (band == GSM_BAND_1800 && bts->band == GSM_BAND_1900) |
| 59 | return 1; |
| 60 | |
| 61 | return 0; |
| 62 | } |
Holger Hans Peter Freyther | b91a106 | 2010-01-06 06:38:14 +0100 | [diff] [blame] | 63 | |
Holger Hans Peter Freyther | f876c39 | 2013-03-06 12:02:33 +0100 | [diff] [blame] | 64 | static int is_dcs_net(const struct gsm_bts *bts) |
| 65 | { |
| 66 | if (bts->band == GSM_BAND_850) |
| 67 | return 0; |
| 68 | if (bts->band == GSM_BAND_1900) |
| 69 | return 0; |
| 70 | return 1; |
| 71 | } |
| 72 | |
Max | 299a999 | 2016-04-28 17:51:15 +0200 | [diff] [blame] | 73 | /* Return p(n) for given NR_OF_TDD_CELLS - see Table 9.1.54.1a, 3GPP TS 44.018 */ |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 74 | unsigned range1024_p(unsigned n) |
| 75 | { |
| 76 | switch (n) { |
| 77 | case 0: return 0; |
| 78 | case 1: return 10; |
| 79 | case 2: return 19; |
| 80 | case 3: return 28; |
| 81 | case 4: return 36; |
| 82 | case 5: return 44; |
| 83 | case 6: return 52; |
| 84 | case 7: return 60; |
| 85 | case 8: return 67; |
| 86 | case 9: return 74; |
| 87 | case 10: return 81; |
| 88 | case 11: return 88; |
| 89 | case 12: return 95; |
| 90 | case 13: return 102; |
| 91 | case 14: return 109; |
| 92 | case 15: return 116; |
| 93 | case 16: return 122; |
| 94 | default: return 0; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /* Return q(m) for given NR_OF_TDD_CELLS - see Table 9.1.54.1b, 3GPP TS 44.018 */ |
| 99 | unsigned range512_q(unsigned m) |
| 100 | { |
| 101 | switch (m) { |
| 102 | case 0: return 0; |
| 103 | case 1: return 9; |
| 104 | case 2: return 17; |
| 105 | case 3: return 25; |
| 106 | case 4: return 32; |
| 107 | case 5: return 39; |
| 108 | case 6: return 46; |
| 109 | case 7: return 53; |
| 110 | case 8: return 59; |
| 111 | case 9: return 65; |
| 112 | case 10: return 71; |
| 113 | case 11: return 77; |
| 114 | case 12: return 83; |
| 115 | case 13: return 89; |
| 116 | case 14: return 95; |
| 117 | case 15: return 101; |
| 118 | case 16: return 106; |
| 119 | case 17: return 111; |
| 120 | case 18: return 116; |
| 121 | case 19: return 121; |
| 122 | case 20: return 126; |
| 123 | default: return 0; |
| 124 | } |
| 125 | } |
| 126 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 127 | size_t si2q_earfcn_count(const struct osmo_earfcn_si2q *e) |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 128 | { |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 129 | unsigned i, ret = 0; |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 130 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 131 | if (!e) |
| 132 | return 0; |
| 133 | |
| 134 | for (i = 0; i < e->length; i++) |
| 135 | if (e->arfcn[i] != OSMO_EARFCN_INVALID) |
| 136 | ret++; |
| 137 | |
| 138 | return ret; |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 139 | } |
| 140 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 141 | /* generate SI2quater messages, return rest octets length of last generated message or negative error code */ |
| 142 | static int make_si2quaters(struct gsm_bts *bts, bool counting) |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 143 | { |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 144 | int rc; |
| 145 | bool memory_exceeded = true; |
| 146 | struct gsm48_system_information_type_2quater *si2q; |
Max | e610e70 | 2016-12-19 13:41:48 +0100 | [diff] [blame] | 147 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 148 | for (bts->si2q_index = 0; bts->si2q_index < SI2Q_MAX_NUM; bts->si2q_index++) { |
| 149 | si2q = GSM_BTS_SI2Q(bts, bts->si2q_index); |
| 150 | if (counting) { /* that's legitimate if we're called for counting purpose: */ |
| 151 | if (bts->si2q_count < bts->si2q_index) |
| 152 | bts->si2q_count = bts->si2q_index; |
| 153 | } else { |
| 154 | memset(si2q, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 155 | |
| 156 | si2q->header.l2_plen = GSM48_LEN2PLEN(22); |
| 157 | si2q->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 158 | si2q->header.skip_indicator = 0; |
| 159 | si2q->header.system_information = GSM48_MT_RR_SYSINFO_2quater; |
| 160 | } |
| 161 | |
| 162 | rc = rest_octets_si2quater(si2q->rest_octets, bts); |
| 163 | if (rc < 0) |
| 164 | return rc; |
| 165 | |
| 166 | if (bts->u_offset >= bts->si_common.uarfcn_length && |
| 167 | bts->e_offset >= si2q_earfcn_count(&bts->si_common.si2quater_neigh_list)) { |
| 168 | memory_exceeded = false; |
| 169 | break; |
Max | e610e70 | 2016-12-19 13:41:48 +0100 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 173 | if (memory_exceeded) |
| 174 | return -ENOMEM; |
Max | e610e70 | 2016-12-19 13:41:48 +0100 | [diff] [blame] | 175 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 176 | return rc; |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 177 | } |
| 178 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 179 | /* we generate SI2q rest octets twice to get proper estimation but it's one time cost anyway */ |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 180 | uint8_t si2q_num(struct gsm_bts *bts) |
Max | aafff96 | 2016-04-20 15:57:14 +0200 | [diff] [blame] | 181 | { |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 182 | int rc = make_si2quaters(bts, true); |
| 183 | uint8_t num = bts->si2q_index + 1; /* number of SI2quater messages */ |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 184 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 185 | /* N. B: si2q_num() should NEVER be called during actualSI2q rest octets generation |
| 186 | we're not re-entrant because of the following code: */ |
| 187 | bts->u_offset = 0; |
| 188 | bts->e_offset = 0; |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 189 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 190 | if (rc < 0) |
| 191 | return 0xFF; /* return impossible index as an indicator of error in generating SI2quater */ |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 192 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 193 | return num; |
Max | aafff96 | 2016-04-20 15:57:14 +0200 | [diff] [blame] | 194 | } |
| 195 | |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 196 | /* 3GPP TS 44.018, Table 9.1.54.1 - prepend diversity bit to scrambling code */ |
Max | 34be86b | 2016-12-16 18:45:51 +0100 | [diff] [blame] | 197 | static inline uint16_t encode_fdd(uint16_t scramble, bool diversity) |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 198 | { |
| 199 | if (diversity) |
| 200 | return scramble | (1 << 9); |
| 201 | return scramble; |
| 202 | } |
| 203 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 204 | int bts_earfcn_add(struct gsm_bts *bts, uint16_t earfcn, uint8_t thresh_hi, uint8_t thresh_lo, uint8_t prio, |
| 205 | uint8_t qrx, uint8_t meas_bw) |
| 206 | { |
| 207 | struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list; |
| 208 | int r = osmo_earfcn_add(e, earfcn, (meas_bw < EARFCN_MEAS_BW_INVALID) ? meas_bw : OSMO_EARFCN_MEAS_INVALID); |
| 209 | |
| 210 | if (r < 0) |
| 211 | return r; |
| 212 | |
| 213 | if (e->thresh_hi && thresh_hi != e->thresh_hi) |
| 214 | r = 1; |
| 215 | |
| 216 | e->thresh_hi = thresh_hi; |
| 217 | |
| 218 | if (thresh_lo != EARFCN_THRESH_LOW_INVALID) { |
| 219 | if (e->thresh_lo_valid && e->thresh_lo != thresh_lo) |
| 220 | r = EARFCN_THRESH_LOW_INVALID; |
| 221 | e->thresh_lo = thresh_lo; |
| 222 | e->thresh_lo_valid = true; |
| 223 | } |
| 224 | |
| 225 | if (qrx != EARFCN_QRXLV_INVALID) { |
| 226 | if (e->qrxlm_valid && e->qrxlm != qrx) |
| 227 | r = EARFCN_QRXLV_INVALID + 1; |
| 228 | e->qrxlm = qrx; |
| 229 | e->qrxlm_valid = true; |
| 230 | } |
| 231 | |
| 232 | if (prio != EARFCN_PRIO_INVALID) { |
| 233 | if (e->prio_valid && e->prio != prio) |
| 234 | r = EARFCN_PRIO_INVALID; |
| 235 | e->prio = prio; |
| 236 | e->prio_valid = true; |
| 237 | } |
| 238 | |
| 239 | return r; |
| 240 | } |
| 241 | |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 242 | int bts_uarfcn_del(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble) |
| 243 | { |
| 244 | uint16_t sc0 = encode_fdd(scramble, false), sc1 = encode_fdd(scramble, true), |
| 245 | *ual = bts->si_common.data.uarfcn_list, |
| 246 | *scl = bts->si_common.data.scramble_list; |
| 247 | size_t len = bts->si_common.uarfcn_length, i; |
| 248 | for (i = 0; i < len; i++) { |
| 249 | if (arfcn == ual[i] && (sc0 == scl[i] || sc1 == scl[i])) { |
| 250 | /* we rely on the assumption that (uarfcn, scramble) |
| 251 | tuple is unique in the lists */ |
| 252 | if (i != len - 1) { /* move the tail if necessary */ |
| 253 | memmove(ual + i, ual + i + 1, 2 * (len - i + 1)); |
| 254 | memmove(scl + i, scl + i + 1, 2 * (len - i + 1)); |
| 255 | } |
| 256 | break; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | if (i == len) |
| 261 | return -EINVAL; |
| 262 | |
| 263 | bts->si_common.uarfcn_length--; |
| 264 | return 0; |
| 265 | } |
| 266 | |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 267 | int bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble, bool diversity) |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 268 | { |
Max | e610e70 | 2016-12-19 13:41:48 +0100 | [diff] [blame] | 269 | size_t len = bts->si_common.uarfcn_length, i, k = 0; |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 270 | uint16_t scr, chk, |
| 271 | *ual = bts->si_common.data.uarfcn_list, |
| 272 | *scl = bts->si_common.data.scramble_list, |
| 273 | scramble1 = encode_fdd(scramble, true), |
| 274 | scramble0 = encode_fdd(scramble, false); |
| 275 | |
| 276 | scr = diversity ? scramble1 : scramble0; |
| 277 | chk = diversity ? scramble0 : scramble1; |
| 278 | |
| 279 | if (len == MAX_EARFCN_LIST) |
| 280 | return -ENOMEM; |
| 281 | |
Max | e610e70 | 2016-12-19 13:41:48 +0100 | [diff] [blame] | 282 | for (i = 0; i < len; i++) /* find the position of arfcn if any */ |
| 283 | if (arfcn == ual[i]) |
| 284 | break; |
| 285 | |
| 286 | for (k = 0; i < len; i++) { |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 287 | if (arfcn == ual[i] && (scr == scl[i] || chk == scl[i])) |
| 288 | return -EADDRINUSE; |
| 289 | if (scr > scl[i]) |
| 290 | k = i + 1; |
| 291 | } |
| 292 | /* we keep lists sorted by scramble code: |
| 293 | insert into appropriate position and move the tail */ |
| 294 | if (len - k) { |
| 295 | memmove(ual + k + 1, ual + k, (len - k) * 2); |
| 296 | memmove(scl + k + 1, scl + k, (len - k) * 2); |
| 297 | } |
Max | e610e70 | 2016-12-19 13:41:48 +0100 | [diff] [blame] | 298 | |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 299 | ual[k] = arfcn; |
| 300 | scl[k] = scr; |
| 301 | bts->si_common.uarfcn_length++; |
Max | aafff96 | 2016-04-20 15:57:14 +0200 | [diff] [blame] | 302 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 303 | if (si2q_num(bts) <= SI2Q_MAX_NUM) { |
| 304 | bts->si2q_count = si2q_num(bts) - 1; |
Max | aafff96 | 2016-04-20 15:57:14 +0200 | [diff] [blame] | 305 | return 0; |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 306 | } |
Max | aafff96 | 2016-04-20 15:57:14 +0200 | [diff] [blame] | 307 | |
| 308 | bts_uarfcn_del(bts, arfcn, scramble); |
| 309 | return -ENOSPC; |
Max | 26679e0 | 2016-04-20 15:57:13 +0200 | [diff] [blame] | 310 | } |
| 311 | |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 312 | static inline int use_arfcn(const struct gsm_bts *bts, const bool bis, const bool ter, |
| 313 | const bool pgsm, const int arfcn) |
Holger Hans Peter Freyther | 9e1952a | 2013-01-17 12:04:17 +0100 | [diff] [blame] | 314 | { |
Jacob Erlbeck | 65d114f | 2014-01-16 11:02:14 +0100 | [diff] [blame] | 315 | if (bts->force_combined_si) |
| 316 | return !bis && !ter; |
Holger Hans Peter Freyther | d4d1d5e | 2013-01-17 13:49:39 +0100 | [diff] [blame] | 317 | if (!bis && !ter && band_compatible(bts, arfcn)) |
Holger Hans Peter Freyther | 9e1952a | 2013-01-17 12:04:17 +0100 | [diff] [blame] | 318 | return 1; |
Jacob Erlbeck | 65d114f | 2014-01-16 11:02:14 +0100 | [diff] [blame] | 319 | /* Correct but somehow broken with either the nanoBTS or the iPhone5 */ |
Holger Hans Peter Freyther | d4d1d5e | 2013-01-17 13:49:39 +0100 | [diff] [blame] | 320 | if (bis && pgsm && band_compatible(bts, arfcn) && (arfcn < 1 || arfcn > 124)) |
Holger Hans Peter Freyther | 9e1952a | 2013-01-17 12:04:17 +0100 | [diff] [blame] | 321 | return 1; |
Holger Hans Peter Freyther | d4d1d5e | 2013-01-17 13:49:39 +0100 | [diff] [blame] | 322 | if (ter && !band_compatible(bts, arfcn)) |
Holger Hans Peter Freyther | 9e1952a | 2013-01-17 12:04:17 +0100 | [diff] [blame] | 323 | return 1; |
| 324 | return 0; |
| 325 | } |
| 326 | |
Harald Welte | da760d3 | 2009-12-14 20:25:05 +0100 | [diff] [blame] | 327 | /* Frequency Lists as per TS 04.08 10.5.2.13 */ |
| 328 | |
| 329 | /* 10.5.2.13.2: Bit map 0 format */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 330 | static int freq_list_bm0_set_arfcn(uint8_t *chan_list, unsigned int arfcn) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 331 | { |
| 332 | unsigned int byte, bit; |
| 333 | |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 334 | if (arfcn > 124 || arfcn < 1) { |
| 335 | LOGP(DRR, LOGL_ERROR, "Bitmap 0 only supports ARFCN 1...124\n"); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 336 | return -EINVAL; |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 337 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 338 | |
Harald Welte | da760d3 | 2009-12-14 20:25:05 +0100 | [diff] [blame] | 339 | /* the bitmask is from 1..124, not from 0..123 */ |
| 340 | arfcn--; |
| 341 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 342 | byte = arfcn / 8; |
| 343 | bit = arfcn % 8; |
| 344 | |
Harald Welte | da760d3 | 2009-12-14 20:25:05 +0100 | [diff] [blame] | 345 | chan_list[GSM48_CELL_CHAN_DESC_SIZE-1-byte] |= (1 << bit); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 346 | |
| 347 | return 0; |
| 348 | } |
| 349 | |
Harald Welte | da760d3 | 2009-12-14 20:25:05 +0100 | [diff] [blame] | 350 | /* 10.5.2.13.7: Variable bit map format */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 351 | static int freq_list_bmrel_set_arfcn(uint8_t *chan_list, unsigned int arfcn) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 352 | { |
| 353 | unsigned int byte, bit; |
| 354 | unsigned int min_arfcn; |
| 355 | unsigned int bitno; |
| 356 | |
| 357 | min_arfcn = (chan_list[0] & 1) << 9; |
| 358 | min_arfcn |= chan_list[1] << 1; |
| 359 | min_arfcn |= (chan_list[2] >> 7) & 1; |
| 360 | |
| 361 | /* The lower end of our bitmaks is always implicitly included */ |
| 362 | if (arfcn == min_arfcn) |
| 363 | return 0; |
| 364 | |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 365 | if (((arfcn - min_arfcn) & 1023) > 111) { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 366 | LOGP(DRR, LOGL_ERROR, "arfcn(%u) > min(%u) + 111\n", arfcn, min_arfcn); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 367 | return -EINVAL; |
Harald Welte | 152b626 | 2009-12-16 11:57:48 +0100 | [diff] [blame] | 368 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 369 | |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 370 | bitno = (arfcn - min_arfcn) & 1023; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 371 | byte = bitno / 8; |
| 372 | bit = bitno % 8; |
| 373 | |
| 374 | chan_list[2 + byte] |= 1 << (7 - bit); |
| 375 | |
| 376 | return 0; |
| 377 | } |
| 378 | |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 379 | /* generate a variable bitmap */ |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 380 | static inline int enc_freq_lst_var_bitmap(uint8_t *chan_list, |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 381 | struct bitvec *bv, const struct gsm_bts *bts, |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 382 | bool bis, bool ter, int min, bool pgsm) |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 383 | { |
| 384 | int i; |
| 385 | |
| 386 | /* set it to 'Variable bitmap format' */ |
| 387 | chan_list[0] = 0x8e; |
| 388 | |
| 389 | chan_list[0] |= (min >> 9) & 1; |
| 390 | chan_list[1] = (min >> 1); |
| 391 | chan_list[2] = (min & 1) << 7; |
| 392 | |
| 393 | for (i = 0; i < bv->data_len*8; i++) { |
| 394 | /* see notes in bitvec2freq_list */ |
| 395 | if (bitvec_get_bit_pos(bv, i) |
Harald Welte | e18f78e | 2015-09-04 06:21:32 +0200 | [diff] [blame] | 396 | && ((!bis && !ter && band_compatible(bts,i)) |
| 397 | || (bis && pgsm && band_compatible(bts,i) && (i < 1 || i > 124)) |
| 398 | || (ter && !band_compatible(bts, i)))) { |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 399 | int rc = freq_list_bmrel_set_arfcn(chan_list, i); |
| 400 | if (rc < 0) |
| 401 | return rc; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | return 0; |
| 406 | } |
| 407 | |
Max | 881064e | 2016-12-14 14:51:40 +0100 | [diff] [blame] | 408 | int range_encode(enum gsm48_range r, int *arfcns, int arfcns_used, int *w, |
| 409 | int f0, uint8_t *chan_list) |
| 410 | { |
| 411 | /* |
| 412 | * Manipulate the ARFCN list according to the rules in J4 depending |
| 413 | * on the selected range. |
| 414 | */ |
| 415 | int rc, f0_included; |
| 416 | |
| 417 | range_enc_filter_arfcns(arfcns, arfcns_used, f0, &f0_included); |
| 418 | |
| 419 | rc = range_enc_arfcns(r, arfcns, arfcns_used, w, 0); |
| 420 | if (rc < 0) |
| 421 | return rc; |
| 422 | |
| 423 | /* Select the range and the amount of bits needed */ |
| 424 | switch (r) { |
| 425 | case ARFCN_RANGE_128: |
| 426 | return range_enc_range128(chan_list, f0, w); |
| 427 | case ARFCN_RANGE_256: |
| 428 | return range_enc_range256(chan_list, f0, w); |
| 429 | case ARFCN_RANGE_512: |
| 430 | return range_enc_range512(chan_list, f0, w); |
| 431 | case ARFCN_RANGE_1024: |
| 432 | return range_enc_range1024(chan_list, f0, f0_included, w); |
| 433 | default: |
| 434 | return -ERANGE; |
| 435 | }; |
| 436 | |
| 437 | return f0_included; |
| 438 | } |
| 439 | |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 440 | /* generate a frequency list with the range 512 format */ |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 441 | static inline int enc_freq_lst_range(uint8_t *chan_list, |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 442 | struct bitvec *bv, const struct gsm_bts *bts, |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 443 | bool bis, bool ter, bool pgsm) |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 444 | { |
| 445 | int arfcns[RANGE_ENC_MAX_ARFCNS]; |
| 446 | int w[RANGE_ENC_MAX_ARFCNS]; |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 447 | int arfcns_used = 0; |
Max | 881064e | 2016-12-14 14:51:40 +0100 | [diff] [blame] | 448 | int i, range, f0; |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 449 | |
| 450 | /* |
| 451 | * Select ARFCNs according to the rules in bitvec2freq_list |
| 452 | */ |
| 453 | for (i = 0; i < bv->data_len * 8; ++i) { |
| 454 | /* More ARFCNs than the maximum */ |
| 455 | if (arfcns_used > ARRAY_SIZE(arfcns)) |
| 456 | return -1; |
| 457 | /* Check if we can select it? */ |
Holger Hans Peter Freyther | 9e1952a | 2013-01-17 12:04:17 +0100 | [diff] [blame] | 458 | if (bitvec_get_bit_pos(bv, i) && use_arfcn(bts, bis, ter, pgsm, i)) |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 459 | arfcns[arfcns_used++] = i; |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | /* |
| 463 | * Check if the given list of ARFCNs can be encoded. |
| 464 | */ |
| 465 | range = range_enc_determine_range(arfcns, arfcns_used, &f0); |
| 466 | if (range == ARFCN_RANGE_INVALID) |
| 467 | return -2; |
| 468 | |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 469 | memset(w, 0, sizeof(w)); |
Max | 881064e | 2016-12-14 14:51:40 +0100 | [diff] [blame] | 470 | return range_encode(range, arfcns, arfcns_used, w, f0, chan_list); |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 471 | } |
| 472 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 473 | /* generate a cell channel list as per Section 10.5.2.1b of 04.08 */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 474 | static int bitvec2freq_list(uint8_t *chan_list, struct bitvec *bv, |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 475 | const struct gsm_bts *bts, bool bis, bool ter) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 476 | { |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 477 | int i, rc, min = -1, max = -1, arfcns = 0; |
| 478 | bool pgsm = false; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 479 | memset(chan_list, 0, 16); |
| 480 | |
Harald Welte | 2935034 | 2012-02-17 15:58:23 +0100 | [diff] [blame] | 481 | if (bts->band == GSM_BAND_900 |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 482 | && bts->c0->arfcn >= 1 && bts->c0->arfcn <= 124) |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 483 | pgsm = true; |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 484 | /* P-GSM-only handsets only support 'bit map 0 format' */ |
| 485 | if (!bis && !ter && pgsm) { |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 486 | chan_list[0] = 0; |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 487 | |
| 488 | for (i = 0; i < bv->data_len*8; i++) { |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 489 | if (i >= 1 && i <= 124 |
| 490 | && bitvec_get_bit_pos(bv, i)) { |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 491 | rc = freq_list_bm0_set_arfcn(chan_list, i); |
| 492 | if (rc < 0) |
| 493 | return rc; |
| 494 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 495 | } |
| 496 | return 0; |
| 497 | } |
| 498 | |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 499 | for (i = 0; i < bv->data_len*8; i++) { |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 500 | /* in case of SI2 or SI5 allow all neighbours in same band |
| 501 | * in case of SI*bis, allow neighbours in same band ouside pgsm |
| 502 | * in case of SI*ter, allow neighbours in different bands |
| 503 | */ |
Holger Hans Peter Freyther | 9e1952a | 2013-01-17 12:04:17 +0100 | [diff] [blame] | 504 | if (!bitvec_get_bit_pos(bv, i)) |
| 505 | continue; |
| 506 | if (!use_arfcn(bts, bis, ter, pgsm, i)) |
| 507 | continue; |
| 508 | /* count the arfcns we want to carry */ |
| 509 | arfcns += 1; |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 510 | |
Holger Hans Peter Freyther | 9e1952a | 2013-01-17 12:04:17 +0100 | [diff] [blame] | 511 | /* 955..1023 < 0..885 */ |
| 512 | if (min < 0) |
| 513 | min = i; |
| 514 | if (i >= 955 && min < 955) |
| 515 | min = i; |
| 516 | if (i >= 955 && min >= 955 && i < min) |
| 517 | min = i; |
| 518 | if (i < 955 && min < 955 && i < min) |
| 519 | min = i; |
| 520 | if (max < 0) |
| 521 | max = i; |
| 522 | if (i < 955 && max >= 955) |
| 523 | max = i; |
| 524 | if (i >= 955 && max >= 955 && i > max) |
| 525 | max = i; |
| 526 | if (i < 955 && max < 955 && i > max) |
| 527 | max = i; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 528 | } |
| 529 | |
Sylvain Munaut | 42a5652 | 2009-12-24 14:20:19 +0100 | [diff] [blame] | 530 | if (max == -1) { |
| 531 | /* Empty set, use 'bit map 0 format' */ |
| 532 | chan_list[0] = 0; |
| 533 | return 0; |
| 534 | } |
| 535 | |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 536 | /* Now find the best encoding */ |
| 537 | if (((max - min) & 1023) <= 111) |
| 538 | return enc_freq_lst_var_bitmap(chan_list, bv, bts, bis, |
| 539 | ter, min, pgsm); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 540 | |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 541 | /* Attempt to do the range encoding */ |
| 542 | rc = enc_freq_lst_range(chan_list, bv, bts, bis, ter, pgsm); |
Max | 881064e | 2016-12-14 14:51:40 +0100 | [diff] [blame] | 543 | if (rc >= 0) |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 544 | return 0; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 545 | |
Holger Hans Peter Freyther | 511f9c3 | 2012-10-13 12:38:54 +0200 | [diff] [blame] | 546 | LOGP(DRR, LOGL_ERROR, "min_arfcn=%u, max_arfcn=%u, arfcns=%d " |
| 547 | "can not generate ARFCN list", min, max, arfcns); |
| 548 | return -EINVAL; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | /* generate a cell channel list as per Section 10.5.2.1b of 04.08 */ |
Dieter Spaar | 1664602 | 2011-07-28 00:01:50 +0200 | [diff] [blame] | 552 | /* static*/ int generate_cell_chan_list(uint8_t *chan_list, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 553 | { |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 554 | struct gsm_bts_trx *trx; |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 555 | struct bitvec *bv = &bts->si_common.cell_alloc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 556 | |
Harald Welte | a39b0f2 | 2010-06-14 22:26:10 +0200 | [diff] [blame] | 557 | /* Zero-initialize the bit-vector */ |
Harald Welte | c8794b5 | 2010-06-16 11:09:18 +0200 | [diff] [blame] | 558 | memset(bv->data, 0, bv->data_len); |
Harald Welte | a39b0f2 | 2010-06-14 22:26:10 +0200 | [diff] [blame] | 559 | |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 560 | /* first we generate a bitvec of all TRX ARFCN's in our BTS */ |
Harald Welte | a39b0f2 | 2010-06-14 22:26:10 +0200 | [diff] [blame] | 561 | llist_for_each_entry(trx, &bts->trx_list, list) { |
| 562 | unsigned int i, j; |
| 563 | /* Always add the TRX's ARFCN */ |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 564 | bitvec_set_bit_pos(bv, trx->arfcn, 1); |
Harald Welte | a39b0f2 | 2010-06-14 22:26:10 +0200 | [diff] [blame] | 565 | for (i = 0; i < ARRAY_SIZE(trx->ts); i++) { |
| 566 | struct gsm_bts_trx_ts *ts = &trx->ts[i]; |
| 567 | /* Add any ARFCNs present in hopping channels */ |
| 568 | for (j = 0; j < 1024; j++) { |
| 569 | if (bitvec_get_bit_pos(&ts->hopping.arfcns, j)) |
| 570 | bitvec_set_bit_pos(bv, j, 1); |
| 571 | } |
| 572 | } |
| 573 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 574 | |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 575 | /* then we generate a GSM 04.08 frequency list from the bitvec */ |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 576 | return bitvec2freq_list(chan_list, bv, bts, false, false); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 577 | } |
| 578 | |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 579 | /* generate a cell channel list as per Section 10.5.2.1b of 04.08 */ |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 580 | static int generate_bcch_chan_list(uint8_t *chan_list, struct gsm_bts *bts, |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 581 | bool si5, bool bis, bool ter) |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 582 | { |
| 583 | struct gsm_bts *cur_bts; |
Harald Welte | 64c07d2 | 2011-02-15 11:43:27 +0100 | [diff] [blame] | 584 | struct bitvec *bv; |
| 585 | |
| 586 | if (si5 && bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP) |
| 587 | bv = &bts->si_common.si5_neigh_list; |
| 588 | else |
| 589 | bv = &bts->si_common.neigh_list; |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 590 | |
Harald Welte | 32c0962 | 2011-01-11 23:44:56 +0100 | [diff] [blame] | 591 | /* Generate list of neighbor cells if we are in automatic mode */ |
Harald Welte | 64c07d2 | 2011-02-15 11:43:27 +0100 | [diff] [blame] | 592 | if (bts->neigh_list_manual_mode == NL_MODE_AUTOMATIC) { |
Harald Welte | 21bbda2 | 2011-02-19 20:43:37 +0100 | [diff] [blame] | 593 | /* Zero-initialize the bit-vector */ |
| 594 | memset(bv->data, 0, bv->data_len); |
| 595 | |
Harald Welte | 32c0962 | 2011-01-11 23:44:56 +0100 | [diff] [blame] | 596 | /* first we generate a bitvec of the BCCH ARFCN's in our BSC */ |
| 597 | llist_for_each_entry(cur_bts, &bts->network->bts_list, list) { |
| 598 | if (cur_bts == bts) |
| 599 | continue; |
| 600 | bitvec_set_bit_pos(bv, cur_bts->c0->arfcn, 1); |
| 601 | } |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | /* then we generate a GSM 04.08 frequency list from the bitvec */ |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 605 | return bitvec2freq_list(chan_list, bv, bts, bis, ter); |
| 606 | } |
| 607 | |
| 608 | static int list_arfcn(uint8_t *chan_list, uint8_t mask, char *text) |
| 609 | { |
| 610 | int n = 0, i; |
| 611 | struct gsm_sysinfo_freq freq[1024]; |
| 612 | |
| 613 | memset(freq, 0, sizeof(freq)); |
| 614 | gsm48_decode_freq_list(freq, chan_list, 16, 0xce, 1); |
| 615 | for (i = 0; i < 1024; i++) { |
| 616 | if (freq[i].mask) { |
| 617 | if (!n) |
| 618 | LOGP(DRR, LOGL_INFO, "%s", text); |
| 619 | LOGPC(DRR, LOGL_INFO, " %d", i); |
| 620 | n++; |
| 621 | } |
| 622 | } |
| 623 | if (n) |
| 624 | LOGPC(DRR, LOGL_INFO, "\n"); |
| 625 | |
| 626 | return n; |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 627 | } |
| 628 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 629 | static int generate_si1(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 630 | { |
| 631 | int rc; |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 632 | struct gsm48_system_information_type_1 *si1 = (struct gsm48_system_information_type_1 *) GSM_BTS_SI(bts, t); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 633 | |
| 634 | memset(si1, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 635 | |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 636 | si1->header.l2_plen = GSM48_LEN2PLEN(21); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 637 | si1->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 638 | si1->header.skip_indicator = 0; |
| 639 | si1->header.system_information = GSM48_MT_RR_SYSINFO_1; |
| 640 | |
| 641 | rc = generate_cell_chan_list(si1->cell_channel_description, bts); |
| 642 | if (rc < 0) |
| 643 | return rc; |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 644 | list_arfcn(si1->cell_channel_description, 0xce, "Serving cell:"); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 645 | |
| 646 | si1->rach_control = bts->si_common.rach_control; |
| 647 | |
Holger Hans Peter Freyther | f876c39 | 2013-03-06 12:02:33 +0100 | [diff] [blame] | 648 | /* |
| 649 | * SI1 Rest Octets (10.5.2.32), contains NCH position and band |
| 650 | * indicator but that is not in the 04.08. |
| 651 | */ |
| 652 | rc = rest_octets_si1(si1->rest_octets, NULL, is_dcs_net(bts)); |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 653 | |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 654 | return sizeof(*si1) + rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 655 | } |
| 656 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 657 | static int generate_si2(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 658 | { |
| 659 | int rc; |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 660 | struct gsm48_system_information_type_2 *si2 = (struct gsm48_system_information_type_2 *) GSM_BTS_SI(bts, t); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 661 | |
| 662 | memset(si2, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 663 | |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 664 | si2->header.l2_plen = GSM48_LEN2PLEN(22); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 665 | si2->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 666 | si2->header.skip_indicator = 0; |
| 667 | si2->header.system_information = GSM48_MT_RR_SYSINFO_2; |
| 668 | |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 669 | rc = generate_bcch_chan_list(si2->bcch_frequency_list, bts, false, false, false); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 670 | if (rc < 0) |
| 671 | return rc; |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 672 | list_arfcn(si2->bcch_frequency_list, 0xce, |
Harald Welte | e5ba92e | 2015-09-04 06:22:46 +0200 | [diff] [blame] | 673 | "SI2 Neighbour cells in same band:"); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 674 | |
| 675 | si2->ncc_permitted = bts->si_common.ncc_permitted; |
| 676 | si2->rach_control = bts->si_common.rach_control; |
| 677 | |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 678 | return sizeof(*si2); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 679 | } |
| 680 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 681 | static int generate_si2bis(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 682 | { |
| 683 | int rc; |
| 684 | struct gsm48_system_information_type_2bis *si2b = |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 685 | (struct gsm48_system_information_type_2bis *) GSM_BTS_SI(bts, t); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 686 | int n; |
| 687 | |
| 688 | memset(si2b, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 689 | |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 690 | si2b->header.l2_plen = GSM48_LEN2PLEN(22); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 691 | si2b->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 692 | si2b->header.skip_indicator = 0; |
| 693 | si2b->header.system_information = GSM48_MT_RR_SYSINFO_2bis; |
| 694 | |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 695 | rc = generate_bcch_chan_list(si2b->bcch_frequency_list, bts, false, true, false); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 696 | if (rc < 0) |
| 697 | return rc; |
| 698 | n = list_arfcn(si2b->bcch_frequency_list, 0xce, |
| 699 | "Neighbour cells in same band, but outside P-GSM:"); |
| 700 | if (n) { |
| 701 | /* indicate in SI2 and SI2bis: there is an extension */ |
| 702 | struct gsm48_system_information_type_2 *si2 = |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 703 | (struct gsm48_system_information_type_2 *) GSM_BTS_SI(bts, SYSINFO_TYPE_2); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 704 | si2->bcch_frequency_list[0] |= 0x20; |
| 705 | si2b->bcch_frequency_list[0] |= 0x20; |
| 706 | } else |
| 707 | bts->si_valid &= ~(1 << SYSINFO_TYPE_2bis); |
| 708 | |
| 709 | si2b->rach_control = bts->si_common.rach_control; |
| 710 | |
| 711 | return sizeof(*si2b); |
| 712 | } |
| 713 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 714 | static int generate_si2ter(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 715 | { |
| 716 | int rc; |
| 717 | struct gsm48_system_information_type_2ter *si2t = |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 718 | (struct gsm48_system_information_type_2ter *) GSM_BTS_SI(bts, t); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 719 | int n; |
| 720 | |
| 721 | memset(si2t, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 722 | |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 723 | si2t->header.l2_plen = GSM48_LEN2PLEN(22); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 724 | si2t->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 725 | si2t->header.skip_indicator = 0; |
| 726 | si2t->header.system_information = GSM48_MT_RR_SYSINFO_2ter; |
| 727 | |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 728 | rc = generate_bcch_chan_list(si2t->ext_bcch_frequency_list, bts, false, false, true); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 729 | if (rc < 0) |
| 730 | return rc; |
| 731 | n = list_arfcn(si2t->ext_bcch_frequency_list, 0x8e, |
| 732 | "Neighbour cells in different band:"); |
| 733 | if (!n) |
| 734 | bts->si_valid &= ~(1 << SYSINFO_TYPE_2ter); |
| 735 | |
| 736 | return sizeof(*si2t); |
| 737 | } |
| 738 | |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 739 | /* SI2quater messages are optional - we only generate them when neighbor UARFCNs or EARFCNs are configured */ |
| 740 | static inline bool si2quater_not_needed(struct gsm_bts *bts) |
| 741 | { |
| 742 | unsigned i = MAX_EARFCN_LIST; |
| 743 | |
| 744 | if (bts->si_common.si2quater_neigh_list.arfcn) |
| 745 | for (i = 0; i < MAX_EARFCN_LIST; i++) |
| 746 | if (bts->si_common.si2quater_neigh_list.arfcn[i] != OSMO_EARFCN_INVALID) |
| 747 | break; |
| 748 | |
| 749 | if (!bts->si_common.uarfcn_length && i == MAX_EARFCN_LIST) { |
| 750 | bts->si_valid &= ~(1 << SYSINFO_TYPE_2quater); /* mark SI2q as invalid if no (E|U)ARFCNs are present */ |
| 751 | return true; |
| 752 | } |
| 753 | |
| 754 | return false; |
| 755 | } |
| 756 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 757 | static int generate_si2quater(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 758 | { |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 759 | int rc; |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 760 | struct gsm48_system_information_type_2quater *si2q; |
Max | f39d03a | 2017-05-12 17:00:30 +0200 | [diff] [blame] | 761 | |
| 762 | if (si2quater_not_needed(bts)) /* generate rest_octets for SI2q only when necessary */ |
| 763 | return GSM_MACBLOCK_LEN; |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 764 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 765 | bts->u_offset = 0; |
| 766 | bts->e_offset = 0; |
| 767 | bts->si2q_index = 0; |
| 768 | bts->si2q_count = si2q_num(bts) - 1; |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 769 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 770 | rc = make_si2quaters(bts, false); |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 771 | if (rc < 0) |
| 772 | return rc; |
| 773 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 774 | OSMO_ASSERT(bts->si2q_count == bts->si2q_index); |
| 775 | OSMO_ASSERT(bts->si2q_count <= SI2Q_MAX_NUM); |
| 776 | |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 777 | return sizeof(*si2q) + rc; |
| 778 | } |
| 779 | |
Harald Welte | 1f89329 | 2010-03-14 23:46:48 +0800 | [diff] [blame] | 780 | static struct gsm48_si_ro_info si_info = { |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 781 | .selection_params = { |
| 782 | .present = 0, |
| 783 | }, |
| 784 | .power_offset = { |
| 785 | .present = 0, |
| 786 | }, |
| 787 | .si2ter_indicator = 0, |
| 788 | .early_cm_ctrl = 1, |
| 789 | .scheduling = { |
| 790 | .present = 0, |
| 791 | }, |
| 792 | .gprs_ind = { |
| 793 | .si13_position = 0, |
| 794 | .ra_colour = 0, |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 795 | .present = 1, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 796 | }, |
Max | f3f3505 | 2016-04-15 16:04:44 +0200 | [diff] [blame] | 797 | .si2quater_indicator = 0, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 798 | .lsa_params = { |
| 799 | .present = 0, |
| 800 | }, |
| 801 | .cell_id = 0, /* FIXME: doesn't the bts have this? */ |
| 802 | .break_ind = 0, |
| 803 | }; |
| 804 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 805 | static int generate_si3(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 806 | { |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 807 | int rc; |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 808 | struct gsm48_system_information_type_3 *si3 = (struct gsm48_system_information_type_3 *) GSM_BTS_SI(bts, t); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 809 | |
| 810 | memset(si3, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 811 | |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 812 | si3->header.l2_plen = GSM48_LEN2PLEN(18); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 813 | si3->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 814 | si3->header.skip_indicator = 0; |
| 815 | si3->header.system_information = GSM48_MT_RR_SYSINFO_3; |
| 816 | |
| 817 | si3->cell_identity = htons(bts->cell_identity); |
Harald Welte | afedeab | 2010-03-04 10:55:40 +0100 | [diff] [blame] | 818 | gsm48_generate_lai(&si3->lai, bts->network->country_code, |
| 819 | bts->network->network_code, |
| 820 | bts->location_area_code); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 821 | si3->control_channel_desc = bts->si_common.chan_desc; |
| 822 | si3->cell_options = bts->si_common.cell_options; |
| 823 | si3->cell_sel_par = bts->si_common.cell_sel_par; |
| 824 | si3->rach_control = bts->si_common.rach_control; |
| 825 | |
Max | c08ee71 | 2016-05-11 12:45:13 +0200 | [diff] [blame] | 826 | /* allow/disallow DTXu */ |
| 827 | gsm48_set_dtx(&si3->cell_options, bts->dtxu, bts->dtxu, true); |
| 828 | |
Max | 9b97b00 | 2017-06-02 10:58:26 +0200 | [diff] [blame] | 829 | if (GSM_BTS_HAS_SI(bts, SYSINFO_TYPE_2ter)) { |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 830 | LOGP(DRR, LOGL_INFO, "SI 2ter is included.\n"); |
| 831 | si_info.si2ter_indicator = 1; |
| 832 | } else { |
| 833 | si_info.si2ter_indicator = 0; |
| 834 | } |
Max | 9b97b00 | 2017-06-02 10:58:26 +0200 | [diff] [blame] | 835 | if (GSM_BTS_HAS_SI(bts, SYSINFO_TYPE_2quater)) { |
Max | 845a3a4 | 2017-05-15 12:02:29 +0200 | [diff] [blame] | 836 | LOGP(DRR, LOGL_INFO, "SI 2quater is included, based on %zu EARFCNs and %zu UARFCNs.\n", |
| 837 | si2q_earfcn_count(&bts->si_common.si2quater_neigh_list), bts->si_common.uarfcn_length); |
Max | f3f3505 | 2016-04-15 16:04:44 +0200 | [diff] [blame] | 838 | si_info.si2quater_indicator = 1; |
| 839 | } else { |
| 840 | si_info.si2quater_indicator = 0; |
| 841 | } |
Harald Welte | 42def72 | 2017-01-13 00:10:32 +0100 | [diff] [blame] | 842 | si_info.early_cm_ctrl = bts->early_classmark_allowed; |
| 843 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 844 | /* SI3 Rest Octets (10.5.2.34), containing |
| 845 | CBQ, CELL_RESELECT_OFFSET, TEMPORARY_OFFSET, PENALTY_TIME |
| 846 | Power Offset, 2ter Indicator, Early Classmark Sending, |
| 847 | Scheduling if and WHERE, GPRS Indicator, SI13 position */ |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 848 | rc = rest_octets_si3(si3->rest_octets, &si_info); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 849 | |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 850 | return sizeof(*si3) + rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 851 | } |
| 852 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 853 | static int generate_si4(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 854 | { |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 855 | int rc; |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 856 | struct gsm48_system_information_type_4 *si4 = (struct gsm48_system_information_type_4 *) GSM_BTS_SI(bts, t); |
Harald Welte | 30f1f37 | 2014-12-28 15:00:45 +0100 | [diff] [blame] | 857 | struct gsm_lchan *cbch_lchan; |
| 858 | uint8_t *restoct = si4->data; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 859 | |
| 860 | /* length of all IEs present except SI4 rest octets and l2_plen */ |
| 861 | int l2_plen = sizeof(*si4) - 1; |
| 862 | |
| 863 | memset(si4, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 864 | |
| 865 | si4->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 866 | si4->header.skip_indicator = 0; |
| 867 | si4->header.system_information = GSM48_MT_RR_SYSINFO_4; |
| 868 | |
Harald Welte | afedeab | 2010-03-04 10:55:40 +0100 | [diff] [blame] | 869 | gsm48_generate_lai(&si4->lai, bts->network->country_code, |
| 870 | bts->network->network_code, |
| 871 | bts->location_area_code); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 872 | si4->cell_sel_par = bts->si_common.cell_sel_par; |
| 873 | si4->rach_control = bts->si_common.rach_control; |
| 874 | |
| 875 | /* Optional: CBCH Channel Description + CBCH Mobile Allocation */ |
Harald Welte | 142d12d | 2014-12-29 17:47:08 +0100 | [diff] [blame] | 876 | cbch_lchan = gsm_bts_get_cbch(bts); |
Harald Welte | 30f1f37 | 2014-12-28 15:00:45 +0100 | [diff] [blame] | 877 | if (cbch_lchan) { |
| 878 | struct gsm48_chan_desc cd; |
| 879 | gsm48_lchan2chan_desc(&cd, cbch_lchan); |
Daniel Willmann | 695675f | 2014-12-30 12:10:25 +0100 | [diff] [blame] | 880 | tv_fixed_put(si4->data, GSM48_IE_CBCH_CHAN_DESC, 3, |
Harald Welte | 30f1f37 | 2014-12-28 15:00:45 +0100 | [diff] [blame] | 881 | (uint8_t *) &cd); |
Daniel Willmann | 695675f | 2014-12-30 12:10:25 +0100 | [diff] [blame] | 882 | l2_plen += 3 + 1; |
| 883 | restoct += 3 + 1; |
Harald Welte | 30f1f37 | 2014-12-28 15:00:45 +0100 | [diff] [blame] | 884 | /* we don't use hopping and thus don't need a CBCH MA */ |
| 885 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 886 | |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 887 | si4->header.l2_plen = GSM48_LEN2PLEN(l2_plen); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 888 | |
| 889 | /* SI4 Rest Octets (10.5.2.35), containing |
| 890 | Optional Power offset, GPRS Indicator, |
| 891 | Cell Identity, LSA ID, Selection Parameter */ |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 892 | rc = rest_octets_si4(restoct, &si_info, (uint8_t *)GSM_BTS_SI(bts, t) + GSM_MACBLOCK_LEN - restoct); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 893 | |
Harald Welte | 30f1f37 | 2014-12-28 15:00:45 +0100 | [diff] [blame] | 894 | return l2_plen + 1 + rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 895 | } |
| 896 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 897 | static int generate_si5(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 898 | { |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 899 | struct gsm48_system_information_type_5 *si5; |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 900 | uint8_t *output = GSM_BTS_SI(bts, t); |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 901 | int rc, l2_plen = 18; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 902 | |
Holger Hans Peter Freyther | 17d81e2 | 2010-01-06 07:52:55 +0100 | [diff] [blame] | 903 | memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 904 | |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 905 | /* ip.access nanoBTS needs l2_plen!! */ |
Harald Welte | fd355a3 | 2011-03-04 13:41:31 +0100 | [diff] [blame] | 906 | switch (bts->type) { |
| 907 | case GSM_BTS_TYPE_NANOBTS: |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 908 | case GSM_BTS_TYPE_OSMOBTS: |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 909 | *output++ = GSM48_LEN2PLEN(l2_plen); |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 910 | l2_plen++; |
Harald Welte | fd355a3 | 2011-03-04 13:41:31 +0100 | [diff] [blame] | 911 | break; |
| 912 | default: |
| 913 | break; |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 914 | } |
| 915 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 916 | si5 = (struct gsm48_system_information_type_5 *) GSM_BTS_SI(bts, t); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 917 | |
| 918 | /* l2 pseudo length, not part of msg: 18 */ |
| 919 | si5->rr_protocol_discriminator = GSM48_PDISC_RR; |
| 920 | si5->skip_indicator = 0; |
| 921 | si5->system_information = GSM48_MT_RR_SYSINFO_5; |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 922 | rc = generate_bcch_chan_list(si5->bcch_frequency_list, bts, true, false, false); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 923 | if (rc < 0) |
| 924 | return rc; |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 925 | list_arfcn(si5->bcch_frequency_list, 0xce, |
Harald Welte | e5ba92e | 2015-09-04 06:22:46 +0200 | [diff] [blame] | 926 | "SI5 Neighbour cells in same band:"); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 927 | |
| 928 | /* 04.08 9.1.37: L2 Pseudo Length of 18 */ |
| 929 | return l2_plen; |
| 930 | } |
| 931 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 932 | static int generate_si5bis(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 933 | { |
| 934 | struct gsm48_system_information_type_5bis *si5b; |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 935 | uint8_t *output = GSM_BTS_SI(bts, t); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 936 | int rc, l2_plen = 18; |
| 937 | int n; |
| 938 | |
| 939 | memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 940 | |
| 941 | /* ip.access nanoBTS needs l2_plen!! */ |
| 942 | switch (bts->type) { |
| 943 | case GSM_BTS_TYPE_NANOBTS: |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 944 | case GSM_BTS_TYPE_OSMOBTS: |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 945 | *output++ = GSM48_LEN2PLEN(l2_plen); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 946 | l2_plen++; |
| 947 | break; |
| 948 | default: |
| 949 | break; |
| 950 | } |
| 951 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 952 | si5b = (struct gsm48_system_information_type_5bis *) GSM_BTS_SI(bts, t); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 953 | |
| 954 | /* l2 pseudo length, not part of msg: 18 */ |
| 955 | si5b->rr_protocol_discriminator = GSM48_PDISC_RR; |
| 956 | si5b->skip_indicator = 0; |
| 957 | si5b->system_information = GSM48_MT_RR_SYSINFO_5bis; |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 958 | rc = generate_bcch_chan_list(si5b->bcch_frequency_list, bts, true, true, false); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 959 | if (rc < 0) |
| 960 | return rc; |
| 961 | n = list_arfcn(si5b->bcch_frequency_list, 0xce, |
| 962 | "Neighbour cells in same band, but outside P-GSM:"); |
| 963 | if (n) { |
| 964 | /* indicate in SI5 and SI5bis: there is an extension */ |
| 965 | struct gsm48_system_information_type_5 *si5 = |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 966 | (struct gsm48_system_information_type_5 *) GSM_BTS_SI(bts, SYSINFO_TYPE_5); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 967 | si5->bcch_frequency_list[0] |= 0x20; |
| 968 | si5b->bcch_frequency_list[0] |= 0x20; |
| 969 | } else |
| 970 | bts->si_valid &= ~(1 << SYSINFO_TYPE_5bis); |
| 971 | |
| 972 | /* 04.08 9.1.37: L2 Pseudo Length of 18 */ |
| 973 | return l2_plen; |
| 974 | } |
| 975 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 976 | static int generate_si5ter(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 977 | { |
| 978 | struct gsm48_system_information_type_5ter *si5t; |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 979 | uint8_t *output = GSM_BTS_SI(bts, t); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 980 | int rc, l2_plen = 18; |
| 981 | int n; |
| 982 | |
| 983 | memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 984 | |
| 985 | /* ip.access nanoBTS needs l2_plen!! */ |
| 986 | switch (bts->type) { |
| 987 | case GSM_BTS_TYPE_NANOBTS: |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 988 | case GSM_BTS_TYPE_OSMOBTS: |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 989 | *output++ = GSM48_LEN2PLEN(l2_plen); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 990 | l2_plen++; |
| 991 | break; |
| 992 | default: |
| 993 | break; |
| 994 | } |
| 995 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 996 | si5t = (struct gsm48_system_information_type_5ter *) GSM_BTS_SI(bts, t); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 997 | |
| 998 | /* l2 pseudo length, not part of msg: 18 */ |
| 999 | si5t->rr_protocol_discriminator = GSM48_PDISC_RR; |
| 1000 | si5t->skip_indicator = 0; |
| 1001 | si5t->system_information = GSM48_MT_RR_SYSINFO_5ter; |
Max | 5fa7e36 | 2016-04-15 16:04:45 +0200 | [diff] [blame] | 1002 | rc = generate_bcch_chan_list(si5t->bcch_frequency_list, bts, true, false, true); |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 1003 | if (rc < 0) |
| 1004 | return rc; |
| 1005 | n = list_arfcn(si5t->bcch_frequency_list, 0x8e, |
| 1006 | "Neighbour cells in different band:"); |
| 1007 | if (!n) |
| 1008 | bts->si_valid &= ~(1 << SYSINFO_TYPE_5ter); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1009 | |
| 1010 | /* 04.08 9.1.37: L2 Pseudo Length of 18 */ |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 1011 | return l2_plen; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1012 | } |
| 1013 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 1014 | static int generate_si6(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1015 | { |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 1016 | struct gsm48_system_information_type_6 *si6; |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 1017 | uint8_t *output = GSM_BTS_SI(bts, t); |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 1018 | int l2_plen = 11; |
Holger Hans Peter Freyther | 82dd983 | 2016-05-17 23:20:03 +0200 | [diff] [blame] | 1019 | int rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1020 | |
Holger Hans Peter Freyther | 17d81e2 | 2010-01-06 07:52:55 +0100 | [diff] [blame] | 1021 | memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 1022 | |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 1023 | /* ip.access nanoBTS needs l2_plen!! */ |
Harald Welte | fd355a3 | 2011-03-04 13:41:31 +0100 | [diff] [blame] | 1024 | switch (bts->type) { |
| 1025 | case GSM_BTS_TYPE_NANOBTS: |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 1026 | case GSM_BTS_TYPE_OSMOBTS: |
Max | 2440f49 | 2016-12-07 18:03:03 +0100 | [diff] [blame] | 1027 | *output++ = GSM48_LEN2PLEN(l2_plen); |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 1028 | l2_plen++; |
Harald Welte | fd355a3 | 2011-03-04 13:41:31 +0100 | [diff] [blame] | 1029 | break; |
| 1030 | default: |
| 1031 | break; |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 1032 | } |
| 1033 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 1034 | si6 = (struct gsm48_system_information_type_6 *) GSM_BTS_SI(bts, t); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1035 | |
| 1036 | /* l2 pseudo length, not part of msg: 11 */ |
| 1037 | si6->rr_protocol_discriminator = GSM48_PDISC_RR; |
| 1038 | si6->skip_indicator = 0; |
| 1039 | si6->system_information = GSM48_MT_RR_SYSINFO_6; |
| 1040 | si6->cell_identity = htons(bts->cell_identity); |
Harald Welte | afedeab | 2010-03-04 10:55:40 +0100 | [diff] [blame] | 1041 | gsm48_generate_lai(&si6->lai, bts->network->country_code, |
| 1042 | bts->network->network_code, |
| 1043 | bts->location_area_code); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1044 | si6->cell_options = bts->si_common.cell_options; |
| 1045 | si6->ncc_permitted = bts->si_common.ncc_permitted; |
Max | c08ee71 | 2016-05-11 12:45:13 +0200 | [diff] [blame] | 1046 | /* allow/disallow DTXu */ |
Max | ea8e983 | 2016-05-23 17:28:13 +0200 | [diff] [blame] | 1047 | gsm48_set_dtx(&si6->cell_options, bts->dtxu, bts->dtxu, false); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1048 | |
| 1049 | /* SI6 Rest Octets: 10.5.2.35a: PCH / NCH info, VBS/VGCS options */ |
Holger Hans Peter Freyther | 82dd983 | 2016-05-17 23:20:03 +0200 | [diff] [blame] | 1050 | rc = rest_octets_si6(si6->rest_octets, is_dcs_net(bts)); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1051 | |
Holger Hans Peter Freyther | 82dd983 | 2016-05-17 23:20:03 +0200 | [diff] [blame] | 1052 | return l2_plen + rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | static struct gsm48_si13_info si13_default = { |
| 1056 | .cell_opts = { |
Harald Welte | 8584918 | 2010-06-02 12:19:21 +0200 | [diff] [blame] | 1057 | .nmo = GPRS_NMO_II, |
Harald Welte | a4b1665 | 2010-05-31 12:54:23 +0200 | [diff] [blame] | 1058 | .t3168 = 2000, |
Andreas Eversberg | becc89a | 2012-09-23 08:14:51 +0200 | [diff] [blame] | 1059 | .t3192 = 1500, |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 1060 | .drx_timer_max = 3, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1061 | .bs_cv_max = 15, |
Max | 292ec58 | 2016-07-28 11:55:37 +0200 | [diff] [blame] | 1062 | .ctrl_ack_type_use_block = true, |
Sylvain Munaut | 851f120 | 2011-10-17 13:56:02 +0200 | [diff] [blame] | 1063 | .ext_info_present = 0, |
bhargava | 350533c | 2016-07-21 11:14:34 +0530 | [diff] [blame] | 1064 | .supports_egprs_11bit_rach = 0, |
Harald Welte | da0586a | 2010-04-18 14:49:05 +0200 | [diff] [blame] | 1065 | .ext_info = { |
| 1066 | /* The values below are just guesses ! */ |
Harald Welte | a06fea0 | 2010-04-18 15:53:40 +0200 | [diff] [blame] | 1067 | .egprs_supported = 0, |
Harald Welte | da0586a | 2010-04-18 14:49:05 +0200 | [diff] [blame] | 1068 | .use_egprs_p_ch_req = 1, |
Harald Welte | a4b1665 | 2010-05-31 12:54:23 +0200 | [diff] [blame] | 1069 | .bep_period = 5, |
Harald Welte | da0586a | 2010-04-18 14:49:05 +0200 | [diff] [blame] | 1070 | .pfc_supported = 0, |
| 1071 | .dtm_supported = 0, |
| 1072 | .bss_paging_coordination = 0, |
| 1073 | }, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1074 | }, |
| 1075 | .pwr_ctrl_pars = { |
Harald Welte | c15d0ac | 2012-10-08 21:22:08 +0200 | [diff] [blame] | 1076 | .alpha = 0, /* a = 0.0 */ |
Harald Welte | a4b1665 | 2010-05-31 12:54:23 +0200 | [diff] [blame] | 1077 | .t_avg_w = 16, |
| 1078 | .t_avg_t = 16, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1079 | .pc_meas_chan = 0, /* downling measured on CCCH */ |
Harald Welte | a4b1665 | 2010-05-31 12:54:23 +0200 | [diff] [blame] | 1080 | .n_avg_i = 8, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1081 | }, |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 1082 | .bcch_change_mark = 1, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1083 | .si_change_field = 0, |
| 1084 | .pbcch_present = 0, |
| 1085 | { |
| 1086 | .no_pbcch = { |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 1087 | .rac = 0, /* needs to be patched */ |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1088 | .spgc_ccch_sup = 0, |
| 1089 | .net_ctrl_ord = 0, |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 1090 | .prio_acc_thr = 6, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1091 | }, |
| 1092 | }, |
| 1093 | }; |
| 1094 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 1095 | static int generate_si13(enum osmo_sysinfo_type t, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1096 | { |
| 1097 | struct gsm48_system_information_type_13 *si13 = |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 1098 | (struct gsm48_system_information_type_13 *) GSM_BTS_SI(bts, t); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1099 | int ret; |
| 1100 | |
| 1101 | memset(si13, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 1102 | |
| 1103 | si13->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 1104 | si13->header.skip_indicator = 0; |
| 1105 | si13->header.system_information = GSM48_MT_RR_SYSINFO_13; |
| 1106 | |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 1107 | si13_default.no_pbcch.rac = bts->gprs.rac; |
Andreas Eversberg | 0c8f9ca | 2013-03-16 16:31:26 +0100 | [diff] [blame] | 1108 | si13_default.no_pbcch.net_ctrl_ord = bts->gprs.net_ctrl_ord; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 1109 | |
Max | 292ec58 | 2016-07-28 11:55:37 +0200 | [diff] [blame] | 1110 | si13_default.cell_opts.ctrl_ack_type_use_block = |
| 1111 | bts->gprs.ctrl_ack_type_use_block; |
| 1112 | |
Holger Hans Peter Freyther | b92a538 | 2014-11-21 10:00:39 +0100 | [diff] [blame] | 1113 | /* Information about the other SIs */ |
| 1114 | si13_default.bcch_change_mark = bts->bcch_change_mark; |
bhargava | 350533c | 2016-07-21 11:14:34 +0530 | [diff] [blame] | 1115 | si13_default.cell_opts.supports_egprs_11bit_rach = |
| 1116 | bts->gprs.supports_egprs_11bit_rach; |
Holger Hans Peter Freyther | b92a538 | 2014-11-21 10:00:39 +0100 | [diff] [blame] | 1117 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1118 | ret = rest_octets_si13(si13->rest_octets, &si13_default); |
| 1119 | if (ret < 0) |
| 1120 | return ret; |
| 1121 | |
Holger Hans Peter Freyther | 1c6f394 | 2010-06-16 12:05:56 +0800 | [diff] [blame] | 1122 | /* length is coded in bit 2 an up */ |
| 1123 | si13->header.l2_plen = 0x01; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1124 | |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 1125 | return sizeof (*si13) + ret; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1126 | } |
| 1127 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 1128 | typedef int (*gen_si_fn_t)(enum osmo_sysinfo_type t, struct gsm_bts *bts); |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 1129 | |
| 1130 | static const gen_si_fn_t gen_si_fn[_MAX_SYSINFO_TYPE] = { |
| 1131 | [SYSINFO_TYPE_1] = &generate_si1, |
| 1132 | [SYSINFO_TYPE_2] = &generate_si2, |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 1133 | [SYSINFO_TYPE_2bis] = &generate_si2bis, |
| 1134 | [SYSINFO_TYPE_2ter] = &generate_si2ter, |
Max | 59a1bf3 | 2016-04-15 16:04:46 +0200 | [diff] [blame] | 1135 | [SYSINFO_TYPE_2quater] = &generate_si2quater, |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 1136 | [SYSINFO_TYPE_3] = &generate_si3, |
| 1137 | [SYSINFO_TYPE_4] = &generate_si4, |
| 1138 | [SYSINFO_TYPE_5] = &generate_si5, |
Andreas Eversberg | c50543b | 2012-02-29 09:04:07 +0100 | [diff] [blame] | 1139 | [SYSINFO_TYPE_5bis] = &generate_si5bis, |
| 1140 | [SYSINFO_TYPE_5ter] = &generate_si5ter, |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 1141 | [SYSINFO_TYPE_6] = &generate_si6, |
| 1142 | [SYSINFO_TYPE_13] = &generate_si13, |
| 1143 | }; |
| 1144 | |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 1145 | int gsm_generate_si(struct gsm_bts *bts, enum osmo_sysinfo_type si_type) |
| 1146 | { |
| 1147 | gen_si_fn_t gen_si; |
| 1148 | |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 1149 | switch (bts->gprs.mode) { |
| 1150 | case BTS_GPRS_EGPRS: |
Harald Welte | a06fea0 | 2010-04-18 15:53:40 +0200 | [diff] [blame] | 1151 | si13_default.cell_opts.ext_info_present = 1; |
| 1152 | si13_default.cell_opts.ext_info.egprs_supported = 1; |
| 1153 | /* fallthrough */ |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 1154 | case BTS_GPRS_GPRS: |
| 1155 | si_info.gprs_ind.present = 1; |
| 1156 | break; |
| 1157 | case BTS_GPRS_NONE: |
| 1158 | si_info.gprs_ind.present = 0; |
| 1159 | break; |
| 1160 | } |
Harald Welte | 1f89329 | 2010-03-14 23:46:48 +0800 | [diff] [blame] | 1161 | |
Sylvain Munaut | e0b06b0 | 2010-11-28 18:17:28 +0100 | [diff] [blame] | 1162 | memcpy(&si_info.selection_params, |
| 1163 | &bts->si_common.cell_ro_sel_par, |
| 1164 | sizeof(struct gsm48_si_selection_params)); |
| 1165 | |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 1166 | gen_si = gen_si_fn[si_type]; |
| 1167 | if (!gen_si) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1168 | return -EINVAL; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1169 | |
Max | 6f0e50c | 2017-04-12 15:30:54 +0200 | [diff] [blame] | 1170 | return gen_si(si_type, bts); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1171 | } |