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> |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * GNU Affero General Public License for more details. |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 17 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <errno.h> |
| 24 | #include <string.h> |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 25 | #include <stdio.h> |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 26 | #include <netinet/in.h> |
| 27 | |
| 28 | #include <openbsc/gsm_04_08.h> |
| 29 | #include <openbsc/gsm_data.h> |
| 30 | #include <openbsc/abis_rsl.h> |
| 31 | #include <openbsc/rest_octets.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 32 | #include <osmocom/core/bitvec.h> |
| 33 | #include <osmocom/core/utils.h> |
Harald Welte | 152b626 | 2009-12-16 11:57:48 +0100 | [diff] [blame] | 34 | #include <openbsc/debug.h> |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 35 | |
| 36 | #define GSM48_CELL_CHAN_DESC_SIZE 16 |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 37 | #define GSM_MACBLOCK_PADDING 0x2b |
| 38 | |
Holger Hans Peter Freyther | b91a106 | 2010-01-06 06:38:14 +0100 | [diff] [blame] | 39 | /* verify the sizes of the system information type structs */ |
| 40 | |
| 41 | /* rest octets are not part of the struct */ |
| 42 | static_assert(sizeof(struct gsm48_system_information_type_header) == 3, _si_header_size); |
| 43 | static_assert(sizeof(struct gsm48_rach_control) == 3, _si_rach_control); |
| 44 | static_assert(sizeof(struct gsm48_system_information_type_1) == 22, _si1_size); |
| 45 | static_assert(sizeof(struct gsm48_system_information_type_2) == 23, _si2_size); |
| 46 | static_assert(sizeof(struct gsm48_system_information_type_3) == 19, _si3_size); |
| 47 | static_assert(sizeof(struct gsm48_system_information_type_4) == 13, _si4_size); |
| 48 | |
| 49 | /* bs11 forgot the l2 len, 0-6 rest octets */ |
| 50 | static_assert(sizeof(struct gsm48_system_information_type_5) == 18, _si5_size); |
| 51 | static_assert(sizeof(struct gsm48_system_information_type_6) == 11, _si6_size); |
| 52 | |
| 53 | static_assert(sizeof(struct gsm48_system_information_type_13) == 3, _si13_size); |
| 54 | |
Harald Welte | da760d3 | 2009-12-14 20:25:05 +0100 | [diff] [blame] | 55 | /* Frequency Lists as per TS 04.08 10.5.2.13 */ |
| 56 | |
| 57 | /* 10.5.2.13.2: Bit map 0 format */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 58 | 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] | 59 | { |
| 60 | unsigned int byte, bit; |
| 61 | |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 62 | if (arfcn > 124 || arfcn < 1) { |
| 63 | LOGP(DRR, LOGL_ERROR, "Bitmap 0 only supports ARFCN 1...124\n"); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 64 | return -EINVAL; |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 65 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 66 | |
Harald Welte | da760d3 | 2009-12-14 20:25:05 +0100 | [diff] [blame] | 67 | /* the bitmask is from 1..124, not from 0..123 */ |
| 68 | arfcn--; |
| 69 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 70 | byte = arfcn / 8; |
| 71 | bit = arfcn % 8; |
| 72 | |
Harald Welte | da760d3 | 2009-12-14 20:25:05 +0100 | [diff] [blame] | 73 | chan_list[GSM48_CELL_CHAN_DESC_SIZE-1-byte] |= (1 << bit); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 74 | |
| 75 | return 0; |
| 76 | } |
| 77 | |
Harald Welte | da760d3 | 2009-12-14 20:25:05 +0100 | [diff] [blame] | 78 | /* 10.5.2.13.7: Variable bit map format */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 79 | 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] | 80 | { |
| 81 | unsigned int byte, bit; |
| 82 | unsigned int min_arfcn; |
| 83 | unsigned int bitno; |
| 84 | |
| 85 | min_arfcn = (chan_list[0] & 1) << 9; |
| 86 | min_arfcn |= chan_list[1] << 1; |
| 87 | min_arfcn |= (chan_list[2] >> 7) & 1; |
| 88 | |
| 89 | /* The lower end of our bitmaks is always implicitly included */ |
| 90 | if (arfcn == min_arfcn) |
| 91 | return 0; |
| 92 | |
Harald Welte | 152b626 | 2009-12-16 11:57:48 +0100 | [diff] [blame] | 93 | if (arfcn < min_arfcn) { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 94 | LOGP(DRR, LOGL_ERROR, "arfcn(%u) < min(%u)\n", arfcn, min_arfcn); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 95 | return -EINVAL; |
Harald Welte | 152b626 | 2009-12-16 11:57:48 +0100 | [diff] [blame] | 96 | } |
| 97 | if (arfcn > min_arfcn + 111) { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 98 | 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] | 99 | return -EINVAL; |
Harald Welte | 152b626 | 2009-12-16 11:57:48 +0100 | [diff] [blame] | 100 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 101 | |
| 102 | bitno = (arfcn - min_arfcn); |
| 103 | byte = bitno / 8; |
| 104 | bit = bitno % 8; |
| 105 | |
| 106 | chan_list[2 + byte] |= 1 << (7 - bit); |
| 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | /* 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] | 112 | static int bitvec2freq_list(uint8_t *chan_list, struct bitvec *bv, |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 113 | const struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 114 | { |
Sylvain Munaut | 42a5652 | 2009-12-24 14:20:19 +0100 | [diff] [blame] | 115 | int i, rc, min = 1024, max = -1; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 116 | |
| 117 | memset(chan_list, 0, 16); |
| 118 | |
| 119 | /* GSM900-only handsets only support 'bit map 0 format' */ |
| 120 | if (bts->band == GSM_BAND_900) { |
| 121 | chan_list[0] = 0; |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 122 | |
| 123 | for (i = 0; i < bv->data_len*8; i++) { |
| 124 | if (bitvec_get_bit_pos(bv, i)) { |
| 125 | rc = freq_list_bm0_set_arfcn(chan_list, i); |
| 126 | if (rc < 0) |
| 127 | return rc; |
| 128 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 129 | } |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | /* We currently only support the 'Variable bitmap format' */ |
| 134 | chan_list[0] = 0x8e; |
| 135 | |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 136 | for (i = 0; i < bv->data_len*8; i++) { |
| 137 | if (bitvec_get_bit_pos(bv, i)) { |
| 138 | if (i < min) |
| 139 | min = i; |
| 140 | if (i > max) |
| 141 | max = i; |
| 142 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 143 | } |
| 144 | |
Sylvain Munaut | 42a5652 | 2009-12-24 14:20:19 +0100 | [diff] [blame] | 145 | if (max == -1) { |
| 146 | /* Empty set, use 'bit map 0 format' */ |
| 147 | chan_list[0] = 0; |
| 148 | return 0; |
| 149 | } |
| 150 | |
Harald Welte | 152b626 | 2009-12-16 11:57:48 +0100 | [diff] [blame] | 151 | if ((max - min) > 111) { |
Harald Welte | b1d4c8e | 2009-12-17 23:10:46 +0100 | [diff] [blame] | 152 | LOGP(DRR, LOGL_ERROR, "min_arfcn=%u, max_arfcn=%u, " |
| 153 | "distance > 111\n", min, max); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 154 | return -EINVAL; |
Harald Welte | 152b626 | 2009-12-16 11:57:48 +0100 | [diff] [blame] | 155 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 156 | |
| 157 | chan_list[0] |= (min >> 9) & 1; |
| 158 | chan_list[1] = (min >> 1); |
| 159 | chan_list[2] = (min & 1) << 7; |
| 160 | |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 161 | for (i = 0; i < bv->data_len*8; i++) { |
Harald Welte | 152b626 | 2009-12-16 11:57:48 +0100 | [diff] [blame] | 162 | if (bitvec_get_bit_pos(bv, i)) { |
| 163 | rc = freq_list_bmrel_set_arfcn(chan_list, i); |
| 164 | if (rc < 0) |
| 165 | return rc; |
| 166 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | return 0; |
| 170 | } |
| 171 | |
| 172 | /* 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] | 173 | 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] | 174 | { |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 175 | struct gsm_bts_trx *trx; |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 176 | struct bitvec *bv = &bts->si_common.cell_alloc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 177 | |
Harald Welte | a39b0f2 | 2010-06-14 22:26:10 +0200 | [diff] [blame] | 178 | /* Zero-initialize the bit-vector */ |
Harald Welte | c8794b5 | 2010-06-16 11:09:18 +0200 | [diff] [blame] | 179 | memset(bv->data, 0, bv->data_len); |
Harald Welte | a39b0f2 | 2010-06-14 22:26:10 +0200 | [diff] [blame] | 180 | |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 181 | /* 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] | 182 | llist_for_each_entry(trx, &bts->trx_list, list) { |
| 183 | unsigned int i, j; |
| 184 | /* Always add the TRX's ARFCN */ |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 185 | bitvec_set_bit_pos(bv, trx->arfcn, 1); |
Harald Welte | a39b0f2 | 2010-06-14 22:26:10 +0200 | [diff] [blame] | 186 | for (i = 0; i < ARRAY_SIZE(trx->ts); i++) { |
| 187 | struct gsm_bts_trx_ts *ts = &trx->ts[i]; |
| 188 | /* Add any ARFCNs present in hopping channels */ |
| 189 | for (j = 0; j < 1024; j++) { |
| 190 | if (bitvec_get_bit_pos(&ts->hopping.arfcns, j)) |
| 191 | bitvec_set_bit_pos(bv, j, 1); |
| 192 | } |
| 193 | } |
| 194 | } |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 195 | |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 196 | /* then we generate a GSM 04.08 frequency list from the bitvec */ |
| 197 | return bitvec2freq_list(chan_list, bv, bts); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 198 | } |
| 199 | |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 200 | /* 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] | 201 | static int generate_bcch_chan_list(uint8_t *chan_list, struct gsm_bts *bts, int si5) |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 202 | { |
| 203 | struct gsm_bts *cur_bts; |
Harald Welte | 64c07d2 | 2011-02-15 11:43:27 +0100 | [diff] [blame] | 204 | struct bitvec *bv; |
| 205 | |
| 206 | if (si5 && bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP) |
| 207 | bv = &bts->si_common.si5_neigh_list; |
| 208 | else |
| 209 | bv = &bts->si_common.neigh_list; |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 210 | |
Harald Welte | 32c0962 | 2011-01-11 23:44:56 +0100 | [diff] [blame] | 211 | /* Generate list of neighbor cells if we are in automatic mode */ |
Harald Welte | 64c07d2 | 2011-02-15 11:43:27 +0100 | [diff] [blame] | 212 | if (bts->neigh_list_manual_mode == NL_MODE_AUTOMATIC) { |
Harald Welte | 21bbda2 | 2011-02-19 20:43:37 +0100 | [diff] [blame] | 213 | /* Zero-initialize the bit-vector */ |
| 214 | memset(bv->data, 0, bv->data_len); |
| 215 | |
Harald Welte | 32c0962 | 2011-01-11 23:44:56 +0100 | [diff] [blame] | 216 | /* first we generate a bitvec of the BCCH ARFCN's in our BSC */ |
| 217 | llist_for_each_entry(cur_bts, &bts->network->bts_list, list) { |
| 218 | if (cur_bts == bts) |
| 219 | continue; |
| 220 | bitvec_set_bit_pos(bv, cur_bts->c0->arfcn, 1); |
| 221 | } |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | /* then we generate a GSM 04.08 frequency list from the bitvec */ |
| 225 | return bitvec2freq_list(chan_list, bv, bts); |
| 226 | } |
| 227 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 228 | static int generate_si1(uint8_t *output, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 229 | { |
| 230 | int rc; |
| 231 | struct gsm48_system_information_type_1 *si1 = |
| 232 | (struct gsm48_system_information_type_1 *) output; |
| 233 | |
| 234 | memset(si1, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 235 | |
| 236 | si1->header.l2_plen = (21 << 2) | 1; |
| 237 | si1->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 238 | si1->header.skip_indicator = 0; |
| 239 | si1->header.system_information = GSM48_MT_RR_SYSINFO_1; |
| 240 | |
| 241 | rc = generate_cell_chan_list(si1->cell_channel_description, bts); |
| 242 | if (rc < 0) |
| 243 | return rc; |
| 244 | |
| 245 | si1->rach_control = bts->si_common.rach_control; |
| 246 | |
| 247 | /* SI1 Rest Octets (10.5.2.32), contains NCH position */ |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 248 | rc = rest_octets_si1(si1->rest_octets, NULL); |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 249 | |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 250 | return sizeof(*si1) + rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 251 | } |
| 252 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 253 | static int generate_si2(uint8_t *output, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 254 | { |
| 255 | int rc; |
| 256 | struct gsm48_system_information_type_2 *si2 = |
| 257 | (struct gsm48_system_information_type_2 *) output; |
| 258 | |
| 259 | memset(si2, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 260 | |
| 261 | si2->header.l2_plen = (22 << 2) | 1; |
| 262 | si2->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 263 | si2->header.skip_indicator = 0; |
| 264 | si2->header.system_information = GSM48_MT_RR_SYSINFO_2; |
| 265 | |
Harald Welte | 64c07d2 | 2011-02-15 11:43:27 +0100 | [diff] [blame] | 266 | rc = generate_bcch_chan_list(si2->bcch_frequency_list, bts, 0); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 267 | if (rc < 0) |
| 268 | return rc; |
| 269 | |
| 270 | si2->ncc_permitted = bts->si_common.ncc_permitted; |
| 271 | si2->rach_control = bts->si_common.rach_control; |
| 272 | |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 273 | return sizeof(*si2); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 274 | } |
| 275 | |
Harald Welte | 1f89329 | 2010-03-14 23:46:48 +0800 | [diff] [blame] | 276 | static struct gsm48_si_ro_info si_info = { |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 277 | .selection_params = { |
| 278 | .present = 0, |
| 279 | }, |
| 280 | .power_offset = { |
| 281 | .present = 0, |
| 282 | }, |
| 283 | .si2ter_indicator = 0, |
| 284 | .early_cm_ctrl = 1, |
| 285 | .scheduling = { |
| 286 | .present = 0, |
| 287 | }, |
| 288 | .gprs_ind = { |
| 289 | .si13_position = 0, |
| 290 | .ra_colour = 0, |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 291 | .present = 1, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 292 | }, |
| 293 | .lsa_params = { |
| 294 | .present = 0, |
| 295 | }, |
| 296 | .cell_id = 0, /* FIXME: doesn't the bts have this? */ |
| 297 | .break_ind = 0, |
| 298 | }; |
| 299 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 300 | static int generate_si3(uint8_t *output, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 301 | { |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 302 | int rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 303 | struct gsm48_system_information_type_3 *si3 = |
| 304 | (struct gsm48_system_information_type_3 *) output; |
| 305 | |
| 306 | memset(si3, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 307 | |
| 308 | si3->header.l2_plen = (18 << 2) | 1; |
| 309 | si3->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 310 | si3->header.skip_indicator = 0; |
| 311 | si3->header.system_information = GSM48_MT_RR_SYSINFO_3; |
| 312 | |
| 313 | si3->cell_identity = htons(bts->cell_identity); |
Harald Welte | afedeab | 2010-03-04 10:55:40 +0100 | [diff] [blame] | 314 | gsm48_generate_lai(&si3->lai, bts->network->country_code, |
| 315 | bts->network->network_code, |
| 316 | bts->location_area_code); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 317 | si3->control_channel_desc = bts->si_common.chan_desc; |
| 318 | si3->cell_options = bts->si_common.cell_options; |
| 319 | si3->cell_sel_par = bts->si_common.cell_sel_par; |
| 320 | si3->rach_control = bts->si_common.rach_control; |
| 321 | |
| 322 | /* SI3 Rest Octets (10.5.2.34), containing |
| 323 | CBQ, CELL_RESELECT_OFFSET, TEMPORARY_OFFSET, PENALTY_TIME |
| 324 | Power Offset, 2ter Indicator, Early Classmark Sending, |
| 325 | Scheduling if and WHERE, GPRS Indicator, SI13 position */ |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 326 | rc = rest_octets_si3(si3->rest_octets, &si_info); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 327 | |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 328 | return sizeof(*si3) + rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 329 | } |
| 330 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 331 | static int generate_si4(uint8_t *output, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 332 | { |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 333 | int rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 334 | struct gsm48_system_information_type_4 *si4 = |
| 335 | (struct gsm48_system_information_type_4 *) output; |
| 336 | |
| 337 | /* length of all IEs present except SI4 rest octets and l2_plen */ |
| 338 | int l2_plen = sizeof(*si4) - 1; |
| 339 | |
| 340 | memset(si4, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 341 | |
| 342 | si4->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 343 | si4->header.skip_indicator = 0; |
| 344 | si4->header.system_information = GSM48_MT_RR_SYSINFO_4; |
| 345 | |
Harald Welte | afedeab | 2010-03-04 10:55:40 +0100 | [diff] [blame] | 346 | gsm48_generate_lai(&si4->lai, bts->network->country_code, |
| 347 | bts->network->network_code, |
| 348 | bts->location_area_code); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 349 | si4->cell_sel_par = bts->si_common.cell_sel_par; |
| 350 | si4->rach_control = bts->si_common.rach_control; |
| 351 | |
| 352 | /* Optional: CBCH Channel Description + CBCH Mobile Allocation */ |
| 353 | |
| 354 | si4->header.l2_plen = (l2_plen << 2) | 1; |
| 355 | |
| 356 | /* SI4 Rest Octets (10.5.2.35), containing |
| 357 | Optional Power offset, GPRS Indicator, |
| 358 | Cell Identity, LSA ID, Selection Parameter */ |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 359 | rc = rest_octets_si4(si4->data, &si_info); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 360 | |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 361 | return sizeof(*si4) + rc; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 362 | } |
| 363 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 364 | static int generate_si5(uint8_t *output, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 365 | { |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 366 | struct gsm48_system_information_type_5 *si5; |
| 367 | int rc, l2_plen = 18; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 368 | |
Holger Hans Peter Freyther | 17d81e2 | 2010-01-06 07:52:55 +0100 | [diff] [blame] | 369 | memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 370 | |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 371 | /* ip.access nanoBTS needs l2_plen!! */ |
Harald Welte | fd355a3 | 2011-03-04 13:41:31 +0100 | [diff] [blame] | 372 | switch (bts->type) { |
| 373 | case GSM_BTS_TYPE_NANOBTS: |
| 374 | case GSM_BTS_TYPE_HSL_FEMTO: |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 375 | *output++ = (l2_plen << 2) | 1; |
| 376 | l2_plen++; |
Harald Welte | fd355a3 | 2011-03-04 13:41:31 +0100 | [diff] [blame] | 377 | break; |
| 378 | default: |
| 379 | break; |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | si5 = (struct gsm48_system_information_type_5 *) output; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 383 | |
| 384 | /* l2 pseudo length, not part of msg: 18 */ |
| 385 | si5->rr_protocol_discriminator = GSM48_PDISC_RR; |
| 386 | si5->skip_indicator = 0; |
| 387 | si5->system_information = GSM48_MT_RR_SYSINFO_5; |
Harald Welte | 64c07d2 | 2011-02-15 11:43:27 +0100 | [diff] [blame] | 388 | rc = generate_bcch_chan_list(si5->bcch_frequency_list, bts, 1); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 389 | if (rc < 0) |
| 390 | return rc; |
| 391 | |
| 392 | /* 04.08 9.1.37: L2 Pseudo Length of 18 */ |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 393 | return l2_plen; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 394 | } |
| 395 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 396 | static int generate_si6(uint8_t *output, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 397 | { |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 398 | struct gsm48_system_information_type_6 *si6; |
| 399 | int l2_plen = 11; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 400 | |
Holger Hans Peter Freyther | 17d81e2 | 2010-01-06 07:52:55 +0100 | [diff] [blame] | 401 | memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 402 | |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 403 | /* ip.access nanoBTS needs l2_plen!! */ |
Harald Welte | fd355a3 | 2011-03-04 13:41:31 +0100 | [diff] [blame] | 404 | switch (bts->type) { |
| 405 | case GSM_BTS_TYPE_NANOBTS: |
| 406 | case GSM_BTS_TYPE_HSL_FEMTO: |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 407 | *output++ = (l2_plen << 2) | 1; |
| 408 | l2_plen++; |
Harald Welte | fd355a3 | 2011-03-04 13:41:31 +0100 | [diff] [blame] | 409 | break; |
| 410 | default: |
| 411 | break; |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | si6 = (struct gsm48_system_information_type_6 *) output; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 415 | |
| 416 | /* l2 pseudo length, not part of msg: 11 */ |
| 417 | si6->rr_protocol_discriminator = GSM48_PDISC_RR; |
| 418 | si6->skip_indicator = 0; |
| 419 | si6->system_information = GSM48_MT_RR_SYSINFO_6; |
| 420 | si6->cell_identity = htons(bts->cell_identity); |
Harald Welte | afedeab | 2010-03-04 10:55:40 +0100 | [diff] [blame] | 421 | gsm48_generate_lai(&si6->lai, bts->network->country_code, |
| 422 | bts->network->network_code, |
| 423 | bts->location_area_code); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 424 | si6->cell_options = bts->si_common.cell_options; |
| 425 | si6->ncc_permitted = bts->si_common.ncc_permitted; |
| 426 | |
| 427 | /* SI6 Rest Octets: 10.5.2.35a: PCH / NCH info, VBS/VGCS options */ |
| 428 | |
Harald Welte | e2d0d5f | 2009-12-19 21:26:54 +0100 | [diff] [blame] | 429 | return l2_plen; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | static struct gsm48_si13_info si13_default = { |
| 433 | .cell_opts = { |
Harald Welte | 8584918 | 2010-06-02 12:19:21 +0200 | [diff] [blame] | 434 | .nmo = GPRS_NMO_II, |
Harald Welte | a4b1665 | 2010-05-31 12:54:23 +0200 | [diff] [blame] | 435 | .t3168 = 2000, |
| 436 | .t3192 = 200, |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 437 | .drx_timer_max = 3, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 438 | .bs_cv_max = 15, |
Harald Welte | a4b1665 | 2010-05-31 12:54:23 +0200 | [diff] [blame] | 439 | .ext_info_present = 1, |
Harald Welte | da0586a | 2010-04-18 14:49:05 +0200 | [diff] [blame] | 440 | .ext_info = { |
| 441 | /* The values below are just guesses ! */ |
Harald Welte | a06fea0 | 2010-04-18 15:53:40 +0200 | [diff] [blame] | 442 | .egprs_supported = 0, |
Harald Welte | da0586a | 2010-04-18 14:49:05 +0200 | [diff] [blame] | 443 | .use_egprs_p_ch_req = 1, |
Harald Welte | a4b1665 | 2010-05-31 12:54:23 +0200 | [diff] [blame] | 444 | .bep_period = 5, |
Harald Welte | da0586a | 2010-04-18 14:49:05 +0200 | [diff] [blame] | 445 | .pfc_supported = 0, |
| 446 | .dtm_supported = 0, |
| 447 | .bss_paging_coordination = 0, |
| 448 | }, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 449 | }, |
| 450 | .pwr_ctrl_pars = { |
| 451 | .alpha = 10, /* a = 1.0 */ |
Harald Welte | a4b1665 | 2010-05-31 12:54:23 +0200 | [diff] [blame] | 452 | .t_avg_w = 16, |
| 453 | .t_avg_t = 16, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 454 | .pc_meas_chan = 0, /* downling measured on CCCH */ |
Harald Welte | a4b1665 | 2010-05-31 12:54:23 +0200 | [diff] [blame] | 455 | .n_avg_i = 8, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 456 | }, |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 457 | .bcch_change_mark = 1, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 458 | .si_change_field = 0, |
| 459 | .pbcch_present = 0, |
| 460 | { |
| 461 | .no_pbcch = { |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 462 | .rac = 0, /* needs to be patched */ |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 463 | .spgc_ccch_sup = 0, |
| 464 | .net_ctrl_ord = 0, |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 465 | .prio_acc_thr = 6, |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 466 | }, |
| 467 | }, |
| 468 | }; |
| 469 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 470 | static int generate_si13(uint8_t *output, struct gsm_bts *bts) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 471 | { |
| 472 | struct gsm48_system_information_type_13 *si13 = |
| 473 | (struct gsm48_system_information_type_13 *) output; |
| 474 | int ret; |
| 475 | |
| 476 | memset(si13, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN); |
| 477 | |
| 478 | si13->header.rr_protocol_discriminator = GSM48_PDISC_RR; |
| 479 | si13->header.skip_indicator = 0; |
| 480 | si13->header.system_information = GSM48_MT_RR_SYSINFO_13; |
| 481 | |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 482 | si13_default.no_pbcch.rac = bts->gprs.rac; |
| 483 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 484 | ret = rest_octets_si13(si13->rest_octets, &si13_default); |
| 485 | if (ret < 0) |
| 486 | return ret; |
| 487 | |
Holger Hans Peter Freyther | 1c6f394 | 2010-06-16 12:05:56 +0800 | [diff] [blame] | 488 | /* length is coded in bit 2 an up */ |
| 489 | si13->header.l2_plen = 0x01; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 490 | |
Holger Hans Peter Freyther | 7ec448d | 2010-01-06 07:52:31 +0100 | [diff] [blame] | 491 | return sizeof (*si13) + ret; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 492 | } |
| 493 | |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 494 | static const uint8_t sitype2rsl[_MAX_SYSINFO_TYPE] = { |
| 495 | [SYSINFO_TYPE_1] = RSL_SYSTEM_INFO_1, |
| 496 | [SYSINFO_TYPE_2] = RSL_SYSTEM_INFO_2, |
| 497 | [SYSINFO_TYPE_3] = RSL_SYSTEM_INFO_3, |
| 498 | [SYSINFO_TYPE_4] = RSL_SYSTEM_INFO_4, |
| 499 | [SYSINFO_TYPE_5] = RSL_SYSTEM_INFO_5, |
| 500 | [SYSINFO_TYPE_6] = RSL_SYSTEM_INFO_6, |
| 501 | [SYSINFO_TYPE_7] = RSL_SYSTEM_INFO_7, |
| 502 | [SYSINFO_TYPE_8] = RSL_SYSTEM_INFO_8, |
| 503 | [SYSINFO_TYPE_9] = RSL_SYSTEM_INFO_9, |
| 504 | [SYSINFO_TYPE_10] = RSL_SYSTEM_INFO_10, |
| 505 | [SYSINFO_TYPE_13] = RSL_SYSTEM_INFO_13, |
| 506 | [SYSINFO_TYPE_16] = RSL_SYSTEM_INFO_16, |
| 507 | [SYSINFO_TYPE_17] = RSL_SYSTEM_INFO_17, |
| 508 | [SYSINFO_TYPE_18] = RSL_SYSTEM_INFO_18, |
| 509 | [SYSINFO_TYPE_19] = RSL_SYSTEM_INFO_19, |
| 510 | [SYSINFO_TYPE_20] = RSL_SYSTEM_INFO_20, |
| 511 | [SYSINFO_TYPE_2bis] = RSL_SYSTEM_INFO_2bis, |
| 512 | [SYSINFO_TYPE_2ter] = RSL_SYSTEM_INFO_2ter, |
| 513 | [SYSINFO_TYPE_2quater] = RSL_SYSTEM_INFO_2quater, |
| 514 | [SYSINFO_TYPE_5bis] = RSL_SYSTEM_INFO_5bis, |
| 515 | [SYSINFO_TYPE_5ter] = RSL_SYSTEM_INFO_5ter, |
| 516 | }; |
| 517 | |
| 518 | static const uint8_t rsl2sitype[0xff] = { |
| 519 | [RSL_SYSTEM_INFO_1] = SYSINFO_TYPE_1, |
| 520 | [RSL_SYSTEM_INFO_2] = SYSINFO_TYPE_2, |
| 521 | [RSL_SYSTEM_INFO_3] = SYSINFO_TYPE_3, |
| 522 | [RSL_SYSTEM_INFO_4] = SYSINFO_TYPE_4, |
| 523 | [RSL_SYSTEM_INFO_5] = SYSINFO_TYPE_5, |
| 524 | [RSL_SYSTEM_INFO_6] = SYSINFO_TYPE_6, |
Harald Welte | 5f827f4 | 2010-07-30 11:11:38 +0200 | [diff] [blame] | 525 | [RSL_SYSTEM_INFO_7] = SYSINFO_TYPE_7, |
| 526 | [RSL_SYSTEM_INFO_8] = SYSINFO_TYPE_8, |
| 527 | [RSL_SYSTEM_INFO_9] = SYSINFO_TYPE_9, |
| 528 | [RSL_SYSTEM_INFO_10] = SYSINFO_TYPE_10, |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 529 | [RSL_SYSTEM_INFO_13] = SYSINFO_TYPE_13, |
Harald Welte | 5f827f4 | 2010-07-30 11:11:38 +0200 | [diff] [blame] | 530 | [RSL_SYSTEM_INFO_16] = SYSINFO_TYPE_16, |
| 531 | [RSL_SYSTEM_INFO_17] = SYSINFO_TYPE_17, |
| 532 | [RSL_SYSTEM_INFO_18] = SYSINFO_TYPE_18, |
| 533 | [RSL_SYSTEM_INFO_19] = SYSINFO_TYPE_19, |
| 534 | [RSL_SYSTEM_INFO_20] = SYSINFO_TYPE_20, |
| 535 | [RSL_SYSTEM_INFO_2bis] = SYSINFO_TYPE_2bis, |
| 536 | [RSL_SYSTEM_INFO_2ter] = SYSINFO_TYPE_2ter, |
| 537 | [RSL_SYSTEM_INFO_2quater] = SYSINFO_TYPE_2quater, |
| 538 | [RSL_SYSTEM_INFO_5bis] = SYSINFO_TYPE_5bis, |
| 539 | [RSL_SYSTEM_INFO_5ter] = SYSINFO_TYPE_5ter, |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 540 | }; |
| 541 | |
| 542 | typedef int (*gen_si_fn_t)(uint8_t *output, struct gsm_bts *bts); |
| 543 | |
| 544 | static const gen_si_fn_t gen_si_fn[_MAX_SYSINFO_TYPE] = { |
| 545 | [SYSINFO_TYPE_1] = &generate_si1, |
| 546 | [SYSINFO_TYPE_2] = &generate_si2, |
| 547 | [SYSINFO_TYPE_3] = &generate_si3, |
| 548 | [SYSINFO_TYPE_4] = &generate_si4, |
| 549 | [SYSINFO_TYPE_5] = &generate_si5, |
| 550 | [SYSINFO_TYPE_6] = &generate_si6, |
| 551 | [SYSINFO_TYPE_13] = &generate_si13, |
| 552 | }; |
| 553 | |
Harald Welte | 5f827f4 | 2010-07-30 11:11:38 +0200 | [diff] [blame] | 554 | const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = { |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 555 | { SYSINFO_TYPE_1, "1" }, |
| 556 | { SYSINFO_TYPE_2, "2" }, |
| 557 | { SYSINFO_TYPE_3, "3" }, |
| 558 | { SYSINFO_TYPE_4, "4" }, |
| 559 | { SYSINFO_TYPE_5, "5" }, |
| 560 | { SYSINFO_TYPE_6, "6" }, |
| 561 | { SYSINFO_TYPE_7, "7" }, |
| 562 | { SYSINFO_TYPE_8, "8" }, |
| 563 | { SYSINFO_TYPE_9, "9" }, |
| 564 | { SYSINFO_TYPE_10, "10" }, |
| 565 | { SYSINFO_TYPE_13, "13" }, |
| 566 | { SYSINFO_TYPE_16, "16" }, |
| 567 | { SYSINFO_TYPE_17, "17" }, |
| 568 | { SYSINFO_TYPE_18, "18" }, |
| 569 | { SYSINFO_TYPE_19, "19" }, |
| 570 | { SYSINFO_TYPE_20, "20" }, |
| 571 | { SYSINFO_TYPE_2bis, "2bis" }, |
| 572 | { SYSINFO_TYPE_2ter, "2ter" }, |
| 573 | { SYSINFO_TYPE_2quater, "2quater" }, |
| 574 | { SYSINFO_TYPE_5bis, "5bis" }, |
| 575 | { SYSINFO_TYPE_5ter, "5ter" }, |
| 576 | { 0, NULL } |
| 577 | }; |
| 578 | |
| 579 | uint8_t gsm_sitype2rsl(enum osmo_sysinfo_type si_type) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 580 | { |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 581 | return sitype2rsl[si_type]; |
| 582 | } |
| 583 | |
| 584 | const char *gsm_sitype_name(enum osmo_sysinfo_type si_type) |
| 585 | { |
Harald Welte | 5f827f4 | 2010-07-30 11:11:38 +0200 | [diff] [blame] | 586 | return get_value_string(osmo_sitype_strs, si_type); |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | int gsm_generate_si(struct gsm_bts *bts, enum osmo_sysinfo_type si_type) |
| 590 | { |
| 591 | gen_si_fn_t gen_si; |
| 592 | |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 593 | switch (bts->gprs.mode) { |
| 594 | case BTS_GPRS_EGPRS: |
Harald Welte | a06fea0 | 2010-04-18 15:53:40 +0200 | [diff] [blame] | 595 | si13_default.cell_opts.ext_info_present = 1; |
| 596 | si13_default.cell_opts.ext_info.egprs_supported = 1; |
| 597 | /* fallthrough */ |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 598 | case BTS_GPRS_GPRS: |
| 599 | si_info.gprs_ind.present = 1; |
| 600 | break; |
| 601 | case BTS_GPRS_NONE: |
| 602 | si_info.gprs_ind.present = 0; |
| 603 | break; |
| 604 | } |
Harald Welte | 1f89329 | 2010-03-14 23:46:48 +0800 | [diff] [blame] | 605 | |
Sylvain Munaut | e0b06b0 | 2010-11-28 18:17:28 +0100 | [diff] [blame] | 606 | memcpy(&si_info.selection_params, |
| 607 | &bts->si_common.cell_ro_sel_par, |
| 608 | sizeof(struct gsm48_si_selection_params)); |
| 609 | |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 610 | gen_si = gen_si_fn[si_type]; |
| 611 | if (!gen_si) |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 612 | return -EINVAL; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 613 | |
Harald Welte | 7401ae6 | 2010-06-15 16:44:12 +0200 | [diff] [blame] | 614 | return gen_si(bts->si_buf[si_type], bts); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 615 | } |