blob: b5f17ac74d240866646d88751de3db60b1e3a4b6 [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
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +08006struct osmo_msc_data;
Holger Hans Peter Freyther2f9d1ef2010-09-16 20:14:01 +08007struct osmo_bsc_sccp_con;
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +08008
Harald Welte4bfdfe72009-06-10 23:11:52 +08009enum gsm_phys_chan_config {
10 GSM_PCHAN_NONE,
11 GSM_PCHAN_CCCH,
12 GSM_PCHAN_CCCH_SDCCH4,
13 GSM_PCHAN_TCH_F,
14 GSM_PCHAN_TCH_H,
15 GSM_PCHAN_SDCCH8_SACCH8C,
Harald Weltea1499d02009-10-24 10:25:50 +020016 GSM_PCHAN_PDCH, /* GPRS PDCH */
17 GSM_PCHAN_TCH_F_PDCH, /* TCH/F if used, PDCH otherwise */
Harald Welte4bfdfe72009-06-10 23:11:52 +080018 GSM_PCHAN_UNKNOWN,
19};
20
21enum gsm_chan_t {
22 GSM_LCHAN_NONE,
23 GSM_LCHAN_SDCCH,
24 GSM_LCHAN_TCH_F,
25 GSM_LCHAN_TCH_H,
26 GSM_LCHAN_UNKNOWN,
27};
28
Harald Welteeab84a12009-12-13 10:53:12 +010029/* RRLP mode of operation */
30enum rrlp_mode {
31 RRLP_MODE_NONE,
32 RRLP_MODE_MS_BASED,
33 RRLP_MODE_MS_PREF,
34 RRLP_MODE_ASS_PREF,
35};
Harald Welte4bfdfe72009-06-10 23:11:52 +080036
37/* Channel Request reason */
38enum gsm_chreq_reason_t {
39 GSM_CHREQ_REASON_EMERG,
40 GSM_CHREQ_REASON_PAG,
41 GSM_CHREQ_REASON_CALL,
42 GSM_CHREQ_REASON_LOCATION_UPD,
43 GSM_CHREQ_REASON_OTHER,
44};
45
Harald Weltedfe6c7d2010-02-20 16:24:02 +010046#include <osmocore/timer.h>
Harald Welte7401ae62010-06-15 16:44:12 +020047#include <openbsc/system_information.h>
Sylvain Munaute0b06b02010-11-28 18:17:28 +010048#include <openbsc/rest_octets.h>
Harald Welte4bfdfe72009-06-10 23:11:52 +080049#include <openbsc/mncc.h>
Harald Welte887deab2010-03-06 11:38:05 +010050
Harald Weltedfe6c7d2010-02-20 16:24:02 +010051#include <osmocore/tlv.h>
52#include <osmocore/bitvec.h>
53#include <osmocore/statistics.h>
54#include <osmocore/gsm_utils.h>
55#include <osmocore/utils.h>
Harald Welte887deab2010-03-06 11:38:05 +010056#include <osmocore/rxlev_stat.h>
Harald Welte8470bf22008-12-25 23:28:35 +000057
Sylvain Munaut81a8bf12010-12-01 22:28:59 +010058#include <osmocore/protocol/gsm_08_58.h>
59
60
Harald Welte85770c72009-01-18 17:47:32 +000061#define TRX_NR_TS 8
Harald Welte8470bf22008-12-25 23:28:35 +000062#define TS_MAX_LCHAN 8
Harald Welte52b1f982008-12-23 20:25:15 +000063
64#define HARDCODED_ARFCN 123
Harald Welte02b0e092009-02-28 13:11:07 +000065#define HARDCODED_TSC 7
Harald Welte78f2f502009-05-23 16:56:52 +000066#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
Harald Welte52b1f982008-12-23 20:25:15 +000067
Harald Welte63589be2009-08-06 17:38:10 +020068/* for multi-drop config */
69#define HARDCODED_BTS0_TS 1
70#define HARDCODED_BTS1_TS 6
71#define HARDCODED_BTS2_TS 11
72
Holger Hans Peter Freyther928ca742010-11-10 09:19:30 +010073/* reserved according to GSM 03.03 ยง 2.4 */
74#define GSM_RESERVED_TMSI 0xFFFFFFFF
75
Harald Welte8e1e3ee2009-02-01 13:32:45 +000076enum gsm_hooks {
77 GSM_HOOK_NM_SWLOAD,
Harald Welte0932d1e2009-02-16 22:53:52 +000078 GSM_HOOK_RR_PAGING,
Sylvain Munaut30a15382009-12-24 00:27:26 +010079 GSM_HOOK_RR_SECURITY,
Harald Welte0932d1e2009-02-16 22:53:52 +000080};
81
82enum gsm_paging_event {
83 GSM_PAGING_SUCCEEDED,
84 GSM_PAGING_EXPIRED,
Holger Freyther85a7b362009-04-18 13:48:55 +020085 GSM_PAGING_OOM,
Harald Welte8e1e3ee2009-02-01 13:32:45 +000086};
87
Harald Welte4511d892010-04-18 15:51:20 +020088enum bts_gprs_mode {
89 BTS_GPRS_NONE = 0,
90 BTS_GPRS_GPRS = 1,
91 BTS_GPRS_EGPRS = 2,
92};
93
Holger Hans Peter Freyther6f615552010-11-15 20:50:42 +010094#define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3]
95
Harald Welte0809d792010-04-30 14:36:25 +020096/* the data structure stored in msgb->cb for openbsc apps */
97struct openbsc_msgb_cb {
Harald Weltefd3fa1d2010-05-02 09:50:42 +020098 unsigned char *bssgph;
99 unsigned char *llch;
Harald Welte44f1c272010-04-30 19:54:29 +0200100
Harald Welte11d7c102010-05-02 11:54:55 +0200101 /* Cell Identifier */
102 unsigned char *bssgp_cell_id;
103
Harald Weltee6afd602010-05-02 11:19:37 +0200104 /* Identifiers of a BTS, equal to 'struct bssgp_bts_ctx' */
Harald Welte44f1c272010-04-30 19:54:29 +0200105 u_int16_t nsei;
106 u_int16_t bvci;
107
Harald Weltee6afd602010-05-02 11:19:37 +0200108 /* Identifier of a MS (inside BTS), equal to 'struct sgsn_mm_ctx' */
Harald Welte0809d792010-04-30 14:36:25 +0200109 u_int32_t tlli;
Harald Welte44f1c272010-04-30 19:54:29 +0200110} __attribute__((packed));
Harald Welte0809d792010-04-30 14:36:25 +0200111#define OBSC_MSGB_CB(__msgb) ((struct openbsc_msgb_cb *)&((__msgb)->cb[0]))
Harald Welte943c5bc2010-04-30 16:33:12 +0200112#define msgb_tlli(__x) OBSC_MSGB_CB(__x)->tlli
Harald Welte44f1c272010-04-30 19:54:29 +0200113#define msgb_nsei(__x) OBSC_MSGB_CB(__x)->nsei
114#define msgb_bvci(__x) OBSC_MSGB_CB(__x)->bvci
Harald Weltefd3fa1d2010-05-02 09:50:42 +0200115#define msgb_gmmh(__x) (__x)->l3h
116#define msgb_bssgph(__x) OBSC_MSGB_CB(__x)->bssgph
Harald Welte721961c2010-05-02 21:29:36 +0200117#define msgb_bssgp_len(__x) ((__x)->tail - (uint8_t *)msgb_bssgph(__x))
Harald Welte11d7c102010-05-02 11:54:55 +0200118#define msgb_bcid(__x) OBSC_MSGB_CB(__x)->bssgp_cell_id
Harald Weltefd3fa1d2010-05-02 09:50:42 +0200119#define msgb_llch(__x) OBSC_MSGB_CB(__x)->llch
Harald Welte0809d792010-04-30 14:36:25 +0200120
Holger Hans Peter Freyther9c595b72010-06-15 11:20:52 +0800121#define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3]
122
Sylvain Munaut30a15382009-12-24 00:27:26 +0100123enum gsm_security_event {
124 GSM_SECURITY_NOAVAIL,
125 GSM_SECURITY_AUTH_FAILED,
126 GSM_SECURITY_SUCCEEDED,
127};
128
Harald Welte8e1e3ee2009-02-01 13:32:45 +0000129struct msgb;
130typedef int gsm_cbfn(unsigned int hooknum,
131 unsigned int event,
132 struct msgb *msg,
133 void *data, void *param);
134
Sylvain Munaut47193072009-12-27 21:56:14 +0100135/* Real authentication information containing Ki */
136enum gsm_auth_algo {
137 AUTH_ALGO_NONE,
138 AUTH_ALGO_XOR,
139 AUTH_ALGO_COMP128v1,
140};
141
142struct gsm_auth_info {
143 enum gsm_auth_algo auth_algo;
144 unsigned int a3a8_ki_len;
145 u_int8_t a3a8_ki[16];
146};
147
148struct gsm_auth_tuple {
149 int use_count;
150 int key_seq;
151 u_int8_t rand[16];
152 u_int8_t sres[4];
153 u_int8_t kc[8];
154};
Sylvain Munautb48216f2010-06-09 12:45:37 +0200155#define GSM_KEY_SEQ_INVAL 7 /* GSM 04.08 - 10.5.1.2 */
Sylvain Munaut47193072009-12-27 21:56:14 +0100156
157
Harald Welte49f48b82009-02-17 15:29:33 +0000158struct gsm_lchan;
159struct gsm_subscriber;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800160struct gsm_mncc;
Harald Welte805f6442009-07-28 18:25:29 +0200161struct rtp_socket;
Holger Hans Peter Freytherabcddf12010-06-14 18:20:15 +0800162struct bsc_api;
Harald Welte49f48b82009-02-17 15:29:33 +0000163
Harald Weltebbcc7a52009-02-14 19:45:44 +0000164/* Network Management State */
165struct gsm_nm_state {
166 u_int8_t operational;
167 u_int8_t administrative;
Harald Welte8c1d0e42009-02-15 03:38:12 +0000168 u_int8_t availability;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000169};
Harald Weltebbcc7a52009-02-14 19:45:44 +0000170
Holger Freyther73487a22008-12-31 18:53:57 +0000171/*
172 * LOCATION UPDATING REQUEST state
173 *
174 * Our current operation is:
175 * - Get imei/tmsi
176 * - Accept/Reject according to global policy
177 */
178struct gsm_loc_updating_operation {
179 struct timer_list updating_timer;
Holger Hans Peter Freyther251aa912009-10-27 10:42:28 +0100180 unsigned int waiting_for_imsi : 1;
181 unsigned int waiting_for_imei : 1;
Sylvain Munaut2030a2a2010-06-10 13:36:59 +0200182 unsigned int key_seq : 4;
Holger Freyther73487a22008-12-31 18:53:57 +0000183};
184
Sylvain Munaut30a15382009-12-24 00:27:26 +0100185/*
186 * AUTHENTICATION/CIPHERING state
187 */
188struct gsm_security_operation {
189 struct gsm_auth_tuple atuple;
190 gsm_cbfn *cb;
191 void *cb_data;
192};
193
Holger Hans Peter Freyther02d39b22010-07-05 15:34:16 +0800194/*
195 * A dummy to keep a connection up for at least
196 * a couple of seconds to work around MSC issues.
197 */
198struct gsm_anchor_operation {
199 struct timer_list timeout;
200};
201
Harald Weltef7c28b02009-12-21 13:30:17 +0100202/* Maximum number of neighbor cells whose average we track */
203#define MAX_NEIGH_MEAS 10
204/* Maximum size of the averaging window for neighbor cells */
205#define MAX_WIN_NEIGH_AVG 10
206
207/* processed neighbor measurements for one cell */
208struct neigh_meas_proc {
209 u_int16_t arfcn;
210 u_int8_t bsic;
211 u_int8_t rxlev[MAX_WIN_NEIGH_AVG];
212 unsigned int rxlev_cnt;
213 u_int8_t last_seen_nr;
214};
215
Harald Welte08d91a52009-08-30 15:37:11 +0900216#define MAX_A5_KEY_LEN (128/8)
Sylvain Munaute824d9c2010-06-11 00:19:42 +0200217#define A38_XOR_MIN_KEY_LEN 12
218#define A38_XOR_MAX_KEY_LEN 16
Sylvain Munaut30a15382009-12-24 00:27:26 +0100219#define A38_COMP128_KEY_LEN 16
Harald Welte08d91a52009-08-30 15:37:11 +0900220#define RSL_ENC_ALG_A5(x) (x+1)
221
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100222/* is the data link established? who established it? */
223#define LCHAN_SAPI_UNUSED 0
224#define LCHAN_SAPI_MS 1
225#define LCHAN_SAPI_NET 2
226
Harald Welteb8bfc562009-12-21 13:27:11 +0100227/* state of a logical channel */
228enum gsm_lchan_state {
229 LCHAN_S_NONE, /* channel is not active */
Harald Welte (local)3e460312009-12-27 18:12:29 +0100230 LCHAN_S_ACT_REQ, /* channel activatin requested */
Harald Welteb8bfc562009-12-21 13:27:11 +0100231 LCHAN_S_ACTIVE, /* channel is active and operational */
Harald Welte8e93b792009-12-29 10:44:17 +0100232 LCHAN_S_REL_REQ, /* channel release has been requested */
Holger Hans Peter Freyther4b4dd102010-05-31 21:38:24 +0800233 LCHAN_S_REL_ERR, /* channel is in an error state */
Harald Welteb8bfc562009-12-21 13:27:11 +0100234 LCHAN_S_INACTIVE, /* channel is set inactive */
235};
236
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100237/* the per subscriber data for lchan */
238struct gsm_subscriber_connection {
Holger Hans Peter Freyther79f763f2010-09-16 00:53:37 +0800239 struct llist_head entry;
240
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100241 /* To whom we are allocated at the moment */
242 struct gsm_subscriber *subscr;
243
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100244 /*
245 * Operations that have a state and might be pending
246 */
247 struct gsm_loc_updating_operation *loc_operation;
Sylvain Munaut30a15382009-12-24 00:27:26 +0100248 struct gsm_security_operation *sec_operation;
Holger Hans Peter Freyther02d39b22010-07-05 15:34:16 +0800249 struct gsm_anchor_operation *anch_operation;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100250
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100251 /* Are we part of a special "silent" call */
252 int silent_call;
253
Holger Hans Peter Freyther2f9d1ef2010-09-16 20:14:01 +0800254 /* bsc structures */
255 struct osmo_bsc_sccp_con *sccp_con;
256
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +0100257 /* back pointers */
Holger Hans Peter Freyther40494552010-06-28 17:09:29 +0800258 int in_release;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100259 struct gsm_lchan *lchan;
Holger Hans Peter Freythere071ab72010-06-30 12:40:10 +0800260 struct gsm_lchan *ho_lchan;
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +0100261 struct gsm_bts *bts;
Holger Hans Peter Freyther77cd95d2010-11-14 16:19:48 +0100262
263 /* for assignment handling */
264 struct timer_list T10;
265 struct gsm_lchan *secondary_lchan;
266
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100267};
268
Harald Welte8470bf22008-12-25 23:28:35 +0000269struct gsm_lchan {
270 /* The TS that we're part of */
271 struct gsm_bts_trx_ts *ts;
272 /* The logical subslot number in the TS */
273 u_int8_t nr;
Harald Welte45b407a2009-05-23 15:51:12 +0000274 /* The logical channel type */
Harald Welte8470bf22008-12-25 23:28:35 +0000275 enum gsm_chan_t type;
Harald Welte9943c5b2009-07-29 15:41:29 +0200276 /* RSL channel mode */
277 enum rsl_cmod_spd rsl_cmode;
Harald Welte45b407a2009-05-23 15:51:12 +0000278 /* If TCH, traffic channel mode */
Harald Welte9943c5b2009-07-29 15:41:29 +0200279 enum gsm48_chan_mode tch_mode;
Harald Welteb8bfc562009-12-21 13:27:11 +0100280 /* State */
281 enum gsm_lchan_state state;
Harald Welted4c9bf32009-02-15 16:56:18 +0000282 /* Power levels for MS and BTS */
283 u_int8_t bs_power;
284 u_int8_t ms_power;
Harald Welte08d91a52009-08-30 15:37:11 +0900285 /* Encryption information */
286 struct {
287 u_int8_t alg_id;
288 u_int8_t key_len;
289 u_int8_t key[MAX_A5_KEY_LEN];
290 } encr;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100291
292 struct timer_list T3101;
Holger Hans Peter Freytherf30c0dc2010-05-31 21:33:15 +0800293 struct timer_list T3111;
Holger Hans Peter Freyther4b4dd102010-05-31 21:38:24 +0800294 struct timer_list error_timer;
Holger Hans Peter Freytherea528022009-11-18 22:57:02 +0100295
296 /* AMR bits */
297 struct gsm48_multi_rate_conf mr_conf;
Harald Welted4c9bf32009-02-15 16:56:18 +0000298
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100299 /* Established data link layer services */
300 u_int8_t sapis[8];
Holger Hans Peter Freyther4b85a322010-07-29 17:09:36 +0800301 int sach_deact;
302 int release_reason;
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100303
Holger Hans Peter Freyther5ba05f42010-06-22 12:11:59 +0800304 /* GSM Random Access data */
305 struct gsm48_req_ref *rqd_ref;
306 uint8_t rqd_ta;
307
Harald Welted12b0fd2009-12-15 21:36:05 +0100308 /* cache of last measurement reports on this lchan */
309 struct gsm_meas_rep meas_rep[6];
310 int meas_rep_idx;
311
Harald Weltef7c28b02009-12-21 13:30:17 +0100312 /* table of neighbor cell measurements */
313 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
314
Harald Welte2c828992009-12-02 01:56:49 +0530315 struct {
316 u_int32_t bound_ip;
Harald Welte5e3d91b2009-12-19 16:42:06 +0100317 u_int32_t connect_ip;
Harald Welte2c828992009-12-02 01:56:49 +0530318 u_int16_t bound_port;
Harald Welte5e3d91b2009-12-19 16:42:06 +0100319 u_int16_t connect_port;
Harald Welte2c828992009-12-02 01:56:49 +0530320 u_int16_t conn_id;
Sylvain Munautb54dda42009-12-20 22:06:40 +0100321 u_int8_t rtp_payload;
Harald Welte5e3d91b2009-12-19 16:42:06 +0100322 u_int8_t rtp_payload2;
323 u_int8_t speech_mode;
Harald Welte2c828992009-12-02 01:56:49 +0530324 struct rtp_socket *rtp_socket;
325 } abis_ip;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100326
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800327 struct gsm_subscriber_connection *conn;
Harald Welte8470bf22008-12-25 23:28:35 +0000328};
329
Harald Welte85770c72009-01-18 17:47:32 +0000330struct gsm_e1_subslot {
331 /* Number of E1 link */
332 u_int8_t e1_nr;
333 /* Number of E1 TS inside E1 link */
334 u_int8_t e1_ts;
335 /* Sub-slot within the E1 TS, 0xff if full TS */
336 u_int8_t e1_ts_ss;
337};
338
Harald Welte4563eab2010-03-28 14:42:09 +0800339#define TS_F_PDCH_MODE 0x1000
Harald Welte52b1f982008-12-23 20:25:15 +0000340/* One Timeslot in a TRX */
341struct gsm_bts_trx_ts {
342 struct gsm_bts_trx *trx;
343 /* number of this timeslot at the TRX */
344 u_int8_t nr;
345
Harald Welte8470bf22008-12-25 23:28:35 +0000346 enum gsm_phys_chan_config pchan;
347
Harald Welte52b1f982008-12-23 20:25:15 +0000348 unsigned int flags;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000349 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200350 struct tlv_parsed nm_attr;
Harald Welte39c7deb2009-08-09 21:49:48 +0200351 u_int8_t nm_chan_comb;
Harald Welte8470bf22008-12-25 23:28:35 +0000352
Harald Welte6e0cd042009-09-12 13:05:33 +0200353 struct {
Harald Weltefd370892010-06-15 08:52:12 +0200354 /* Parameters below are configured by VTY */
Harald Weltea39b0f22010-06-14 22:26:10 +0200355 int enabled;
Harald Welte6e0cd042009-09-12 13:05:33 +0200356 u_int8_t maio;
357 u_int8_t hsn;
Harald Weltea39b0f22010-06-14 22:26:10 +0200358 struct bitvec arfcns;
359 u_int8_t arfcns_data[1024/8];
Harald Weltefd370892010-06-15 08:52:12 +0200360 /* This is the pre-computed MA for channel assignments */
361 struct bitvec ma;
Harald Welte29aca172010-06-15 16:45:51 +0200362 u_int8_t ma_len; /* part of ma_data that is used */
Harald Weltefd370892010-06-15 08:52:12 +0200363 u_int8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
Harald Welte6e0cd042009-09-12 13:05:33 +0200364 } hopping;
365
Harald Welte85770c72009-01-18 17:47:32 +0000366 /* To which E1 subslot are we connected */
367 struct gsm_e1_subslot e1_link;
368
Harald Welte8470bf22008-12-25 23:28:35 +0000369 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +0000370};
371
372/* One TRX in a BTS */
373struct gsm_bts_trx {
Harald Weltee441d9c2009-06-21 16:17:15 +0200374 /* list header in bts->trx_list */
375 struct llist_head list;
376
Harald Welte52b1f982008-12-23 20:25:15 +0000377 struct gsm_bts *bts;
378 /* number of this TRX in the BTS */
379 u_int8_t nr;
Harald Welte197dea92010-05-14 17:59:53 +0200380 /* human readable name / description */
381 char *description;
Harald Welte1fa60c82009-02-09 18:13:26 +0000382 /* how do we talk RSL with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200383 struct gsm_e1_subslot rsl_e1_link;
384 u_int8_t rsl_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000385 struct e1inp_sign_link *rsl_link;
Harald Welte42581822009-08-08 16:12:58 +0200386
Harald Weltebbcc7a52009-02-14 19:45:44 +0000387 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200388 struct tlv_parsed nm_attr;
Harald Welte8c1d0e42009-02-15 03:38:12 +0000389 struct {
390 struct gsm_nm_state nm_state;
391 } bb_transc;
Harald Welte52b1f982008-12-23 20:25:15 +0000392
393 u_int16_t arfcn;
Harald Weltefcd24452009-06-20 18:15:19 +0200394 int nominal_power; /* in dBm */
395 unsigned int max_power_red; /* in actual dB */
Harald Welte8b697c72009-06-05 19:18:45 +0000396
397 union {
398 struct {
399 struct {
400 struct gsm_nm_state nm_state;
401 } bbsig;
402 struct {
403 struct gsm_nm_state nm_state;
404 } pa;
405 } bs11;
Harald Welte549faad2010-03-05 19:36:20 +0100406 struct {
407 unsigned int test_state;
Harald Weltea0b0f362010-03-09 22:35:37 +0100408 u_int8_t test_nr;
Harald Welte887deab2010-03-06 11:38:05 +0100409 struct rxlev_stats rxlev_stat;
Harald Welte549faad2010-03-05 19:36:20 +0100410 } ipaccess;
Harald Welte8b697c72009-06-05 19:18:45 +0000411 };
Harald Welte85770c72009-01-18 17:47:32 +0000412 struct gsm_bts_trx_ts ts[TRX_NR_TS];
Harald Welte52b1f982008-12-23 20:25:15 +0000413};
414
Harald Welte7401ae62010-06-15 16:44:12 +0200415#define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i])
416
Harald Welte978cb422009-01-18 17:57:27 +0000417enum gsm_bts_type {
418 GSM_BTS_TYPE_UNKNOWN,
419 GSM_BTS_TYPE_BS11,
Mike Habene2d82272009-10-02 12:19:34 +0100420 GSM_BTS_TYPE_NANOBTS,
Harald Welte978cb422009-01-18 17:57:27 +0000421};
422
Harald Welte39315c42010-01-10 18:01:52 +0100423struct gsm_bts_model {
424 struct llist_head list;
425
426 enum gsm_bts_type type;
427 const char *name;
428
429 struct tlv_definition nm_att_tlvdef;
Harald Weltef3d8e922010-06-14 22:44:42 +0200430
431 struct bitvec features;
432 uint8_t _features_data[128/8];
433};
434
435enum gsm_bts_features {
436 BTS_FEAT_HSCSD,
437 BTS_FEAT_GPRS,
438 BTS_FEAT_EGPRS,
439 BTS_FEAT_ECSD,
440 BTS_FEAT_HOPPING,
Harald Welte39315c42010-01-10 18:01:52 +0100441};
442
Holger Freytherceb59b72009-02-06 18:54:00 +0000443/*
444 * This keeps track of the paging status of one BTS. It
445 * includes a number of pending requests, a back pointer
446 * to the gsm_bts, a timer and some more state.
447 */
448struct gsm_bts_paging_state {
Holger Freytherceb59b72009-02-06 18:54:00 +0000449 /* pending requests */
450 struct llist_head pending_requests;
Holger Freytherceb59b72009-02-06 18:54:00 +0000451 struct gsm_bts *bts;
452
Harald Welte75a1fa82009-02-17 01:39:41 +0000453 struct timer_list work_timer;
Holger Hans Peter Freyther6410d932010-04-19 19:41:26 +0800454 struct timer_list credit_timer;
Harald Welte75a1fa82009-02-17 01:39:41 +0000455
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800456 /* free chans needed */
457 int free_chans_need;
458
Holger Freyther392209c2009-02-10 00:06:19 +0000459 /* load */
460 u_int16_t available_slots;
Holger Freytherceb59b72009-02-06 18:54:00 +0000461};
462
Harald Welte8b697c72009-06-05 19:18:45 +0000463struct gsm_envabtse {
464 struct gsm_nm_state nm_state;
465};
466
Harald Welte55dd4432009-10-24 10:19:14 +0200467struct gsm_bts_gprs_nsvc {
468 struct gsm_bts *bts;
Harald Welteab88a622010-03-18 00:01:23 +0800469 /* data read via VTY config file, to configure the BTS
470 * via OML from BSC */
Harald Welte55dd4432009-10-24 10:19:14 +0200471 int id;
Harald Welte97a282b2010-03-14 15:37:43 +0800472 u_int16_t nsvci;
Harald Welteab88a622010-03-18 00:01:23 +0800473 u_int16_t local_port; /* on the BTS */
474 u_int16_t remote_port; /* on the SGSN */
475 u_int32_t remote_ip; /* on the SGSN */
476
Harald Welte55dd4432009-10-24 10:19:14 +0200477 struct gsm_nm_state nm_state;
478};
479
Harald Welte52b1f982008-12-23 20:25:15 +0000480/* One BTS */
481struct gsm_bts {
Harald Weltee441d9c2009-06-21 16:17:15 +0200482 /* list header in net->bts_list */
483 struct llist_head list;
484
Harald Welte52b1f982008-12-23 20:25:15 +0000485 struct gsm_network *network;
486 /* number of ths BTS in network */
487 u_int8_t nr;
Harald Welte197dea92010-05-14 17:59:53 +0200488 /* human readable name / description */
489 char *description;
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200490 /* Cell Identity */
491 u_int16_t cell_identity;
Harald Welte52b1f982008-12-23 20:25:15 +0000492 /* location area code of this BTS */
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +0200493 u_int16_t location_area_code;
Harald Welte02b0e092009-02-28 13:11:07 +0000494 /* Training Sequence Code */
495 u_int8_t tsc;
Harald Welte78f2f502009-05-23 16:56:52 +0000496 /* Base Station Identification Code (BSIC) */
497 u_int8_t bsic;
Harald Welte978cb422009-01-18 17:57:27 +0000498 /* type of BTS */
499 enum gsm_bts_type type;
Harald Welte39315c42010-01-10 18:01:52 +0100500 struct gsm_bts_model *model;
Harald Weltefcd24452009-06-20 18:15:19 +0200501 enum gsm_band band;
Harald Weltefc0d9522009-08-10 13:46:55 +0200502 /* should the channel allocator allocate channels from high TRX to TRX0,
503 * rather than starting from TRX0 and go upwards? */
504 int chan_alloc_reverse;
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200505 /* maximum Tx power that the MS is permitted to use in this cell */
506 int ms_max_power;
Harald Weltefc0d9522009-08-10 13:46:55 +0200507
Harald Welte1fa60c82009-02-09 18:13:26 +0000508 /* how do we talk OML with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200509 struct gsm_e1_subslot oml_e1_link;
510 u_int8_t oml_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000511 struct e1inp_sign_link *oml_link;
Harald Welte52b1f982008-12-23 20:25:15 +0000512
513 /* Abis network management O&M handle */
514 struct abis_nm_h *nmh;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000515 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200516 struct tlv_parsed nm_attr;
Harald Welte978cb422009-01-18 17:57:27 +0000517
Harald Welte52b1f982008-12-23 20:25:15 +0000518 /* number of this BTS on given E1 link */
519 u_int8_t bts_nr;
520
Holger Freytherceb59b72009-02-06 18:54:00 +0000521 /* paging state and control */
522 struct gsm_bts_paging_state paging;
523
Harald Welte52b1f982008-12-23 20:25:15 +0000524 /* CCCH is on C0 */
525 struct gsm_bts_trx *c0;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000526
527 struct {
528 struct gsm_nm_state nm_state;
529 } site_mgr;
Harald Welteedb37782009-05-01 14:59:07 +0000530
Harald Weltea43f7892009-12-01 18:04:30 +0530531 /* parameters from which we build SYSTEM INFORMATION */
532 struct {
533 struct gsm48_rach_control rach_control;
534 u_int8_t ncc_permitted;
535 struct gsm48_cell_sel_par cell_sel_par;
Sylvain Munaute0b06b02010-11-28 18:17:28 +0100536 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
Harald Weltea43f7892009-12-01 18:04:30 +0530537 struct gsm48_cell_options cell_options;
538 struct gsm48_control_channel_descr chan_desc;
Harald Welte6c40def2009-12-14 22:07:14 +0100539 struct bitvec neigh_list;
540 struct bitvec cell_alloc;
541 struct {
542 /* bitmask large enough for all possible ARFCN's */
543 u_int8_t neigh_list[1024/8];
544 u_int8_t cell_alloc[1024/8];
545 } data;
Harald Weltea43f7892009-12-01 18:04:30 +0530546 } si_common;
547
Harald Welte9fbff4a2010-07-30 11:50:09 +0200548 /* do we use static (user-defined) system information messages? (bitmask) */
549 uint32_t si_mode_static;
550 /* bitmask of all SI that are present/valid in si_buf */
551 uint32_t si_valid;
Harald Welte7401ae62010-06-15 16:44:12 +0200552 /* buffers where we put the pre-computed SI */
553 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
554
Harald Welteedb37782009-05-01 14:59:07 +0000555 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
Harald Welte7b26bcb2009-05-28 11:39:21 +0000556 union {
557 struct {
558 u_int16_t site_id;
559 u_int16_t bts_id;
Harald Welte88a412a2009-12-16 17:32:37 +0100560 u_int32_t flags;
Harald Welte7b26bcb2009-05-28 11:39:21 +0000561 } ip_access;
562 struct {
563 struct {
564 struct gsm_nm_state nm_state;
565 } cclk;
566 struct {
567 struct gsm_nm_state nm_state;
568 } rack;
Harald Welte8b697c72009-06-05 19:18:45 +0000569 struct gsm_envabtse envabtse[4];
Harald Welte7b26bcb2009-05-28 11:39:21 +0000570 } bs11;
571 };
Harald Welte55dd4432009-10-24 10:19:14 +0200572
573 /* Not entirely sure how ip.access specific this is */
574 struct {
Harald Welte4511d892010-04-18 15:51:20 +0200575 enum bts_gprs_mode mode;
Harald Welte55dd4432009-10-24 10:19:14 +0200576 struct {
577 struct gsm_nm_state nm_state;
Harald Weltea5731cf2010-03-22 11:48:36 +0800578 u_int16_t nsei;
Harald Welte615e9562010-05-11 23:50:21 +0200579 uint8_t timer[7];
Harald Welte55dd4432009-10-24 10:19:14 +0200580 } nse;
581 struct {
582 struct gsm_nm_state nm_state;
Harald Welte97a282b2010-03-14 15:37:43 +0800583 u_int16_t bvci;
Harald Welte615e9562010-05-11 23:50:21 +0200584 uint8_t timer[11];
Harald Welte55dd4432009-10-24 10:19:14 +0200585 } cell;
586 struct gsm_bts_gprs_nsvc nsvc[2];
Harald Welte97a282b2010-03-14 15:37:43 +0800587 u_int8_t rac;
Harald Welte55dd4432009-10-24 10:19:14 +0200588 } gprs;
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +0800589
590 /* RACH NM values */
591 int rach_b_thresh;
592 int rach_ldavg_slots;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000593
Harald Welte52b1f982008-12-23 20:25:15 +0000594 /* transceivers */
595 int num_trx;
Harald Weltee441d9c2009-06-21 16:17:15 +0200596 struct llist_head trx_list;
Holger Hans Peter Freyther6f615552010-11-15 20:50:42 +0100597
598 /* Abis NM queue */
599 struct llist_head abis_queue;
600 int abis_nm_pend;
Harald Welte52b1f982008-12-23 20:25:15 +0000601};
602
Harald Welte24ff6ee2009-12-22 00:41:05 +0100603/* Some statistics of our network */
604struct gsmnet_stats {
605 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100606 struct counter *total;
607 struct counter *no_channel;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100608 } chreq;
609 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100610 struct counter *attempted;
611 struct counter *no_channel; /* no channel available */
612 struct counter *timeout; /* T3103 timeout */
613 struct counter *completed; /* HO COMPL received */
614 struct counter *failed; /* HO FAIL received */
Harald Welte24ff6ee2009-12-22 00:41:05 +0100615 } handover;
616 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100617 struct counter *attach;
618 struct counter *normal;
619 struct counter *periodic;
620 struct counter *detach;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100621 } loc_upd_type;
622 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100623 struct counter *reject;
624 struct counter *accept;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100625 } loc_upd_resp;
626 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100627 struct counter *attempted;
628 struct counter *detached;
629 struct counter *completed;
630 struct counter *expired;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100631 } paging;
632 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100633 struct counter *submitted; /* MO SMS submissions */
634 struct counter *no_receiver;
635 struct counter *delivered; /* MT SMS deliveries */
636 struct counter *rp_err_mem;
637 struct counter *rp_err_other;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100638 } sms;
639 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100640 struct counter *dialled; /* total number of dialled calls */
641 struct counter *alerted; /* we alerted the other end */
642 struct counter *connected;/* how many calls were accepted */
Harald Welte24ff6ee2009-12-22 00:41:05 +0100643 } call;
Holger Hans Peter Freyther3ba36d52010-04-17 06:48:29 +0200644 struct {
645 struct counter *rf_fail;
646 struct counter *rll_err;
647 } chan;
Holger Hans Peter Freytherbb110f92010-04-12 10:45:52 +0200648 struct {
649 struct counter *oml_fail;
650 struct counter *rsl_fail;
651 } bts;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100652};
653
Harald Welte (local)69de3972009-08-12 14:42:23 +0200654enum gsm_auth_policy {
655 GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */
656 GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */
657 GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */
658};
659
Harald Welteb84ddfc2009-12-01 17:36:54 +0530660#define GSM_T3101_DEFAULT 10
661#define GSM_T3113_DEFAULT 60
662
Harald Welte52b1f982008-12-23 20:25:15 +0000663struct gsm_network {
664 /* global parameters */
Harald Welteb84e2f42008-12-28 23:42:04 +0000665 u_int16_t country_code;
666 u_int16_t network_code;
Harald Weltec6ba9c22008-12-30 18:01:02 +0000667 char *name_long;
668 char *name_short;
Harald Welte (local)69de3972009-08-12 14:42:23 +0200669 enum gsm_auth_policy auth_policy;
Harald Welte1085c092009-11-18 20:33:19 +0100670 enum gsm48_reject_value reject_cause;
Harald Welte4381cfe2009-08-30 15:47:06 +0900671 int a5_encryption;
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100672 int neci;
Harald Welte648b6ce2009-12-14 09:00:24 +0100673 int send_mm_info;
Harald Weltebc814502009-12-19 21:41:52 +0100674 struct {
675 int active;
Harald Weltef7c28b02009-12-21 13:30:17 +0100676 /* Window RXLEV averaging */
677 unsigned int win_rxlev_avg; /* number of SACCH frames */
678 /* Window RXQUAL averaging */
679 unsigned int win_rxqual_avg; /* number of SACCH frames */
680 /* Window RXLEV neighbouring cells averaging */
681 unsigned int win_rxlev_avg_neigh; /* number of SACCH frames */
682
683 /* how often should we check for power budget HO */
684 unsigned int pwr_interval; /* SACCH frames */
685 /* how much better does a neighbor cell have to be ? */
686 unsigned int pwr_hysteresis; /* dBm */
687 /* maximum distacne before we try a handover */
688 unsigned int max_distance; /* TA values */
Harald Weltebc814502009-12-19 21:41:52 +0100689 } handover;
Harald Welte52b1f982008-12-23 20:25:15 +0000690
Harald Welte24ff6ee2009-12-22 00:41:05 +0100691 struct gsmnet_stats stats;
692
Harald Welte4bfdfe72009-06-10 23:11:52 +0800693 /* layer 4 */
694 int (*mncc_recv) (struct gsm_network *net, int msg_type, void *arg);
695 struct llist_head upqueue;
696 struct llist_head trans_list;
Holger Hans Peter Freytherabcddf12010-06-14 18:20:15 +0800697 struct bsc_api *bsc_api;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800698
Harald Welte52b1f982008-12-23 20:25:15 +0000699 unsigned int num_bts;
Harald Weltee441d9c2009-06-21 16:17:15 +0200700 struct llist_head bts_list;
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100701
702 /* timer values */
703 int T3101;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100704 int T3103;
705 int T3105;
706 int T3107;
707 int T3109;
708 int T3111;
709 int T3113;
710 int T3115;
711 int T3117;
712 int T3119;
Harald Welte2862dca2010-12-23 14:39:29 +0100713 int T3122;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100714 int T3141;
Harald Welteeab84a12009-12-13 10:53:12 +0100715
716 /* Radio Resource Location Protocol (TS 04.31) */
717 struct {
718 enum rrlp_mode mode;
719 } rrlp;
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +0800720
721 /* enable the DTXu and DTXd for this network */
722 int dtx_enabled;
723
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +0800724 enum gsm_chan_t ctype_by_chreq[16];
725
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800726 /* Use a TCH for handling requests of type paging any */
727 int pag_any_tch;
728
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +0800729 /* MSC data in case we are a true BSC */
730 struct osmo_msc_data *msc_data;
Holger Hans Peter Freyther8cc59032010-11-14 21:09:08 +0100731 int hardcoded_rtp_payload;
Harald Welte52b1f982008-12-23 20:25:15 +0000732};
733
Harald Welte7e310b12009-03-30 20:56:32 +0000734#define SMS_HDR_SIZE 128
735#define SMS_TEXT_SIZE 256
736struct gsm_sms {
Harald Welted409be72009-11-07 00:06:19 +0900737 unsigned long long id;
Harald Welte7e310b12009-03-30 20:56:32 +0000738 struct gsm_subscriber *sender;
739 struct gsm_subscriber *receiver;
740
Harald Welteb9c758b2009-07-05 14:02:46 +0200741 unsigned long validity_minutes;
Harald Welte76042182009-08-08 16:03:15 +0200742 u_int8_t reply_path_req;
743 u_int8_t status_rep_req;
744 u_int8_t ud_hdr_ind;
745 u_int8_t protocol_id;
746 u_int8_t data_coding_scheme;
747 u_int8_t msg_ref;
748 char dest_addr[20+1]; /* DA LV is 12 bytes max, i.e. 10 bytes
749 * BCD == 20 bytes string */
750 u_int8_t user_data_len;
751 u_int8_t user_data[SMS_TEXT_SIZE];
Harald Weltef3efc592009-07-27 20:11:35 +0200752
Harald Welte7e310b12009-03-30 20:56:32 +0000753 char text[SMS_TEXT_SIZE];
754};
755
Harald Welte3606cc52009-12-05 15:13:22 +0530756
Harald Weltee441d9c2009-06-21 16:17:15 +0200757struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_code,
Harald Welte4bfdfe72009-06-10 23:11:52 +0800758 int (*mncc_recv)(struct gsm_network *, int, void *));
Harald Weltee441d9c2009-06-21 16:17:15 +0200759struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
760 u_int8_t tsc, u_int8_t bsic);
761struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
Harald Welte39315c42010-01-10 18:01:52 +0100762int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
Harald Weltee441d9c2009-06-21 16:17:15 +0200763
764struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte84874c92009-12-14 22:33:02 +0100765
766/* Get reference to a neighbor cell on a given BCCH ARFCN */
Harald Welte0b121032009-12-15 00:21:31 +0100767struct gsm_bts *gsm_bts_neighbor(const struct gsm_bts *bts,
768 u_int16_t arfcn, u_int8_t bsic);
Harald Welte84874c92009-12-14 22:33:02 +0100769
Harald Weltee441d9c2009-06-21 16:17:15 +0200770struct gsm_bts_trx *gsm_bts_trx_num(struct gsm_bts *bts, int num);
Harald Welte8470bf22008-12-25 23:28:35 +0000771
Harald Weltea72c98e2009-01-04 16:10:38 +0000772const char *gsm_pchan_name(enum gsm_phys_chan_config c);
Harald Welte65da9122009-08-07 00:32:22 +0200773enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
Harald Welte (local)ccd88452009-12-27 18:05:25 +0100774const char *gsm_lchant_name(enum gsm_chan_t c);
Harald Weltea72c98e2009-01-04 16:10:38 +0000775const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte (local)d48f4eb2009-12-28 23:14:22 +0100776char *gsm_trx_name(struct gsm_bts_trx *trx);
Harald Welte23a68632009-02-19 17:06:42 +0000777char *gsm_ts_name(struct gsm_bts_trx_ts *ts);
Harald Welte (local)19ef62a2009-12-27 18:16:36 +0100778char *gsm_lchan_name(struct gsm_lchan *lchan);
Harald Welte1887f9d2009-12-29 10:52:38 +0100779const char *gsm_lchans_name(enum gsm_lchan_state s);
Harald Weltea72c98e2009-01-04 16:10:38 +0000780
Harald Weltead384642008-12-26 10:20:07 +0000781enum gsm_e1_event {
782 EVT_E1_NONE,
Harald Welte1fa60c82009-02-09 18:13:26 +0000783 EVT_E1_TEI_UP,
784 EVT_E1_TEI_DN,
Harald Weltead384642008-12-26 10:20:07 +0000785};
786
Harald Weltecd06bfb2009-02-10 17:33:56 +0000787void set_ts_e1link(struct gsm_bts_trx_ts *ts, u_int8_t e1_nr,
788 u_int8_t e1_ts, u_int8_t e1_ts_ss);
Harald Welte1d014a52009-08-08 15:38:29 +0200789enum gsm_bts_type parse_btstype(const char *arg);
Holger Hans Peter Freyther2dceae62009-06-12 17:39:38 +0200790const char *btstype2str(enum gsm_bts_type type);
Harald Welte6e670aa2010-01-07 20:44:32 +0100791struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr);
Harald Weltebe991492009-05-23 13:56:40 +0000792struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac,
793 struct gsm_bts *start_bts);
Harald Welte32201c12009-03-10 12:15:10 +0000794
Andreas Eversberg8226fa72009-06-29 15:19:38 +0200795extern void *tall_bsc_ctx;
Harald Weltef88c8a02009-12-20 13:48:15 +0100796extern int ipacc_rtp_direct;
Harald Welte2cf161b2009-06-20 22:36:41 +0200797
Harald Welte32201c12009-03-10 12:15:10 +0000798static inline int is_ipaccess_bts(struct gsm_bts *bts)
799{
800 switch (bts->type) {
Mike Habene2d82272009-10-02 12:19:34 +0100801 case GSM_BTS_TYPE_NANOBTS:
Harald Welte32201c12009-03-10 12:15:10 +0000802 return 1;
803 default:
804 break;
805 }
806 return 0;
807}
808
Harald Welte5b570672009-08-10 10:08:01 +0200809static inline int is_siemens_bts(struct gsm_bts *bts)
810{
811 switch (bts->type) {
812 case GSM_BTS_TYPE_BS11:
813 return 1;
814 default:
815 break;
816 }
817
818 return 0;
819}
820
Harald Welte (local)69de3972009-08-12 14:42:23 +0200821
822enum gsm_auth_policy gsm_auth_policy_parse(const char *arg);
823const char *gsm_auth_policy_name(enum gsm_auth_policy policy);
824
Harald Welteeab84a12009-12-13 10:53:12 +0100825enum rrlp_mode rrlp_mode_parse(const char *arg);
826const char *rrlp_mode_name(enum rrlp_mode mode);
827
Harald Welte4511d892010-04-18 15:51:20 +0200828enum bts_gprs_mode bts_gprs_mode_parse(const char *arg);
829const char *bts_gprs_mode_name(enum bts_gprs_mode mode);
830
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +0100831void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
832
Harald Welte97a282b2010-03-14 15:37:43 +0800833int gsm48_ra_id_by_bts(u_int8_t *buf, struct gsm_bts *bts);
834void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
Harald Welted12b0fd2009-12-15 21:36:05 +0100835struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan);
836
Harald Weltef3d8e922010-06-14 22:44:42 +0200837int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat);
838int gsm_bts_has_feature(struct gsm_bts *bts, enum gsm_bts_features feat);
Harald Weltefbda4e12010-03-04 11:04:52 +0100839int gsm_bts_model_register(struct gsm_bts_model *model);
840
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800841struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan);
842void subscr_con_free(struct gsm_subscriber_connection *conn);
843
Harald Welte434bb3f2010-12-22 19:02:27 +0100844/* FIXME: this should go some other header file, but there is no good one */
845static inline void mncc_upq_enqueue(struct gsm_network *net, struct msgb *msg)
846{
847 msgb_enqueue(&net->upqueue, msg);
848}
849
Harald Welte52b1f982008-12-23 20:25:15 +0000850#endif