Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | /* A hackish minimal BSC (+MSC +HLR) implementation */ |
| 2 | |
| 3 | /* (C) 2008 by Harald Welte <laforge@gnumonks.org> |
| 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | * |
| 20 | */ |
| 21 | |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 22 | #include <unistd.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <stdio.h> |
| 25 | #include <stdarg.h> |
| 26 | #include <time.h> |
| 27 | #include <string.h> |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 28 | #include <errno.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 29 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 30 | #include <openbsc/gsm_data.h> |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 31 | #include <openbsc/select.h> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 32 | #include <openbsc/abis_rsl.h> |
| 33 | #include <openbsc/abis_nm.h> |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 34 | #include <openbsc/debug.h> |
Holger Freyther | 5677ae3 | 2008-12-27 09:41:03 +0000 | [diff] [blame] | 35 | #include <openbsc/misdn.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 36 | |
| 37 | /* global pointer to the gsm network data structure */ |
| 38 | static struct gsm_network *gsmnet; |
| 39 | |
| 40 | /* The following definitions are for OM and NM packets that we cannot yet |
| 41 | * generate by code but we just pass on */ |
| 42 | |
| 43 | // BTS Site Manager, SET ATTRIBUTES |
| 44 | |
| 45 | /* |
| 46 | Object Class: BTS Site Manager |
| 47 | Instance 1: FF |
| 48 | Instance 2: FF |
| 49 | Instance 3: FF |
| 50 | SET ATTRIBUTES |
| 51 | sAbisExternalTime: 2007/09/08 14:36:11 |
| 52 | omLAPDRelTimer: 30sec |
| 53 | shortLAPDIntTimer: 5sec |
| 54 | emergencyTimer1: 10 minutes |
| 55 | emergencyTimer2: 0 minutes |
| 56 | */ |
| 57 | |
| 58 | unsigned char msg_1[] = |
| 59 | { |
| 60 | 0xD0, 0x00, 0xFF, 0xFF, 0xFF, 0x91, 0x07, 0xD7, 0x09, 0x08, 0x0E, 0x24, |
| 61 | 0x0B, 0xCE, 0x02, 0x00, 0x1E, 0xE8, 0x01, 0x05, 0x42, 0x02, 0x00, 0x0A, 0x44, |
| 62 | 0x02, 0x00, 0x00 |
| 63 | }; |
| 64 | |
| 65 | // BTS, SET BTS ATTRIBUTES |
| 66 | |
| 67 | /* |
| 68 | Object Class: BTS |
| 69 | BTS relat. Number: 0 |
| 70 | Instance 2: FF |
| 71 | Instance 3: FF |
| 72 | SET BTS ATTRIBUTES |
| 73 | bsIdentityCode / BSIC: |
| 74 | PLMN_colour_code: 7h |
| 75 | BS_colour_code: 7h |
| 76 | BTS Air Timer T3105: 4 ,unit 10 ms |
| 77 | btsIsHopping: FALSE |
| 78 | periodCCCHLoadIndication: 255sec |
| 79 | thresholdCCCHLoadIndication: 100% |
| 80 | cellAllocationNumber: 00h = GSM 900 |
| 81 | enableInterferenceClass: 00h = Disabled |
| 82 | fACCHQual: 6 (FACCH stealing flags minus 1) |
| 83 | intaveParameter: 31 SACCH multiframes |
| 84 | interferenceLevelBoundaries: |
| 85 | Interference Boundary 1: 0Ah |
| 86 | Interference Boundary 2: 0Fh |
| 87 | Interference Boundary 3: 14h |
| 88 | Interference Boundary 4: 19h |
| 89 | Interference Boundary 5: 1Eh |
| 90 | mSTxPwrMax: 11 |
| 91 | GSM range: 2=39dBm, 15=13dBm, stepsize 2 dBm |
| 92 | DCS1800 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 93 | PCS1900 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 94 | 30=33dBm, 31=32dBm |
| 95 | ny1: |
| 96 | Maximum number of repetitions for PHYSICAL INFORMATION message (GSM 04.08): 20 |
| 97 | powerOutputThresholds: |
| 98 | Out Power Fault Threshold: -10 dB |
| 99 | Red Out Power Threshold: - 6 dB |
| 100 | Excessive Out Power Threshold: 5 dB |
| 101 | rACHBusyThreshold: -127 dBm |
| 102 | rACHLoadAveragingSlots: 250 ,number of RACH burst periods |
| 103 | rfResourceIndicationPeriod: 125 SACCH multiframes |
| 104 | T200: |
| 105 | SDCCH: 044 in 5 ms |
| 106 | FACCH/Full rate: 031 in 5 ms |
| 107 | FACCH/Half rate: 041 in 5 ms |
| 108 | SACCH with TCH SAPI0: 090 in 10 ms |
| 109 | SACCH with SDCCH: 090 in 10 ms |
| 110 | SDCCH with SAPI3: 090 in 5 ms |
| 111 | SACCH with TCH SAPI3: 135 in 10 ms |
| 112 | tSync: 9000 units of 10 msec |
| 113 | tTrau: 9000 units of 10 msec |
| 114 | enableUmLoopTest: 00h = disabled |
| 115 | enableExcessiveDistance: 00h = Disabled |
| 116 | excessiveDistance: 64km |
| 117 | hoppingMode: 00h = baseband hopping |
| 118 | cellType: 00h = Standard Cell |
| 119 | BCCH ARFCN / bCCHFrequency: 1 |
| 120 | */ |
| 121 | |
| 122 | unsigned char msg_2[] = |
| 123 | { |
| 124 | 0x41, 0x01, 0x00, 0xFF, 0xFF, 0x09, 0x3F, 0x0A, 0x04, 0x61, 0x00, 0x0B, |
| 125 | 0xFF, 0x0C, 0x64, 0x62, 0x00, 0x66, 0x00, 0x6E, 0x06, 0x18, 0x1F, 0x19, |
| 126 | 0x0A, 0x0F, 0x14, 0x19, 0x1E, 0x7B, 0x0B, 0x23, 0x14, 0x28, 0x00, 0x04, |
| 127 | 0x03, 0x2A, 0x7F, 0x2B, 0x00, 0xFA, 0x8F, 0x7D, 0x33, 0x2C, 0x1F, 0x29, |
| 128 | 0x5A, 0x5A, 0x5A, 0x87, 0x94, 0x23, 0x28, 0x95, 0x23, 0x28, 0x35, 0x01, |
| 129 | 0x00, 0x46, 0x01, 0x00, 0x58, 0x01, 0x40, 0xC5, 0x01, 0x00, 0xF2, 0x01, |
| 130 | 0x00, 0x08, 0x00, HARDCODED_ARFCN/*0x01*/, |
| 131 | }; |
| 132 | |
| 133 | // Handover Recognition, SET ATTRIBUTES |
| 134 | |
| 135 | /* |
| 136 | Illegal Contents GSM Formatted O&M Msg |
| 137 | Object Class: Handover Recognition |
| 138 | BTS relat. Number: 0 |
| 139 | Instance 2: FF |
| 140 | Instance 3: FF |
| 141 | SET ATTRIBUTES |
| 142 | enableDelayPowerBudgetHO: 00h = Disabled |
| 143 | enableDistanceHO: 00h = Disabled |
| 144 | enableInternalInterCellHandover: 00h = Disabled |
| 145 | enableInternalIntraCellHandover: 00h = Disabled |
| 146 | enablePowerBudgetHO: 00h = Disabled |
| 147 | enableRXLEVHO: 00h = Disabled |
| 148 | enableRXQUALHO: 00h = Disabled |
| 149 | hoAveragingDistance: 8 SACCH multiframes |
| 150 | hoAveragingLev: |
| 151 | A_LEV_HO: 8 SACCH multiframes |
| 152 | W_LEV_HO: 1 SACCH multiframes |
| 153 | hoAveragingPowerBudget: 16 SACCH multiframes |
| 154 | hoAveragingQual: |
| 155 | A_QUAL_HO: 8 SACCH multiframes |
| 156 | W_QUAL_HO: 2 SACCH multiframes |
| 157 | hoLowerThresholdLevDL: (10 - 110) dBm |
| 158 | hoLowerThresholdLevUL: (5 - 110) dBm |
| 159 | hoLowerThresholdQualDL: 06h = 6.4% < BER < 12.8% |
| 160 | hoLowerThresholdQualUL: 06h = 6.4% < BER < 12.8% |
| 161 | hoThresholdLevDLintra : (20 - 110) dBm |
| 162 | hoThresholdLevULintra: (20 - 110) dBm |
| 163 | hoThresholdMsRangeMax: 20 km |
| 164 | nCell: 06h |
| 165 | timerHORequest: 3 ,unit 2 SACCH multiframes |
| 166 | */ |
| 167 | |
| 168 | unsigned char msg_3[] = |
| 169 | { |
| 170 | 0xD0, 0xA1, 0x00, 0xFF, 0xFF, 0xD0, 0x00, 0x64, 0x00, 0x67, 0x00, 0x68, |
| 171 | 0x00, 0x6A, 0x00, 0x6C, 0x00, 0x6D, 0x00, 0x6F, 0x08, 0x70, 0x08, 0x01, |
| 172 | 0x71, 0x10, 0x10, 0x10, 0x72, 0x08, 0x02, 0x73, 0x0A, 0x74, 0x05, 0x75, |
| 173 | 0x06, 0x76, 0x06, 0x78, 0x14, 0x79, 0x14, 0x7A, 0x14, 0x7D, 0x06, 0x92, |
| 174 | 0x03, 0x20, 0x01, 0x00, 0x45, 0x01, 0x00, 0x48, 0x01, 0x00, 0x5A, 0x01, |
| 175 | 0x00, 0x5B, 0x01, 0x05, 0x5E, 0x01, 0x1A, 0x5F, 0x01, 0x20, 0x9D, 0x01, |
| 176 | 0x00, 0x47, 0x01, 0x00, 0x5C, 0x01, 0x64, 0x5D, 0x01, 0x1E, 0x97, 0x01, |
| 177 | 0x20, 0xF7, 0x01, 0x3C, |
| 178 | }; |
| 179 | |
| 180 | // Power Control, SET ATTRIBUTES |
| 181 | |
| 182 | /* |
| 183 | Object Class: Power Control |
| 184 | BTS relat. Number: 0 |
| 185 | Instance 2: FF |
| 186 | Instance 3: FF |
| 187 | SET ATTRIBUTES |
| 188 | enableMsPowerControl: 00h = Disabled |
| 189 | enablePowerControlRLFW: 00h = Disabled |
| 190 | pcAveragingLev: |
| 191 | A_LEV_PC: 4 SACCH multiframes |
| 192 | W_LEV_PC: 1 SACCH multiframes |
| 193 | pcAveragingQual: |
| 194 | A_QUAL_PC: 4 SACCH multiframes |
| 195 | W_QUAL_PC: 2 SACCH multiframes |
| 196 | pcLowerThresholdLevDL: 0Fh |
| 197 | pcLowerThresholdLevUL: 0Ah |
| 198 | pcLowerThresholdQualDL: 05h = 3.2% < BER < 6.4% |
| 199 | pcLowerThresholdQualUL: 05h = 3.2% < BER < 6.4% |
| 200 | pcRLFThreshold: 0Ch |
| 201 | pcUpperThresholdLevDL: 14h |
| 202 | pcUpperThresholdLevUL: 0Fh |
| 203 | pcUpperThresholdQualDL: 04h = 1.6% < BER < 3.2% |
| 204 | pcUpperThresholdQualUL: 04h = 1.6% < BER < 3.2% |
| 205 | powerConfirm: 2 ,unit 2 SACCH multiframes |
| 206 | powerControlInterval: 2 ,unit 2 SACCH multiframes |
| 207 | powerIncrStepSize: 02h = 4 dB |
| 208 | powerRedStepSize: 01h = 2 dB |
| 209 | radioLinkTimeoutBs: 64 SACCH multiframes |
| 210 | enableBSPowerControl: 00h = disabled |
| 211 | */ |
| 212 | |
| 213 | unsigned char msg_4[] = |
| 214 | { |
| 215 | 0xD0, 0xA2, 0x00, 0xFF, 0xFF, 0x69, 0x00, 0x6B, 0x00, 0x7E, 0x04, 0x01, |
| 216 | 0x7F, 0x04, 0x02, 0x80, 0x0F, 0x81, 0x0A, 0x82, 0x05, 0x83, 0x05, 0x84, |
| 217 | 0x0C, 0x85, 0x14, 0x86, 0x0F, 0x87, 0x04, 0x88, 0x04, 0x89, 0x02, 0x8A, |
| 218 | 0x02, 0x8B, 0x02, 0x8C, 0x01, 0x8D, 0x40, 0x65, 0x01, 0x00 // set to 0x01 to enable BSPowerControl |
| 219 | }; |
| 220 | |
| 221 | |
| 222 | // Transceiver, SET TRX ATTRIBUTES (TRX 0) |
| 223 | |
| 224 | /* |
| 225 | Object Class: Transceiver |
| 226 | BTS relat. Number: 0 |
| 227 | Tranceiver number: 0 |
| 228 | Instance 3: FF |
| 229 | SET TRX ATTRIBUTES |
| 230 | aRFCNList (HEX): 0001 |
| 231 | txPwrMaxReduction: 00h = 0dB |
| 232 | radioMeasGran: 254 SACCH multiframes |
| 233 | radioMeasRep: 01h = enabled |
| 234 | memberOfEmergencyConfig: 01h = TRUE |
| 235 | trxArea: 00h = TRX doesn't belong to a concentric cell |
| 236 | */ |
| 237 | |
| 238 | unsigned char msg_6[] = |
| 239 | { |
| 240 | 0x44, 0x02, 0x00, 0x00, 0xFF, 0x05, 0x01, 0x00, HARDCODED_ARFCN /*0x01*/, 0x2D, |
| 241 | 0x00, 0xDC, 0x01, 0xFE, 0xDD, 0x01, 0x01, 0x9B, 0x01, 0x01, 0x9F, 0x01, 0x00, |
| 242 | }; |
| 243 | |
| 244 | |
| 245 | static void bootstrap_om(struct gsm_bts *bts) |
| 246 | { |
| 247 | struct gsm_bts_trx *trx = &bts->trx[0]; |
| 248 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 249 | fprintf(stdout, "bootstrapping OML\n"); |
| 250 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 251 | /* stop sending event reports */ |
| 252 | abis_nm_event_reports(bts, 0); |
| 253 | |
| 254 | /* begin DB transmission */ |
| 255 | abis_nm_db_transmission(bts, 1); |
| 256 | |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 257 | /* end DB transmission */ |
| 258 | abis_nm_db_transmission(bts, 0); |
| 259 | |
| 260 | /* Reset BTS Site manager resource */ |
| 261 | abis_nm_reset_resource(bts); |
| 262 | |
| 263 | /* begin DB transmission */ |
| 264 | abis_nm_db_transmission(bts, 1); |
| 265 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 266 | abis_nm_raw_msg(bts, sizeof(msg_1), msg_1); /* set BTS SiteMgr attr*/ |
| 267 | abis_nm_raw_msg(bts, sizeof(msg_2), msg_2); /* set BTS attr */ |
| 268 | abis_nm_raw_msg(bts, sizeof(msg_3), msg_3); /* set BTS handover attr */ |
| 269 | abis_nm_raw_msg(bts, sizeof(msg_4), msg_4); /* set BTS power control attr */ |
| 270 | |
| 271 | /* Connect signalling of bts0/trx0 to e1_0/ts1/64kbps */ |
| 272 | abis_nm_conn_terr_sign(trx, 0, 1, 0xff); |
| 273 | abis_nm_raw_msg(bts, sizeof(msg_6), msg_6); /* SET TRX ATTRIBUTES */ |
| 274 | |
| 275 | /* Use TEI 1 for signalling */ |
| 276 | abis_nm_establish_tei(bts, 0, 0, 1, 0xff, 0x01); |
| 277 | abis_nm_set_channel_attr(&trx->ts[0], NM_CHANC_SDCCH_CBCH); |
| 278 | #if 0 |
| 279 | /* TRX 1 */ |
| 280 | abis_nm_conn_terr_sign(&bts->trx[1], 0, 1, 0xff); |
| 281 | /* FIXME: TRX ATTRIBUTE */ |
| 282 | abis_nm_establish_tei(bts, 0, 0, 1, 0xff, 0x02); |
| 283 | #endif |
| 284 | |
| 285 | /* SET CHANNEL ATTRIBUTE TS1 */ |
| 286 | abis_nm_set_channel_attr(&trx->ts[1], 0x09); |
| 287 | /* Connect traffic of bts0/trx0/ts1 to e1_0/ts2/b */ |
| 288 | abis_nm_conn_terr_traf(&trx->ts[1], 0, 2, 1); |
| 289 | |
| 290 | /* SET CHANNEL ATTRIBUTE TS2 */ |
| 291 | abis_nm_set_channel_attr(&trx->ts[2], 0x09); |
| 292 | /* Connect traffic of bts0/trx0/ts2 to e1_0/ts2/c */ |
| 293 | abis_nm_conn_terr_traf(&trx->ts[2], 0, 2, 2); |
| 294 | |
| 295 | /* SET CHANNEL ATTRIBUTE TS3 */ |
| 296 | abis_nm_set_channel_attr(&trx->ts[3], 0x09); |
| 297 | /* Connect traffic of bts0/trx0/ts3 to e1_0/ts2/d */ |
| 298 | abis_nm_conn_terr_traf(&trx->ts[3], 0, 2, 3); |
| 299 | |
| 300 | /* SET CHANNEL ATTRIBUTE TS4 */ |
| 301 | abis_nm_set_channel_attr(&trx->ts[4], 0x09); |
| 302 | /* Connect traffic of bts0/trx0/ts4 to e1_0/ts3/a */ |
| 303 | abis_nm_conn_terr_traf(&trx->ts[4], 0, 3, 0); |
| 304 | |
| 305 | /* SET CHANNEL ATTRIBUTE TS5 */ |
| 306 | abis_nm_set_channel_attr(&trx->ts[5], 0x09); |
| 307 | /* Connect traffic of bts0/trx0/ts5 to e1_0/ts3/b */ |
| 308 | abis_nm_conn_terr_traf(&trx->ts[5], 0, 3, 1); |
| 309 | |
| 310 | /* SET CHANNEL ATTRIBUTE TS6 */ |
| 311 | abis_nm_set_channel_attr(&trx->ts[6], 0x09); |
| 312 | /* Connect traffic of bts0/trx0/ts6 to e1_0/ts3/c */ |
| 313 | abis_nm_conn_terr_traf(&trx->ts[6], 0, 3, 2); |
| 314 | |
| 315 | /* SET CHANNEL ATTRIBUTE TS7 */ |
| 316 | abis_nm_set_channel_attr(&trx->ts[7], 0x09); |
| 317 | /* Connect traffic of bts0/trx0/ts7 to e1_0/ts3/d */ |
| 318 | abis_nm_conn_terr_traf(&trx->ts[7], 0, 3, 3); |
| 319 | |
| 320 | /* end DB transmission */ |
| 321 | abis_nm_db_transmission(bts, 0); |
| 322 | |
| 323 | /* Reset BTS Site manager resource */ |
| 324 | abis_nm_reset_resource(bts); |
| 325 | |
| 326 | /* restart sending event reports */ |
| 327 | abis_nm_event_reports(bts, 1); |
| 328 | } |
| 329 | |
| 330 | |
| 331 | |
| 332 | struct bcch_info { |
| 333 | u_int8_t type; |
| 334 | u_int8_t len; |
| 335 | const u_int8_t *data; |
| 336 | }; |
| 337 | |
| 338 | /* |
| 339 | SYSTEM INFORMATION TYPE 1 |
| 340 | Cell channel description |
| 341 | Format-ID bit map 0 |
| 342 | CA-ARFCN Bit 124...001 (Hex): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 |
| 343 | RACH Control Parameters |
| 344 | maximum 7 retransmissions |
| 345 | 8 slots used to spread transmission |
| 346 | cell not barred for access |
| 347 | call reestablishment not allowed |
| 348 | Access Control Class = 0000 |
| 349 | */ |
| 350 | static const u_int8_t si1[] = { |
| 351 | 0x55, 0x06, 0x19, 0x04 /*0x00*/, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 352 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /*0x01*/,0xD5, |
| 353 | 0x00, 0x00, 0x2B |
| 354 | }; |
| 355 | |
| 356 | /* |
| 357 | SYSTEM INFORMATION TYPE 2 |
| 358 | Neighbour Cells Description |
| 359 | EXT-IND: Carries the complete BA |
| 360 | BA-IND = 0 |
| 361 | Format-ID bit map 0 |
| 362 | CA-ARFCN Bit 124...001 (Hex): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 363 | NCC permitted (NCC) = FF |
| 364 | RACH Control Parameters |
| 365 | maximum 7 retransmissions |
| 366 | 8 slots used to spread transmission |
| 367 | cell not barred for access |
| 368 | call reestablishment not allowed |
| 369 | Access Control Class = 0000 |
| 370 | */ |
| 371 | static const u_int8_t si2[] = { |
| 372 | 0x59, 0x06, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 373 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xD5, 0x00, |
| 374 | 0x00 |
| 375 | }; |
| 376 | |
| 377 | /* |
| 378 | SYSTEM INFORMATION TYPE 3 |
| 379 | Cell identity = 00001 (1h) |
| 380 | Location area identification |
| 381 | Mobile Country Code (MCC): 001 |
| 382 | Mobile Network Code (MNC): 01 |
| 383 | Location Area Code (LAC): 00001 (1h) |
| 384 | Control Channel Description |
| 385 | Attach-detach: MSs in the cell are not allowed to apply IMSI attach /detach |
| 386 | 0 blocks reserved for access grant |
| 387 | 1 channel used for CCCH, with SDCCH |
| 388 | 5 multiframes period for PAGING REQUEST |
| 389 | Time-out T3212 = 0 |
| 390 | Cell Options BCCH |
| 391 | Power control indicator: not set |
| 392 | MSs shall not use uplink DTX |
| 393 | Radio link timeout = 36 |
| 394 | Cell Selection Parameters |
| 395 | Cell reselect hysteresis = 6 dB RXLEV hysteresis for LA re-selection |
| 396 | max.TX power level MS may use for CCH = 2 |
| 397 | Additional Reselect Parameter Indication (ACS) = only SYSTEM INFO 4: The SI rest octets, if present, shall be used to derive the value of PI and possibly C2 parameters |
| 398 | Half rate support (NECI): New establishment causes are not supported |
| 399 | min.RX signal level for MS = 0 |
| 400 | RACH Control Parameters |
| 401 | maximum 7 retransmissions |
| 402 | 8 slots used to spread transmission |
| 403 | cell not barred for access |
| 404 | call reestablishment not allowed |
| 405 | Access Control Class = 0000 |
| 406 | SI 3 Rest Octets |
| 407 | Cell Bar Qualify (CBQ): 0 |
| 408 | Cell Reselect Offset = 0 dB |
| 409 | Temporary Offset = 0 dB |
| 410 | Penalty Time = 20 s |
| 411 | System Information 2ter Indicator (2TI): 0 = not available |
| 412 | Early Classmark Sending Control (ECSC): 0 = forbidden |
| 413 | Scheduling Information is not sent in SYSTEM INFORMATION TYPE 9 on the BCCH |
| 414 | */ |
| 415 | unsigned char si3[] = { |
| 416 | 0x49, 0x06, 0x1B, 0x00, 0x01, 0x00, 0xF1, 0x10, 0x00, 0x01, |
| 417 | 0x01, 0x03, 0x00, 0x28, 0x62, 0x00, 0xD5, 0x00, 0x00, 0x80, |
| 418 | 0x00, 0x00, 0x2B |
| 419 | }; |
| 420 | |
| 421 | /* |
| 422 | SYSTEM INFORMATION TYPE 4 |
| 423 | Location area identification |
| 424 | Mobile Country Code (MCC): 001 |
| 425 | Mobile Network Code (MNC): 01 |
| 426 | Location Area Code (LAC): 00001 (1h) |
| 427 | Cell Selection Parameters |
| 428 | Cell reselect hysteresis = 6 dB RXLEV hysteresis for LA re-selection |
| 429 | max.TX power level MS may use for CCH = 2 |
| 430 | Additional Reselect Parameter Indication (ACS) = only SYSTEM INFO 4: The SI rest octets, if present, shall be used to derive the value of PI and possibly C2 parameters |
| 431 | Half rate support (NECI): New establishment causes are not supported |
| 432 | min.RX signal level for MS = 0 |
| 433 | RACH Control Parameters |
| 434 | maximum 7 retransmissions |
| 435 | 8 slots used to spread transmission |
| 436 | cell not barred for access |
| 437 | call reestablishment not allowed |
| 438 | Access Control Class = 0000 |
| 439 | Channel Description |
| 440 | Type = SDCCH/4[2] |
| 441 | Timeslot Number: 0 |
| 442 | Training Sequence Code: 7h |
| 443 | ARFCN: 1 |
| 444 | SI Rest Octets |
| 445 | Cell Bar Qualify (CBQ): 0 |
| 446 | Cell Reselect Offset = 0 dB |
| 447 | Temporary Offset = 0 dB |
| 448 | Penalty Time = 20 s |
| 449 | */ |
| 450 | static const u_int8_t si4[] = { |
| 451 | 0x41, 0x06, 0x1C, 0x00, 0xF1, 0x10, 0x00, 0x01, 0x62, 0x00, |
| 452 | 0xD5, 0x00, 0x00, 0x64, 0x30, 0xE0, HARDCODED_ARFCN/*0x01*/, 0x80, 0x00, 0x00, |
| 453 | 0x2B, 0x2B, 0x2B |
| 454 | }; |
| 455 | |
| 456 | /* |
| 457 | SYSTEM INFORMATION TYPE 5 |
| 458 | Neighbour Cells Description |
| 459 | EXT-IND: Carries the complete BA |
| 460 | BA-IND = 0 |
| 461 | Format-ID bit map 0 |
| 462 | CA-ARFCN Bit 124...001 (Hex): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 463 | */ |
| 464 | |
| 465 | static const u_int8_t si5[] = { |
| 466 | 0x06, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 467 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 468 | }; |
| 469 | |
| 470 | // SYSTEM INFORMATION TYPE 6 |
| 471 | |
| 472 | /* |
| 473 | SACCH FILLING |
| 474 | System Info Type: SYSTEM INFORMATION 6 |
| 475 | L3 Information (Hex): 06 1E 00 01 xx xx 10 00 01 28 FF |
| 476 | |
| 477 | SYSTEM INFORMATION TYPE 6 |
| 478 | Cell identity = 00001 (1h) |
| 479 | Location area identification |
| 480 | Mobile Country Code (MCC): 001 |
| 481 | Mobile Network Code (MNC): 01 |
| 482 | Location Area Code (LAC): 00001 (1h) |
| 483 | Cell Options SACCH |
| 484 | Power control indicator: not set |
| 485 | MSs shall not use uplink DTX on a TCH-F. MS shall not use uplink DTX on TCH-H. |
| 486 | Radio link timeout = 36 |
| 487 | NCC permitted (NCC) = FF |
| 488 | */ |
| 489 | |
| 490 | static const u_int8_t si6[] = { |
| 491 | 0x06, 0x1E, 0x00, 0x01, 0x00, 0xF1, 0x10, 0x00, 0x01, 0x28, 0xFF, |
| 492 | }; |
| 493 | |
| 494 | |
| 495 | |
| 496 | static const struct bcch_info bcch_infos[] = { |
| 497 | { |
| 498 | .type = RSL_SYSTEM_INFO_1, |
| 499 | .len = sizeof(si1), |
| 500 | .data = si1, |
| 501 | }, { |
| 502 | .type = RSL_SYSTEM_INFO_2, |
| 503 | .len = sizeof(si2), |
| 504 | .data = si2, |
| 505 | }, { |
| 506 | .type = RSL_SYSTEM_INFO_3, |
| 507 | .len = sizeof(si3), |
| 508 | .data = si3, |
| 509 | }, { |
| 510 | .type = RSL_SYSTEM_INFO_4, |
| 511 | .len = sizeof(si4), |
| 512 | .data = si4, |
| 513 | }, |
| 514 | }; |
| 515 | |
| 516 | /* set all system information types */ |
| 517 | static int set_system_infos(struct gsm_bts *bts) |
| 518 | { |
| 519 | int i; |
| 520 | |
| 521 | for (i = 0; i < ARRAY_SIZE(bcch_infos); i++) { |
| 522 | rsl_bcch_info(bts, bcch_infos[i].type, |
| 523 | bcch_infos[i].data, |
| 524 | bcch_infos[i].len); |
| 525 | } |
| 526 | rsl_sacch_filling(bts, RSL_SYSTEM_INFO_5, si5, sizeof(si5)); |
| 527 | rsl_sacch_filling(bts, RSL_SYSTEM_INFO_6, si6, sizeof(si6)); |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 528 | |
| 529 | return 0; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | static void activate_traffic_channels(struct gsm_bts_trx *trx) |
| 533 | { |
| 534 | int i; |
| 535 | |
| 536 | /* channel 0 is CCCH */ |
| 537 | for (i = 1; i < 8; i++) |
| 538 | rsl_chan_activate_tch_f(&trx->ts[i]); |
| 539 | } |
| 540 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 541 | static void bootstrap_rsl(struct gsm_bts *bts) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 542 | { |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 543 | fprintf(stdout, "bootstrapping RSL\n"); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 544 | set_system_infos(bts); |
| 545 | |
| 546 | /* FIXME: defer this until the channels are used */ |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 547 | //activate_traffic_channels(&bts->trx[0]); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 550 | static void mi_cb(int event, struct gsm_bts *bts) |
| 551 | { |
| 552 | switch (event) { |
| 553 | case EVT_E1_OML_UP: |
| 554 | bootstrap_om(bts); |
| 555 | break; |
| 556 | case EVT_E1_RSL_UP: |
| 557 | bootstrap_rsl(bts); |
| 558 | break; |
| 559 | default: |
| 560 | /* FIXME: deal with TEI or L1 link loss */ |
| 561 | break; |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | static int bootstrap_network(void) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 566 | { |
| 567 | struct gsm_bts *bts; |
| 568 | |
| 569 | /* initialize our data structures */ |
| 570 | gsmnet = gsm_network_init(1, 1, 1); |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 571 | if (!gsmnet) |
| 572 | return -ENOMEM; |
| 573 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 574 | bts = &gsmnet->bts[0]; |
| 575 | bts->location_area_code = 1; |
| 576 | bts->trx[0].arfcn = HARDCODED_ARFCN; |
| 577 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 578 | if (mi_setup(bts, 0, mi_cb) < 0) |
| 579 | return -EIO; |
| 580 | |
| 581 | return 0; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 582 | } |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 583 | |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 584 | int main(int argc, char **argv) |
| 585 | { |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 586 | bootstrap_network(); |
| 587 | |
| 588 | while (1) { |
| 589 | bsc_select_main(); |
| 590 | } |
| 591 | } |