blob: 012481a5f7c0f6e95768ae239ade5b3ab4c85f1b [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001#ifndef _GSM_DATA_H
2#define _GSM_DATA_H
3
4#include <sys/types.h>
5
Harald Welteccda9652009-11-12 22:28:18 +09006struct value_string {
7 unsigned int value;
8 const char *str;
9};
10
11const char *get_value_string(const struct value_string *vs, u_int32_t val);
12
Harald Weltefcd24452009-06-20 18:15:19 +020013enum gsm_band {
14 GSM_BAND_400,
15 GSM_BAND_850,
16 GSM_BAND_900,
17 GSM_BAND_1800,
18 GSM_BAND_1900,
19};
20
Harald Welte4bfdfe72009-06-10 23:11:52 +080021enum gsm_phys_chan_config {
22 GSM_PCHAN_NONE,
23 GSM_PCHAN_CCCH,
24 GSM_PCHAN_CCCH_SDCCH4,
25 GSM_PCHAN_TCH_F,
26 GSM_PCHAN_TCH_H,
27 GSM_PCHAN_SDCCH8_SACCH8C,
Harald Weltea1499d02009-10-24 10:25:50 +020028 GSM_PCHAN_PDCH, /* GPRS PDCH */
29 GSM_PCHAN_TCH_F_PDCH, /* TCH/F if used, PDCH otherwise */
Harald Welte4bfdfe72009-06-10 23:11:52 +080030 GSM_PCHAN_UNKNOWN,
31};
32
33enum gsm_chan_t {
34 GSM_LCHAN_NONE,
35 GSM_LCHAN_SDCCH,
36 GSM_LCHAN_TCH_F,
37 GSM_LCHAN_TCH_H,
38 GSM_LCHAN_UNKNOWN,
39};
40
Harald Welteeab84a12009-12-13 10:53:12 +010041/* RRLP mode of operation */
42enum rrlp_mode {
43 RRLP_MODE_NONE,
44 RRLP_MODE_MS_BASED,
45 RRLP_MODE_MS_PREF,
46 RRLP_MODE_ASS_PREF,
47};
Harald Welte4bfdfe72009-06-10 23:11:52 +080048
49/* Channel Request reason */
50enum gsm_chreq_reason_t {
51 GSM_CHREQ_REASON_EMERG,
52 GSM_CHREQ_REASON_PAG,
53 GSM_CHREQ_REASON_CALL,
54 GSM_CHREQ_REASON_LOCATION_UPD,
55 GSM_CHREQ_REASON_OTHER,
56};
57
Harald Welte255539c2008-12-28 02:26:27 +000058#include <openbsc/timer.h>
Holger Freyther1adb4ff2009-02-04 00:04:52 +000059#include <openbsc/gsm_04_08.h>
Harald Welte9943c5b2009-07-29 15:41:29 +020060#include <openbsc/abis_rsl.h>
Harald Welte4bfdfe72009-06-10 23:11:52 +080061#include <openbsc/mncc.h>
Harald Welte93e9d172009-06-20 19:04:31 +020062#include <openbsc/tlv.h>
Harald Welte6c40def2009-12-14 22:07:14 +010063#include <openbsc/bitvec.h>
Harald Welte255539c2008-12-28 02:26:27 +000064
Harald Welte8470bf22008-12-25 23:28:35 +000065#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
66
Harald Welte85770c72009-01-18 17:47:32 +000067#define TRX_NR_TS 8
Harald Welte8470bf22008-12-25 23:28:35 +000068#define TS_MAX_LCHAN 8
Harald Welte52b1f982008-12-23 20:25:15 +000069
70#define HARDCODED_ARFCN 123
Harald Welte02b0e092009-02-28 13:11:07 +000071#define HARDCODED_TSC 7
Harald Welte78f2f502009-05-23 16:56:52 +000072#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
Harald Welte52b1f982008-12-23 20:25:15 +000073
Harald Welte63589be2009-08-06 17:38:10 +020074/* for multi-drop config */
75#define HARDCODED_BTS0_TS 1
76#define HARDCODED_BTS1_TS 6
77#define HARDCODED_BTS2_TS 11
78
Harald Welte8e1e3ee2009-02-01 13:32:45 +000079enum gsm_hooks {
80 GSM_HOOK_NM_SWLOAD,
Harald Welte0932d1e2009-02-16 22:53:52 +000081 GSM_HOOK_RR_PAGING,
82};
83
84enum gsm_paging_event {
85 GSM_PAGING_SUCCEEDED,
86 GSM_PAGING_EXPIRED,
Holger Freyther85a7b362009-04-18 13:48:55 +020087 GSM_PAGING_OOM,
Harald Welte8e1e3ee2009-02-01 13:32:45 +000088};
89
90struct msgb;
91typedef int gsm_cbfn(unsigned int hooknum,
92 unsigned int event,
93 struct msgb *msg,
94 void *data, void *param);
95
Holger Freytherc6ea9db2008-12-30 19:18:21 +000096/*
97 * Use the channel. As side effect the lchannel recycle timer
98 * will be started.
99 */
Harald Welteb9c758b2009-07-05 14:02:46 +0200100#define LCHAN_RELEASE_TIMEOUT 20, 0
Holger Freytherc6ea9db2008-12-30 19:18:21 +0000101#define use_lchan(lchan) \
102 do { lchan->use_count++; \
Holger Freyther4f584c32009-06-02 02:55:07 +0000103 DEBUGP(DCC, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) increases usage to: %d\n", \
104 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr, \
105 lchan->nr, lchan->use_count); \
Harald Welteff117a82009-05-23 05:22:08 +0000106 bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0);
Holger Freytherc6ea9db2008-12-30 19:18:21 +0000107
108#define put_lchan(lchan) \
Holger Freyther4f584c32009-06-02 02:55:07 +0000109 do { lchan->use_count--; \
110 DEBUGP(DCC, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) decreases usage to: %d\n", \
111 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr, \
112 lchan->nr, lchan->use_count); \
113 } while(0);
114
Holger Freytherc6ea9db2008-12-30 19:18:21 +0000115
Harald Welte52b1f982008-12-23 20:25:15 +0000116/* communications link with a BTS */
117struct gsm_bts_link {
118 struct gsm_bts *bts;
119};
120
Harald Welte49f48b82009-02-17 15:29:33 +0000121struct gsm_lchan;
122struct gsm_subscriber;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800123struct gsm_mncc;
Harald Welte805f6442009-07-28 18:25:29 +0200124struct rtp_socket;
Harald Welte49f48b82009-02-17 15:29:33 +0000125
Harald Weltebbcc7a52009-02-14 19:45:44 +0000126/* Network Management State */
127struct gsm_nm_state {
128 u_int8_t operational;
129 u_int8_t administrative;
Harald Welte8c1d0e42009-02-15 03:38:12 +0000130 u_int8_t availability;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000131};
Harald Weltebbcc7a52009-02-14 19:45:44 +0000132
Holger Freyther73487a22008-12-31 18:53:57 +0000133/*
134 * LOCATION UPDATING REQUEST state
135 *
136 * Our current operation is:
137 * - Get imei/tmsi
138 * - Accept/Reject according to global policy
139 */
140struct gsm_loc_updating_operation {
141 struct timer_list updating_timer;
Holger Hans Peter Freyther251aa912009-10-27 10:42:28 +0100142 unsigned int waiting_for_imsi : 1;
143 unsigned int waiting_for_imei : 1;
Holger Freyther73487a22008-12-31 18:53:57 +0000144};
145
Harald Welte08d91a52009-08-30 15:37:11 +0900146#define MAX_A5_KEY_LEN (128/8)
147#define RSL_ENC_ALG_A5(x) (x+1)
148
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100149/* is the data link established? who established it? */
150#define LCHAN_SAPI_UNUSED 0
151#define LCHAN_SAPI_MS 1
152#define LCHAN_SAPI_NET 2
153
Harald Welte8470bf22008-12-25 23:28:35 +0000154struct gsm_lchan {
155 /* The TS that we're part of */
156 struct gsm_bts_trx_ts *ts;
157 /* The logical subslot number in the TS */
158 u_int8_t nr;
Harald Welte45b407a2009-05-23 15:51:12 +0000159 /* The logical channel type */
Harald Welte8470bf22008-12-25 23:28:35 +0000160 enum gsm_chan_t type;
Harald Welte9943c5b2009-07-29 15:41:29 +0200161 /* RSL channel mode */
162 enum rsl_cmod_spd rsl_cmode;
Harald Welte45b407a2009-05-23 15:51:12 +0000163 /* If TCH, traffic channel mode */
Harald Welte9943c5b2009-07-29 15:41:29 +0200164 enum gsm48_chan_mode tch_mode;
Harald Welted4c9bf32009-02-15 16:56:18 +0000165 /* Power levels for MS and BTS */
166 u_int8_t bs_power;
167 u_int8_t ms_power;
Harald Welte08d91a52009-08-30 15:37:11 +0900168 /* Encryption information */
169 struct {
170 u_int8_t alg_id;
171 u_int8_t key_len;
172 u_int8_t key[MAX_A5_KEY_LEN];
173 } encr;
Holger Hans Peter Freytherea528022009-11-18 22:57:02 +0100174
175 /* AMR bits */
176 struct gsm48_multi_rate_conf mr_conf;
Harald Welted4c9bf32009-02-15 16:56:18 +0000177
Harald Welte8470bf22008-12-25 23:28:35 +0000178 /* To whom we are allocated at the moment */
179 struct gsm_subscriber *subscr;
Holger Freytherc6ea9db2008-12-30 19:18:21 +0000180
181 /* Timer started to release the channel */
182 struct timer_list release_timer;
Harald Weltea3d04382008-12-27 17:02:56 +0000183
Harald Welteb7e81162009-08-10 00:26:10 +0200184 struct timer_list T3101;
185
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100186 /* Established data link layer services */
187 u_int8_t sapis[8];
188
Holger Freyther73487a22008-12-31 18:53:57 +0000189 /*
190 * Operations that have a state and might be pending
191 */
192 struct gsm_loc_updating_operation *loc_operation;
193
Holger Freytherb7193e42008-12-29 17:44:08 +0000194 /* use count. how many users use this channel */
195 unsigned int use_count;
Harald Welte2c828992009-12-02 01:56:49 +0530196
197 struct {
198 u_int32_t bound_ip;
199 u_int16_t bound_port;
200 u_int8_t rtp_payload2;
201 u_int16_t conn_id;
202 struct rtp_socket *rtp_socket;
203 } abis_ip;
Harald Welte8470bf22008-12-25 23:28:35 +0000204};
205
Harald Welte85770c72009-01-18 17:47:32 +0000206struct gsm_e1_subslot {
207 /* Number of E1 link */
208 u_int8_t e1_nr;
209 /* Number of E1 TS inside E1 link */
210 u_int8_t e1_ts;
211 /* Sub-slot within the E1 TS, 0xff if full TS */
212 u_int8_t e1_ts_ss;
213};
214
Harald Welte52b1f982008-12-23 20:25:15 +0000215#define BTS_TRX_F_ACTIVATED 0x0001
216/* One Timeslot in a TRX */
217struct gsm_bts_trx_ts {
218 struct gsm_bts_trx *trx;
219 /* number of this timeslot at the TRX */
220 u_int8_t nr;
221
Harald Welte8470bf22008-12-25 23:28:35 +0000222 enum gsm_phys_chan_config pchan;
223
Harald Welte52b1f982008-12-23 20:25:15 +0000224 unsigned int flags;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000225 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200226 struct tlv_parsed nm_attr;
Harald Welte39c7deb2009-08-09 21:49:48 +0200227 u_int8_t nm_chan_comb;
Harald Welte8470bf22008-12-25 23:28:35 +0000228
Harald Welte85770c72009-01-18 17:47:32 +0000229 /* To which E1 subslot are we connected */
230 struct gsm_e1_subslot e1_link;
231
Harald Welte8470bf22008-12-25 23:28:35 +0000232 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +0000233};
234
235/* One TRX in a BTS */
236struct gsm_bts_trx {
Harald Weltee441d9c2009-06-21 16:17:15 +0200237 /* list header in bts->trx_list */
238 struct llist_head list;
239
Harald Welte52b1f982008-12-23 20:25:15 +0000240 struct gsm_bts *bts;
241 /* number of this TRX in the BTS */
242 u_int8_t nr;
Harald Welte1fa60c82009-02-09 18:13:26 +0000243 /* how do we talk RSL with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200244 struct gsm_e1_subslot rsl_e1_link;
245 u_int8_t rsl_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000246 struct e1inp_sign_link *rsl_link;
Harald Welte42581822009-08-08 16:12:58 +0200247
Harald Weltebbcc7a52009-02-14 19:45:44 +0000248 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200249 struct tlv_parsed nm_attr;
Harald Welte8c1d0e42009-02-15 03:38:12 +0000250 struct {
251 struct gsm_nm_state nm_state;
252 } bb_transc;
Harald Welte52b1f982008-12-23 20:25:15 +0000253
254 u_int16_t arfcn;
Harald Weltefcd24452009-06-20 18:15:19 +0200255 int nominal_power; /* in dBm */
256 unsigned int max_power_red; /* in actual dB */
Harald Welte8b697c72009-06-05 19:18:45 +0000257
258 union {
259 struct {
260 struct {
261 struct gsm_nm_state nm_state;
262 } bbsig;
263 struct {
264 struct gsm_nm_state nm_state;
265 } pa;
266 } bs11;
267 };
Harald Welte85770c72009-01-18 17:47:32 +0000268 struct gsm_bts_trx_ts ts[TRX_NR_TS];
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +0100269
270 /* NM state */
271 int rf_locked;
Harald Welte52b1f982008-12-23 20:25:15 +0000272};
273
Harald Welte978cb422009-01-18 17:57:27 +0000274enum gsm_bts_type {
275 GSM_BTS_TYPE_UNKNOWN,
276 GSM_BTS_TYPE_BS11,
Mike Habene2d82272009-10-02 12:19:34 +0100277 GSM_BTS_TYPE_NANOBTS,
Harald Welte978cb422009-01-18 17:57:27 +0000278};
279
Holger Freytherceb59b72009-02-06 18:54:00 +0000280/**
281 * A pending paging request
282 */
283struct gsm_paging_request {
Harald Welte0932d1e2009-02-16 22:53:52 +0000284 /* list_head for list of all paging requests */
Holger Freytherceb59b72009-02-06 18:54:00 +0000285 struct llist_head entry;
Harald Welte0932d1e2009-02-16 22:53:52 +0000286 /* the subscriber which we're paging. Later gsm_paging_request
287 * should probably become a part of the gsm_subscriber struct? */
Holger Freytherceb59b72009-02-06 18:54:00 +0000288 struct gsm_subscriber *subscr;
Harald Welte0932d1e2009-02-16 22:53:52 +0000289 /* back-pointer to the BTS on which we are paging */
Holger Freytherceb59b72009-02-06 18:54:00 +0000290 struct gsm_bts *bts;
Harald Welte0932d1e2009-02-16 22:53:52 +0000291 /* what kind of channel type do we ask the MS to establish */
Holger Freytherceb59b72009-02-06 18:54:00 +0000292 int chan_type;
Harald Weltecd06bfb2009-02-10 17:33:56 +0000293
294 /* Timer 3113: how long do we try to page? */
295 struct timer_list T3113;
Harald Welte0932d1e2009-02-16 22:53:52 +0000296
297 /* callback to be called in case paging completes */
298 gsm_cbfn *cbfn;
299 void *cbfn_param;
Holger Freytherceb59b72009-02-06 18:54:00 +0000300};
301
302/*
303 * This keeps track of the paging status of one BTS. It
304 * includes a number of pending requests, a back pointer
305 * to the gsm_bts, a timer and some more state.
306 */
307struct gsm_bts_paging_state {
Holger Freytherceb59b72009-02-06 18:54:00 +0000308 /* pending requests */
309 struct llist_head pending_requests;
310 struct gsm_paging_request *last_request;
311 struct gsm_bts *bts;
312
Harald Welte75a1fa82009-02-17 01:39:41 +0000313 struct timer_list work_timer;
314
Holger Freyther392209c2009-02-10 00:06:19 +0000315 /* load */
316 u_int16_t available_slots;
Holger Freytherceb59b72009-02-06 18:54:00 +0000317};
318
Harald Welte8b697c72009-06-05 19:18:45 +0000319struct gsm_envabtse {
320 struct gsm_nm_state nm_state;
321};
322
Harald Welte55dd4432009-10-24 10:19:14 +0200323struct gsm_bts_gprs_nsvc {
324 struct gsm_bts *bts;
325 int id;
326 struct gsm_nm_state nm_state;
327};
328
Harald Welte52b1f982008-12-23 20:25:15 +0000329/* One BTS */
330struct gsm_bts {
Harald Weltee441d9c2009-06-21 16:17:15 +0200331 /* list header in net->bts_list */
332 struct llist_head list;
333
Harald Welte52b1f982008-12-23 20:25:15 +0000334 struct gsm_network *network;
335 /* number of ths BTS in network */
336 u_int8_t nr;
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200337 /* Cell Identity */
338 u_int16_t cell_identity;
Harald Welte52b1f982008-12-23 20:25:15 +0000339 /* location area code of this BTS */
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +0200340 u_int16_t location_area_code;
Harald Welte02b0e092009-02-28 13:11:07 +0000341 /* Training Sequence Code */
342 u_int8_t tsc;
Harald Welte78f2f502009-05-23 16:56:52 +0000343 /* Base Station Identification Code (BSIC) */
344 u_int8_t bsic;
Harald Welte978cb422009-01-18 17:57:27 +0000345 /* type of BTS */
346 enum gsm_bts_type type;
Harald Weltefcd24452009-06-20 18:15:19 +0200347 enum gsm_band band;
Harald Weltefc0d9522009-08-10 13:46:55 +0200348 /* should the channel allocator allocate channels from high TRX to TRX0,
349 * rather than starting from TRX0 and go upwards? */
350 int chan_alloc_reverse;
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200351 int cell_barred;
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200352 /* maximum Tx power that the MS is permitted to use in this cell */
353 int ms_max_power;
Harald Weltefc0d9522009-08-10 13:46:55 +0200354
Harald Welte1fa60c82009-02-09 18:13:26 +0000355 /* how do we talk OML with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200356 struct gsm_e1_subslot oml_e1_link;
357 u_int8_t oml_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000358 struct e1inp_sign_link *oml_link;
Harald Welte52b1f982008-12-23 20:25:15 +0000359
360 /* Abis network management O&M handle */
361 struct abis_nm_h *nmh;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000362 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200363 struct tlv_parsed nm_attr;
Harald Welte978cb422009-01-18 17:57:27 +0000364
Harald Welte52b1f982008-12-23 20:25:15 +0000365 /* number of this BTS on given E1 link */
366 u_int8_t bts_nr;
367
Holger Freytherceb59b72009-02-06 18:54:00 +0000368 /* paging state and control */
369 struct gsm_bts_paging_state paging;
370
Harald Welte52b1f982008-12-23 20:25:15 +0000371 /* CCCH is on C0 */
372 struct gsm_bts_trx *c0;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000373
374 struct {
375 struct gsm_nm_state nm_state;
376 } site_mgr;
Harald Welteedb37782009-05-01 14:59:07 +0000377
Harald Weltea43f7892009-12-01 18:04:30 +0530378 /* parameters from which we build SYSTEM INFORMATION */
379 struct {
380 struct gsm48_rach_control rach_control;
381 u_int8_t ncc_permitted;
382 struct gsm48_cell_sel_par cell_sel_par;
383 struct gsm48_cell_options cell_options;
384 struct gsm48_control_channel_descr chan_desc;
Harald Welte6c40def2009-12-14 22:07:14 +0100385 struct bitvec neigh_list;
386 struct bitvec cell_alloc;
387 struct {
388 /* bitmask large enough for all possible ARFCN's */
389 u_int8_t neigh_list[1024/8];
390 u_int8_t cell_alloc[1024/8];
391 } data;
Harald Weltea43f7892009-12-01 18:04:30 +0530392 } si_common;
393
Harald Welteedb37782009-05-01 14:59:07 +0000394 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
Harald Welte7b26bcb2009-05-28 11:39:21 +0000395 union {
396 struct {
397 u_int16_t site_id;
398 u_int16_t bts_id;
399 } ip_access;
400 struct {
401 struct {
402 struct gsm_nm_state nm_state;
403 } cclk;
404 struct {
405 struct gsm_nm_state nm_state;
406 } rack;
Harald Welte8b697c72009-06-05 19:18:45 +0000407 struct gsm_envabtse envabtse[4];
Harald Welte7b26bcb2009-05-28 11:39:21 +0000408 } bs11;
409 };
Harald Welte55dd4432009-10-24 10:19:14 +0200410
411 /* Not entirely sure how ip.access specific this is */
412 struct {
413 struct {
414 struct gsm_nm_state nm_state;
415 } nse;
416 struct {
417 struct gsm_nm_state nm_state;
418 } cell;
419 struct gsm_bts_gprs_nsvc nsvc[2];
420 } gprs;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000421
Harald Welte52b1f982008-12-23 20:25:15 +0000422 /* transceivers */
423 int num_trx;
Harald Weltee441d9c2009-06-21 16:17:15 +0200424 struct llist_head trx_list;
Harald Welte52b1f982008-12-23 20:25:15 +0000425};
426
Harald Welte (local)69de3972009-08-12 14:42:23 +0200427enum gsm_auth_policy {
428 GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */
429 GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */
430 GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */
431};
432
Harald Welteb84ddfc2009-12-01 17:36:54 +0530433#define GSM_T3101_DEFAULT 10
434#define GSM_T3113_DEFAULT 60
435
Harald Welte52b1f982008-12-23 20:25:15 +0000436struct gsm_network {
437 /* global parameters */
Harald Welteb84e2f42008-12-28 23:42:04 +0000438 u_int16_t country_code;
439 u_int16_t network_code;
Harald Weltec6ba9c22008-12-30 18:01:02 +0000440 char *name_long;
441 char *name_short;
Harald Welte (local)69de3972009-08-12 14:42:23 +0200442 enum gsm_auth_policy auth_policy;
Harald Welte1085c092009-11-18 20:33:19 +0100443 enum gsm48_reject_value reject_cause;
Harald Welte4381cfe2009-08-30 15:47:06 +0900444 int a5_encryption;
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100445 int neci;
Harald Welte648b6ce2009-12-14 09:00:24 +0100446 int send_mm_info;
Harald Welte52b1f982008-12-23 20:25:15 +0000447
Harald Welte4bfdfe72009-06-10 23:11:52 +0800448 /* layer 4 */
449 int (*mncc_recv) (struct gsm_network *net, int msg_type, void *arg);
450 struct llist_head upqueue;
451 struct llist_head trans_list;
452
Harald Welte52b1f982008-12-23 20:25:15 +0000453 unsigned int num_bts;
Harald Weltee441d9c2009-06-21 16:17:15 +0200454 struct llist_head bts_list;
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100455
456 /* timer values */
457 int T3101;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100458 int T3103;
459 int T3105;
460 int T3107;
461 int T3109;
462 int T3111;
463 int T3113;
464 int T3115;
465 int T3117;
466 int T3119;
467 int T3141;
Harald Welteeab84a12009-12-13 10:53:12 +0100468
469 /* Radio Resource Location Protocol (TS 04.31) */
470 struct {
471 enum rrlp_mode mode;
472 } rrlp;
Harald Welte52b1f982008-12-23 20:25:15 +0000473};
474
Harald Welte7e310b12009-03-30 20:56:32 +0000475#define SMS_HDR_SIZE 128
476#define SMS_TEXT_SIZE 256
477struct gsm_sms {
Harald Welted409be72009-11-07 00:06:19 +0900478 unsigned long long id;
Harald Welte7e310b12009-03-30 20:56:32 +0000479 struct gsm_subscriber *sender;
480 struct gsm_subscriber *receiver;
481
Harald Welteb9c758b2009-07-05 14:02:46 +0200482 unsigned long validity_minutes;
Harald Welte76042182009-08-08 16:03:15 +0200483 u_int8_t reply_path_req;
484 u_int8_t status_rep_req;
485 u_int8_t ud_hdr_ind;
486 u_int8_t protocol_id;
487 u_int8_t data_coding_scheme;
488 u_int8_t msg_ref;
489 char dest_addr[20+1]; /* DA LV is 12 bytes max, i.e. 10 bytes
490 * BCD == 20 bytes string */
491 u_int8_t user_data_len;
492 u_int8_t user_data[SMS_TEXT_SIZE];
Harald Weltef3efc592009-07-27 20:11:35 +0200493
Harald Welte7e310b12009-03-30 20:56:32 +0000494 char text[SMS_TEXT_SIZE];
495};
496
Harald Weltee441d9c2009-06-21 16:17:15 +0200497struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_code,
Harald Welte4bfdfe72009-06-10 23:11:52 +0800498 int (*mncc_recv)(struct gsm_network *, int, void *));
Harald Weltee441d9c2009-06-21 16:17:15 +0200499struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
500 u_int8_t tsc, u_int8_t bsic);
501struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
502
503struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte84874c92009-12-14 22:33:02 +0100504
505/* Get reference to a neighbor cell on a given BCCH ARFCN */
Harald Welte0b121032009-12-15 00:21:31 +0100506struct gsm_bts *gsm_bts_neighbor(const struct gsm_bts *bts,
507 u_int16_t arfcn, u_int8_t bsic);
Harald Welte84874c92009-12-14 22:33:02 +0100508
Harald Weltee441d9c2009-06-21 16:17:15 +0200509struct gsm_bts_trx *gsm_bts_trx_num(struct gsm_bts *bts, int num);
Harald Welte8470bf22008-12-25 23:28:35 +0000510
Harald Weltea72c98e2009-01-04 16:10:38 +0000511const char *gsm_pchan_name(enum gsm_phys_chan_config c);
Harald Welte65da9122009-08-07 00:32:22 +0200512enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
Harald Weltea72c98e2009-01-04 16:10:38 +0000513const char *gsm_lchan_name(enum gsm_chan_t c);
514const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte23a68632009-02-19 17:06:42 +0000515char *gsm_ts_name(struct gsm_bts_trx_ts *ts);
Harald Weltea72c98e2009-01-04 16:10:38 +0000516
Harald Weltead384642008-12-26 10:20:07 +0000517enum gsm_e1_event {
518 EVT_E1_NONE,
Harald Welte1fa60c82009-02-09 18:13:26 +0000519 EVT_E1_TEI_UP,
520 EVT_E1_TEI_DN,
Harald Weltead384642008-12-26 10:20:07 +0000521};
522
Harald Weltecd06bfb2009-02-10 17:33:56 +0000523void set_ts_e1link(struct gsm_bts_trx_ts *ts, u_int8_t e1_nr,
524 u_int8_t e1_ts, u_int8_t e1_ts_ss);
Harald Welte1d014a52009-08-08 15:38:29 +0200525enum gsm_bts_type parse_btstype(const char *arg);
Holger Hans Peter Freyther2dceae62009-06-12 17:39:38 +0200526const char *btstype2str(enum gsm_bts_type type);
Harald Weltebe991492009-05-23 13:56:40 +0000527struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac,
528 struct gsm_bts *start_bts);
Harald Welte32201c12009-03-10 12:15:10 +0000529
Harald Weltefcd24452009-06-20 18:15:19 +0200530char *gsm_band_name(enum gsm_band band);
Harald Welte42581822009-08-08 16:12:58 +0200531enum gsm_band gsm_band_parse(const char *mhz);
Harald Weltefcd24452009-06-20 18:15:19 +0200532
Andreas Eversberg8226fa72009-06-29 15:19:38 +0200533extern void *tall_bsc_ctx;
Harald Welte2cf161b2009-06-20 22:36:41 +0200534
Harald Welte32201c12009-03-10 12:15:10 +0000535static inline int is_ipaccess_bts(struct gsm_bts *bts)
536{
537 switch (bts->type) {
Mike Habene2d82272009-10-02 12:19:34 +0100538 case GSM_BTS_TYPE_NANOBTS:
Harald Welte32201c12009-03-10 12:15:10 +0000539 return 1;
540 default:
541 break;
542 }
543 return 0;
544}
545
Harald Welte5b570672009-08-10 10:08:01 +0200546static inline int is_siemens_bts(struct gsm_bts *bts)
547{
548 switch (bts->type) {
549 case GSM_BTS_TYPE_BS11:
550 return 1;
551 default:
552 break;
553 }
554
555 return 0;
556}
557
Harald Welte (local)69de3972009-08-12 14:42:23 +0200558
559enum gsm_auth_policy gsm_auth_policy_parse(const char *arg);
560const char *gsm_auth_policy_name(enum gsm_auth_policy policy);
561
Harald Welteeab84a12009-12-13 10:53:12 +0100562enum rrlp_mode rrlp_mode_parse(const char *arg);
563const char *rrlp_mode_name(enum rrlp_mode mode);
564
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +0100565void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
566
Harald Welte52b1f982008-12-23 20:25:15 +0000567#endif