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> |
Holger Freyther | 219518d | 2009-01-02 22:04:43 +0000 | [diff] [blame] | 4 | * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | */ |
| 22 | |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 23 | #include <unistd.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <stdio.h> |
| 26 | #include <stdarg.h> |
| 27 | #include <time.h> |
| 28 | #include <string.h> |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 29 | #include <errno.h> |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 30 | #include <signal.h> |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 31 | #include <fcntl.h> |
| 32 | #include <sys/stat.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 33 | |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 34 | #define _GNU_SOURCE |
| 35 | #include <getopt.h> |
| 36 | |
Harald Welte | 255539c | 2008-12-28 02:26:27 +0000 | [diff] [blame] | 37 | #include <openbsc/db.h> |
| 38 | #include <openbsc/timer.h> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 39 | #include <openbsc/gsm_data.h> |
Harald Welte | 255539c | 2008-12-28 02:26:27 +0000 | [diff] [blame] | 40 | #include <openbsc/gsm_04_08.h> |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 41 | #include <openbsc/select.h> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 42 | #include <openbsc/abis_rsl.h> |
| 43 | #include <openbsc/abis_nm.h> |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 44 | #include <openbsc/debug.h> |
Holger Freyther | 5677ae3 | 2008-12-27 09:41:03 +0000 | [diff] [blame] | 45 | #include <openbsc/misdn.h> |
Holger Freyther | 219518d | 2009-01-02 22:04:43 +0000 | [diff] [blame] | 46 | #include <openbsc/telnet_interface.h> |
Harald Welte | 38c2f13 | 2009-01-06 23:10:57 +0000 | [diff] [blame] | 47 | #include <openbsc/paging.h> |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 48 | #include <openbsc/e1_input.h> |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 49 | |
| 50 | /* global pointer to the gsm network data structure */ |
| 51 | static struct gsm_network *gsmnet; |
| 52 | |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 53 | /* MCC and MNC for the Location Area Identifier */ |
| 54 | static int MCC = 1; |
| 55 | static int MNC = 1; |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 56 | static int ARFCN = HARDCODED_ARFCN; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 57 | static enum gsm_bts_type BTS_TYPE = GSM_BTS_TYPE_BS11; |
Holger Freyther | bde3610 | 2008-12-28 22:51:39 +0000 | [diff] [blame] | 58 | static const char *database_name = "hlr.sqlite3"; |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 59 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 60 | /* The following definitions are for OM and NM packets that we cannot yet |
| 61 | * generate by code but we just pass on */ |
| 62 | |
| 63 | // BTS Site Manager, SET ATTRIBUTES |
| 64 | |
| 65 | /* |
| 66 | Object Class: BTS Site Manager |
| 67 | Instance 1: FF |
| 68 | Instance 2: FF |
| 69 | Instance 3: FF |
| 70 | SET ATTRIBUTES |
| 71 | sAbisExternalTime: 2007/09/08 14:36:11 |
| 72 | omLAPDRelTimer: 30sec |
| 73 | shortLAPDIntTimer: 5sec |
| 74 | emergencyTimer1: 10 minutes |
| 75 | emergencyTimer2: 0 minutes |
| 76 | */ |
| 77 | |
| 78 | unsigned char msg_1[] = |
| 79 | { |
| 80 | 0xD0, 0x00, 0xFF, 0xFF, 0xFF, 0x91, 0x07, 0xD7, 0x09, 0x08, 0x0E, 0x24, |
| 81 | 0x0B, 0xCE, 0x02, 0x00, 0x1E, 0xE8, 0x01, 0x05, 0x42, 0x02, 0x00, 0x0A, 0x44, |
| 82 | 0x02, 0x00, 0x00 |
| 83 | }; |
| 84 | |
| 85 | // BTS, SET BTS ATTRIBUTES |
| 86 | |
| 87 | /* |
| 88 | Object Class: BTS |
| 89 | BTS relat. Number: 0 |
| 90 | Instance 2: FF |
| 91 | Instance 3: FF |
| 92 | SET BTS ATTRIBUTES |
| 93 | bsIdentityCode / BSIC: |
| 94 | PLMN_colour_code: 7h |
| 95 | BS_colour_code: 7h |
| 96 | BTS Air Timer T3105: 4 ,unit 10 ms |
| 97 | btsIsHopping: FALSE |
Harald Welte | 8328229 | 2009-02-01 16:22:19 +0000 | [diff] [blame] | 98 | periodCCCHLoadIndication: 1sec |
Holger Freyther | 3b91043 | 2009-02-11 00:43:48 +0000 | [diff] [blame] | 99 | thresholdCCCHLoadIndication: 0% |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 100 | cellAllocationNumber: 00h = GSM 900 |
| 101 | enableInterferenceClass: 00h = Disabled |
| 102 | fACCHQual: 6 (FACCH stealing flags minus 1) |
| 103 | intaveParameter: 31 SACCH multiframes |
| 104 | interferenceLevelBoundaries: |
| 105 | Interference Boundary 1: 0Ah |
| 106 | Interference Boundary 2: 0Fh |
| 107 | Interference Boundary 3: 14h |
| 108 | Interference Boundary 4: 19h |
| 109 | Interference Boundary 5: 1Eh |
| 110 | mSTxPwrMax: 11 |
| 111 | GSM range: 2=39dBm, 15=13dBm, stepsize 2 dBm |
| 112 | DCS1800 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 113 | PCS1900 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 114 | 30=33dBm, 31=32dBm |
| 115 | ny1: |
| 116 | Maximum number of repetitions for PHYSICAL INFORMATION message (GSM 04.08): 20 |
| 117 | powerOutputThresholds: |
| 118 | Out Power Fault Threshold: -10 dB |
| 119 | Red Out Power Threshold: - 6 dB |
| 120 | Excessive Out Power Threshold: 5 dB |
| 121 | rACHBusyThreshold: -127 dBm |
| 122 | rACHLoadAveragingSlots: 250 ,number of RACH burst periods |
| 123 | rfResourceIndicationPeriod: 125 SACCH multiframes |
| 124 | T200: |
| 125 | SDCCH: 044 in 5 ms |
| 126 | FACCH/Full rate: 031 in 5 ms |
| 127 | FACCH/Half rate: 041 in 5 ms |
| 128 | SACCH with TCH SAPI0: 090 in 10 ms |
| 129 | SACCH with SDCCH: 090 in 10 ms |
| 130 | SDCCH with SAPI3: 090 in 5 ms |
| 131 | SACCH with TCH SAPI3: 135 in 10 ms |
| 132 | tSync: 9000 units of 10 msec |
| 133 | tTrau: 9000 units of 10 msec |
| 134 | enableUmLoopTest: 00h = disabled |
| 135 | enableExcessiveDistance: 00h = Disabled |
| 136 | excessiveDistance: 64km |
| 137 | hoppingMode: 00h = baseband hopping |
| 138 | cellType: 00h = Standard Cell |
| 139 | BCCH ARFCN / bCCHFrequency: 1 |
| 140 | */ |
| 141 | |
| 142 | unsigned char msg_2[] = |
| 143 | { |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 144 | 0x41, 0x01, 0x00, 0xFF, 0xFF, |
| 145 | NM_ATT_BSIC, 0x3F, |
| 146 | NM_ATT_BTS_AIR_TIMER, 0x04, |
| 147 | 0x61, 0x00, |
| 148 | NM_ATT_CCCH_L_I_P, 0x01, |
| 149 | NM_ATT_CCCH_L_T, 0x00, |
| 150 | 0x62, 0x00, |
| 151 | 0x66, 0x00, |
| 152 | 0x6E, 0x06, |
| 153 | NM_ATT_INTAVE_PARAM, 0x1F, |
| 154 | NM_ATT_INTERF_BOUND, 0x0A, 0x0F, 0x14, 0x19, 0x1E, 0x7B, |
| 155 | NM_ATT_CCCH_L_T, 0x23, |
| 156 | NM_ATT_GSM_TIME, 0x28, 0x00, |
| 157 | NM_ATT_ADM_STATE, 0x03, |
| 158 | NM_ATT_RACH_B_THRESH, 0x7F, |
| 159 | NM_ATT_LDAVG_SLOTS, 0x00, 0xFA, |
| 160 | 0x8F, 0x7D, |
| 161 | NM_ATT_T200, 0x2C, 0x1F, 0x29, 0x5A, 0x5A, 0x5A, 0x87, |
| 162 | 0x94, 0x23, 0x28, |
| 163 | 0x95, 0x23, 0x28, |
| 164 | 0x35, 0x01, 0x00, |
| 165 | 0x46, 0x01, 0x00, |
| 166 | 0x58, 0x01, 0x40, |
| 167 | 0xC5, 0x01, 0x00, |
| 168 | 0xF2, 0x01, 0x00, |
| 169 | NM_ATT_BCCH_ARFCN, 0x00, HARDCODED_ARFCN/*0x01*/, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | // Handover Recognition, SET ATTRIBUTES |
| 173 | |
| 174 | /* |
| 175 | Illegal Contents GSM Formatted O&M Msg |
| 176 | Object Class: Handover Recognition |
| 177 | BTS relat. Number: 0 |
| 178 | Instance 2: FF |
| 179 | Instance 3: FF |
| 180 | SET ATTRIBUTES |
| 181 | enableDelayPowerBudgetHO: 00h = Disabled |
| 182 | enableDistanceHO: 00h = Disabled |
| 183 | enableInternalInterCellHandover: 00h = Disabled |
| 184 | enableInternalIntraCellHandover: 00h = Disabled |
| 185 | enablePowerBudgetHO: 00h = Disabled |
| 186 | enableRXLEVHO: 00h = Disabled |
| 187 | enableRXQUALHO: 00h = Disabled |
| 188 | hoAveragingDistance: 8 SACCH multiframes |
| 189 | hoAveragingLev: |
| 190 | A_LEV_HO: 8 SACCH multiframes |
| 191 | W_LEV_HO: 1 SACCH multiframes |
| 192 | hoAveragingPowerBudget: 16 SACCH multiframes |
| 193 | hoAveragingQual: |
| 194 | A_QUAL_HO: 8 SACCH multiframes |
| 195 | W_QUAL_HO: 2 SACCH multiframes |
| 196 | hoLowerThresholdLevDL: (10 - 110) dBm |
| 197 | hoLowerThresholdLevUL: (5 - 110) dBm |
| 198 | hoLowerThresholdQualDL: 06h = 6.4% < BER < 12.8% |
| 199 | hoLowerThresholdQualUL: 06h = 6.4% < BER < 12.8% |
| 200 | hoThresholdLevDLintra : (20 - 110) dBm |
| 201 | hoThresholdLevULintra: (20 - 110) dBm |
| 202 | hoThresholdMsRangeMax: 20 km |
| 203 | nCell: 06h |
| 204 | timerHORequest: 3 ,unit 2 SACCH multiframes |
| 205 | */ |
| 206 | |
| 207 | unsigned char msg_3[] = |
| 208 | { |
| 209 | 0xD0, 0xA1, 0x00, 0xFF, 0xFF, 0xD0, 0x00, 0x64, 0x00, 0x67, 0x00, 0x68, |
| 210 | 0x00, 0x6A, 0x00, 0x6C, 0x00, 0x6D, 0x00, 0x6F, 0x08, 0x70, 0x08, 0x01, |
| 211 | 0x71, 0x10, 0x10, 0x10, 0x72, 0x08, 0x02, 0x73, 0x0A, 0x74, 0x05, 0x75, |
| 212 | 0x06, 0x76, 0x06, 0x78, 0x14, 0x79, 0x14, 0x7A, 0x14, 0x7D, 0x06, 0x92, |
| 213 | 0x03, 0x20, 0x01, 0x00, 0x45, 0x01, 0x00, 0x48, 0x01, 0x00, 0x5A, 0x01, |
| 214 | 0x00, 0x5B, 0x01, 0x05, 0x5E, 0x01, 0x1A, 0x5F, 0x01, 0x20, 0x9D, 0x01, |
| 215 | 0x00, 0x47, 0x01, 0x00, 0x5C, 0x01, 0x64, 0x5D, 0x01, 0x1E, 0x97, 0x01, |
| 216 | 0x20, 0xF7, 0x01, 0x3C, |
| 217 | }; |
| 218 | |
| 219 | // Power Control, SET ATTRIBUTES |
| 220 | |
| 221 | /* |
| 222 | Object Class: Power Control |
| 223 | BTS relat. Number: 0 |
| 224 | Instance 2: FF |
| 225 | Instance 3: FF |
| 226 | SET ATTRIBUTES |
| 227 | enableMsPowerControl: 00h = Disabled |
| 228 | enablePowerControlRLFW: 00h = Disabled |
| 229 | pcAveragingLev: |
| 230 | A_LEV_PC: 4 SACCH multiframes |
| 231 | W_LEV_PC: 1 SACCH multiframes |
| 232 | pcAveragingQual: |
| 233 | A_QUAL_PC: 4 SACCH multiframes |
| 234 | W_QUAL_PC: 2 SACCH multiframes |
| 235 | pcLowerThresholdLevDL: 0Fh |
| 236 | pcLowerThresholdLevUL: 0Ah |
| 237 | pcLowerThresholdQualDL: 05h = 3.2% < BER < 6.4% |
| 238 | pcLowerThresholdQualUL: 05h = 3.2% < BER < 6.4% |
| 239 | pcRLFThreshold: 0Ch |
| 240 | pcUpperThresholdLevDL: 14h |
| 241 | pcUpperThresholdLevUL: 0Fh |
| 242 | pcUpperThresholdQualDL: 04h = 1.6% < BER < 3.2% |
| 243 | pcUpperThresholdQualUL: 04h = 1.6% < BER < 3.2% |
| 244 | powerConfirm: 2 ,unit 2 SACCH multiframes |
| 245 | powerControlInterval: 2 ,unit 2 SACCH multiframes |
| 246 | powerIncrStepSize: 02h = 4 dB |
| 247 | powerRedStepSize: 01h = 2 dB |
| 248 | radioLinkTimeoutBs: 64 SACCH multiframes |
| 249 | enableBSPowerControl: 00h = disabled |
| 250 | */ |
| 251 | |
| 252 | unsigned char msg_4[] = |
| 253 | { |
| 254 | 0xD0, 0xA2, 0x00, 0xFF, 0xFF, 0x69, 0x00, 0x6B, 0x00, 0x7E, 0x04, 0x01, |
| 255 | 0x7F, 0x04, 0x02, 0x80, 0x0F, 0x81, 0x0A, 0x82, 0x05, 0x83, 0x05, 0x84, |
| 256 | 0x0C, 0x85, 0x14, 0x86, 0x0F, 0x87, 0x04, 0x88, 0x04, 0x89, 0x02, 0x8A, |
| 257 | 0x02, 0x8B, 0x02, 0x8C, 0x01, 0x8D, 0x40, 0x65, 0x01, 0x00 // set to 0x01 to enable BSPowerControl |
| 258 | }; |
| 259 | |
| 260 | |
| 261 | // Transceiver, SET TRX ATTRIBUTES (TRX 0) |
| 262 | |
| 263 | /* |
| 264 | Object Class: Transceiver |
| 265 | BTS relat. Number: 0 |
| 266 | Tranceiver number: 0 |
| 267 | Instance 3: FF |
| 268 | SET TRX ATTRIBUTES |
| 269 | aRFCNList (HEX): 0001 |
| 270 | txPwrMaxReduction: 00h = 0dB |
| 271 | radioMeasGran: 254 SACCH multiframes |
| 272 | radioMeasRep: 01h = enabled |
| 273 | memberOfEmergencyConfig: 01h = TRUE |
| 274 | trxArea: 00h = TRX doesn't belong to a concentric cell |
| 275 | */ |
| 276 | |
| 277 | unsigned char msg_6[] = |
| 278 | { |
| 279 | 0x44, 0x02, 0x00, 0x00, 0xFF, 0x05, 0x01, 0x00, HARDCODED_ARFCN /*0x01*/, 0x2D, |
| 280 | 0x00, 0xDC, 0x01, 0xFE, 0xDD, 0x01, 0x01, 0x9B, 0x01, 0x01, 0x9F, 0x01, 0x00, |
| 281 | }; |
| 282 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 283 | static unsigned char nanobts_attr_bts[] = { |
| 284 | NM_ATT_INTERF_BOUND, 0x55, 0x5b, 0x61, 0x67, 0x6d, 0x73, |
| 285 | NM_ATT_INTAVE_PARAM, 0x06, |
| 286 | NM_ATT_CONN_FAIL_CRIT, 0x00, 0x02, 0x01, 0x10, |
| 287 | NM_ATT_T200, 0x1e, 0x24, 0x24, 0xa8, 0x34, 0x21, 0xa8, |
| 288 | NM_ATT_MAX_TA, 0x3f, |
| 289 | NM_ATT_OVERL_PERIOD, 0x00, 0x01, 0x0a, |
| 290 | NM_ATT_CCCH_L_T, 0x1e, |
| 291 | NM_ATT_CCCH_L_I_P, 0x64, |
| 292 | NM_ATT_RACH_B_THRESH, 0x0a, |
| 293 | NM_ATT_LDAVG_SLOTS, 0x03, 0xe8, |
| 294 | NM_ATT_BTS_AIR_TIMER, 0x80, |
| 295 | NM_ATT_NY1, 0x0a, |
| 296 | NM_ATT_BCCH_ARFCN, HARDCODED_ARFCN >> 8, HARDCODED_ARFCN & 0xff, |
| 297 | NM_ATT_BSIC, 0x20, |
| 298 | }; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 299 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 300 | static unsigned char nanobts_attr_radio[] = { |
| 301 | NM_ATT_RF_MAXPOWR_R, 0x0c, |
| 302 | NM_ATT_ARFCN_LIST, 0x00, 0x02, HARDCODED_ARFCN >> 8, HARDCODED_ARFCN & 0xff, |
| 303 | }; |
| 304 | |
| 305 | int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj, |
| 306 | struct gsm_nm_state *old_state, struct gsm_nm_state *new_state) |
| 307 | { |
| 308 | struct gsm_bts *bts; |
| 309 | struct gsm_bts_trx *trx; |
| 310 | struct gsm_bts_trx_ts *ts; |
| 311 | |
| 312 | /* This is currently only required on nanoBTS */ |
| 313 | |
| 314 | switch (evt) { |
| 315 | case EVT_STATECHG_OPER: |
| 316 | switch (obj_class) { |
| 317 | case NM_OC_SITE_MANAGER: |
| 318 | bts = container_of(obj, struct gsm_bts, site_mgr); |
| 319 | if (old_state->operational != 2 && new_state->operational == 2) { |
| 320 | abis_nm_opstart(bts, NM_OC_SITE_MANAGER, 0xff, 0xff, 0xff); |
| 321 | } |
| 322 | break; |
| 323 | case NM_OC_BTS: |
| 324 | bts = obj; |
| 325 | if (new_state->availability == 5) { |
| 326 | abis_nm_set_bts_attr(bts, nanobts_attr_bts, |
| 327 | sizeof(nanobts_attr_bts)); |
| 328 | abis_nm_opstart(bts, NM_OC_BTS, |
| 329 | bts->nr, 0xff, 0xff); |
| 330 | abis_nm_chg_adm_state(bts, NM_OC_BTS, |
| 331 | bts->nr, 0xff, 0xff, |
| 332 | NM_STATE_UNLOCKED); |
| 333 | } |
| 334 | break; |
| 335 | case NM_OC_RADIO_CARRIER: |
| 336 | trx = obj; |
| 337 | if (new_state->availability == 3) { |
| 338 | abis_nm_set_radio_attr(trx, nanobts_attr_radio, |
| 339 | sizeof(nanobts_attr_radio)); |
| 340 | abis_nm_opstart(trx->bts, NM_OC_RADIO_CARRIER, |
| 341 | trx->bts->nr, trx->nr, 0xff); |
| 342 | abis_nm_chg_adm_state(trx->bts, NM_OC_RADIO_CARRIER, |
| 343 | trx->bts->nr, trx->nr, 0xff, |
| 344 | NM_STATE_UNLOCKED); |
| 345 | } |
| 346 | break; |
| 347 | case NM_OC_CHANNEL: |
| 348 | ts = obj; |
| 349 | trx = ts->trx; |
| 350 | if (new_state->availability == 5) { |
| 351 | if (ts->nr == 0 && trx == trx->bts->c0) |
| 352 | abis_nm_set_channel_attr(ts, NM_CHANC_SDCCH_CBCH); |
| 353 | else |
| 354 | abis_nm_set_channel_attr(ts, NM_CHANC_TCHFull); |
| 355 | abis_nm_opstart(trx->bts, NM_OC_CHANNEL, |
| 356 | trx->bts->nr, trx->nr, ts->nr); |
| 357 | abis_nm_chg_adm_state(trx->bts, NM_OC_CHANNEL, |
| 358 | trx->bts->nr, trx->nr, ts->nr, |
| 359 | NM_STATE_UNLOCKED); |
| 360 | } |
| 361 | break; |
| 362 | case NM_OC_BASEB_TRANSC: |
| 363 | trx = container_of(obj, struct gsm_bts_trx, bb_transc); |
| 364 | if (new_state->availability == 5) { |
| 365 | abis_nm_opstart(trx->bts, NM_OC_BASEB_TRANSC, |
| 366 | trx->bts->nr, trx->nr, 0xff); |
| 367 | abis_nm_chg_adm_state(trx->bts, NM_OC_BASEB_TRANSC, |
| 368 | trx->bts->nr, trx->nr, 0xff, |
| 369 | NM_STATE_UNLOCKED); |
| 370 | } |
| 371 | break; |
| 372 | } |
| 373 | break; |
| 374 | } |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | static void bootstrap_om_nanobts(struct gsm_bts *bts) |
| 379 | { |
| 380 | #if 0 |
| 381 | struct gsm_bts_trx *trx = &bts->trx[0]; |
| 382 | int i; |
| 383 | |
| 384 | abis_nm_set_bts_attr(bts, nanobts_attr_bts, sizeof(nanobts_attr_bts)); |
| 385 | abis_nm_opstart(bts, NM_OC_BTS, 0x00, 0xff, 0xff); |
| 386 | abis_nm_set_radio_attr(bts->c0, nanobts_attr_radio, sizeof(nanobts_attr_radio)); |
| 387 | |
| 388 | abis_nm_set_channel_attr(&trx->ts[0], NM_CHANC_SDCCH_CBCH); |
| 389 | for (i = 1; i < TRX_NR_TS; i++) |
| 390 | abis_nm_set_channel_attr(&trx->ts[i], NM_CHANC_TCHFull); |
| 391 | |
| 392 | abis_nm_opstart(bts, NM_OC_BASEB_TRANSC, 0x00, 0x00, 0xff); |
| 393 | abis_nm_opstart(bts, NM_OC_RADIO_CARRIER, 0x00, 0x00, 0xff); |
| 394 | |
| 395 | |
| 396 | for (i = 0; i < TRX_NR_TS; i++) |
| 397 | abis_nm_opstart(bts, NM_OC_CHANNEL, 0x00, 0x00, i); |
| 398 | |
| 399 | abis_nm_chg_adm_state(bts, NM_OC_BASEB_TRANSC, 0x00, 0x00, 0xff, |
| 400 | NM_STATE_UNLOCKED); |
| 401 | |
| 402 | abis_nm_chg_adm_state(bts, NM_OC_RADIO_CARRIER, 0x00, 0x00, 0xff, |
| 403 | NM_STATE_UNLOCKED); |
| 404 | |
| 405 | for (i = 0; i < TRX_NR_TS; i++) |
| 406 | abis_nm_chg_adm_state(bts, NM_OC_CHANNEL, 0x00, 0x00, i, |
| 407 | NM_STATE_UNLOCKED); |
| 408 | |
| 409 | #endif |
| 410 | } |
| 411 | |
| 412 | static void bootstrap_om_bs11(struct gsm_bts *bts) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 413 | { |
| 414 | struct gsm_bts_trx *trx = &bts->trx[0]; |
| 415 | |
| 416 | /* stop sending event reports */ |
| 417 | abis_nm_event_reports(bts, 0); |
| 418 | |
| 419 | /* begin DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 420 | abis_nm_bs11_db_transmission(bts, 1); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 421 | |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 422 | /* end DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 423 | abis_nm_bs11_db_transmission(bts, 0); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 424 | |
| 425 | /* Reset BTS Site manager resource */ |
Harald Welte | 7837489 | 2009-01-18 19:09:22 +0000 | [diff] [blame] | 426 | abis_nm_bs11_reset_resource(bts); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 427 | |
| 428 | /* begin DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 429 | abis_nm_bs11_db_transmission(bts, 1); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 430 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 431 | abis_nm_raw_msg(bts, sizeof(msg_1), msg_1); /* set BTS SiteMgr attr*/ |
| 432 | abis_nm_raw_msg(bts, sizeof(msg_2), msg_2); /* set BTS attr */ |
| 433 | abis_nm_raw_msg(bts, sizeof(msg_3), msg_3); /* set BTS handover attr */ |
| 434 | abis_nm_raw_msg(bts, sizeof(msg_4), msg_4); /* set BTS power control attr */ |
| 435 | |
| 436 | /* Connect signalling of bts0/trx0 to e1_0/ts1/64kbps */ |
| 437 | abis_nm_conn_terr_sign(trx, 0, 1, 0xff); |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 438 | set_ts_e1link(&trx->ts[0], 0, 1, 0xff); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 439 | abis_nm_raw_msg(bts, sizeof(msg_6), msg_6); /* SET TRX ATTRIBUTES */ |
| 440 | |
| 441 | /* Use TEI 1 for signalling */ |
| 442 | abis_nm_establish_tei(bts, 0, 0, 1, 0xff, 0x01); |
| 443 | abis_nm_set_channel_attr(&trx->ts[0], NM_CHANC_SDCCH_CBCH); |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 444 | |
| 445 | #ifdef HAVE_TRX1 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 446 | /* TRX 1 */ |
| 447 | abis_nm_conn_terr_sign(&bts->trx[1], 0, 1, 0xff); |
| 448 | /* FIXME: TRX ATTRIBUTE */ |
| 449 | abis_nm_establish_tei(bts, 0, 0, 1, 0xff, 0x02); |
| 450 | #endif |
| 451 | |
| 452 | /* SET CHANNEL ATTRIBUTE TS1 */ |
| 453 | abis_nm_set_channel_attr(&trx->ts[1], 0x09); |
| 454 | /* Connect traffic of bts0/trx0/ts1 to e1_0/ts2/b */ |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 455 | set_ts_e1link(&trx->ts[1], 0, 2, 1); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 456 | abis_nm_conn_terr_traf(&trx->ts[1], 0, 2, 1); |
| 457 | |
| 458 | /* SET CHANNEL ATTRIBUTE TS2 */ |
| 459 | abis_nm_set_channel_attr(&trx->ts[2], 0x09); |
| 460 | /* Connect traffic of bts0/trx0/ts2 to e1_0/ts2/c */ |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 461 | set_ts_e1link(&trx->ts[2], 0, 2, 2); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 462 | abis_nm_conn_terr_traf(&trx->ts[2], 0, 2, 2); |
| 463 | |
| 464 | /* SET CHANNEL ATTRIBUTE TS3 */ |
| 465 | abis_nm_set_channel_attr(&trx->ts[3], 0x09); |
| 466 | /* Connect traffic of bts0/trx0/ts3 to e1_0/ts2/d */ |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 467 | set_ts_e1link(&trx->ts[3], 0, 2, 3); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 468 | abis_nm_conn_terr_traf(&trx->ts[3], 0, 2, 3); |
| 469 | |
| 470 | /* SET CHANNEL ATTRIBUTE TS4 */ |
| 471 | abis_nm_set_channel_attr(&trx->ts[4], 0x09); |
| 472 | /* Connect traffic of bts0/trx0/ts4 to e1_0/ts3/a */ |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 473 | set_ts_e1link(&trx->ts[4], 0, 3, 0); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 474 | abis_nm_conn_terr_traf(&trx->ts[4], 0, 3, 0); |
| 475 | |
| 476 | /* SET CHANNEL ATTRIBUTE TS5 */ |
| 477 | abis_nm_set_channel_attr(&trx->ts[5], 0x09); |
| 478 | /* Connect traffic of bts0/trx0/ts5 to e1_0/ts3/b */ |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 479 | set_ts_e1link(&trx->ts[5], 0, 3, 1); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 480 | abis_nm_conn_terr_traf(&trx->ts[5], 0, 3, 1); |
| 481 | |
| 482 | /* SET CHANNEL ATTRIBUTE TS6 */ |
| 483 | abis_nm_set_channel_attr(&trx->ts[6], 0x09); |
| 484 | /* Connect traffic of bts0/trx0/ts6 to e1_0/ts3/c */ |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 485 | set_ts_e1link(&trx->ts[6], 0, 3, 2); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 486 | abis_nm_conn_terr_traf(&trx->ts[6], 0, 3, 2); |
| 487 | |
| 488 | /* SET CHANNEL ATTRIBUTE TS7 */ |
| 489 | abis_nm_set_channel_attr(&trx->ts[7], 0x09); |
| 490 | /* Connect traffic of bts0/trx0/ts7 to e1_0/ts3/d */ |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 491 | set_ts_e1link(&trx->ts[7], 0, 3, 3); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 492 | abis_nm_conn_terr_traf(&trx->ts[7], 0, 3, 3); |
| 493 | |
| 494 | /* end DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 495 | abis_nm_bs11_db_transmission(bts, 0); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 496 | |
| 497 | /* Reset BTS Site manager resource */ |
Harald Welte | 7837489 | 2009-01-18 19:09:22 +0000 | [diff] [blame] | 498 | abis_nm_bs11_reset_resource(bts); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 499 | |
| 500 | /* restart sending event reports */ |
| 501 | abis_nm_event_reports(bts, 1); |
| 502 | } |
| 503 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 504 | static void bootstrap_om(struct gsm_bts *bts) |
| 505 | { |
| 506 | fprintf(stdout, "bootstrapping OML\n"); |
| 507 | |
| 508 | switch (bts->type) { |
| 509 | case GSM_BTS_TYPE_BS11: |
| 510 | bootstrap_om_bs11(bts); |
| 511 | break; |
| 512 | case GSM_BTS_TYPE_NANOBTS_900: |
| 513 | case GSM_BTS_TYPE_NANOBTS_1800: |
| 514 | bootstrap_om_nanobts(bts); |
| 515 | break; |
| 516 | default: |
| 517 | fprintf(stderr, "Unable to bootstrap OML: Unknown BTS type %d\n", bts->type); |
| 518 | } |
| 519 | } |
| 520 | |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 521 | static int shutdown_om(struct gsm_bts *bts) |
| 522 | { |
| 523 | /* stop sending event reports */ |
| 524 | abis_nm_event_reports(bts, 0); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 525 | |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 526 | /* begin DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 527 | abis_nm_bs11_db_transmission(bts, 1); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 528 | |
| 529 | /* end DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 530 | abis_nm_bs11_db_transmission(bts, 0); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 531 | |
| 532 | /* Reset BTS Site manager resource */ |
Harald Welte | 7837489 | 2009-01-18 19:09:22 +0000 | [diff] [blame] | 533 | abis_nm_bs11_reset_resource(bts); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 534 | |
| 535 | return 0; |
| 536 | } |
| 537 | |
| 538 | static int shutdown_net(struct gsm_network *net) |
| 539 | { |
| 540 | int i; |
| 541 | for (i = 0; i < net->num_bts; i++) { |
| 542 | int rc; |
| 543 | rc = shutdown_om(&net->bts[i]); |
| 544 | if (rc < 0) |
| 545 | return rc; |
| 546 | } |
| 547 | |
| 548 | return 0; |
| 549 | } |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 550 | |
| 551 | struct bcch_info { |
| 552 | u_int8_t type; |
| 553 | u_int8_t len; |
| 554 | const u_int8_t *data; |
| 555 | }; |
| 556 | |
| 557 | /* |
| 558 | SYSTEM INFORMATION TYPE 1 |
| 559 | Cell channel description |
| 560 | Format-ID bit map 0 |
| 561 | CA-ARFCN Bit 124...001 (Hex): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 |
| 562 | RACH Control Parameters |
| 563 | maximum 7 retransmissions |
| 564 | 8 slots used to spread transmission |
| 565 | cell not barred for access |
| 566 | call reestablishment not allowed |
| 567 | Access Control Class = 0000 |
| 568 | */ |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 569 | static u_int8_t si1[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 570 | /* header */0x55, 0x06, 0x19, |
| 571 | /* ccdesc */0x04 /*0x00*/, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 572 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /*0x01*/, |
| 573 | /* rach */0xD5, 0x00, 0x00, |
| 574 | /* s1 reset*/0x2B |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 575 | }; |
| 576 | |
| 577 | /* |
| 578 | SYSTEM INFORMATION TYPE 2 |
| 579 | Neighbour Cells Description |
| 580 | EXT-IND: Carries the complete BA |
| 581 | BA-IND = 0 |
| 582 | Format-ID bit map 0 |
| 583 | CA-ARFCN Bit 124...001 (Hex): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 584 | NCC permitted (NCC) = FF |
| 585 | RACH Control Parameters |
| 586 | maximum 7 retransmissions |
| 587 | 8 slots used to spread transmission |
| 588 | cell not barred for access |
| 589 | call reestablishment not allowed |
| 590 | Access Control Class = 0000 |
| 591 | */ |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 592 | static u_int8_t si2[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 593 | /* header */0x59, 0x06, 0x1A, |
| 594 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 595 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 596 | /* ncc */0xFF, |
| 597 | /* rach*/0xD5, 0x00, 0x00 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 598 | }; |
| 599 | |
| 600 | /* |
| 601 | SYSTEM INFORMATION TYPE 3 |
| 602 | Cell identity = 00001 (1h) |
| 603 | Location area identification |
| 604 | Mobile Country Code (MCC): 001 |
| 605 | Mobile Network Code (MNC): 01 |
| 606 | Location Area Code (LAC): 00001 (1h) |
| 607 | Control Channel Description |
| 608 | Attach-detach: MSs in the cell are not allowed to apply IMSI attach /detach |
| 609 | 0 blocks reserved for access grant |
| 610 | 1 channel used for CCCH, with SDCCH |
| 611 | 5 multiframes period for PAGING REQUEST |
| 612 | Time-out T3212 = 0 |
| 613 | Cell Options BCCH |
| 614 | Power control indicator: not set |
| 615 | MSs shall not use uplink DTX |
| 616 | Radio link timeout = 36 |
| 617 | Cell Selection Parameters |
| 618 | Cell reselect hysteresis = 6 dB RXLEV hysteresis for LA re-selection |
Harald Welte | 3b2ec42 | 2008-12-29 04:11:14 +0000 | [diff] [blame] | 619 | max.TX power level MS may use for CCH = 2 <- according to GSM05.05 39dBm (max) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 620 | 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 |
| 621 | Half rate support (NECI): New establishment causes are not supported |
| 622 | min.RX signal level for MS = 0 |
| 623 | RACH Control Parameters |
| 624 | maximum 7 retransmissions |
| 625 | 8 slots used to spread transmission |
| 626 | cell not barred for access |
| 627 | call reestablishment not allowed |
| 628 | Access Control Class = 0000 |
| 629 | SI 3 Rest Octets |
| 630 | Cell Bar Qualify (CBQ): 0 |
| 631 | Cell Reselect Offset = 0 dB |
| 632 | Temporary Offset = 0 dB |
| 633 | Penalty Time = 20 s |
| 634 | System Information 2ter Indicator (2TI): 0 = not available |
| 635 | Early Classmark Sending Control (ECSC): 0 = forbidden |
| 636 | Scheduling Information is not sent in SYSTEM INFORMATION TYPE 9 on the BCCH |
| 637 | */ |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 638 | static u_int8_t si3[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 639 | /* header */0x49, 0x06, 0x1B, |
| 640 | /* cell */0x00, 0x01, |
| 641 | /* lai */0x00, 0xF1, 0x10, 0x00, 0x01, |
| 642 | /* desc */0x01, 0x03, 0x00, |
| 643 | /* option*/0x28, |
| 644 | /* selection*/0x62, 0x00, |
| 645 | /* rach */0xD5, 0x00, 0x00, |
| 646 | /* reset*/0x80, 0x00, 0x00, 0x2B |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 647 | }; |
| 648 | |
| 649 | /* |
| 650 | SYSTEM INFORMATION TYPE 4 |
| 651 | Location area identification |
| 652 | Mobile Country Code (MCC): 001 |
| 653 | Mobile Network Code (MNC): 01 |
| 654 | Location Area Code (LAC): 00001 (1h) |
| 655 | Cell Selection Parameters |
| 656 | Cell reselect hysteresis = 6 dB RXLEV hysteresis for LA re-selection |
| 657 | max.TX power level MS may use for CCH = 2 |
| 658 | 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 |
| 659 | Half rate support (NECI): New establishment causes are not supported |
| 660 | min.RX signal level for MS = 0 |
| 661 | RACH Control Parameters |
| 662 | maximum 7 retransmissions |
| 663 | 8 slots used to spread transmission |
| 664 | cell not barred for access |
| 665 | call reestablishment not allowed |
| 666 | Access Control Class = 0000 |
| 667 | Channel Description |
| 668 | Type = SDCCH/4[2] |
| 669 | Timeslot Number: 0 |
| 670 | Training Sequence Code: 7h |
| 671 | ARFCN: 1 |
| 672 | SI Rest Octets |
| 673 | Cell Bar Qualify (CBQ): 0 |
| 674 | Cell Reselect Offset = 0 dB |
| 675 | Temporary Offset = 0 dB |
| 676 | Penalty Time = 20 s |
| 677 | */ |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 678 | static u_int8_t si4[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 679 | /* header */0x41, 0x06, 0x1C, |
| 680 | /* lai */0x00, 0xF1, 0x10, 0x00, 0x01, |
| 681 | /* sel */0x62, 0x00, |
| 682 | /* rach*/0xD5, 0x00, 0x00, |
| 683 | /* var */0x64, 0x30, 0xE0, HARDCODED_ARFCN/*0x01*/, 0x80, 0x00, 0x00, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 684 | 0x2B, 0x2B, 0x2B |
| 685 | }; |
| 686 | |
| 687 | /* |
| 688 | SYSTEM INFORMATION TYPE 5 |
| 689 | Neighbour Cells Description |
| 690 | EXT-IND: Carries the complete BA |
| 691 | BA-IND = 0 |
| 692 | Format-ID bit map 0 |
| 693 | CA-ARFCN Bit 124...001 (Hex): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 694 | */ |
| 695 | |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 696 | static u_int8_t si5[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 697 | /* header without l2 len*/0x06, 0x1D, |
| 698 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 699 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 700 | }; |
| 701 | |
| 702 | // SYSTEM INFORMATION TYPE 6 |
| 703 | |
| 704 | /* |
| 705 | SACCH FILLING |
| 706 | System Info Type: SYSTEM INFORMATION 6 |
| 707 | L3 Information (Hex): 06 1E 00 01 xx xx 10 00 01 28 FF |
| 708 | |
| 709 | SYSTEM INFORMATION TYPE 6 |
| 710 | Cell identity = 00001 (1h) |
| 711 | Location area identification |
| 712 | Mobile Country Code (MCC): 001 |
| 713 | Mobile Network Code (MNC): 01 |
| 714 | Location Area Code (LAC): 00001 (1h) |
| 715 | Cell Options SACCH |
| 716 | Power control indicator: not set |
| 717 | MSs shall not use uplink DTX on a TCH-F. MS shall not use uplink DTX on TCH-H. |
| 718 | Radio link timeout = 36 |
| 719 | NCC permitted (NCC) = FF |
| 720 | */ |
| 721 | |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 722 | static u_int8_t si6[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 723 | /* header */0x06, 0x1E, |
| 724 | /* cell id*/ 0x00, 0x01, |
| 725 | /* lai */ 0x00, 0xF1, 0x10, 0x00, 0x01, |
| 726 | /* options */ 0x28, |
| 727 | /* ncc */ 0xFF, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 728 | }; |
| 729 | |
| 730 | |
| 731 | |
| 732 | static const struct bcch_info bcch_infos[] = { |
| 733 | { |
| 734 | .type = RSL_SYSTEM_INFO_1, |
| 735 | .len = sizeof(si1), |
| 736 | .data = si1, |
| 737 | }, { |
| 738 | .type = RSL_SYSTEM_INFO_2, |
| 739 | .len = sizeof(si2), |
| 740 | .data = si2, |
| 741 | }, { |
| 742 | .type = RSL_SYSTEM_INFO_3, |
| 743 | .len = sizeof(si3), |
| 744 | .data = si3, |
| 745 | }, { |
| 746 | .type = RSL_SYSTEM_INFO_4, |
| 747 | .len = sizeof(si4), |
| 748 | .data = si4, |
| 749 | }, |
| 750 | }; |
| 751 | |
Holger Freyther | 24287b6 | 2008-12-28 16:32:41 +0000 | [diff] [blame] | 752 | static_assert(sizeof(si1) == sizeof(struct gsm48_system_information_type_1), type1) |
| 753 | static_assert(sizeof(si2) == sizeof(struct gsm48_system_information_type_2), type2) |
| 754 | static_assert(sizeof(si3) == sizeof(struct gsm48_system_information_type_3), type3) |
| 755 | static_assert(sizeof(si4) >= sizeof(struct gsm48_system_information_type_4), type4) |
Harald Welte | 104604e | 2008-12-28 16:36:11 +0000 | [diff] [blame] | 756 | static_assert(sizeof(si5) == sizeof(struct gsm48_system_information_type_5), type5) |
| 757 | static_assert(sizeof(si6) >= sizeof(struct gsm48_system_information_type_6), type6) |
Holger Freyther | 24287b6 | 2008-12-28 16:32:41 +0000 | [diff] [blame] | 758 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 759 | /* set all system information types */ |
Harald Welte | e79769b | 2009-02-07 00:48:17 +0000 | [diff] [blame] | 760 | static int set_system_infos(struct gsm_bts_trx *trx) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 761 | { |
| 762 | int i; |
| 763 | |
| 764 | for (i = 0; i < ARRAY_SIZE(bcch_infos); i++) { |
Harald Welte | e79769b | 2009-02-07 00:48:17 +0000 | [diff] [blame] | 765 | rsl_bcch_info(trx, bcch_infos[i].type, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 766 | bcch_infos[i].data, |
| 767 | bcch_infos[i].len); |
| 768 | } |
Harald Welte | e79769b | 2009-02-07 00:48:17 +0000 | [diff] [blame] | 769 | rsl_sacch_filling(trx, RSL_SYSTEM_INFO_5, si5, sizeof(si5)); |
| 770 | rsl_sacch_filling(trx, RSL_SYSTEM_INFO_6, si6, sizeof(si6)); |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 771 | |
| 772 | return 0; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 773 | } |
| 774 | |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 775 | /* |
Harald Welte | 38c2f13 | 2009-01-06 23:10:57 +0000 | [diff] [blame] | 776 | * Inform anyone... |
| 777 | */ |
| 778 | static void bsc_hack_channel_allocated(struct gsm_lchan *lchan) { |
| 779 | } |
| 780 | |
| 781 | /* |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 782 | * Patch the various SYSTEM INFORMATION tables to update |
| 783 | * the LAI |
| 784 | */ |
| 785 | static void patch_tables(struct gsm_bts *bts) |
| 786 | { |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 787 | u_int8_t arfcn_low = ARFCN & 0xff; |
| 788 | u_int8_t arfcn_high = (ARFCN >> 8) & 0x0f; |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 789 | /* covert the raw packet to the struct */ |
| 790 | struct gsm48_system_information_type_3 *type_3 = |
| 791 | (struct gsm48_system_information_type_3*)&si3; |
| 792 | struct gsm48_system_information_type_4 *type_4 = |
| 793 | (struct gsm48_system_information_type_4*)&si4; |
| 794 | struct gsm48_system_information_type_6 *type_6 = |
| 795 | (struct gsm48_system_information_type_6*)&si6; |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 796 | struct gsm48_loc_area_id lai; |
| 797 | |
| 798 | gsm0408_generate_lai(&lai, bts->network->country_code, |
| 799 | bts->network->network_code, bts->location_area_code); |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 800 | |
| 801 | /* assign the MCC and MNC */ |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 802 | type_3->lai = lai; |
| 803 | type_4->lai = lai; |
| 804 | type_6->lai = lai; |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 805 | |
| 806 | /* patch ARFCN */ |
| 807 | msg_2[74] &= 0xf0; |
| 808 | msg_2[74] |= arfcn_high; |
| 809 | msg_2[75] = arfcn_low; |
| 810 | |
| 811 | msg_6[7] &= 0xf0; |
| 812 | msg_6[7] |= arfcn_high; |
| 813 | msg_6[8] = arfcn_low; |
| 814 | |
| 815 | type_4->data[2] &= 0xf0; |
| 816 | type_4->data[2] |= arfcn_high; |
| 817 | type_4->data[3] = arfcn_low; |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 818 | |
| 819 | /* patch Control Channel Description 10.5.2.11 */ |
| 820 | type_3->control_channel_desc = bts->chan_desc; |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | |
Harald Welte | e79769b | 2009-02-07 00:48:17 +0000 | [diff] [blame] | 824 | static void bootstrap_rsl(struct gsm_bts_trx *trx) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 825 | { |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 826 | fprintf(stdout, "bootstrapping RSL MCC=%u MNC=%u\n", MCC, MNC); |
Harald Welte | e79769b | 2009-02-07 00:48:17 +0000 | [diff] [blame] | 827 | set_system_infos(trx); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 828 | } |
| 829 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 830 | void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx) |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 831 | { |
| 832 | switch (event) { |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 833 | case EVT_E1_TEI_UP: |
| 834 | switch (type) { |
| 835 | case E1INP_SIGN_OML: |
| 836 | bootstrap_om(trx->bts); |
| 837 | break; |
| 838 | case E1INP_SIGN_RSL: |
| 839 | bootstrap_rsl(trx); |
| 840 | break; |
| 841 | default: |
| 842 | break; |
| 843 | } |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 844 | break; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 845 | case EVT_E1_TEI_DN: |
| 846 | fprintf(stderr, "Lost some E1 TEI link\n"); |
| 847 | /* FIXME: deal with TEI or L1 link loss */ |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 848 | break; |
| 849 | default: |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 850 | break; |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | static int bootstrap_network(void) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 855 | { |
| 856 | struct gsm_bts *bts; |
| 857 | |
| 858 | /* initialize our data structures */ |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 859 | gsmnet = gsm_network_init(1, BTS_TYPE, MCC, MNC); |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 860 | if (!gsmnet) |
| 861 | return -ENOMEM; |
Harald Welte | f5cbab7 | 2008-12-30 18:00:15 +0000 | [diff] [blame] | 862 | |
| 863 | gsmnet->name_short = "25C3"; |
| 864 | gsmnet->name_long = "25C3 GSM"; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 865 | bts = &gsmnet->bts[0]; |
| 866 | bts->location_area_code = 1; |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 867 | bts->trx[0].arfcn = ARFCN; |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 868 | |
| 869 | /* Control Channel Description */ |
| 870 | memset(&bts->chan_desc, 0, sizeof(struct gsm48_control_channel_descr)); |
| 871 | bts->chan_desc.att = 0; |
| 872 | bts->chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_1_C; |
| 873 | bts->chan_desc.bs_pa_mfrms = RSL_BS_PA_MFRMS_5; |
| 874 | bts->chan_desc.t3212 = 0; |
| 875 | |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 876 | patch_tables(bts); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 877 | |
Holger Freyther | 1fd3414 | 2009-02-09 23:42:03 +0000 | [diff] [blame] | 878 | paging_init(bts); |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 879 | bts->paging.channel_allocated = bsc_hack_channel_allocated; |
Harald Welte | 38c2f13 | 2009-01-06 23:10:57 +0000 | [diff] [blame] | 880 | |
Holger Freyther | 219518d | 2009-01-02 22:04:43 +0000 | [diff] [blame] | 881 | telnet_init(gsmnet, 4242); |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 882 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 883 | /* E1 mISDN input setup */ |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 884 | if (BTS_TYPE == GSM_BTS_TYPE_BS11) |
| 885 | return e1_config(bts); |
| 886 | else |
| 887 | return ia_config(bts); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 888 | } |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 889 | |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 890 | static void create_pcap_file(char *file) |
| 891 | { |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 892 | #if 0 |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 893 | mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; |
| 894 | int fd = open(file, O_WRONLY|O_TRUNC|O_CREAT, mode); |
| 895 | |
| 896 | if (fd < 0) { |
| 897 | perror("Failed to open file for pcap"); |
| 898 | return; |
| 899 | } |
| 900 | |
| 901 | mi_set_pcap_fd(fd); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 902 | #else |
| 903 | fprintf(stderr, "PCAP support currently disabled!!\n"); |
| 904 | #endif |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 905 | } |
| 906 | |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 907 | static void print_usage() |
| 908 | { |
| 909 | printf("Usage: bsc_hack\n"); |
| 910 | } |
| 911 | |
| 912 | static void print_help() |
| 913 | { |
| 914 | printf(" Some useful help...\n"); |
| 915 | printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM enable debugging\n"); |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 916 | printf(" -s --disable-color\n"); |
| 917 | printf(" -n --network-code number(MNC) \n"); |
| 918 | printf(" -c --country-code number (MCC) \n"); |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 919 | printf(" -f --arfcn number The frequency ARFCN\n"); |
Holger Freyther | bde3610 | 2008-12-28 22:51:39 +0000 | [diff] [blame] | 920 | printf(" -l --database db-name The database to use\n"); |
Holger Freyther | 89824fc | 2008-12-30 16:18:18 +0000 | [diff] [blame] | 921 | printf(" -a --authorize-everyone Allow everyone into the network.\n"); |
Holger Freyther | e97f7fb | 2008-12-31 18:52:11 +0000 | [diff] [blame] | 922 | printf(" -r --reject-cause number The reject cause for LOCATION UPDATING REJECT.\n"); |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 923 | printf(" -p --pcap file The filename of the pcap file\n"); |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 924 | printf(" -h --help this text\n"); |
| 925 | } |
| 926 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 927 | static const char *bts_types[] = { |
| 928 | [GSM_BTS_TYPE_UNKNOWN] = "unknown", |
| 929 | [GSM_BTS_TYPE_BS11] = "bs11", |
| 930 | [GSM_BTS_TYPE_NANOBTS_900] = "nanobts900", |
| 931 | [GSM_BTS_TYPE_NANOBTS_1800] = "nanobts1800", |
| 932 | }; |
| 933 | |
| 934 | enum gsm_bts_type parse_btstype(char *arg) |
| 935 | { |
| 936 | int i; |
| 937 | for (i = 0; i < ARRAY_SIZE(bts_types); i++) { |
| 938 | if (!strcmp(arg, bts_types[i])) |
| 939 | return i; |
| 940 | } |
| 941 | return 0; /* Default: BS11 */ |
| 942 | } |
| 943 | |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 944 | static void handle_options(int argc, char** argv) |
| 945 | { |
| 946 | while (1) { |
| 947 | int option_index = 0, c; |
| 948 | static struct option long_options[] = { |
| 949 | {"help", 0, 0, 'h'}, |
| 950 | {"debug", 1, 0, 'd'}, |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 951 | {"disable-color", 0, 0, 's'}, |
| 952 | {"network-code", 1, 0, 'n'}, |
| 953 | {"country-code", 1, 0, 'c'}, |
Holger Freyther | bde3610 | 2008-12-28 22:51:39 +0000 | [diff] [blame] | 954 | {"database", 1, 0, 'l'}, |
Holger Freyther | 89824fc | 2008-12-30 16:18:18 +0000 | [diff] [blame] | 955 | {"authorize-everyone", 0, 0, 'a'}, |
Holger Freyther | e97f7fb | 2008-12-31 18:52:11 +0000 | [diff] [blame] | 956 | {"reject-cause", 1, 0, 'r'}, |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 957 | {"pcap", 1, 0, 'p'}, |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 958 | {"arfcn", 1, 0, 'f'}, |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 959 | {"bts-type", 1, 0, 't'}, |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 960 | {0, 0, 0, 0} |
| 961 | }; |
| 962 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 963 | c = getopt_long(argc, argv, "hc:n:d:sar:p:f:t:", |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 964 | long_options, &option_index); |
| 965 | if (c == -1) |
| 966 | break; |
| 967 | |
| 968 | switch (c) { |
| 969 | case 'h': |
| 970 | print_usage(); |
| 971 | print_help(); |
| 972 | exit(0); |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 973 | case 's': |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 974 | debug_use_color(0); |
| 975 | break; |
| 976 | case 'd': |
| 977 | debug_parse_category_mask(optarg); |
| 978 | break; |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 979 | case 'n': |
| 980 | MNC = atoi(optarg); |
| 981 | break; |
| 982 | case 'c': |
| 983 | MCC = atoi(optarg); |
| 984 | break; |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 985 | case 'f': |
| 986 | ARFCN = atoi(optarg); |
| 987 | break; |
Harald Welte | 8965da4 | 2009-01-06 18:09:02 +0000 | [diff] [blame] | 988 | case 'l': |
Holger Freyther | bde3610 | 2008-12-28 22:51:39 +0000 | [diff] [blame] | 989 | database_name = strdup(optarg); |
| 990 | break; |
Holger Freyther | 89824fc | 2008-12-30 16:18:18 +0000 | [diff] [blame] | 991 | case 'a': |
| 992 | gsm0408_allow_everyone(1); |
| 993 | break; |
Holger Freyther | e97f7fb | 2008-12-31 18:52:11 +0000 | [diff] [blame] | 994 | case 'r': |
| 995 | gsm0408_set_reject_cause(atoi(optarg)); |
| 996 | break; |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 997 | case 'p': |
| 998 | create_pcap_file(optarg); |
| 999 | break; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame^] | 1000 | case 't': |
| 1001 | BTS_TYPE = parse_btstype(optarg); |
| 1002 | break; |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1003 | default: |
| 1004 | /* ignore */ |
| 1005 | break; |
| 1006 | } |
| 1007 | } |
| 1008 | } |
| 1009 | |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 1010 | static void signal_handler(int signal) |
| 1011 | { |
| 1012 | fprintf(stdout, "signal %u received\n", signal); |
| 1013 | |
| 1014 | switch (signal) { |
| 1015 | case SIGHUP: |
| 1016 | case SIGABRT: |
| 1017 | shutdown_net(gsmnet); |
| 1018 | break; |
| 1019 | default: |
| 1020 | break; |
| 1021 | } |
| 1022 | } |
| 1023 | |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 1024 | int main(int argc, char **argv) |
| 1025 | { |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 1026 | int rc; |
| 1027 | |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1028 | /* parse options */ |
| 1029 | handle_options(argc, argv); |
| 1030 | |
Holger Freyther | bde3610 | 2008-12-28 22:51:39 +0000 | [diff] [blame] | 1031 | if (db_init(database_name)) { |
Harald Welte | 75a983f | 2008-12-27 21:34:06 +0000 | [diff] [blame] | 1032 | printf("DB: Failed to init database. Please check the option settings.\n"); |
| 1033 | return 1; |
| 1034 | } |
| 1035 | printf("DB: Database initialized.\n"); |
| 1036 | |
| 1037 | if (db_prepare()) { |
| 1038 | printf("DB: Failed to prepare database.\n"); |
| 1039 | return 1; |
| 1040 | } |
| 1041 | printf("DB: Database prepared.\n"); |
| 1042 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 1043 | rc = bootstrap_network(); |
| 1044 | if (rc < 0) |
| 1045 | exit(1); |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 1046 | |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 1047 | signal(SIGHUP, &signal_handler); |
| 1048 | signal(SIGABRT, &signal_handler); |
| 1049 | |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 1050 | while (1) { |
| 1051 | bsc_select_main(); |
| 1052 | } |
| 1053 | } |