blob: b4a8ef550cdacdab5295811c045e4faa1b5697fd [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
41
42/* Channel Request reason */
43enum gsm_chreq_reason_t {
44 GSM_CHREQ_REASON_EMERG,
45 GSM_CHREQ_REASON_PAG,
46 GSM_CHREQ_REASON_CALL,
47 GSM_CHREQ_REASON_LOCATION_UPD,
48 GSM_CHREQ_REASON_OTHER,
49};
50
Harald Welte255539c2008-12-28 02:26:27 +000051#include <openbsc/timer.h>
Holger Freyther1adb4ff2009-02-04 00:04:52 +000052#include <openbsc/gsm_04_08.h>
Harald Welte9943c5b2009-07-29 15:41:29 +020053#include <openbsc/abis_rsl.h>
Harald Welte4bfdfe72009-06-10 23:11:52 +080054#include <openbsc/mncc.h>
Harald Welte93e9d172009-06-20 19:04:31 +020055#include <openbsc/tlv.h>
Harald Welte255539c2008-12-28 02:26:27 +000056
Harald Welte8470bf22008-12-25 23:28:35 +000057#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
58
Harald Welte85770c72009-01-18 17:47:32 +000059#define TRX_NR_TS 8
Harald Welte8470bf22008-12-25 23:28:35 +000060#define TS_MAX_LCHAN 8
Harald Welte52b1f982008-12-23 20:25:15 +000061
62#define HARDCODED_ARFCN 123
Harald Welte02b0e092009-02-28 13:11:07 +000063#define HARDCODED_TSC 7
Harald Welte78f2f502009-05-23 16:56:52 +000064#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
Harald Welte52b1f982008-12-23 20:25:15 +000065
Harald Welte63589be2009-08-06 17:38:10 +020066/* for multi-drop config */
67#define HARDCODED_BTS0_TS 1
68#define HARDCODED_BTS1_TS 6
69#define HARDCODED_BTS2_TS 11
70
Harald Welte8e1e3ee2009-02-01 13:32:45 +000071enum gsm_hooks {
72 GSM_HOOK_NM_SWLOAD,
Harald Welte0932d1e2009-02-16 22:53:52 +000073 GSM_HOOK_RR_PAGING,
74};
75
76enum gsm_paging_event {
77 GSM_PAGING_SUCCEEDED,
78 GSM_PAGING_EXPIRED,
Holger Freyther85a7b362009-04-18 13:48:55 +020079 GSM_PAGING_OOM,
Harald Welte8e1e3ee2009-02-01 13:32:45 +000080};
81
82struct msgb;
83typedef int gsm_cbfn(unsigned int hooknum,
84 unsigned int event,
85 struct msgb *msg,
86 void *data, void *param);
87
Holger Freytherc6ea9db2008-12-30 19:18:21 +000088/*
89 * Use the channel. As side effect the lchannel recycle timer
90 * will be started.
91 */
Harald Welteb9c758b2009-07-05 14:02:46 +020092#define LCHAN_RELEASE_TIMEOUT 20, 0
Holger Freytherc6ea9db2008-12-30 19:18:21 +000093#define use_lchan(lchan) \
94 do { lchan->use_count++; \
Holger Freyther4f584c32009-06-02 02:55:07 +000095 DEBUGP(DCC, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) increases usage to: %d\n", \
96 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr, \
97 lchan->nr, lchan->use_count); \
Harald Welteff117a82009-05-23 05:22:08 +000098 bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0);
Holger Freytherc6ea9db2008-12-30 19:18:21 +000099
100#define put_lchan(lchan) \
Holger Freyther4f584c32009-06-02 02:55:07 +0000101 do { lchan->use_count--; \
102 DEBUGP(DCC, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) decreases usage to: %d\n", \
103 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr, \
104 lchan->nr, lchan->use_count); \
105 } while(0);
106
Holger Freytherc6ea9db2008-12-30 19:18:21 +0000107
Harald Welte52b1f982008-12-23 20:25:15 +0000108/* communications link with a BTS */
109struct gsm_bts_link {
110 struct gsm_bts *bts;
111};
112
Harald Welte49f48b82009-02-17 15:29:33 +0000113struct gsm_lchan;
114struct gsm_subscriber;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800115struct gsm_mncc;
Harald Welte805f6442009-07-28 18:25:29 +0200116struct rtp_socket;
Harald Welte49f48b82009-02-17 15:29:33 +0000117
Harald Weltebbcc7a52009-02-14 19:45:44 +0000118/* Network Management State */
119struct gsm_nm_state {
120 u_int8_t operational;
121 u_int8_t administrative;
Harald Welte8c1d0e42009-02-15 03:38:12 +0000122 u_int8_t availability;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000123};
Harald Weltebbcc7a52009-02-14 19:45:44 +0000124
Holger Freyther73487a22008-12-31 18:53:57 +0000125/*
126 * LOCATION UPDATING REQUEST state
127 *
128 * Our current operation is:
129 * - Get imei/tmsi
130 * - Accept/Reject according to global policy
131 */
132struct gsm_loc_updating_operation {
133 struct timer_list updating_timer;
Holger Hans Peter Freyther251aa912009-10-27 10:42:28 +0100134 unsigned int waiting_for_imsi : 1;
135 unsigned int waiting_for_imei : 1;
Holger Freyther73487a22008-12-31 18:53:57 +0000136};
137
Harald Welte08d91a52009-08-30 15:37:11 +0900138#define MAX_A5_KEY_LEN (128/8)
139#define RSL_ENC_ALG_A5(x) (x+1)
140
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100141/* is the data link established? who established it? */
142#define LCHAN_SAPI_UNUSED 0
143#define LCHAN_SAPI_MS 1
144#define LCHAN_SAPI_NET 2
145
Harald Welte8470bf22008-12-25 23:28:35 +0000146struct gsm_lchan {
147 /* The TS that we're part of */
148 struct gsm_bts_trx_ts *ts;
149 /* The logical subslot number in the TS */
150 u_int8_t nr;
Harald Welte45b407a2009-05-23 15:51:12 +0000151 /* The logical channel type */
Harald Welte8470bf22008-12-25 23:28:35 +0000152 enum gsm_chan_t type;
Harald Welte9943c5b2009-07-29 15:41:29 +0200153 /* RSL channel mode */
154 enum rsl_cmod_spd rsl_cmode;
Harald Welte45b407a2009-05-23 15:51:12 +0000155 /* If TCH, traffic channel mode */
Harald Welte9943c5b2009-07-29 15:41:29 +0200156 enum gsm48_chan_mode tch_mode;
Harald Welted4c9bf32009-02-15 16:56:18 +0000157 /* Power levels for MS and BTS */
158 u_int8_t bs_power;
159 u_int8_t ms_power;
Harald Welte08d91a52009-08-30 15:37:11 +0900160 /* Encryption information */
161 struct {
162 u_int8_t alg_id;
163 u_int8_t key_len;
164 u_int8_t key[MAX_A5_KEY_LEN];
165 } encr;
Holger Hans Peter Freytherea528022009-11-18 22:57:02 +0100166
167 /* AMR bits */
168 struct gsm48_multi_rate_conf mr_conf;
Harald Welted4c9bf32009-02-15 16:56:18 +0000169
Harald Welte8470bf22008-12-25 23:28:35 +0000170 /* To whom we are allocated at the moment */
171 struct gsm_subscriber *subscr;
Holger Freytherc6ea9db2008-12-30 19:18:21 +0000172
173 /* Timer started to release the channel */
174 struct timer_list release_timer;
Harald Weltea3d04382008-12-27 17:02:56 +0000175
Harald Welteb7e81162009-08-10 00:26:10 +0200176 struct timer_list T3101;
177
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100178 /* Established data link layer services */
179 u_int8_t sapis[8];
180
Holger Freyther73487a22008-12-31 18:53:57 +0000181 /*
182 * Operations that have a state and might be pending
183 */
184 struct gsm_loc_updating_operation *loc_operation;
185
Holger Freytherb7193e42008-12-29 17:44:08 +0000186 /* use count. how many users use this channel */
187 unsigned int use_count;
Harald Welte8470bf22008-12-25 23:28:35 +0000188};
189
Harald Welte85770c72009-01-18 17:47:32 +0000190struct gsm_e1_subslot {
191 /* Number of E1 link */
192 u_int8_t e1_nr;
193 /* Number of E1 TS inside E1 link */
194 u_int8_t e1_ts;
195 /* Sub-slot within the E1 TS, 0xff if full TS */
196 u_int8_t e1_ts_ss;
197};
198
Harald Welte52b1f982008-12-23 20:25:15 +0000199#define BTS_TRX_F_ACTIVATED 0x0001
200/* One Timeslot in a TRX */
201struct gsm_bts_trx_ts {
202 struct gsm_bts_trx *trx;
203 /* number of this timeslot at the TRX */
204 u_int8_t nr;
205
Harald Welte8470bf22008-12-25 23:28:35 +0000206 enum gsm_phys_chan_config pchan;
207
Harald Welte52b1f982008-12-23 20:25:15 +0000208 unsigned int flags;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000209 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200210 struct tlv_parsed nm_attr;
Harald Welte39c7deb2009-08-09 21:49:48 +0200211 u_int8_t nm_chan_comb;
Harald Welte8470bf22008-12-25 23:28:35 +0000212
Harald Welte85770c72009-01-18 17:47:32 +0000213 /* To which E1 subslot are we connected */
214 struct gsm_e1_subslot e1_link;
Harald Welte75099262009-02-16 21:12:08 +0000215 struct {
216 u_int32_t bound_ip;
217 u_int16_t bound_port;
Harald Welte20855542009-07-12 09:50:35 +0200218 u_int8_t rtp_payload2;
219 u_int16_t conn_id;
Harald Welte805f6442009-07-28 18:25:29 +0200220 struct rtp_socket *rtp_socket;
Harald Welte75099262009-02-16 21:12:08 +0000221 } abis_ip;
Harald Welte85770c72009-01-18 17:47:32 +0000222
Harald Welte8470bf22008-12-25 23:28:35 +0000223 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +0000224};
225
226/* One TRX in a BTS */
227struct gsm_bts_trx {
Harald Weltee441d9c2009-06-21 16:17:15 +0200228 /* list header in bts->trx_list */
229 struct llist_head list;
230
Harald Welte52b1f982008-12-23 20:25:15 +0000231 struct gsm_bts *bts;
232 /* number of this TRX in the BTS */
233 u_int8_t nr;
Harald Welte1fa60c82009-02-09 18:13:26 +0000234 /* how do we talk RSL with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200235 struct gsm_e1_subslot rsl_e1_link;
236 u_int8_t rsl_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000237 struct e1inp_sign_link *rsl_link;
Harald Welte42581822009-08-08 16:12:58 +0200238
Harald Weltebbcc7a52009-02-14 19:45:44 +0000239 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200240 struct tlv_parsed nm_attr;
Harald Welte8c1d0e42009-02-15 03:38:12 +0000241 struct {
242 struct gsm_nm_state nm_state;
243 } bb_transc;
Harald Welte52b1f982008-12-23 20:25:15 +0000244
245 u_int16_t arfcn;
Harald Weltefcd24452009-06-20 18:15:19 +0200246 int nominal_power; /* in dBm */
247 unsigned int max_power_red; /* in actual dB */
Harald Welte8b697c72009-06-05 19:18:45 +0000248
249 union {
250 struct {
251 struct {
252 struct gsm_nm_state nm_state;
253 } bbsig;
254 struct {
255 struct gsm_nm_state nm_state;
256 } pa;
257 } bs11;
258 };
Harald Welte85770c72009-01-18 17:47:32 +0000259 struct gsm_bts_trx_ts ts[TRX_NR_TS];
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +0100260
261 /* NM state */
262 int rf_locked;
Harald Welte52b1f982008-12-23 20:25:15 +0000263};
264
Harald Welte978cb422009-01-18 17:57:27 +0000265enum gsm_bts_type {
266 GSM_BTS_TYPE_UNKNOWN,
267 GSM_BTS_TYPE_BS11,
Mike Habene2d82272009-10-02 12:19:34 +0100268 GSM_BTS_TYPE_NANOBTS,
Harald Welte978cb422009-01-18 17:57:27 +0000269};
270
Holger Freytherceb59b72009-02-06 18:54:00 +0000271/**
272 * A pending paging request
273 */
274struct gsm_paging_request {
Harald Welte0932d1e2009-02-16 22:53:52 +0000275 /* list_head for list of all paging requests */
Holger Freytherceb59b72009-02-06 18:54:00 +0000276 struct llist_head entry;
Harald Welte0932d1e2009-02-16 22:53:52 +0000277 /* the subscriber which we're paging. Later gsm_paging_request
278 * should probably become a part of the gsm_subscriber struct? */
Holger Freytherceb59b72009-02-06 18:54:00 +0000279 struct gsm_subscriber *subscr;
Harald Welte0932d1e2009-02-16 22:53:52 +0000280 /* back-pointer to the BTS on which we are paging */
Holger Freytherceb59b72009-02-06 18:54:00 +0000281 struct gsm_bts *bts;
Harald Welte0932d1e2009-02-16 22:53:52 +0000282 /* what kind of channel type do we ask the MS to establish */
Holger Freytherceb59b72009-02-06 18:54:00 +0000283 int chan_type;
Harald Weltecd06bfb2009-02-10 17:33:56 +0000284
285 /* Timer 3113: how long do we try to page? */
286 struct timer_list T3113;
Harald Welte0932d1e2009-02-16 22:53:52 +0000287
288 /* callback to be called in case paging completes */
289 gsm_cbfn *cbfn;
290 void *cbfn_param;
Holger Freytherceb59b72009-02-06 18:54:00 +0000291};
292
293/*
294 * This keeps track of the paging status of one BTS. It
295 * includes a number of pending requests, a back pointer
296 * to the gsm_bts, a timer and some more state.
297 */
298struct gsm_bts_paging_state {
Holger Freytherceb59b72009-02-06 18:54:00 +0000299 /* pending requests */
300 struct llist_head pending_requests;
301 struct gsm_paging_request *last_request;
302 struct gsm_bts *bts;
303
Harald Welte75a1fa82009-02-17 01:39:41 +0000304 struct timer_list work_timer;
305
Holger Freyther392209c2009-02-10 00:06:19 +0000306 /* load */
307 u_int16_t available_slots;
Holger Freytherceb59b72009-02-06 18:54:00 +0000308};
309
Harald Welte8b697c72009-06-05 19:18:45 +0000310struct gsm_envabtse {
311 struct gsm_nm_state nm_state;
312};
313
Harald Welte55dd4432009-10-24 10:19:14 +0200314struct gsm_bts_gprs_nsvc {
315 struct gsm_bts *bts;
316 int id;
317 struct gsm_nm_state nm_state;
318};
319
Harald Welte52b1f982008-12-23 20:25:15 +0000320/* One BTS */
321struct gsm_bts {
Harald Weltee441d9c2009-06-21 16:17:15 +0200322 /* list header in net->bts_list */
323 struct llist_head list;
324
Harald Welte52b1f982008-12-23 20:25:15 +0000325 struct gsm_network *network;
326 /* number of ths BTS in network */
327 u_int8_t nr;
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200328 /* Cell Identity */
329 u_int16_t cell_identity;
Harald Welte52b1f982008-12-23 20:25:15 +0000330 /* location area code of this BTS */
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +0200331 u_int16_t location_area_code;
Harald Welte02b0e092009-02-28 13:11:07 +0000332 /* Training Sequence Code */
333 u_int8_t tsc;
Harald Welte78f2f502009-05-23 16:56:52 +0000334 /* Base Station Identification Code (BSIC) */
335 u_int8_t bsic;
Harald Welte978cb422009-01-18 17:57:27 +0000336 /* type of BTS */
337 enum gsm_bts_type type;
Harald Weltefcd24452009-06-20 18:15:19 +0200338 enum gsm_band band;
Harald Weltefc0d9522009-08-10 13:46:55 +0200339 /* should the channel allocator allocate channels from high TRX to TRX0,
340 * rather than starting from TRX0 and go upwards? */
341 int chan_alloc_reverse;
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200342 int cell_barred;
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200343 /* maximum Tx power that the MS is permitted to use in this cell */
344 int ms_max_power;
Harald Weltefc0d9522009-08-10 13:46:55 +0200345
Harald Welte1fa60c82009-02-09 18:13:26 +0000346 /* how do we talk OML with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200347 struct gsm_e1_subslot oml_e1_link;
348 u_int8_t oml_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000349 struct e1inp_sign_link *oml_link;
Harald Welte52b1f982008-12-23 20:25:15 +0000350
351 /* Abis network management O&M handle */
352 struct abis_nm_h *nmh;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000353 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200354 struct tlv_parsed nm_attr;
Harald Welte978cb422009-01-18 17:57:27 +0000355
Harald Welte52b1f982008-12-23 20:25:15 +0000356 /* number of this BTS on given E1 link */
357 u_int8_t bts_nr;
358
Holger Freyther1adb4ff2009-02-04 00:04:52 +0000359 struct gsm48_control_channel_descr chan_desc;
360
Holger Freytherceb59b72009-02-06 18:54:00 +0000361 /* paging state and control */
362 struct gsm_bts_paging_state paging;
363
Harald Welte52b1f982008-12-23 20:25:15 +0000364 /* CCCH is on C0 */
365 struct gsm_bts_trx *c0;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000366
367 struct {
368 struct gsm_nm_state nm_state;
369 } site_mgr;
Harald Welteedb37782009-05-01 14:59:07 +0000370
371 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
Harald Welte7b26bcb2009-05-28 11:39:21 +0000372 union {
373 struct {
374 u_int16_t site_id;
375 u_int16_t bts_id;
376 } ip_access;
377 struct {
378 struct {
379 struct gsm_nm_state nm_state;
380 } cclk;
381 struct {
382 struct gsm_nm_state nm_state;
383 } rack;
Harald Welte8b697c72009-06-05 19:18:45 +0000384 struct gsm_envabtse envabtse[4];
Harald Welte7b26bcb2009-05-28 11:39:21 +0000385 } bs11;
386 };
Harald Welte55dd4432009-10-24 10:19:14 +0200387
388 /* Not entirely sure how ip.access specific this is */
389 struct {
390 struct {
391 struct gsm_nm_state nm_state;
392 } nse;
393 struct {
394 struct gsm_nm_state nm_state;
395 } cell;
396 struct gsm_bts_gprs_nsvc nsvc[2];
397 } gprs;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000398
Harald Welte52b1f982008-12-23 20:25:15 +0000399 /* transceivers */
400 int num_trx;
Harald Weltee441d9c2009-06-21 16:17:15 +0200401 struct llist_head trx_list;
Harald Welte52b1f982008-12-23 20:25:15 +0000402};
403
Harald Welte (local)69de3972009-08-12 14:42:23 +0200404enum gsm_auth_policy {
405 GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */
406 GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */
407 GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */
408};
409
Harald Welteb84ddfc2009-12-01 17:36:54 +0530410#define GSM_T3101_DEFAULT 10
411#define GSM_T3113_DEFAULT 60
412
Harald Welte52b1f982008-12-23 20:25:15 +0000413struct gsm_network {
414 /* global parameters */
Harald Welteb84e2f42008-12-28 23:42:04 +0000415 u_int16_t country_code;
416 u_int16_t network_code;
Harald Weltec6ba9c22008-12-30 18:01:02 +0000417 char *name_long;
418 char *name_short;
Harald Welte (local)69de3972009-08-12 14:42:23 +0200419 enum gsm_auth_policy auth_policy;
Harald Welte4381cfe2009-08-30 15:47:06 +0900420 int a5_encryption;
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100421 int neci;
Harald Welte52b1f982008-12-23 20:25:15 +0000422
Harald Welte4bfdfe72009-06-10 23:11:52 +0800423 /* layer 4 */
424 int (*mncc_recv) (struct gsm_network *net, int msg_type, void *arg);
425 struct llist_head upqueue;
426 struct llist_head trans_list;
427
Harald Welte52b1f982008-12-23 20:25:15 +0000428 unsigned int num_bts;
Harald Weltee441d9c2009-06-21 16:17:15 +0200429 struct llist_head bts_list;
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100430
431 /* timer values */
432 int T3101;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100433 int T3103;
434 int T3105;
435 int T3107;
436 int T3109;
437 int T3111;
438 int T3113;
439 int T3115;
440 int T3117;
441 int T3119;
442 int T3141;
Harald Welte52b1f982008-12-23 20:25:15 +0000443};
444
Harald Welte7e310b12009-03-30 20:56:32 +0000445#define SMS_HDR_SIZE 128
446#define SMS_TEXT_SIZE 256
447struct gsm_sms {
Harald Welted409be72009-11-07 00:06:19 +0900448 unsigned long long id;
Harald Welte7e310b12009-03-30 20:56:32 +0000449 struct gsm_subscriber *sender;
450 struct gsm_subscriber *receiver;
451
Harald Welteb9c758b2009-07-05 14:02:46 +0200452 unsigned long validity_minutes;
Harald Welte76042182009-08-08 16:03:15 +0200453 u_int8_t reply_path_req;
454 u_int8_t status_rep_req;
455 u_int8_t ud_hdr_ind;
456 u_int8_t protocol_id;
457 u_int8_t data_coding_scheme;
458 u_int8_t msg_ref;
459 char dest_addr[20+1]; /* DA LV is 12 bytes max, i.e. 10 bytes
460 * BCD == 20 bytes string */
461 u_int8_t user_data_len;
462 u_int8_t user_data[SMS_TEXT_SIZE];
Harald Weltef3efc592009-07-27 20:11:35 +0200463
Harald Welte7e310b12009-03-30 20:56:32 +0000464 char text[SMS_TEXT_SIZE];
465};
466
Harald Weltee441d9c2009-06-21 16:17:15 +0200467struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_code,
Harald Welte4bfdfe72009-06-10 23:11:52 +0800468 int (*mncc_recv)(struct gsm_network *, int, void *));
Harald Weltee441d9c2009-06-21 16:17:15 +0200469struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
470 u_int8_t tsc, u_int8_t bsic);
471struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
472
473struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
474struct gsm_bts_trx *gsm_bts_trx_num(struct gsm_bts *bts, int num);
Harald Welte8470bf22008-12-25 23:28:35 +0000475
Harald Weltea72c98e2009-01-04 16:10:38 +0000476const char *gsm_pchan_name(enum gsm_phys_chan_config c);
Harald Welte65da9122009-08-07 00:32:22 +0200477enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
Harald Weltea72c98e2009-01-04 16:10:38 +0000478const char *gsm_lchan_name(enum gsm_chan_t c);
479const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte23a68632009-02-19 17:06:42 +0000480char *gsm_ts_name(struct gsm_bts_trx_ts *ts);
Harald Weltea72c98e2009-01-04 16:10:38 +0000481
Harald Weltead384642008-12-26 10:20:07 +0000482enum gsm_e1_event {
483 EVT_E1_NONE,
Harald Welte1fa60c82009-02-09 18:13:26 +0000484 EVT_E1_TEI_UP,
485 EVT_E1_TEI_DN,
Harald Weltead384642008-12-26 10:20:07 +0000486};
487
Harald Weltecd06bfb2009-02-10 17:33:56 +0000488void set_ts_e1link(struct gsm_bts_trx_ts *ts, u_int8_t e1_nr,
489 u_int8_t e1_ts, u_int8_t e1_ts_ss);
Harald Welte1d014a52009-08-08 15:38:29 +0200490enum gsm_bts_type parse_btstype(const char *arg);
Holger Hans Peter Freyther2dceae62009-06-12 17:39:38 +0200491const char *btstype2str(enum gsm_bts_type type);
Harald Weltebe991492009-05-23 13:56:40 +0000492struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac,
493 struct gsm_bts *start_bts);
Harald Welte32201c12009-03-10 12:15:10 +0000494
Harald Weltefcd24452009-06-20 18:15:19 +0200495char *gsm_band_name(enum gsm_band band);
Harald Welte42581822009-08-08 16:12:58 +0200496enum gsm_band gsm_band_parse(const char *mhz);
Harald Weltefcd24452009-06-20 18:15:19 +0200497
Andreas Eversberg8226fa72009-06-29 15:19:38 +0200498extern void *tall_bsc_ctx;
Harald Welte2cf161b2009-06-20 22:36:41 +0200499
Harald Welte32201c12009-03-10 12:15:10 +0000500static inline int is_ipaccess_bts(struct gsm_bts *bts)
501{
502 switch (bts->type) {
Mike Habene2d82272009-10-02 12:19:34 +0100503 case GSM_BTS_TYPE_NANOBTS:
Harald Welte32201c12009-03-10 12:15:10 +0000504 return 1;
505 default:
506 break;
507 }
508 return 0;
509}
510
Harald Welte5b570672009-08-10 10:08:01 +0200511static inline int is_siemens_bts(struct gsm_bts *bts)
512{
513 switch (bts->type) {
514 case GSM_BTS_TYPE_BS11:
515 return 1;
516 default:
517 break;
518 }
519
520 return 0;
521}
522
Harald Welte (local)69de3972009-08-12 14:42:23 +0200523
524enum gsm_auth_policy gsm_auth_policy_parse(const char *arg);
525const char *gsm_auth_policy_name(enum gsm_auth_policy policy);
526
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +0100527void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
528
Harald Welte52b1f982008-12-23 20:25:15 +0000529#endif