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