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