Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | /* A hackish minimal BSC (+MSC +HLR) implementation */ |
| 2 | |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 3 | /* (C) 2008-2009 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 | 66b6a8d | 2009-08-09 14:45:18 +0200 | [diff] [blame] | 40 | #include <openbsc/gsm_utils.h> |
Harald Welte | 255539c | 2008-12-28 02:26:27 +0000 | [diff] [blame] | 41 | #include <openbsc/gsm_04_08.h> |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 42 | #include <openbsc/select.h> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 43 | #include <openbsc/abis_rsl.h> |
| 44 | #include <openbsc/abis_nm.h> |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 45 | #include <openbsc/debug.h> |
Holger Freyther | 5677ae3 | 2008-12-27 09:41:03 +0000 | [diff] [blame] | 46 | #include <openbsc/misdn.h> |
Holger Freyther | 219518d | 2009-01-02 22:04:43 +0000 | [diff] [blame] | 47 | #include <openbsc/telnet_interface.h> |
Harald Welte | 38c2f13 | 2009-01-06 23:10:57 +0000 | [diff] [blame] | 48 | #include <openbsc/paging.h> |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 49 | #include <openbsc/e1_input.h> |
Harald Welte | b463060 | 2009-05-01 15:43:22 +0000 | [diff] [blame] | 50 | #include <openbsc/signal.h> |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 51 | #include <openbsc/talloc.h> |
| 52 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 53 | /* global pointer to the gsm network data structure */ |
Harald Welte | 879c85a | 2009-05-01 15:00:20 +0000 | [diff] [blame] | 54 | static struct gsm_network *gsmnet; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 55 | |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 56 | /* MCC and MNC for the Location Area Identifier */ |
| 57 | static int MCC = 1; |
| 58 | static int MNC = 1; |
Holger Freyther | dda22c1 | 2009-04-22 22:07:31 +0000 | [diff] [blame] | 59 | static int cardnr = 0; |
Holger Freyther | b5c00f5 | 2009-04-22 22:08:07 +0000 | [diff] [blame] | 60 | static int release_l2 = 0; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 61 | static enum gsm_bts_type BTS_TYPE = GSM_BTS_TYPE_BS11; |
Holger Freyther | bde3610 | 2008-12-28 22:51:39 +0000 | [diff] [blame] | 62 | static const char *database_name = "hlr.sqlite3"; |
Holger Hans Peter Freyther | d5d1cef | 2009-08-10 08:39:27 +0200 | [diff] [blame] | 63 | static const char *config_file = "openbsc.cfg"; |
Harald Welte | 805f644 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 64 | extern int ipacc_rtp_direct; |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 65 | |
Harald Welte | 000c0f4 | 2009-08-12 21:45:02 +0200 | [diff] [blame] | 66 | static void patch_nm_tables(struct gsm_bts *bts); |
| 67 | static void patch_si_tables(struct gsm_bts *bts); |
Holger Hans Peter Freyther | 03582a8 | 2009-07-16 15:24:27 +0200 | [diff] [blame] | 68 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 69 | /* The following definitions are for OM and NM packets that we cannot yet |
| 70 | * generate by code but we just pass on */ |
| 71 | |
| 72 | // BTS Site Manager, SET ATTRIBUTES |
| 73 | |
| 74 | /* |
| 75 | Object Class: BTS Site Manager |
| 76 | Instance 1: FF |
| 77 | Instance 2: FF |
| 78 | Instance 3: FF |
| 79 | SET ATTRIBUTES |
| 80 | sAbisExternalTime: 2007/09/08 14:36:11 |
| 81 | omLAPDRelTimer: 30sec |
| 82 | shortLAPDIntTimer: 5sec |
| 83 | emergencyTimer1: 10 minutes |
| 84 | emergencyTimer2: 0 minutes |
| 85 | */ |
| 86 | |
| 87 | unsigned char msg_1[] = |
| 88 | { |
Harald Welte | a865f1b | 2009-06-20 10:42:17 +0200 | [diff] [blame] | 89 | NM_MT_BS11_SET_ATTR, NM_OC_SITE_MANAGER, 0xFF, 0xFF, 0xFF, |
Harald Welte | 110c0ab | 2009-05-23 16:27:05 +0000 | [diff] [blame] | 90 | NM_ATT_BS11_ABIS_EXT_TIME, 0x07, |
| 91 | 0xD7, 0x09, 0x08, 0x0E, 0x24, 0x0B, 0xCE, |
| 92 | 0x02, |
| 93 | 0x00, 0x1E, |
| 94 | NM_ATT_BS11_SH_LAPD_INT_TIMER, |
| 95 | 0x01, 0x05, |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 96 | 0x42, 0x02, 0x00, 0x0A, |
| 97 | 0x44, 0x02, 0x00, 0x00 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | // BTS, SET BTS ATTRIBUTES |
| 101 | |
| 102 | /* |
| 103 | Object Class: BTS |
| 104 | BTS relat. Number: 0 |
| 105 | Instance 2: FF |
| 106 | Instance 3: FF |
| 107 | SET BTS ATTRIBUTES |
| 108 | bsIdentityCode / BSIC: |
| 109 | PLMN_colour_code: 7h |
| 110 | BS_colour_code: 7h |
| 111 | BTS Air Timer T3105: 4 ,unit 10 ms |
| 112 | btsIsHopping: FALSE |
Harald Welte | 8328229 | 2009-02-01 16:22:19 +0000 | [diff] [blame] | 113 | periodCCCHLoadIndication: 1sec |
Holger Freyther | 3b91043 | 2009-02-11 00:43:48 +0000 | [diff] [blame] | 114 | thresholdCCCHLoadIndication: 0% |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 115 | cellAllocationNumber: 00h = GSM 900 |
| 116 | enableInterferenceClass: 00h = Disabled |
| 117 | fACCHQual: 6 (FACCH stealing flags minus 1) |
| 118 | intaveParameter: 31 SACCH multiframes |
| 119 | interferenceLevelBoundaries: |
| 120 | Interference Boundary 1: 0Ah |
| 121 | Interference Boundary 2: 0Fh |
| 122 | Interference Boundary 3: 14h |
| 123 | Interference Boundary 4: 19h |
| 124 | Interference Boundary 5: 1Eh |
| 125 | mSTxPwrMax: 11 |
| 126 | GSM range: 2=39dBm, 15=13dBm, stepsize 2 dBm |
| 127 | DCS1800 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 128 | PCS1900 range: 0=30dBm, 15=0dBm, stepsize 2 dBm |
| 129 | 30=33dBm, 31=32dBm |
| 130 | ny1: |
| 131 | Maximum number of repetitions for PHYSICAL INFORMATION message (GSM 04.08): 20 |
| 132 | powerOutputThresholds: |
| 133 | Out Power Fault Threshold: -10 dB |
| 134 | Red Out Power Threshold: - 6 dB |
| 135 | Excessive Out Power Threshold: 5 dB |
| 136 | rACHBusyThreshold: -127 dBm |
| 137 | rACHLoadAveragingSlots: 250 ,number of RACH burst periods |
| 138 | rfResourceIndicationPeriod: 125 SACCH multiframes |
| 139 | T200: |
| 140 | SDCCH: 044 in 5 ms |
| 141 | FACCH/Full rate: 031 in 5 ms |
| 142 | FACCH/Half rate: 041 in 5 ms |
| 143 | SACCH with TCH SAPI0: 090 in 10 ms |
| 144 | SACCH with SDCCH: 090 in 10 ms |
| 145 | SDCCH with SAPI3: 090 in 5 ms |
| 146 | SACCH with TCH SAPI3: 135 in 10 ms |
| 147 | tSync: 9000 units of 10 msec |
| 148 | tTrau: 9000 units of 10 msec |
| 149 | enableUmLoopTest: 00h = disabled |
| 150 | enableExcessiveDistance: 00h = Disabled |
| 151 | excessiveDistance: 64km |
| 152 | hoppingMode: 00h = baseband hopping |
| 153 | cellType: 00h = Standard Cell |
| 154 | BCCH ARFCN / bCCHFrequency: 1 |
| 155 | */ |
| 156 | |
Harald Welte | a865f1b | 2009-06-20 10:42:17 +0200 | [diff] [blame] | 157 | static unsigned char bs11_attr_bts[] = |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 158 | { |
Harald Welte | 060f6df | 2009-05-23 17:50:53 +0000 | [diff] [blame] | 159 | NM_ATT_BSIC, HARDCODED_BSIC, |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 160 | NM_ATT_BTS_AIR_TIMER, 0x04, |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 161 | NM_ATT_BS11_BTSLS_HOPPING, 0x00, |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 162 | NM_ATT_CCCH_L_I_P, 0x01, |
| 163 | NM_ATT_CCCH_L_T, 0x00, |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 164 | NM_ATT_BS11_CELL_ALLOC_NR, NM_BS11_CANR_GSM, |
| 165 | NM_ATT_BS11_ENA_INTERF_CLASS, 0x01, |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 166 | NM_ATT_BS11_FACCH_QUAL, 0x06, |
Harald Welte | fe609d8 | 2009-05-23 18:14:31 +0000 | [diff] [blame] | 167 | /* interference avg. period in numbers of SACCH multifr */ |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 168 | NM_ATT_INTAVE_PARAM, 0x1F, |
| 169 | NM_ATT_INTERF_BOUND, 0x0A, 0x0F, 0x14, 0x19, 0x1E, 0x7B, |
| 170 | NM_ATT_CCCH_L_T, 0x23, |
| 171 | NM_ATT_GSM_TIME, 0x28, 0x00, |
| 172 | NM_ATT_ADM_STATE, 0x03, |
| 173 | NM_ATT_RACH_B_THRESH, 0x7F, |
| 174 | NM_ATT_LDAVG_SLOTS, 0x00, 0xFA, |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 175 | NM_ATT_BS11_RF_RES_IND_PER, 0x7D, |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 176 | NM_ATT_T200, 0x2C, 0x1F, 0x29, 0x5A, 0x5A, 0x5A, 0x87, |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 177 | NM_ATT_BS11_TSYNC, 0x23, 0x28, |
| 178 | NM_ATT_BS11_TTRAU, 0x23, 0x28, |
| 179 | NM_ATT_TEST_DUR, 0x01, 0x00, |
| 180 | NM_ATT_OUTST_ALARM, 0x01, 0x00, |
| 181 | NM_ATT_BS11_EXCESSIVE_DISTANCE, 0x01, 0x40, |
| 182 | NM_ATT_BS11_HOPPING_MODE, 0x01, 0x00, |
| 183 | NM_ATT_BS11_PLL, 0x01, 0x00, |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 184 | NM_ATT_BCCH_ARFCN, 0x00, HARDCODED_ARFCN/*0x01*/, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | // Handover Recognition, SET ATTRIBUTES |
| 188 | |
| 189 | /* |
| 190 | Illegal Contents GSM Formatted O&M Msg |
| 191 | Object Class: Handover Recognition |
| 192 | BTS relat. Number: 0 |
| 193 | Instance 2: FF |
| 194 | Instance 3: FF |
| 195 | SET ATTRIBUTES |
| 196 | enableDelayPowerBudgetHO: 00h = Disabled |
| 197 | enableDistanceHO: 00h = Disabled |
| 198 | enableInternalInterCellHandover: 00h = Disabled |
| 199 | enableInternalIntraCellHandover: 00h = Disabled |
| 200 | enablePowerBudgetHO: 00h = Disabled |
| 201 | enableRXLEVHO: 00h = Disabled |
| 202 | enableRXQUALHO: 00h = Disabled |
| 203 | hoAveragingDistance: 8 SACCH multiframes |
| 204 | hoAveragingLev: |
| 205 | A_LEV_HO: 8 SACCH multiframes |
| 206 | W_LEV_HO: 1 SACCH multiframes |
| 207 | hoAveragingPowerBudget: 16 SACCH multiframes |
| 208 | hoAveragingQual: |
| 209 | A_QUAL_HO: 8 SACCH multiframes |
| 210 | W_QUAL_HO: 2 SACCH multiframes |
| 211 | hoLowerThresholdLevDL: (10 - 110) dBm |
| 212 | hoLowerThresholdLevUL: (5 - 110) dBm |
| 213 | hoLowerThresholdQualDL: 06h = 6.4% < BER < 12.8% |
| 214 | hoLowerThresholdQualUL: 06h = 6.4% < BER < 12.8% |
| 215 | hoThresholdLevDLintra : (20 - 110) dBm |
| 216 | hoThresholdLevULintra: (20 - 110) dBm |
| 217 | hoThresholdMsRangeMax: 20 km |
| 218 | nCell: 06h |
| 219 | timerHORequest: 3 ,unit 2 SACCH multiframes |
| 220 | */ |
| 221 | |
| 222 | unsigned char msg_3[] = |
| 223 | { |
Harald Welte | a865f1b | 2009-06-20 10:42:17 +0200 | [diff] [blame] | 224 | NM_MT_BS11_SET_ATTR, NM_OC_BS11_HANDOVER, 0x00, 0xFF, 0xFF, |
Harald Welte | 5655471 | 2009-07-18 16:18:11 +0200 | [diff] [blame] | 225 | 0xD0, 0x00, /* enableDelayPowerBudgetHO */ |
| 226 | 0x64, 0x00, /* enableDistanceHO */ |
| 227 | 0x67, 0x00, /* enableInternalInterCellHandover */ |
| 228 | 0x68, 0x00, /* enableInternalInterCellHandover */ |
| 229 | 0x6A, 0x00, /* enablePowerBudgetHO */ |
| 230 | 0x6C, 0x00, /* enableRXLEVHO */ |
| 231 | 0x6D, 0x00, /* enableRXQUALHO */ |
| 232 | 0x6F, 0x08, /* hoAveragingDistance */ |
| 233 | 0x70, 0x08, 0x01, /* hoAveragingLev */ |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 234 | 0x71, 0x10, 0x10, 0x10, |
Harald Welte | 5655471 | 2009-07-18 16:18:11 +0200 | [diff] [blame] | 235 | 0x72, 0x08, 0x02, /* hoAveragingQual */ |
| 236 | 0x73, 0x0A, /* hoLowerThresholdLevDL */ |
| 237 | 0x74, 0x05, /* hoLowerThresholdLevUL */ |
| 238 | 0x75, 0x06, /* hoLowerThresholdQualDL */ |
| 239 | 0x76, 0x06, /* hoLowerThresholdQualUL */ |
| 240 | 0x78, 0x14, /* hoThresholdLevDLintra */ |
| 241 | 0x79, 0x14, /* hoThresholdLevULintra */ |
| 242 | 0x7A, 0x14, /* hoThresholdMsRangeMax */ |
| 243 | 0x7D, 0x06, /* nCell */ |
| 244 | NM_ATT_BS11_TIMER_HO_REQUEST, 0x03, |
| 245 | 0x20, 0x01, 0x00, |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 246 | 0x45, 0x01, 0x00, |
| 247 | 0x48, 0x01, 0x00, |
| 248 | 0x5A, 0x01, 0x00, |
| 249 | 0x5B, 0x01, 0x05, |
| 250 | 0x5E, 0x01, 0x1A, |
| 251 | 0x5F, 0x01, 0x20, |
| 252 | 0x9D, 0x01, 0x00, |
| 253 | 0x47, 0x01, 0x00, |
| 254 | 0x5C, 0x01, 0x64, |
| 255 | 0x5D, 0x01, 0x1E, |
| 256 | 0x97, 0x01, 0x20, |
| 257 | 0xF7, 0x01, 0x3C, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 258 | }; |
| 259 | |
| 260 | // Power Control, SET ATTRIBUTES |
| 261 | |
| 262 | /* |
| 263 | Object Class: Power Control |
| 264 | BTS relat. Number: 0 |
| 265 | Instance 2: FF |
| 266 | Instance 3: FF |
| 267 | SET ATTRIBUTES |
| 268 | enableMsPowerControl: 00h = Disabled |
| 269 | enablePowerControlRLFW: 00h = Disabled |
| 270 | pcAveragingLev: |
| 271 | A_LEV_PC: 4 SACCH multiframes |
| 272 | W_LEV_PC: 1 SACCH multiframes |
| 273 | pcAveragingQual: |
| 274 | A_QUAL_PC: 4 SACCH multiframes |
| 275 | W_QUAL_PC: 2 SACCH multiframes |
| 276 | pcLowerThresholdLevDL: 0Fh |
| 277 | pcLowerThresholdLevUL: 0Ah |
| 278 | pcLowerThresholdQualDL: 05h = 3.2% < BER < 6.4% |
| 279 | pcLowerThresholdQualUL: 05h = 3.2% < BER < 6.4% |
| 280 | pcRLFThreshold: 0Ch |
| 281 | pcUpperThresholdLevDL: 14h |
| 282 | pcUpperThresholdLevUL: 0Fh |
| 283 | pcUpperThresholdQualDL: 04h = 1.6% < BER < 3.2% |
| 284 | pcUpperThresholdQualUL: 04h = 1.6% < BER < 3.2% |
| 285 | powerConfirm: 2 ,unit 2 SACCH multiframes |
| 286 | powerControlInterval: 2 ,unit 2 SACCH multiframes |
| 287 | powerIncrStepSize: 02h = 4 dB |
| 288 | powerRedStepSize: 01h = 2 dB |
| 289 | radioLinkTimeoutBs: 64 SACCH multiframes |
| 290 | enableBSPowerControl: 00h = disabled |
| 291 | */ |
| 292 | |
| 293 | unsigned char msg_4[] = |
| 294 | { |
Harald Welte | a865f1b | 2009-06-20 10:42:17 +0200 | [diff] [blame] | 295 | NM_MT_BS11_SET_ATTR, NM_OC_BS11_PWR_CTRL, 0x00, 0xFF, 0xFF, |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 296 | NM_ATT_BS11_ENA_MS_PWR_CTRL, 0x00, |
| 297 | NM_ATT_BS11_ENA_PWR_CTRL_RLFW, 0x00, |
Harald Welte | 5655471 | 2009-07-18 16:18:11 +0200 | [diff] [blame] | 298 | 0x7E, 0x04, 0x01, /* pcAveragingLev */ |
| 299 | 0x7F, 0x04, 0x02, /* pcAveragingQual */ |
| 300 | 0x80, 0x0F, /* pcLowerThresholdLevDL */ |
| 301 | 0x81, 0x0A, /* pcLowerThresholdLevUL */ |
| 302 | 0x82, 0x05, /* pcLowerThresholdQualDL */ |
| 303 | 0x83, 0x05, /* pcLowerThresholdQualUL */ |
| 304 | 0x84, 0x0C, /* pcRLFThreshold */ |
| 305 | 0x85, 0x14, /* pcUpperThresholdLevDL */ |
| 306 | 0x86, 0x0F, /* pcUpperThresholdLevUL */ |
| 307 | 0x87, 0x04, /* pcUpperThresholdQualDL */ |
| 308 | 0x88, 0x04, /* pcUpperThresholdQualUL */ |
| 309 | 0x89, 0x02, /* powerConfirm */ |
| 310 | 0x8A, 0x02, /* powerConfirmInterval */ |
| 311 | 0x8B, 0x02, /* powerIncrStepSize */ |
| 312 | 0x8C, 0x01, /* powerRedStepSize */ |
| 313 | 0x8D, 0x40, /* radioLinkTimeoutBs */ |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 314 | 0x65, 0x01, 0x00 // set to 0x01 to enable BSPowerControl |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 315 | }; |
| 316 | |
| 317 | |
| 318 | // Transceiver, SET TRX ATTRIBUTES (TRX 0) |
| 319 | |
| 320 | /* |
| 321 | Object Class: Transceiver |
| 322 | BTS relat. Number: 0 |
| 323 | Tranceiver number: 0 |
| 324 | Instance 3: FF |
| 325 | SET TRX ATTRIBUTES |
| 326 | aRFCNList (HEX): 0001 |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 327 | txPwrMaxReduction: 00h = 30dB |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 328 | radioMeasGran: 254 SACCH multiframes |
| 329 | radioMeasRep: 01h = enabled |
| 330 | memberOfEmergencyConfig: 01h = TRUE |
| 331 | trxArea: 00h = TRX doesn't belong to a concentric cell |
| 332 | */ |
| 333 | |
Harald Welte | a865f1b | 2009-06-20 10:42:17 +0200 | [diff] [blame] | 334 | static unsigned char bs11_attr_radio[] = |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 335 | { |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 336 | NM_ATT_ARFCN_LIST, 0x01, 0x00, HARDCODED_ARFCN /*0x01*/, |
Harald Welte | 311d0cf | 2009-02-17 17:45:59 +0000 | [diff] [blame] | 337 | NM_ATT_RF_MAXPOWR_R, 0x00, |
Harald Welte | e991c26 | 2009-08-10 14:09:28 +0200 | [diff] [blame] | 338 | NM_ATT_BS11_RADIO_MEAS_GRAN, 0x01, 0x05, |
Harald Welte | cd99387 | 2009-02-15 16:16:28 +0000 | [diff] [blame] | 339 | NM_ATT_BS11_RADIO_MEAS_REP, 0x01, 0x01, |
| 340 | NM_ATT_BS11_EMRG_CFG_MEMBER, 0x01, 0x01, |
| 341 | NM_ATT_BS11_TRX_AREA, 0x01, 0x00, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 342 | }; |
| 343 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 344 | static unsigned char nanobts_attr_bts[] = { |
| 345 | NM_ATT_INTERF_BOUND, 0x55, 0x5b, 0x61, 0x67, 0x6d, 0x73, |
Harald Welte | fe609d8 | 2009-05-23 18:14:31 +0000 | [diff] [blame] | 346 | /* interference avg. period in numbers of SACCH multifr */ |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 347 | NM_ATT_INTAVE_PARAM, 0x06, |
Harald Welte | d0fbab5 | 2009-06-09 20:04:44 +0000 | [diff] [blame] | 348 | /* conn fail based on SACCH error rate */ |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 349 | NM_ATT_CONN_FAIL_CRIT, 0x00, 0x02, 0x01, 0x10, |
| 350 | NM_ATT_T200, 0x1e, 0x24, 0x24, 0xa8, 0x34, 0x21, 0xa8, |
| 351 | NM_ATT_MAX_TA, 0x3f, |
Harald Welte | 311d0cf | 2009-02-17 17:45:59 +0000 | [diff] [blame] | 352 | NM_ATT_OVERL_PERIOD, 0x00, 0x01, 10, /* seconds */ |
| 353 | NM_ATT_CCCH_L_T, 10, /* percent */ |
| 354 | NM_ATT_CCCH_L_I_P, 1, /* seconds */ |
Harald Welte | fe609d8 | 2009-05-23 18:14:31 +0000 | [diff] [blame] | 355 | NM_ATT_RACH_B_THRESH, 10, /* busy threshold in - dBm */ |
Harald Welte | d0fbab5 | 2009-06-09 20:04:44 +0000 | [diff] [blame] | 356 | NM_ATT_LDAVG_SLOTS, 0x03, 0xe8, /* rach load averaging 1000 slots */ |
Harald Welte | fe609d8 | 2009-05-23 18:14:31 +0000 | [diff] [blame] | 357 | NM_ATT_BTS_AIR_TIMER, 128, /* miliseconds */ |
| 358 | NM_ATT_NY1, 10, /* 10 retransmissions of physical config */ |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 359 | NM_ATT_BCCH_ARFCN, HARDCODED_ARFCN >> 8, HARDCODED_ARFCN & 0xff, |
Harald Welte | 060f6df | 2009-05-23 17:50:53 +0000 | [diff] [blame] | 360 | NM_ATT_BSIC, HARDCODED_BSIC, |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 361 | }; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 362 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 363 | static unsigned char nanobts_attr_radio[] = { |
Harald Welte | d0fbab5 | 2009-06-09 20:04:44 +0000 | [diff] [blame] | 364 | NM_ATT_RF_MAXPOWR_R, 0x0c, /* number of -2dB reduction steps / Pn */ |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 365 | NM_ATT_ARFCN_LIST, 0x00, 0x02, HARDCODED_ARFCN >> 8, HARDCODED_ARFCN & 0xff, |
| 366 | }; |
| 367 | |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 368 | static unsigned char nanobts_attr_e0[] = { |
Harald Welte | 0efe9b7 | 2009-07-12 09:33:54 +0200 | [diff] [blame] | 369 | NM_ATT_IPACC_STREAM_ID, 0x00, |
| 370 | NM_ATT_IPACC_DST_IP_PORT, 0x0b, 0xbb, /* TCP PORT for RSL */ |
Harald Welte | 5c1e458 | 2009-02-15 11:57:29 +0000 | [diff] [blame] | 371 | }; |
| 372 | |
Harald Welte | b463060 | 2009-05-01 15:43:22 +0000 | [diff] [blame] | 373 | /* Callback function to be called whenever we get a GSM 12.21 state change event */ |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 374 | int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj, |
| 375 | struct gsm_nm_state *old_state, struct gsm_nm_state *new_state) |
| 376 | { |
| 377 | struct gsm_bts *bts; |
| 378 | struct gsm_bts_trx *trx; |
| 379 | struct gsm_bts_trx_ts *ts; |
| 380 | |
| 381 | /* This is currently only required on nanoBTS */ |
| 382 | |
| 383 | switch (evt) { |
| 384 | case EVT_STATECHG_OPER: |
| 385 | switch (obj_class) { |
| 386 | case NM_OC_SITE_MANAGER: |
| 387 | bts = container_of(obj, struct gsm_bts, site_mgr); |
| 388 | if (old_state->operational != 2 && new_state->operational == 2) { |
| 389 | abis_nm_opstart(bts, NM_OC_SITE_MANAGER, 0xff, 0xff, 0xff); |
| 390 | } |
| 391 | break; |
| 392 | case NM_OC_BTS: |
| 393 | bts = obj; |
| 394 | if (new_state->availability == 5) { |
Harald Welte | 000c0f4 | 2009-08-12 21:45:02 +0200 | [diff] [blame] | 395 | patch_nm_tables(bts); |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 396 | abis_nm_set_bts_attr(bts, nanobts_attr_bts, |
| 397 | sizeof(nanobts_attr_bts)); |
| 398 | abis_nm_opstart(bts, NM_OC_BTS, |
Harald Welte | 191280d | 2009-05-01 13:20:04 +0000 | [diff] [blame] | 399 | bts->bts_nr, 0xff, 0xff); |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 400 | abis_nm_chg_adm_state(bts, NM_OC_BTS, |
Harald Welte | 191280d | 2009-05-01 13:20:04 +0000 | [diff] [blame] | 401 | bts->bts_nr, 0xff, 0xff, |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 402 | NM_STATE_UNLOCKED); |
| 403 | } |
| 404 | break; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 405 | case NM_OC_CHANNEL: |
| 406 | ts = obj; |
| 407 | trx = ts->trx; |
| 408 | if (new_state->availability == 5) { |
| 409 | if (ts->nr == 0 && trx == trx->bts->c0) |
Harald Welte | 89e9d59 | 2009-08-09 22:01:26 +0200 | [diff] [blame] | 410 | abis_nm_set_channel_attr(ts, NM_CHANC_BCCHComb); |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 411 | else |
| 412 | abis_nm_set_channel_attr(ts, NM_CHANC_TCHFull); |
| 413 | abis_nm_opstart(trx->bts, NM_OC_CHANNEL, |
Harald Welte | 191280d | 2009-05-01 13:20:04 +0000 | [diff] [blame] | 414 | trx->bts->bts_nr, trx->nr, ts->nr); |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 415 | abis_nm_chg_adm_state(trx->bts, NM_OC_CHANNEL, |
Harald Welte | 191280d | 2009-05-01 13:20:04 +0000 | [diff] [blame] | 416 | trx->bts->bts_nr, trx->nr, ts->nr, |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 417 | NM_STATE_UNLOCKED); |
| 418 | } |
| 419 | break; |
Harald Welte | a994a48 | 2009-05-01 15:54:23 +0000 | [diff] [blame] | 420 | default: |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 421 | break; |
| 422 | } |
| 423 | break; |
Harald Welte | a994a48 | 2009-05-01 15:54:23 +0000 | [diff] [blame] | 424 | default: |
| 425 | //DEBUGP(DMM, "Unhandled state change in %s:%d\n", __func__, __LINE__); |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 426 | break; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 427 | } |
| 428 | return 0; |
| 429 | } |
| 430 | |
Harald Welte | b463060 | 2009-05-01 15:43:22 +0000 | [diff] [blame] | 431 | /* Callback function to be called every time we receive a 12.21 SW activated report */ |
| 432 | static int sw_activ_rep(struct msgb *mb) |
| 433 | { |
| 434 | struct abis_om_fom_hdr *foh = msgb_l3(mb); |
| 435 | struct gsm_bts_trx *trx = mb->trx; |
| 436 | |
| 437 | switch (foh->obj_class) { |
| 438 | case NM_OC_BASEB_TRANSC: |
| 439 | /* TRX software is active, tell it to initiate RSL Link */ |
| 440 | abis_nm_ipaccess_msg(trx->bts, 0xe0, NM_OC_BASEB_TRANSC, |
| 441 | trx->bts->bts_nr, trx->nr, 0xff, |
| 442 | nanobts_attr_e0, sizeof(nanobts_attr_e0)); |
| 443 | abis_nm_opstart(trx->bts, NM_OC_BASEB_TRANSC, |
| 444 | trx->bts->bts_nr, trx->nr, 0xff); |
| 445 | abis_nm_chg_adm_state(trx->bts, NM_OC_BASEB_TRANSC, |
| 446 | trx->bts->bts_nr, trx->nr, 0xff, |
| 447 | NM_STATE_UNLOCKED); |
| 448 | break; |
| 449 | case NM_OC_RADIO_CARRIER: |
Harald Welte | 000c0f4 | 2009-08-12 21:45:02 +0200 | [diff] [blame] | 450 | patch_nm_tables(trx->bts); |
Harald Welte | b463060 | 2009-05-01 15:43:22 +0000 | [diff] [blame] | 451 | abis_nm_set_radio_attr(trx, nanobts_attr_radio, |
| 452 | sizeof(nanobts_attr_radio)); |
| 453 | abis_nm_opstart(trx->bts, NM_OC_RADIO_CARRIER, |
| 454 | trx->bts->bts_nr, trx->nr, 0xff); |
| 455 | abis_nm_chg_adm_state(trx->bts, NM_OC_RADIO_CARRIER, |
| 456 | trx->bts->bts_nr, trx->nr, 0xff, |
| 457 | NM_STATE_UNLOCKED); |
| 458 | break; |
| 459 | } |
| 460 | return 0; |
| 461 | } |
| 462 | |
Holger Hans Peter Freyther | 500f3ca | 2009-06-10 10:48:14 +0200 | [diff] [blame] | 463 | /* Callback function for NACK on the OML NM */ |
| 464 | static int oml_msg_nack(int mt) |
| 465 | { |
| 466 | if (mt == NM_MT_SET_BTS_ATTR_NACK) { |
| 467 | fprintf(stderr, "Failed to set BTS attributes. That is fatal. " |
| 468 | "Was the bts type and frequency properly specified?\n"); |
| 469 | exit(-1); |
| 470 | } |
| 471 | |
| 472 | return 0; |
| 473 | } |
| 474 | |
Harald Welte | b463060 | 2009-05-01 15:43:22 +0000 | [diff] [blame] | 475 | /* Callback function to be called every time we receive a signal from NM */ |
| 476 | static int nm_sig_cb(unsigned int subsys, unsigned int signal, |
| 477 | void *handler_data, void *signal_data) |
| 478 | { |
| 479 | switch (signal) { |
| 480 | case S_NM_SW_ACTIV_REP: |
| 481 | return sw_activ_rep(signal_data); |
Holger Hans Peter Freyther | 500f3ca | 2009-06-10 10:48:14 +0200 | [diff] [blame] | 482 | case S_NM_NACK: |
| 483 | return oml_msg_nack((int)signal_data); |
Harald Welte | b463060 | 2009-05-01 15:43:22 +0000 | [diff] [blame] | 484 | default: |
| 485 | break; |
| 486 | } |
| 487 | return 0; |
| 488 | } |
| 489 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 490 | static void bootstrap_om_nanobts(struct gsm_bts *bts) |
| 491 | { |
Harald Welte | e1bd241 | 2009-02-15 14:40:09 +0000 | [diff] [blame] | 492 | /* We don't do callback based bootstrapping, but event driven (see above) */ |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 493 | } |
| 494 | |
Harald Welte | 349aba6 | 2009-08-10 12:31:31 +0200 | [diff] [blame] | 495 | static void nm_reconfig_ts(struct gsm_bts_trx_ts *ts) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 496 | { |
Harald Welte | 349aba6 | 2009-08-10 12:31:31 +0200 | [diff] [blame] | 497 | enum abis_nm_chan_comb ccomb = abis_nm_chcomb4pchan(ts->pchan); |
| 498 | struct gsm_e1_subslot *e1l = &ts->e1_link; |
Harald Welte | ac56e8b | 2009-08-06 17:40:24 +0200 | [diff] [blame] | 499 | |
Harald Welte | 349aba6 | 2009-08-10 12:31:31 +0200 | [diff] [blame] | 500 | abis_nm_set_channel_attr(ts, ccomb); |
| 501 | |
| 502 | if (is_ipaccess_bts(ts->trx->bts)) |
Harald Welte | ac56e8b | 2009-08-06 17:40:24 +0200 | [diff] [blame] | 503 | return; |
Harald Welte | 349aba6 | 2009-08-10 12:31:31 +0200 | [diff] [blame] | 504 | |
| 505 | switch (ts->pchan) { |
| 506 | case GSM_PCHAN_TCH_F: |
| 507 | case GSM_PCHAN_TCH_H: |
| 508 | abis_nm_conn_terr_traf(ts, e1l->e1_nr, e1l->e1_ts, |
| 509 | e1l->e1_ts_ss); |
| 510 | break; |
| 511 | default: |
| 512 | break; |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | static void nm_reconfig_trx(struct gsm_bts_trx *trx) |
| 517 | { |
| 518 | struct gsm_e1_subslot *e1l = &trx->rsl_e1_link; |
| 519 | int i; |
| 520 | |
Harald Welte | 000c0f4 | 2009-08-12 21:45:02 +0200 | [diff] [blame] | 521 | patch_nm_tables(trx->bts); |
| 522 | |
Harald Welte | 349aba6 | 2009-08-10 12:31:31 +0200 | [diff] [blame] | 523 | switch (trx->bts->type) { |
| 524 | case GSM_BTS_TYPE_BS11: |
Harald Welte (local) | 7f28cd5 | 2009-08-12 10:40:17 +0200 | [diff] [blame] | 525 | /* FIXME: discover this by fetching an attribute */ |
| 526 | #if 0 |
| 527 | trx->nominal_power = 15; /* 15dBm == 30mW PA configuration */ |
| 528 | #else |
| 529 | trx->nominal_power = 24; /* 24dBm == 250mW PA configuration */ |
| 530 | #endif |
Harald Welte | 349aba6 | 2009-08-10 12:31:31 +0200 | [diff] [blame] | 531 | abis_nm_conn_terr_sign(trx, e1l->e1_nr, e1l->e1_ts, |
| 532 | e1l->e1_ts_ss); |
| 533 | abis_nm_establish_tei(trx->bts, trx->nr, e1l->e1_nr, |
| 534 | e1l->e1_ts, e1l->e1_ts_ss, trx->rsl_tei); |
| 535 | |
| 536 | /* Set Radio Attributes */ |
| 537 | if (trx == trx->bts->c0) |
| 538 | abis_nm_set_radio_attr(trx, bs11_attr_radio, |
| 539 | sizeof(bs11_attr_radio)); |
| 540 | else { |
| 541 | u_int8_t trx1_attr_radio[sizeof(bs11_attr_radio)]; |
| 542 | u_int8_t arfcn_low = trx->arfcn & 0xff; |
| 543 | u_int8_t arfcn_high = (trx->arfcn >> 8) & 0x0f; |
| 544 | memcpy(trx1_attr_radio, bs11_attr_radio, |
| 545 | sizeof(trx1_attr_radio)); |
| 546 | |
| 547 | /* patch ARFCN into TRX Attributes */ |
| 548 | trx1_attr_radio[2] &= 0xf0; |
| 549 | trx1_attr_radio[2] |= arfcn_high; |
| 550 | trx1_attr_radio[3] = arfcn_low; |
| 551 | |
| 552 | abis_nm_set_radio_attr(trx, trx1_attr_radio, |
| 553 | sizeof(trx1_attr_radio)); |
| 554 | } |
| 555 | break; |
Harald Welte (local) | 7f28cd5 | 2009-08-12 10:40:17 +0200 | [diff] [blame] | 556 | case GSM_BTS_TYPE_NANOBTS_900: |
| 557 | case GSM_BTS_TYPE_NANOBTS_1800: |
| 558 | trx->nominal_power = 20; |
Harald Welte | 349aba6 | 2009-08-10 12:31:31 +0200 | [diff] [blame] | 559 | default: |
| 560 | break; |
Harald Welte | ac56e8b | 2009-08-06 17:40:24 +0200 | [diff] [blame] | 561 | } |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 562 | |
Harald Welte | 349aba6 | 2009-08-10 12:31:31 +0200 | [diff] [blame] | 563 | for (i = 0; i < TRX_NR_TS; i++) |
| 564 | nm_reconfig_ts(&trx->ts[i]); |
| 565 | } |
| 566 | |
| 567 | static void nm_reconfig_bts(struct gsm_bts *bts) |
| 568 | { |
| 569 | struct gsm_bts_trx *trx; |
| 570 | |
| 571 | switch (bts->type) { |
| 572 | case GSM_BTS_TYPE_BS11: |
| 573 | abis_nm_raw_msg(bts, sizeof(msg_1), msg_1); /* set BTS SiteMgr attr*/ |
| 574 | abis_nm_set_bts_attr(bts, bs11_attr_bts, sizeof(bs11_attr_bts)); |
| 575 | abis_nm_raw_msg(bts, sizeof(msg_3), msg_3); /* set BTS handover attr */ |
| 576 | abis_nm_raw_msg(bts, sizeof(msg_4), msg_4); /* set BTS power control attr */ |
| 577 | break; |
| 578 | default: |
| 579 | break; |
| 580 | } |
| 581 | |
| 582 | llist_for_each_entry(trx, &bts->trx_list, list) |
| 583 | nm_reconfig_trx(trx); |
| 584 | } |
| 585 | |
| 586 | static void bootstrap_om_bs11(struct gsm_bts *bts) |
| 587 | { |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 588 | /* stop sending event reports */ |
| 589 | abis_nm_event_reports(bts, 0); |
| 590 | |
| 591 | /* begin DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 592 | abis_nm_bs11_db_transmission(bts, 1); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 593 | |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 594 | /* end DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 595 | abis_nm_bs11_db_transmission(bts, 0); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 596 | |
| 597 | /* Reset BTS Site manager resource */ |
Harald Welte | 7837489 | 2009-01-18 19:09:22 +0000 | [diff] [blame] | 598 | abis_nm_bs11_reset_resource(bts); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 599 | |
| 600 | /* begin DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 601 | abis_nm_bs11_db_transmission(bts, 1); |
Harald Welte | 702d870 | 2008-12-26 20:25:35 +0000 | [diff] [blame] | 602 | |
Harald Welte | 349aba6 | 2009-08-10 12:31:31 +0200 | [diff] [blame] | 603 | /* reconfigure BTS with all TRX and all TS */ |
| 604 | nm_reconfig_bts(bts); |
Harald Welte | 67b4c30 | 2009-07-29 16:42:16 +0200 | [diff] [blame] | 605 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 606 | /* end DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 607 | abis_nm_bs11_db_transmission(bts, 0); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 608 | |
| 609 | /* Reset BTS Site manager resource */ |
Harald Welte | 7837489 | 2009-01-18 19:09:22 +0000 | [diff] [blame] | 610 | abis_nm_bs11_reset_resource(bts); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 611 | |
| 612 | /* restart sending event reports */ |
| 613 | abis_nm_event_reports(bts, 1); |
| 614 | } |
| 615 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 616 | static void bootstrap_om(struct gsm_bts *bts) |
| 617 | { |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 618 | fprintf(stdout, "bootstrapping OML for BTS %u\n", bts->nr); |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 619 | |
| 620 | switch (bts->type) { |
| 621 | case GSM_BTS_TYPE_BS11: |
| 622 | bootstrap_om_bs11(bts); |
| 623 | break; |
| 624 | case GSM_BTS_TYPE_NANOBTS_900: |
| 625 | case GSM_BTS_TYPE_NANOBTS_1800: |
| 626 | bootstrap_om_nanobts(bts); |
| 627 | break; |
| 628 | default: |
| 629 | fprintf(stderr, "Unable to bootstrap OML: Unknown BTS type %d\n", bts->type); |
| 630 | } |
| 631 | } |
| 632 | |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 633 | static int shutdown_om(struct gsm_bts *bts) |
| 634 | { |
Harald Welte | f294f45 | 2009-08-06 17:43:50 +0200 | [diff] [blame] | 635 | fprintf(stdout, "shutting down OML for BTS %u\n", bts->nr); |
| 636 | |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 637 | /* stop sending event reports */ |
| 638 | abis_nm_event_reports(bts, 0); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 639 | |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 640 | /* begin DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 641 | abis_nm_bs11_db_transmission(bts, 1); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 642 | |
| 643 | /* end DB transmission */ |
Harald Welte | 05188ee | 2009-01-18 11:39:08 +0000 | [diff] [blame] | 644 | abis_nm_bs11_db_transmission(bts, 0); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 645 | |
| 646 | /* Reset BTS Site manager resource */ |
Harald Welte | 7837489 | 2009-01-18 19:09:22 +0000 | [diff] [blame] | 647 | abis_nm_bs11_reset_resource(bts); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 648 | |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | static int shutdown_net(struct gsm_network *net) |
| 653 | { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 654 | struct gsm_bts *bts; |
| 655 | |
| 656 | llist_for_each_entry(bts, &net->bts_list, list) { |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 657 | int rc; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 658 | rc = shutdown_om(bts); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 659 | if (rc < 0) |
| 660 | return rc; |
| 661 | } |
| 662 | |
| 663 | return 0; |
| 664 | } |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 665 | |
| 666 | struct bcch_info { |
| 667 | u_int8_t type; |
| 668 | u_int8_t len; |
| 669 | const u_int8_t *data; |
| 670 | }; |
| 671 | |
| 672 | /* |
| 673 | SYSTEM INFORMATION TYPE 1 |
| 674 | Cell channel description |
| 675 | Format-ID bit map 0 |
| 676 | CA-ARFCN Bit 124...001 (Hex): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 |
| 677 | RACH Control Parameters |
| 678 | maximum 7 retransmissions |
| 679 | 8 slots used to spread transmission |
| 680 | cell not barred for access |
| 681 | call reestablishment not allowed |
| 682 | Access Control Class = 0000 |
| 683 | */ |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 684 | static u_int8_t si1[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 685 | /* header */0x55, 0x06, 0x19, |
| 686 | /* ccdesc */0x04 /*0x00*/, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 687 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /*0x01*/, |
Harald Welte | 7f69816 | 2009-08-13 20:26:10 +0200 | [diff] [blame^] | 688 | /* rach */0xD5, 0x04, 0x00, |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 689 | /* s1 reset*/0x2B |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 690 | }; |
| 691 | |
| 692 | /* |
| 693 | SYSTEM INFORMATION TYPE 2 |
| 694 | Neighbour Cells Description |
| 695 | EXT-IND: Carries the complete BA |
| 696 | BA-IND = 0 |
| 697 | Format-ID bit map 0 |
| 698 | CA-ARFCN Bit 124...001 (Hex): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 699 | NCC permitted (NCC) = FF |
| 700 | RACH Control Parameters |
| 701 | maximum 7 retransmissions |
| 702 | 8 slots used to spread transmission |
| 703 | cell not barred for access |
| 704 | call reestablishment not allowed |
| 705 | Access Control Class = 0000 |
| 706 | */ |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 707 | static u_int8_t si2[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 708 | /* header */0x59, 0x06, 0x1A, |
| 709 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 710 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 711 | /* ncc */0xFF, |
Harald Welte | 7f69816 | 2009-08-13 20:26:10 +0200 | [diff] [blame^] | 712 | /* rach*/0xD5, 0x04, 0x00 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 713 | }; |
| 714 | |
| 715 | /* |
| 716 | SYSTEM INFORMATION TYPE 3 |
| 717 | Cell identity = 00001 (1h) |
| 718 | Location area identification |
| 719 | Mobile Country Code (MCC): 001 |
| 720 | Mobile Network Code (MNC): 01 |
| 721 | Location Area Code (LAC): 00001 (1h) |
| 722 | Control Channel Description |
| 723 | Attach-detach: MSs in the cell are not allowed to apply IMSI attach /detach |
| 724 | 0 blocks reserved for access grant |
| 725 | 1 channel used for CCCH, with SDCCH |
| 726 | 5 multiframes period for PAGING REQUEST |
| 727 | Time-out T3212 = 0 |
| 728 | Cell Options BCCH |
| 729 | Power control indicator: not set |
| 730 | MSs shall not use uplink DTX |
| 731 | Radio link timeout = 36 |
| 732 | Cell Selection Parameters |
| 733 | Cell reselect hysteresis = 6 dB RXLEV hysteresis for LA re-selection |
Harald Welte | 3b2ec42 | 2008-12-29 04:11:14 +0000 | [diff] [blame] | 734 | 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] | 735 | 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 |
| 736 | Half rate support (NECI): New establishment causes are not supported |
| 737 | min.RX signal level for MS = 0 |
| 738 | RACH Control Parameters |
| 739 | maximum 7 retransmissions |
| 740 | 8 slots used to spread transmission |
| 741 | cell not barred for access |
| 742 | call reestablishment not allowed |
| 743 | Access Control Class = 0000 |
Harald Welte | 53833f6 | 2009-07-05 13:41:40 +0200 | [diff] [blame] | 744 | SI 3 Rest Octets (not present) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 745 | */ |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 746 | static u_int8_t si3[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 747 | /* header */0x49, 0x06, 0x1B, |
| 748 | /* cell */0x00, 0x01, |
| 749 | /* lai */0x00, 0xF1, 0x10, 0x00, 0x01, |
| 750 | /* desc */0x01, 0x03, 0x00, |
| 751 | /* option*/0x28, |
| 752 | /* selection*/0x62, 0x00, |
Harald Welte | 7f69816 | 2009-08-13 20:26:10 +0200 | [diff] [blame^] | 753 | /* rach */0xD5, 0x04, 0x00, |
Harald Welte | 53833f6 | 2009-07-05 13:41:40 +0200 | [diff] [blame] | 754 | /* rest */ 0x2B, 0x2B, 0x2B, 0x2B |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 755 | }; |
| 756 | |
| 757 | /* |
| 758 | SYSTEM INFORMATION TYPE 4 |
| 759 | Location area identification |
| 760 | Mobile Country Code (MCC): 001 |
| 761 | Mobile Network Code (MNC): 01 |
| 762 | Location Area Code (LAC): 00001 (1h) |
| 763 | Cell Selection Parameters |
| 764 | Cell reselect hysteresis = 6 dB RXLEV hysteresis for LA re-selection |
| 765 | max.TX power level MS may use for CCH = 2 |
| 766 | 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 |
| 767 | Half rate support (NECI): New establishment causes are not supported |
| 768 | min.RX signal level for MS = 0 |
| 769 | RACH Control Parameters |
| 770 | maximum 7 retransmissions |
| 771 | 8 slots used to spread transmission |
| 772 | cell not barred for access |
| 773 | call reestablishment not allowed |
| 774 | Access Control Class = 0000 |
Harald Welte | 53833f6 | 2009-07-05 13:41:40 +0200 | [diff] [blame] | 775 | CBCH Channel Description |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 776 | Type = SDCCH/4[2] |
| 777 | Timeslot Number: 0 |
| 778 | Training Sequence Code: 7h |
| 779 | ARFCN: 1 |
Harald Welte | 53833f6 | 2009-07-05 13:41:40 +0200 | [diff] [blame] | 780 | SI Rest Octets (not present) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 781 | */ |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 782 | static u_int8_t si4[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 783 | /* header */0x41, 0x06, 0x1C, |
| 784 | /* lai */0x00, 0xF1, 0x10, 0x00, 0x01, |
| 785 | /* sel */0x62, 0x00, |
Harald Welte | 7f69816 | 2009-08-13 20:26:10 +0200 | [diff] [blame^] | 786 | /* rach*/0xD5, 0x04, 0x00, |
Harald Welte | 53833f6 | 2009-07-05 13:41:40 +0200 | [diff] [blame] | 787 | /* cbch chan desc */ 0x64, 0x30, 0xE0, HARDCODED_ARFCN/*0x01*/, |
| 788 | /* rest octets */ 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 789 | }; |
| 790 | |
| 791 | /* |
| 792 | SYSTEM INFORMATION TYPE 5 |
| 793 | Neighbour Cells Description |
| 794 | EXT-IND: Carries the complete BA |
| 795 | BA-IND = 0 |
| 796 | Format-ID bit map 0 |
| 797 | CA-ARFCN Bit 124...001 (Hex): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 798 | */ |
| 799 | |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 800 | static u_int8_t si5[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 801 | /* header without l2 len*/0x06, 0x1D, |
| 802 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 803 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 804 | }; |
| 805 | |
| 806 | // SYSTEM INFORMATION TYPE 6 |
| 807 | |
| 808 | /* |
| 809 | SACCH FILLING |
| 810 | System Info Type: SYSTEM INFORMATION 6 |
| 811 | L3 Information (Hex): 06 1E 00 01 xx xx 10 00 01 28 FF |
| 812 | |
| 813 | SYSTEM INFORMATION TYPE 6 |
| 814 | Cell identity = 00001 (1h) |
| 815 | Location area identification |
| 816 | Mobile Country Code (MCC): 001 |
| 817 | Mobile Network Code (MNC): 01 |
| 818 | Location Area Code (LAC): 00001 (1h) |
| 819 | Cell Options SACCH |
| 820 | Power control indicator: not set |
| 821 | MSs shall not use uplink DTX on a TCH-F. MS shall not use uplink DTX on TCH-H. |
| 822 | Radio link timeout = 36 |
| 823 | NCC permitted (NCC) = FF |
| 824 | */ |
| 825 | |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 826 | static u_int8_t si6[] = { |
Holger Freyther | 4d50547 | 2008-12-28 16:32:42 +0000 | [diff] [blame] | 827 | /* header */0x06, 0x1E, |
| 828 | /* cell id*/ 0x00, 0x01, |
| 829 | /* lai */ 0x00, 0xF1, 0x10, 0x00, 0x01, |
| 830 | /* options */ 0x28, |
| 831 | /* ncc */ 0xFF, |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 832 | }; |
| 833 | |
| 834 | |
| 835 | |
| 836 | static const struct bcch_info bcch_infos[] = { |
| 837 | { |
| 838 | .type = RSL_SYSTEM_INFO_1, |
| 839 | .len = sizeof(si1), |
| 840 | .data = si1, |
| 841 | }, { |
| 842 | .type = RSL_SYSTEM_INFO_2, |
| 843 | .len = sizeof(si2), |
| 844 | .data = si2, |
| 845 | }, { |
| 846 | .type = RSL_SYSTEM_INFO_3, |
| 847 | .len = sizeof(si3), |
| 848 | .data = si3, |
| 849 | }, { |
| 850 | .type = RSL_SYSTEM_INFO_4, |
| 851 | .len = sizeof(si4), |
| 852 | .data = si4, |
| 853 | }, |
| 854 | }; |
| 855 | |
Holger Freyther | 24287b6 | 2008-12-28 16:32:41 +0000 | [diff] [blame] | 856 | static_assert(sizeof(si1) == sizeof(struct gsm48_system_information_type_1), type1) |
| 857 | static_assert(sizeof(si2) == sizeof(struct gsm48_system_information_type_2), type2) |
| 858 | static_assert(sizeof(si3) == sizeof(struct gsm48_system_information_type_3), type3) |
| 859 | static_assert(sizeof(si4) >= sizeof(struct gsm48_system_information_type_4), type4) |
Harald Welte | 104604e | 2008-12-28 16:36:11 +0000 | [diff] [blame] | 860 | static_assert(sizeof(si5) == sizeof(struct gsm48_system_information_type_5), type5) |
| 861 | static_assert(sizeof(si6) >= sizeof(struct gsm48_system_information_type_6), type6) |
Holger Freyther | 24287b6 | 2008-12-28 16:32:41 +0000 | [diff] [blame] | 862 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 863 | /* set all system information types */ |
Harald Welte | e79769b | 2009-02-07 00:48:17 +0000 | [diff] [blame] | 864 | static int set_system_infos(struct gsm_bts_trx *trx) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 865 | { |
| 866 | int i; |
| 867 | |
Harald Welte | d158605 | 2009-08-06 17:41:19 +0200 | [diff] [blame] | 868 | if (trx == trx->bts->c0) { |
| 869 | for (i = 0; i < ARRAY_SIZE(bcch_infos); i++) { |
| 870 | rsl_bcch_info(trx, bcch_infos[i].type, |
| 871 | bcch_infos[i].data, |
| 872 | bcch_infos[i].len); |
| 873 | } |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 874 | } |
Harald Welte | e79769b | 2009-02-07 00:48:17 +0000 | [diff] [blame] | 875 | rsl_sacch_filling(trx, RSL_SYSTEM_INFO_5, si5, sizeof(si5)); |
| 876 | rsl_sacch_filling(trx, RSL_SYSTEM_INFO_6, si6, sizeof(si6)); |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 877 | |
| 878 | return 0; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 879 | } |
| 880 | |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 881 | /* |
| 882 | * Patch the various SYSTEM INFORMATION tables to update |
| 883 | * the LAI |
| 884 | */ |
Harald Welte | 000c0f4 | 2009-08-12 21:45:02 +0200 | [diff] [blame] | 885 | static void patch_nm_tables(struct gsm_bts *bts) |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 886 | { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 887 | u_int8_t arfcn_low = bts->c0->arfcn & 0xff; |
| 888 | u_int8_t arfcn_high = (bts->c0->arfcn >> 8) & 0x0f; |
Harald Welte | 000c0f4 | 2009-08-12 21:45:02 +0200 | [diff] [blame] | 889 | |
| 890 | /* patch ARFCN into BTS Attributes */ |
| 891 | bs11_attr_bts[69] &= 0xf0; |
| 892 | bs11_attr_bts[69] |= arfcn_high; |
| 893 | bs11_attr_bts[70] = arfcn_low; |
| 894 | nanobts_attr_bts[42] &= 0xf0; |
| 895 | nanobts_attr_bts[42] |= arfcn_high; |
| 896 | nanobts_attr_bts[43] = arfcn_low; |
| 897 | |
| 898 | /* patch ARFCN into TRX Attributes */ |
| 899 | bs11_attr_radio[2] &= 0xf0; |
| 900 | bs11_attr_radio[2] |= arfcn_high; |
| 901 | bs11_attr_radio[3] = arfcn_low; |
| 902 | nanobts_attr_radio[5] &= 0xf0; |
| 903 | nanobts_attr_radio[5] |= arfcn_high; |
| 904 | nanobts_attr_radio[6] = arfcn_low; |
| 905 | |
| 906 | /* patch BSIC */ |
| 907 | bs11_attr_bts[1] = bts->bsic; |
| 908 | nanobts_attr_bts[sizeof(nanobts_attr_bts)-1] = bts->bsic; |
Harald Welte | 61cd883 | 2009-08-12 21:50:41 +0200 | [diff] [blame] | 909 | |
| 910 | /* patch the power reduction */ |
| 911 | bs11_attr_radio[5] = bts->c0->max_power_red / 2; |
| 912 | nanobts_attr_radio[1] = bts->c0->max_power_red / 2; |
Harald Welte | 000c0f4 | 2009-08-12 21:45:02 +0200 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | /* |
| 916 | * Patch the various SYSTEM INFORMATION tables to update |
| 917 | * the LAI |
| 918 | */ |
| 919 | static void patch_si_tables(struct gsm_bts *bts) |
| 920 | { |
| 921 | u_int8_t arfcn_low = bts->c0->arfcn & 0xff; |
| 922 | u_int8_t arfcn_high = (bts->c0->arfcn >> 8) & 0x0f; |
| 923 | |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 924 | /* covert the raw packet to the struct */ |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 925 | struct gsm48_system_information_type_1 *type_1 = |
| 926 | (struct gsm48_system_information_type_1*)&si1; |
| 927 | struct gsm48_system_information_type_2 *type_2 = |
| 928 | (struct gsm48_system_information_type_2*)&si2; |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 929 | struct gsm48_system_information_type_3 *type_3 = |
| 930 | (struct gsm48_system_information_type_3*)&si3; |
| 931 | struct gsm48_system_information_type_4 *type_4 = |
| 932 | (struct gsm48_system_information_type_4*)&si4; |
| 933 | struct gsm48_system_information_type_6 *type_6 = |
| 934 | (struct gsm48_system_information_type_6*)&si6; |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 935 | struct gsm48_loc_area_id lai; |
| 936 | |
| 937 | gsm0408_generate_lai(&lai, bts->network->country_code, |
Harald Welte | 110c0ab | 2009-05-23 16:27:05 +0000 | [diff] [blame] | 938 | bts->network->network_code, |
| 939 | bts->location_area_code); |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 940 | |
| 941 | /* assign the MCC and MNC */ |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 942 | type_3->lai = lai; |
| 943 | type_4->lai = lai; |
| 944 | type_6->lai = lai; |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 945 | |
Harald Welte | 9898188 | 2009-01-06 18:59:11 +0000 | [diff] [blame] | 946 | type_4->data[2] &= 0xf0; |
| 947 | type_4->data[2] |= arfcn_high; |
| 948 | type_4->data[3] = arfcn_low; |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 949 | |
| 950 | /* patch Control Channel Description 10.5.2.11 */ |
| 951 | type_3->control_channel_desc = bts->chan_desc; |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 952 | |
Harald Welte | f8d536d | 2009-07-21 22:12:23 +0200 | [diff] [blame] | 953 | /* patch TSC */ |
| 954 | si4[15] &= ~0xe0; |
| 955 | si4[15] |= (bts->tsc & 7) << 5; |
Harald Welte | 31f03a6 | 2009-08-09 14:38:49 +0200 | [diff] [blame] | 956 | |
| 957 | /* patch MS max power for CCH */ |
| 958 | type_4->cell_sel_par.ms_txpwr_max_ccch = |
Harald Welte | 66b6a8d | 2009-08-09 14:45:18 +0200 | [diff] [blame] | 959 | ms_pwr_ctl_lvl(bts->band, 20 /* dBm == 100mW */); |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 960 | |
| 961 | if (bts->cell_barred) { |
| 962 | type_1->rach_control.cell_bar = 1; |
| 963 | type_2->rach_control.cell_bar = 1; |
| 964 | type_3->rach_control.cell_bar = 1; |
| 965 | type_4->rach_control.cell_bar = 1; |
| 966 | } else { |
| 967 | type_1->rach_control.cell_bar = 0; |
| 968 | type_2->rach_control.cell_bar = 0; |
| 969 | type_3->rach_control.cell_bar = 0; |
| 970 | type_4->rach_control.cell_bar = 0; |
| 971 | } |
Holger Freyther | b9ddfd0 | 2008-12-28 16:32:45 +0000 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | |
Harald Welte | e79769b | 2009-02-07 00:48:17 +0000 | [diff] [blame] | 975 | static void bootstrap_rsl(struct gsm_bts_trx *trx) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 976 | { |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 977 | fprintf(stdout, "bootstrapping RSL for BTS/TRX (%u/%u) " |
Harald Welte | f8d536d | 2009-07-21 22:12:23 +0200 | [diff] [blame] | 978 | "using MCC=%u MNC=%u BSIC=%u TSC=%u\n", |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 979 | trx->bts->nr, trx->nr, gsmnet->country_code, |
| 980 | gsmnet->network_code, trx->bts->bsic, trx->bts->tsc); |
Harald Welte | 000c0f4 | 2009-08-12 21:45:02 +0200 | [diff] [blame] | 981 | patch_si_tables(trx->bts); |
Harald Welte | e79769b | 2009-02-07 00:48:17 +0000 | [diff] [blame] | 982 | set_system_infos(trx); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 983 | } |
| 984 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 985 | 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] | 986 | { |
| 987 | switch (event) { |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 988 | case EVT_E1_TEI_UP: |
| 989 | switch (type) { |
| 990 | case E1INP_SIGN_OML: |
| 991 | bootstrap_om(trx->bts); |
| 992 | break; |
| 993 | case E1INP_SIGN_RSL: |
| 994 | bootstrap_rsl(trx); |
| 995 | break; |
| 996 | default: |
| 997 | break; |
| 998 | } |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 999 | break; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 1000 | case EVT_E1_TEI_DN: |
| 1001 | fprintf(stderr, "Lost some E1 TEI link\n"); |
| 1002 | /* FIXME: deal with TEI or L1 link loss */ |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 1003 | break; |
| 1004 | default: |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 1005 | break; |
| 1006 | } |
| 1007 | } |
| 1008 | |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 1009 | static int bootstrap_bts(struct gsm_bts *bts) |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1010 | { |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1011 | switch (bts->type) { |
| 1012 | case GSM_BTS_TYPE_NANOBTS_1800: |
| 1013 | if (bts->c0->arfcn < 512 || bts->c0->arfcn > 885) { |
| 1014 | fprintf(stderr, "GSM1800 channel must be between 512-885.\n"); |
| 1015 | return -EINVAL; |
| 1016 | } |
| 1017 | break; |
| 1018 | case GSM_BTS_TYPE_BS11: |
| 1019 | case GSM_BTS_TYPE_NANOBTS_900: |
| 1020 | /* Assume we have a P-GSM900 here */ |
| 1021 | if (bts->c0->arfcn < 1 || bts->c0->arfcn > 124) { |
| 1022 | fprintf(stderr, "GSM900 channel must be between 1-124.\n"); |
| 1023 | return -EINVAL; |
| 1024 | } |
| 1025 | break; |
| 1026 | case GSM_BTS_TYPE_UNKNOWN: |
| 1027 | fprintf(stderr, "Unknown BTS. Please specify\n"); |
| 1028 | return -EINVAL; |
| 1029 | } |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 1030 | |
| 1031 | /* Control Channel Description */ |
| 1032 | memset(&bts->chan_desc, 0, sizeof(struct gsm48_control_channel_descr)); |
Harald Welte | 41fbf44 | 2009-02-24 22:34:22 +0000 | [diff] [blame] | 1033 | bts->chan_desc.att = 1; |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 1034 | bts->chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_1_C; |
| 1035 | bts->chan_desc.bs_pa_mfrms = RSL_BS_PA_MFRMS_5; |
| 1036 | bts->chan_desc.t3212 = 0; |
| 1037 | |
Holger Freyther | 1fd3414 | 2009-02-09 23:42:03 +0000 | [diff] [blame] | 1038 | paging_init(bts); |
Harald Welte | 38c2f13 | 2009-01-06 23:10:57 +0000 | [diff] [blame] | 1039 | |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 1040 | return 0; |
| 1041 | } |
| 1042 | |
| 1043 | static int bootstrap_network(void) |
| 1044 | { |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1045 | struct gsm_bts *bts; |
Harald Welte | 5146006 | 2009-08-06 17:54:21 +0200 | [diff] [blame] | 1046 | int rc; |
| 1047 | |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 1048 | /* initialize our data structures */ |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1049 | gsmnet = gsm_network_init(MCC, MNC, mncc_recv); |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 1050 | if (!gsmnet) |
| 1051 | return -ENOMEM; |
| 1052 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1053 | gsmnet->name_long = talloc_strdup(gsmnet, "OpenBSC"); |
| 1054 | gsmnet->name_short = talloc_strdup(gsmnet, "OpenBSC"); |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 1055 | |
Holger Freyther | c7b86f9 | 2009-06-06 13:54:20 +0000 | [diff] [blame] | 1056 | if (db_init(database_name)) { |
Holger Freyther | ef7f7ce | 2009-04-19 06:35:12 +0000 | [diff] [blame] | 1057 | printf("DB: Failed to init database. Please check the option settings.\n"); |
| 1058 | return -1; |
| 1059 | } |
| 1060 | printf("DB: Database initialized.\n"); |
| 1061 | |
| 1062 | if (db_prepare()) { |
| 1063 | printf("DB: Failed to prepare database.\n"); |
| 1064 | return -1; |
| 1065 | } |
| 1066 | printf("DB: Database prepared.\n"); |
| 1067 | |
Holger Freyther | 219518d | 2009-01-02 22:04:43 +0000 | [diff] [blame] | 1068 | telnet_init(gsmnet, 4242); |
Holger Hans Peter Freyther | d5d1cef | 2009-08-10 08:39:27 +0200 | [diff] [blame] | 1069 | rc = vty_read_config_file(config_file); |
Holger Hans Peter Freyther | 100325a | 2009-08-10 10:35:24 +0200 | [diff] [blame] | 1070 | if (rc < 0) { |
| 1071 | fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1072 | return rc; |
Holger Hans Peter Freyther | 100325a | 2009-08-10 10:35:24 +0200 | [diff] [blame] | 1073 | } |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 1074 | |
Harald Welte | b463060 | 2009-05-01 15:43:22 +0000 | [diff] [blame] | 1075 | register_signal_handler(SS_NM, nm_sig_cb, NULL); |
| 1076 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1077 | llist_for_each_entry(bts, &gsmnet->bts_list, list) { |
Holger Hans Peter Freyther | 03582a8 | 2009-07-16 15:24:27 +0200 | [diff] [blame] | 1078 | bootstrap_bts(bts); |
Holger Hans Peter Freyther | 557ca78 | 2009-08-10 14:16:08 +0200 | [diff] [blame] | 1079 | if (!is_ipaccess_bts(bts)) |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1080 | rc = e1_reconfig_bts(bts); |
Holger Hans Peter Freyther | 03582a8 | 2009-07-16 15:24:27 +0200 | [diff] [blame] | 1081 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1082 | if (rc < 0) |
| 1083 | exit (1); |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 1084 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1085 | |
Holger Hans Peter Freyther | 557ca78 | 2009-08-10 14:16:08 +0200 | [diff] [blame] | 1086 | /* initialize nanoBTS support omce */ |
| 1087 | rc = ipaccess_setup(gsmnet); |
| 1088 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1089 | return 0; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1090 | } |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 1091 | |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 1092 | static void create_pcap_file(char *file) |
| 1093 | { |
| 1094 | mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; |
| 1095 | int fd = open(file, O_WRONLY|O_TRUNC|O_CREAT, mode); |
| 1096 | |
| 1097 | if (fd < 0) { |
| 1098 | perror("Failed to open file for pcap"); |
| 1099 | return; |
| 1100 | } |
| 1101 | |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 1102 | e1_set_pcap_fd(fd); |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 1103 | } |
| 1104 | |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1105 | static void print_usage() |
| 1106 | { |
| 1107 | printf("Usage: bsc_hack\n"); |
| 1108 | } |
| 1109 | |
| 1110 | static void print_help() |
| 1111 | { |
| 1112 | printf(" Some useful help...\n"); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1113 | printf(" -h --help this text\n"); |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1114 | 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] | 1115 | printf(" -s --disable-color\n"); |
Holger Hans Peter Freyther | d5d1cef | 2009-08-10 08:39:27 +0200 | [diff] [blame] | 1116 | printf(" -c --config-file filename The config file to use.\n"); |
Holger Freyther | bde3610 | 2008-12-28 22:51:39 +0000 | [diff] [blame] | 1117 | printf(" -l --database db-name The database to use\n"); |
Holger Freyther | 89824fc | 2008-12-30 16:18:18 +0000 | [diff] [blame] | 1118 | printf(" -a --authorize-everyone Allow everyone into the network.\n"); |
Holger Freyther | e97f7fb | 2008-12-31 18:52:11 +0000 | [diff] [blame] | 1119 | 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] | 1120 | printf(" -p --pcap file The filename of the pcap file\n"); |
Holger Freyther | dda22c1 | 2009-04-22 22:07:31 +0000 | [diff] [blame] | 1121 | printf(" -C --cardnr number For bs11 select E1 card number other than 0\n"); |
Holger Freyther | b5c00f5 | 2009-04-22 22:08:07 +0000 | [diff] [blame] | 1122 | printf(" -R --release-l2 Releases mISDN layer 2 after exit, to unload driver.\n"); |
Harald Welte | c70979a | 2009-08-12 21:52:11 +0200 | [diff] [blame] | 1123 | printf(" -T --timestamp Prefix every log line with a timestamp\n"); |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | static void handle_options(int argc, char** argv) |
| 1127 | { |
| 1128 | while (1) { |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 1129 | int option_index = 0, c; |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1130 | static struct option long_options[] = { |
| 1131 | {"help", 0, 0, 'h'}, |
| 1132 | {"debug", 1, 0, 'd'}, |
Holger Hans Peter Freyther | d5d1cef | 2009-08-10 08:39:27 +0200 | [diff] [blame] | 1133 | {"config-file", 1, 0, 'c'}, |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 1134 | {"disable-color", 0, 0, 's'}, |
Holger Freyther | bde3610 | 2008-12-28 22:51:39 +0000 | [diff] [blame] | 1135 | {"database", 1, 0, 'l'}, |
Holger Freyther | 89824fc | 2008-12-30 16:18:18 +0000 | [diff] [blame] | 1136 | {"authorize-everyone", 0, 0, 'a'}, |
Holger Freyther | e97f7fb | 2008-12-31 18:52:11 +0000 | [diff] [blame] | 1137 | {"reject-cause", 1, 0, 'r'}, |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 1138 | {"pcap", 1, 0, 'p'}, |
Holger Freyther | dda22c1 | 2009-04-22 22:07:31 +0000 | [diff] [blame] | 1139 | {"cardnr", 1, 0, 'C'}, |
Holger Freyther | b5c00f5 | 2009-04-22 22:08:07 +0000 | [diff] [blame] | 1140 | {"release-l2", 0, 0, 'R'}, |
Harald Welte | d3ff51d | 2009-06-09 20:21:57 +0000 | [diff] [blame] | 1141 | {"timestamp", 0, 0, 'T'}, |
Harald Welte | 805f644 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 1142 | {"rtp-proxy", 0, 0, 'P'}, |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1143 | {0, 0, 0, 0} |
| 1144 | }; |
| 1145 | |
Holger Hans Peter Freyther | d5d1cef | 2009-08-10 08:39:27 +0200 | [diff] [blame] | 1146 | c = getopt_long(argc, argv, "hd:sl:ar:p:C:RTPc:", |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1147 | long_options, &option_index); |
| 1148 | if (c == -1) |
| 1149 | break; |
| 1150 | |
| 1151 | switch (c) { |
| 1152 | case 'h': |
| 1153 | print_usage(); |
| 1154 | print_help(); |
| 1155 | exit(0); |
Holger Freyther | efde7fb | 2008-12-28 14:14:56 +0000 | [diff] [blame] | 1156 | case 's': |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1157 | debug_use_color(0); |
| 1158 | break; |
| 1159 | case 'd': |
| 1160 | debug_parse_category_mask(optarg); |
| 1161 | break; |
Harald Welte | 8965da4 | 2009-01-06 18:09:02 +0000 | [diff] [blame] | 1162 | case 'l': |
Holger Freyther | bde3610 | 2008-12-28 22:51:39 +0000 | [diff] [blame] | 1163 | database_name = strdup(optarg); |
| 1164 | break; |
Holger Hans Peter Freyther | d5d1cef | 2009-08-10 08:39:27 +0200 | [diff] [blame] | 1165 | case 'c': |
| 1166 | config_file = strdup(optarg); |
| 1167 | break; |
Holger Freyther | 89824fc | 2008-12-30 16:18:18 +0000 | [diff] [blame] | 1168 | case 'a': |
| 1169 | gsm0408_allow_everyone(1); |
| 1170 | break; |
Holger Freyther | e97f7fb | 2008-12-31 18:52:11 +0000 | [diff] [blame] | 1171 | case 'r': |
| 1172 | gsm0408_set_reject_cause(atoi(optarg)); |
| 1173 | break; |
Holger Freyther | 9a3ee0f | 2009-01-02 00:40:15 +0000 | [diff] [blame] | 1174 | case 'p': |
| 1175 | create_pcap_file(optarg); |
| 1176 | break; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 1177 | case 't': |
| 1178 | BTS_TYPE = parse_btstype(optarg); |
| 1179 | break; |
Holger Freyther | dda22c1 | 2009-04-22 22:07:31 +0000 | [diff] [blame] | 1180 | case 'C': |
| 1181 | cardnr = atoi(optarg); |
| 1182 | break; |
Holger Freyther | b5c00f5 | 2009-04-22 22:08:07 +0000 | [diff] [blame] | 1183 | case 'R': |
| 1184 | release_l2 = 1; |
| 1185 | break; |
Harald Welte | d3ff51d | 2009-06-09 20:21:57 +0000 | [diff] [blame] | 1186 | case 'T': |
| 1187 | debug_timestamp(1); |
| 1188 | break; |
Harald Welte | 805f644 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 1189 | case 'P': |
| 1190 | ipacc_rtp_direct = 0; |
| 1191 | break; |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1192 | default: |
| 1193 | /* ignore */ |
| 1194 | break; |
| 1195 | } |
| 1196 | } |
| 1197 | } |
| 1198 | |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 1199 | static void signal_handler(int signal) |
| 1200 | { |
| 1201 | fprintf(stdout, "signal %u received\n", signal); |
| 1202 | |
| 1203 | switch (signal) { |
Harald Welte | f294f45 | 2009-08-06 17:43:50 +0200 | [diff] [blame] | 1204 | case SIGINT: |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 1205 | shutdown_net(gsmnet); |
Harald Welte | f294f45 | 2009-08-06 17:43:50 +0200 | [diff] [blame] | 1206 | sleep(3); |
| 1207 | exit(0); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 1208 | break; |
Harald Welte | 31c3d34 | 2009-08-07 00:29:44 +0200 | [diff] [blame] | 1209 | case SIGABRT: |
| 1210 | /* in case of abort, we want to obtain a talloc report |
| 1211 | * and then return to the caller, who will abort the process */ |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 1212 | case SIGUSR1: |
| 1213 | talloc_report_full(tall_bsc_ctx, stderr); |
| 1214 | break; |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 1215 | default: |
| 1216 | break; |
| 1217 | } |
| 1218 | } |
| 1219 | |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 1220 | int main(int argc, char **argv) |
| 1221 | { |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 1222 | int rc; |
| 1223 | |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 1224 | tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc"); |
| 1225 | |
Holger Freyther | b332f61 | 2008-12-27 12:46:51 +0000 | [diff] [blame] | 1226 | /* parse options */ |
| 1227 | handle_options(argc, argv); |
| 1228 | |
Harald Welte | 65ccf88 | 2009-02-24 22:36:20 +0000 | [diff] [blame] | 1229 | /* seed the PRNG */ |
| 1230 | srand(time(NULL)); |
| 1231 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 1232 | rc = bootstrap_network(); |
| 1233 | if (rc < 0) |
| 1234 | exit(1); |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 1235 | |
Harald Welte | f294f45 | 2009-08-06 17:43:50 +0200 | [diff] [blame] | 1236 | signal(SIGINT, &signal_handler); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 1237 | signal(SIGABRT, &signal_handler); |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 1238 | signal(SIGUSR1, &signal_handler); |
Harald Welte | d125250 | 2009-01-01 01:50:32 +0000 | [diff] [blame] | 1239 | |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 1240 | while (1) { |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 1241 | bsc_upqueue(gsmnet); |
Harald Welte | 04d3c92 | 2009-05-23 06:07:04 +0000 | [diff] [blame] | 1242 | bsc_select_main(0); |
Harald Welte | f6b7a90 | 2008-12-26 00:05:11 +0000 | [diff] [blame] | 1243 | } |
| 1244 | } |