blob: 59599ab0310580672274acc3d963eafabff2f059 [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 Freyther11b28f92010-12-24 13:48:27 +01008struct gsm_sms_queue;
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +08009
Harald Welte4bfdfe72009-06-10 23:11:52 +080010enum gsm_phys_chan_config {
11 GSM_PCHAN_NONE,
12 GSM_PCHAN_CCCH,
13 GSM_PCHAN_CCCH_SDCCH4,
14 GSM_PCHAN_TCH_F,
15 GSM_PCHAN_TCH_H,
16 GSM_PCHAN_SDCCH8_SACCH8C,
Harald Weltea1499d02009-10-24 10:25:50 +020017 GSM_PCHAN_PDCH, /* GPRS PDCH */
18 GSM_PCHAN_TCH_F_PDCH, /* TCH/F if used, PDCH otherwise */
Harald Welte4bfdfe72009-06-10 23:11:52 +080019 GSM_PCHAN_UNKNOWN,
20};
21
22enum gsm_chan_t {
23 GSM_LCHAN_NONE,
24 GSM_LCHAN_SDCCH,
25 GSM_LCHAN_TCH_F,
26 GSM_LCHAN_TCH_H,
27 GSM_LCHAN_UNKNOWN,
28};
29
Harald Welteeab84a12009-12-13 10:53:12 +010030/* RRLP mode of operation */
31enum rrlp_mode {
32 RRLP_MODE_NONE,
33 RRLP_MODE_MS_BASED,
34 RRLP_MODE_MS_PREF,
35 RRLP_MODE_ASS_PREF,
36};
Harald Welte4bfdfe72009-06-10 23:11:52 +080037
38/* Channel Request reason */
39enum gsm_chreq_reason_t {
40 GSM_CHREQ_REASON_EMERG,
41 GSM_CHREQ_REASON_PAG,
42 GSM_CHREQ_REASON_CALL,
43 GSM_CHREQ_REASON_LOCATION_UPD,
44 GSM_CHREQ_REASON_OTHER,
45};
46
Harald Weltedfe6c7d2010-02-20 16:24:02 +010047#include <osmocore/timer.h>
Harald Welte7401ae62010-06-15 16:44:12 +020048#include <openbsc/system_information.h>
Sylvain Munaute0b06b02010-11-28 18:17:28 +010049#include <openbsc/rest_octets.h>
Harald Welte4bfdfe72009-06-10 23:11:52 +080050#include <openbsc/mncc.h>
Harald Welte887deab2010-03-06 11:38:05 +010051
Harald Weltedfe6c7d2010-02-20 16:24:02 +010052#include <osmocore/tlv.h>
53#include <osmocore/bitvec.h>
54#include <osmocore/statistics.h>
55#include <osmocore/gsm_utils.h>
56#include <osmocore/utils.h>
Harald Welte887deab2010-03-06 11:38:05 +010057#include <osmocore/rxlev_stat.h>
Harald Welte8470bf22008-12-25 23:28:35 +000058
Sylvain Munaut81a8bf12010-12-01 22:28:59 +010059#include <osmocore/protocol/gsm_08_58.h>
60
61
Harald Welte85770c72009-01-18 17:47:32 +000062#define TRX_NR_TS 8
Harald Welte8470bf22008-12-25 23:28:35 +000063#define TS_MAX_LCHAN 8
Harald Welte52b1f982008-12-23 20:25:15 +000064
65#define HARDCODED_ARFCN 123
Harald Welte02b0e092009-02-28 13:11:07 +000066#define HARDCODED_TSC 7
Harald Welte78f2f502009-05-23 16:56:52 +000067#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
Harald Welte52b1f982008-12-23 20:25:15 +000068
Harald Welte63589be2009-08-06 17:38:10 +020069/* for multi-drop config */
70#define HARDCODED_BTS0_TS 1
71#define HARDCODED_BTS1_TS 6
72#define HARDCODED_BTS2_TS 11
73
Holger Hans Peter Freyther928ca742010-11-10 09:19:30 +010074/* reserved according to GSM 03.03 ยง 2.4 */
75#define GSM_RESERVED_TMSI 0xFFFFFFFF
76
Harald Welte8e1e3ee2009-02-01 13:32:45 +000077enum gsm_hooks {
78 GSM_HOOK_NM_SWLOAD,
Harald Welte0932d1e2009-02-16 22:53:52 +000079 GSM_HOOK_RR_PAGING,
Sylvain Munaut30a15382009-12-24 00:27:26 +010080 GSM_HOOK_RR_SECURITY,
Harald Welte0932d1e2009-02-16 22:53:52 +000081};
82
83enum gsm_paging_event {
84 GSM_PAGING_SUCCEEDED,
85 GSM_PAGING_EXPIRED,
Holger Freyther85a7b362009-04-18 13:48:55 +020086 GSM_PAGING_OOM,
Holger Hans Peter Freytherd3baf412010-12-23 18:19:17 +010087 GSM_PAGING_BUSY,
Harald Welte8e1e3ee2009-02-01 13:32:45 +000088};
89
Harald Welte4511d892010-04-18 15:51:20 +020090enum bts_gprs_mode {
91 BTS_GPRS_NONE = 0,
92 BTS_GPRS_GPRS = 1,
93 BTS_GPRS_EGPRS = 2,
94};
95
Holger Hans Peter Freyther6f615552010-11-15 20:50:42 +010096#define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3]
97
Harald Welte0809d792010-04-30 14:36:25 +020098/* the data structure stored in msgb->cb for openbsc apps */
99struct openbsc_msgb_cb {
Harald Weltefd3fa1d2010-05-02 09:50:42 +0200100 unsigned char *bssgph;
101 unsigned char *llch;
Harald Welte44f1c272010-04-30 19:54:29 +0200102
Harald Welte11d7c102010-05-02 11:54:55 +0200103 /* Cell Identifier */
104 unsigned char *bssgp_cell_id;
105
Harald Weltee6afd602010-05-02 11:19:37 +0200106 /* Identifiers of a BTS, equal to 'struct bssgp_bts_ctx' */
Harald Welte44f1c272010-04-30 19:54:29 +0200107 u_int16_t nsei;
108 u_int16_t bvci;
109
Harald Weltee6afd602010-05-02 11:19:37 +0200110 /* Identifier of a MS (inside BTS), equal to 'struct sgsn_mm_ctx' */
Harald Welte0809d792010-04-30 14:36:25 +0200111 u_int32_t tlli;
Harald Welte44f1c272010-04-30 19:54:29 +0200112} __attribute__((packed));
Harald Welte0809d792010-04-30 14:36:25 +0200113#define OBSC_MSGB_CB(__msgb) ((struct openbsc_msgb_cb *)&((__msgb)->cb[0]))
Harald Welte943c5bc2010-04-30 16:33:12 +0200114#define msgb_tlli(__x) OBSC_MSGB_CB(__x)->tlli
Harald Welte44f1c272010-04-30 19:54:29 +0200115#define msgb_nsei(__x) OBSC_MSGB_CB(__x)->nsei
116#define msgb_bvci(__x) OBSC_MSGB_CB(__x)->bvci
Harald Weltefd3fa1d2010-05-02 09:50:42 +0200117#define msgb_gmmh(__x) (__x)->l3h
118#define msgb_bssgph(__x) OBSC_MSGB_CB(__x)->bssgph
Harald Welte721961c2010-05-02 21:29:36 +0200119#define msgb_bssgp_len(__x) ((__x)->tail - (uint8_t *)msgb_bssgph(__x))
Harald Welte11d7c102010-05-02 11:54:55 +0200120#define msgb_bcid(__x) OBSC_MSGB_CB(__x)->bssgp_cell_id
Harald Weltefd3fa1d2010-05-02 09:50:42 +0200121#define msgb_llch(__x) OBSC_MSGB_CB(__x)->llch
Harald Welte0809d792010-04-30 14:36:25 +0200122
Holger Hans Peter Freyther9c595b72010-06-15 11:20:52 +0800123#define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3]
124
Sylvain Munaut30a15382009-12-24 00:27:26 +0100125enum gsm_security_event {
126 GSM_SECURITY_NOAVAIL,
127 GSM_SECURITY_AUTH_FAILED,
128 GSM_SECURITY_SUCCEEDED,
129};
130
Harald Welte8e1e3ee2009-02-01 13:32:45 +0000131struct msgb;
132typedef int gsm_cbfn(unsigned int hooknum,
133 unsigned int event,
134 struct msgb *msg,
135 void *data, void *param);
136
Sylvain Munaut47193072009-12-27 21:56:14 +0100137/* Real authentication information containing Ki */
138enum gsm_auth_algo {
139 AUTH_ALGO_NONE,
140 AUTH_ALGO_XOR,
141 AUTH_ALGO_COMP128v1,
142};
143
144struct gsm_auth_info {
145 enum gsm_auth_algo auth_algo;
146 unsigned int a3a8_ki_len;
147 u_int8_t a3a8_ki[16];
148};
149
150struct gsm_auth_tuple {
151 int use_count;
152 int key_seq;
153 u_int8_t rand[16];
154 u_int8_t sres[4];
155 u_int8_t kc[8];
156};
Sylvain Munautb48216f2010-06-09 12:45:37 +0200157#define GSM_KEY_SEQ_INVAL 7 /* GSM 04.08 - 10.5.1.2 */
Sylvain Munaut47193072009-12-27 21:56:14 +0100158
159
Harald Welte49f48b82009-02-17 15:29:33 +0000160struct gsm_lchan;
161struct gsm_subscriber;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800162struct gsm_mncc;
Harald Welte805f6442009-07-28 18:25:29 +0200163struct rtp_socket;
Holger Hans Peter Freytherabcddf12010-06-14 18:20:15 +0800164struct bsc_api;
Harald Welte49f48b82009-02-17 15:29:33 +0000165
Harald Weltebbcc7a52009-02-14 19:45:44 +0000166/* Network Management State */
167struct gsm_nm_state {
168 u_int8_t operational;
169 u_int8_t administrative;
Harald Welte8c1d0e42009-02-15 03:38:12 +0000170 u_int8_t availability;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000171};
Harald Weltebbcc7a52009-02-14 19:45:44 +0000172
Holger Freyther73487a22008-12-31 18:53:57 +0000173/*
174 * LOCATION UPDATING REQUEST state
175 *
176 * Our current operation is:
177 * - Get imei/tmsi
178 * - Accept/Reject according to global policy
179 */
180struct gsm_loc_updating_operation {
181 struct timer_list updating_timer;
Holger Hans Peter Freyther251aa912009-10-27 10:42:28 +0100182 unsigned int waiting_for_imsi : 1;
183 unsigned int waiting_for_imei : 1;
Sylvain Munaut2030a2a2010-06-10 13:36:59 +0200184 unsigned int key_seq : 4;
Holger Freyther73487a22008-12-31 18:53:57 +0000185};
186
Sylvain Munaut30a15382009-12-24 00:27:26 +0100187/*
188 * AUTHENTICATION/CIPHERING state
189 */
190struct gsm_security_operation {
191 struct gsm_auth_tuple atuple;
192 gsm_cbfn *cb;
193 void *cb_data;
194};
195
Holger Hans Peter Freyther02d39b22010-07-05 15:34:16 +0800196/*
197 * A dummy to keep a connection up for at least
198 * a couple of seconds to work around MSC issues.
199 */
200struct gsm_anchor_operation {
201 struct timer_list timeout;
202};
203
Harald Weltef7c28b02009-12-21 13:30:17 +0100204/* Maximum number of neighbor cells whose average we track */
205#define MAX_NEIGH_MEAS 10
206/* Maximum size of the averaging window for neighbor cells */
207#define MAX_WIN_NEIGH_AVG 10
208
209/* processed neighbor measurements for one cell */
210struct neigh_meas_proc {
211 u_int16_t arfcn;
212 u_int8_t bsic;
213 u_int8_t rxlev[MAX_WIN_NEIGH_AVG];
214 unsigned int rxlev_cnt;
215 u_int8_t last_seen_nr;
216};
217
Harald Welte08d91a52009-08-30 15:37:11 +0900218#define MAX_A5_KEY_LEN (128/8)
Sylvain Munaute824d9c2010-06-11 00:19:42 +0200219#define A38_XOR_MIN_KEY_LEN 12
220#define A38_XOR_MAX_KEY_LEN 16
Sylvain Munaut30a15382009-12-24 00:27:26 +0100221#define A38_COMP128_KEY_LEN 16
Harald Welte08d91a52009-08-30 15:37:11 +0900222#define RSL_ENC_ALG_A5(x) (x+1)
223
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100224/* is the data link established? who established it? */
225#define LCHAN_SAPI_UNUSED 0
226#define LCHAN_SAPI_MS 1
227#define LCHAN_SAPI_NET 2
228
Harald Welteb8bfc562009-12-21 13:27:11 +0100229/* state of a logical channel */
230enum gsm_lchan_state {
231 LCHAN_S_NONE, /* channel is not active */
Harald Welte (local)3e460312009-12-27 18:12:29 +0100232 LCHAN_S_ACT_REQ, /* channel activatin requested */
Harald Welteb8bfc562009-12-21 13:27:11 +0100233 LCHAN_S_ACTIVE, /* channel is active and operational */
Harald Welte8e93b792009-12-29 10:44:17 +0100234 LCHAN_S_REL_REQ, /* channel release has been requested */
Holger Hans Peter Freyther4b4dd102010-05-31 21:38:24 +0800235 LCHAN_S_REL_ERR, /* channel is in an error state */
Harald Welteb8bfc562009-12-21 13:27:11 +0100236 LCHAN_S_INACTIVE, /* channel is set inactive */
237};
238
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100239/* the per subscriber data for lchan */
240struct gsm_subscriber_connection {
Holger Hans Peter Freyther79f763f2010-09-16 00:53:37 +0800241 struct llist_head entry;
242
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100243 /* To whom we are allocated at the moment */
244 struct gsm_subscriber *subscr;
245
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100246 /*
247 * Operations that have a state and might be pending
248 */
249 struct gsm_loc_updating_operation *loc_operation;
Sylvain Munaut30a15382009-12-24 00:27:26 +0100250 struct gsm_security_operation *sec_operation;
Holger Hans Peter Freyther02d39b22010-07-05 15:34:16 +0800251 struct gsm_anchor_operation *anch_operation;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100252
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100253 /* Are we part of a special "silent" call */
254 int silent_call;
255
Holger Hans Peter Freyther2f9d1ef2010-09-16 20:14:01 +0800256 /* bsc structures */
257 struct osmo_bsc_sccp_con *sccp_con;
258
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +0100259 /* back pointers */
Holger Hans Peter Freyther40494552010-06-28 17:09:29 +0800260 int in_release;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100261 struct gsm_lchan *lchan;
Holger Hans Peter Freythere071ab72010-06-30 12:40:10 +0800262 struct gsm_lchan *ho_lchan;
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +0100263 struct gsm_bts *bts;
Holger Hans Peter Freyther77cd95d2010-11-14 16:19:48 +0100264
265 /* for assignment handling */
266 struct timer_list T10;
267 struct gsm_lchan *secondary_lchan;
268
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100269};
270
Harald Welte8470bf22008-12-25 23:28:35 +0000271struct gsm_lchan {
272 /* The TS that we're part of */
273 struct gsm_bts_trx_ts *ts;
274 /* The logical subslot number in the TS */
275 u_int8_t nr;
Harald Welte45b407a2009-05-23 15:51:12 +0000276 /* The logical channel type */
Harald Welte8470bf22008-12-25 23:28:35 +0000277 enum gsm_chan_t type;
Harald Welte9943c5b2009-07-29 15:41:29 +0200278 /* RSL channel mode */
279 enum rsl_cmod_spd rsl_cmode;
Harald Welte45b407a2009-05-23 15:51:12 +0000280 /* If TCH, traffic channel mode */
Harald Welte9943c5b2009-07-29 15:41:29 +0200281 enum gsm48_chan_mode tch_mode;
Harald Welteb8bfc562009-12-21 13:27:11 +0100282 /* State */
283 enum gsm_lchan_state state;
Harald Welted4c9bf32009-02-15 16:56:18 +0000284 /* Power levels for MS and BTS */
285 u_int8_t bs_power;
286 u_int8_t ms_power;
Harald Welte08d91a52009-08-30 15:37:11 +0900287 /* Encryption information */
288 struct {
289 u_int8_t alg_id;
290 u_int8_t key_len;
291 u_int8_t key[MAX_A5_KEY_LEN];
292 } encr;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100293
294 struct timer_list T3101;
Holger Hans Peter Freytherf30c0dc2010-05-31 21:33:15 +0800295 struct timer_list T3111;
Holger Hans Peter Freyther4b4dd102010-05-31 21:38:24 +0800296 struct timer_list error_timer;
Holger Hans Peter Freytherea528022009-11-18 22:57:02 +0100297
298 /* AMR bits */
299 struct gsm48_multi_rate_conf mr_conf;
Harald Welted4c9bf32009-02-15 16:56:18 +0000300
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100301 /* Established data link layer services */
302 u_int8_t sapis[8];
Holger Hans Peter Freyther4b85a322010-07-29 17:09:36 +0800303 int sach_deact;
304 int release_reason;
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100305
Holger Hans Peter Freyther5ba05f42010-06-22 12:11:59 +0800306 /* GSM Random Access data */
307 struct gsm48_req_ref *rqd_ref;
308 uint8_t rqd_ta;
309
Harald Welted12b0fd2009-12-15 21:36:05 +0100310 /* cache of last measurement reports on this lchan */
311 struct gsm_meas_rep meas_rep[6];
312 int meas_rep_idx;
313
Harald Weltef7c28b02009-12-21 13:30:17 +0100314 /* table of neighbor cell measurements */
315 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
316
Harald Welte2c828992009-12-02 01:56:49 +0530317 struct {
318 u_int32_t bound_ip;
Harald Welte5e3d91b2009-12-19 16:42:06 +0100319 u_int32_t connect_ip;
Harald Welte2c828992009-12-02 01:56:49 +0530320 u_int16_t bound_port;
Harald Welte5e3d91b2009-12-19 16:42:06 +0100321 u_int16_t connect_port;
Harald Welte2c828992009-12-02 01:56:49 +0530322 u_int16_t conn_id;
Sylvain Munautb54dda42009-12-20 22:06:40 +0100323 u_int8_t rtp_payload;
Harald Welte5e3d91b2009-12-19 16:42:06 +0100324 u_int8_t rtp_payload2;
325 u_int8_t speech_mode;
Harald Welte2c828992009-12-02 01:56:49 +0530326 struct rtp_socket *rtp_socket;
327 } abis_ip;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100328
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800329 struct gsm_subscriber_connection *conn;
Harald Welte8470bf22008-12-25 23:28:35 +0000330};
331
Harald Welte85770c72009-01-18 17:47:32 +0000332struct gsm_e1_subslot {
333 /* Number of E1 link */
334 u_int8_t e1_nr;
335 /* Number of E1 TS inside E1 link */
336 u_int8_t e1_ts;
337 /* Sub-slot within the E1 TS, 0xff if full TS */
338 u_int8_t e1_ts_ss;
339};
340
Harald Welte4563eab2010-03-28 14:42:09 +0800341#define TS_F_PDCH_MODE 0x1000
Harald Welte52b1f982008-12-23 20:25:15 +0000342/* One Timeslot in a TRX */
343struct gsm_bts_trx_ts {
344 struct gsm_bts_trx *trx;
345 /* number of this timeslot at the TRX */
346 u_int8_t nr;
347
Harald Welte8470bf22008-12-25 23:28:35 +0000348 enum gsm_phys_chan_config pchan;
349
Harald Welte52b1f982008-12-23 20:25:15 +0000350 unsigned int flags;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000351 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200352 struct tlv_parsed nm_attr;
Harald Welte39c7deb2009-08-09 21:49:48 +0200353 u_int8_t nm_chan_comb;
Harald Welte8470bf22008-12-25 23:28:35 +0000354
Harald Welte6e0cd042009-09-12 13:05:33 +0200355 struct {
Harald Weltefd370892010-06-15 08:52:12 +0200356 /* Parameters below are configured by VTY */
Harald Weltea39b0f22010-06-14 22:26:10 +0200357 int enabled;
Harald Welte6e0cd042009-09-12 13:05:33 +0200358 u_int8_t maio;
359 u_int8_t hsn;
Harald Weltea39b0f22010-06-14 22:26:10 +0200360 struct bitvec arfcns;
361 u_int8_t arfcns_data[1024/8];
Harald Weltefd370892010-06-15 08:52:12 +0200362 /* This is the pre-computed MA for channel assignments */
363 struct bitvec ma;
Harald Welte29aca172010-06-15 16:45:51 +0200364 u_int8_t ma_len; /* part of ma_data that is used */
Harald Weltefd370892010-06-15 08:52:12 +0200365 u_int8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
Harald Welte6e0cd042009-09-12 13:05:33 +0200366 } hopping;
367
Harald Welte85770c72009-01-18 17:47:32 +0000368 /* To which E1 subslot are we connected */
369 struct gsm_e1_subslot e1_link;
370
Harald Welte8470bf22008-12-25 23:28:35 +0000371 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +0000372};
373
374/* One TRX in a BTS */
375struct gsm_bts_trx {
Harald Weltee441d9c2009-06-21 16:17:15 +0200376 /* list header in bts->trx_list */
377 struct llist_head list;
378
Harald Welte52b1f982008-12-23 20:25:15 +0000379 struct gsm_bts *bts;
380 /* number of this TRX in the BTS */
381 u_int8_t nr;
Harald Welte197dea92010-05-14 17:59:53 +0200382 /* human readable name / description */
383 char *description;
Harald Welte1fa60c82009-02-09 18:13:26 +0000384 /* how do we talk RSL with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200385 struct gsm_e1_subslot rsl_e1_link;
386 u_int8_t rsl_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000387 struct e1inp_sign_link *rsl_link;
Harald Welte42581822009-08-08 16:12:58 +0200388
Harald Weltebbcc7a52009-02-14 19:45:44 +0000389 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200390 struct tlv_parsed nm_attr;
Harald Welte8c1d0e42009-02-15 03:38:12 +0000391 struct {
392 struct gsm_nm_state nm_state;
393 } bb_transc;
Harald Welte52b1f982008-12-23 20:25:15 +0000394
395 u_int16_t arfcn;
Harald Weltefcd24452009-06-20 18:15:19 +0200396 int nominal_power; /* in dBm */
397 unsigned int max_power_red; /* in actual dB */
Harald Welte8b697c72009-06-05 19:18:45 +0000398
399 union {
400 struct {
401 struct {
402 struct gsm_nm_state nm_state;
403 } bbsig;
404 struct {
405 struct gsm_nm_state nm_state;
406 } pa;
407 } bs11;
Harald Welte549faad2010-03-05 19:36:20 +0100408 struct {
409 unsigned int test_state;
Harald Weltea0b0f362010-03-09 22:35:37 +0100410 u_int8_t test_nr;
Harald Welte887deab2010-03-06 11:38:05 +0100411 struct rxlev_stats rxlev_stat;
Harald Welte549faad2010-03-05 19:36:20 +0100412 } ipaccess;
Harald Welte8b697c72009-06-05 19:18:45 +0000413 };
Harald Welte85770c72009-01-18 17:47:32 +0000414 struct gsm_bts_trx_ts ts[TRX_NR_TS];
Harald Welte52b1f982008-12-23 20:25:15 +0000415};
416
Harald Welte7401ae62010-06-15 16:44:12 +0200417#define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i])
418
Harald Welte978cb422009-01-18 17:57:27 +0000419enum gsm_bts_type {
420 GSM_BTS_TYPE_UNKNOWN,
421 GSM_BTS_TYPE_BS11,
Mike Habene2d82272009-10-02 12:19:34 +0100422 GSM_BTS_TYPE_NANOBTS,
Harald Welte978cb422009-01-18 17:57:27 +0000423};
424
Harald Welte39315c42010-01-10 18:01:52 +0100425struct gsm_bts_model {
426 struct llist_head list;
427
428 enum gsm_bts_type type;
429 const char *name;
430
431 struct tlv_definition nm_att_tlvdef;
Harald Weltef3d8e922010-06-14 22:44:42 +0200432
433 struct bitvec features;
434 uint8_t _features_data[128/8];
435};
436
437enum gsm_bts_features {
438 BTS_FEAT_HSCSD,
439 BTS_FEAT_GPRS,
440 BTS_FEAT_EGPRS,
441 BTS_FEAT_ECSD,
442 BTS_FEAT_HOPPING,
Harald Welte39315c42010-01-10 18:01:52 +0100443};
444
Holger Freytherceb59b72009-02-06 18:54:00 +0000445/*
446 * This keeps track of the paging status of one BTS. It
447 * includes a number of pending requests, a back pointer
448 * to the gsm_bts, a timer and some more state.
449 */
450struct gsm_bts_paging_state {
Holger Freytherceb59b72009-02-06 18:54:00 +0000451 /* pending requests */
452 struct llist_head pending_requests;
Holger Freytherceb59b72009-02-06 18:54:00 +0000453 struct gsm_bts *bts;
454
Harald Welte75a1fa82009-02-17 01:39:41 +0000455 struct timer_list work_timer;
Holger Hans Peter Freyther6410d932010-04-19 19:41:26 +0800456 struct timer_list credit_timer;
Harald Welte75a1fa82009-02-17 01:39:41 +0000457
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800458 /* free chans needed */
459 int free_chans_need;
460
Holger Freyther392209c2009-02-10 00:06:19 +0000461 /* load */
462 u_int16_t available_slots;
Holger Freytherceb59b72009-02-06 18:54:00 +0000463};
464
Harald Welte8b697c72009-06-05 19:18:45 +0000465struct gsm_envabtse {
466 struct gsm_nm_state nm_state;
467};
468
Harald Welte55dd4432009-10-24 10:19:14 +0200469struct gsm_bts_gprs_nsvc {
470 struct gsm_bts *bts;
Harald Welteab88a622010-03-18 00:01:23 +0800471 /* data read via VTY config file, to configure the BTS
472 * via OML from BSC */
Harald Welte55dd4432009-10-24 10:19:14 +0200473 int id;
Harald Welte97a282b2010-03-14 15:37:43 +0800474 u_int16_t nsvci;
Harald Welteab88a622010-03-18 00:01:23 +0800475 u_int16_t local_port; /* on the BTS */
476 u_int16_t remote_port; /* on the SGSN */
477 u_int32_t remote_ip; /* on the SGSN */
478
Harald Welte55dd4432009-10-24 10:19:14 +0200479 struct gsm_nm_state nm_state;
480};
481
Harald Welte52b1f982008-12-23 20:25:15 +0000482/* One BTS */
483struct gsm_bts {
Harald Weltee441d9c2009-06-21 16:17:15 +0200484 /* list header in net->bts_list */
485 struct llist_head list;
486
Harald Welte52b1f982008-12-23 20:25:15 +0000487 struct gsm_network *network;
488 /* number of ths BTS in network */
489 u_int8_t nr;
Harald Welte197dea92010-05-14 17:59:53 +0200490 /* human readable name / description */
491 char *description;
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200492 /* Cell Identity */
493 u_int16_t cell_identity;
Harald Welte52b1f982008-12-23 20:25:15 +0000494 /* location area code of this BTS */
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +0200495 u_int16_t location_area_code;
Harald Welte02b0e092009-02-28 13:11:07 +0000496 /* Training Sequence Code */
497 u_int8_t tsc;
Harald Welte78f2f502009-05-23 16:56:52 +0000498 /* Base Station Identification Code (BSIC) */
499 u_int8_t bsic;
Harald Welte978cb422009-01-18 17:57:27 +0000500 /* type of BTS */
501 enum gsm_bts_type type;
Harald Welte39315c42010-01-10 18:01:52 +0100502 struct gsm_bts_model *model;
Harald Weltefcd24452009-06-20 18:15:19 +0200503 enum gsm_band band;
Harald Weltefc0d9522009-08-10 13:46:55 +0200504 /* should the channel allocator allocate channels from high TRX to TRX0,
505 * rather than starting from TRX0 and go upwards? */
506 int chan_alloc_reverse;
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200507 /* maximum Tx power that the MS is permitted to use in this cell */
508 int ms_max_power;
Harald Weltefc0d9522009-08-10 13:46:55 +0200509
Harald Welte1fa60c82009-02-09 18:13:26 +0000510 /* how do we talk OML with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200511 struct gsm_e1_subslot oml_e1_link;
512 u_int8_t oml_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000513 struct e1inp_sign_link *oml_link;
Harald Welte52b1f982008-12-23 20:25:15 +0000514
515 /* Abis network management O&M handle */
516 struct abis_nm_h *nmh;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000517 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200518 struct tlv_parsed nm_attr;
Harald Welte978cb422009-01-18 17:57:27 +0000519
Harald Welte52b1f982008-12-23 20:25:15 +0000520 /* number of this BTS on given E1 link */
521 u_int8_t bts_nr;
522
Holger Freytherceb59b72009-02-06 18:54:00 +0000523 /* paging state and control */
524 struct gsm_bts_paging_state paging;
525
Harald Welte52b1f982008-12-23 20:25:15 +0000526 /* CCCH is on C0 */
527 struct gsm_bts_trx *c0;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000528
529 struct {
530 struct gsm_nm_state nm_state;
531 } site_mgr;
Harald Welteedb37782009-05-01 14:59:07 +0000532
Harald Weltea43f7892009-12-01 18:04:30 +0530533 /* parameters from which we build SYSTEM INFORMATION */
534 struct {
535 struct gsm48_rach_control rach_control;
536 u_int8_t ncc_permitted;
537 struct gsm48_cell_sel_par cell_sel_par;
Sylvain Munaute0b06b02010-11-28 18:17:28 +0100538 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
Harald Weltea43f7892009-12-01 18:04:30 +0530539 struct gsm48_cell_options cell_options;
540 struct gsm48_control_channel_descr chan_desc;
Harald Welte6c40def2009-12-14 22:07:14 +0100541 struct bitvec neigh_list;
542 struct bitvec cell_alloc;
543 struct {
544 /* bitmask large enough for all possible ARFCN's */
545 u_int8_t neigh_list[1024/8];
546 u_int8_t cell_alloc[1024/8];
547 } data;
Harald Weltea43f7892009-12-01 18:04:30 +0530548 } si_common;
549
Harald Welte9fbff4a2010-07-30 11:50:09 +0200550 /* do we use static (user-defined) system information messages? (bitmask) */
551 uint32_t si_mode_static;
552 /* bitmask of all SI that are present/valid in si_buf */
553 uint32_t si_valid;
Harald Welte7401ae62010-06-15 16:44:12 +0200554 /* buffers where we put the pre-computed SI */
555 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
556
Harald Welteedb37782009-05-01 14:59:07 +0000557 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
Harald Welte7b26bcb2009-05-28 11:39:21 +0000558 union {
559 struct {
560 u_int16_t site_id;
561 u_int16_t bts_id;
Harald Welte88a412a2009-12-16 17:32:37 +0100562 u_int32_t flags;
Harald Welte7b26bcb2009-05-28 11:39:21 +0000563 } ip_access;
564 struct {
565 struct {
566 struct gsm_nm_state nm_state;
567 } cclk;
568 struct {
569 struct gsm_nm_state nm_state;
570 } rack;
Harald Welte8b697c72009-06-05 19:18:45 +0000571 struct gsm_envabtse envabtse[4];
Harald Welte7b26bcb2009-05-28 11:39:21 +0000572 } bs11;
573 };
Harald Welte55dd4432009-10-24 10:19:14 +0200574
575 /* Not entirely sure how ip.access specific this is */
576 struct {
Harald Welte4511d892010-04-18 15:51:20 +0200577 enum bts_gprs_mode mode;
Harald Welte55dd4432009-10-24 10:19:14 +0200578 struct {
579 struct gsm_nm_state nm_state;
Harald Weltea5731cf2010-03-22 11:48:36 +0800580 u_int16_t nsei;
Harald Welte615e9562010-05-11 23:50:21 +0200581 uint8_t timer[7];
Harald Welte55dd4432009-10-24 10:19:14 +0200582 } nse;
583 struct {
584 struct gsm_nm_state nm_state;
Harald Welte97a282b2010-03-14 15:37:43 +0800585 u_int16_t bvci;
Harald Welte615e9562010-05-11 23:50:21 +0200586 uint8_t timer[11];
Harald Welte55dd4432009-10-24 10:19:14 +0200587 } cell;
588 struct gsm_bts_gprs_nsvc nsvc[2];
Harald Welte97a282b2010-03-14 15:37:43 +0800589 u_int8_t rac;
Harald Welte55dd4432009-10-24 10:19:14 +0200590 } gprs;
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +0800591
592 /* RACH NM values */
593 int rach_b_thresh;
594 int rach_ldavg_slots;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000595
Harald Welte52b1f982008-12-23 20:25:15 +0000596 /* transceivers */
597 int num_trx;
Harald Weltee441d9c2009-06-21 16:17:15 +0200598 struct llist_head trx_list;
Holger Hans Peter Freyther6f615552010-11-15 20:50:42 +0100599
600 /* Abis NM queue */
601 struct llist_head abis_queue;
602 int abis_nm_pend;
Harald Welte52b1f982008-12-23 20:25:15 +0000603};
604
Harald Welte24ff6ee2009-12-22 00:41:05 +0100605/* Some statistics of our network */
606struct gsmnet_stats {
607 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100608 struct counter *total;
609 struct counter *no_channel;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100610 } chreq;
611 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100612 struct counter *attempted;
613 struct counter *no_channel; /* no channel available */
614 struct counter *timeout; /* T3103 timeout */
615 struct counter *completed; /* HO COMPL received */
616 struct counter *failed; /* HO FAIL received */
Harald Welte24ff6ee2009-12-22 00:41:05 +0100617 } handover;
618 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100619 struct counter *attach;
620 struct counter *normal;
621 struct counter *periodic;
622 struct counter *detach;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100623 } loc_upd_type;
624 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100625 struct counter *reject;
626 struct counter *accept;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100627 } loc_upd_resp;
628 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100629 struct counter *attempted;
630 struct counter *detached;
631 struct counter *completed;
632 struct counter *expired;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100633 } paging;
634 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100635 struct counter *submitted; /* MO SMS submissions */
636 struct counter *no_receiver;
637 struct counter *delivered; /* MT SMS deliveries */
638 struct counter *rp_err_mem;
639 struct counter *rp_err_other;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100640 } sms;
641 struct {
Harald Weltea29e43a2010-12-24 16:06:33 +0100642 struct counter *mo_setup;
643 struct counter *mo_connect_ack;
644 struct counter *mt_setup;
645 struct counter *mt_connect;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100646 } call;
Holger Hans Peter Freyther3ba36d52010-04-17 06:48:29 +0200647 struct {
648 struct counter *rf_fail;
649 struct counter *rll_err;
650 } chan;
Holger Hans Peter Freytherbb110f92010-04-12 10:45:52 +0200651 struct {
652 struct counter *oml_fail;
653 struct counter *rsl_fail;
654 } bts;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100655};
656
Harald Welte (local)69de3972009-08-12 14:42:23 +0200657enum gsm_auth_policy {
658 GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */
659 GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */
660 GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */
661};
662
Harald Welteb84ddfc2009-12-01 17:36:54 +0530663#define GSM_T3101_DEFAULT 10
664#define GSM_T3113_DEFAULT 60
665
Harald Welte52b1f982008-12-23 20:25:15 +0000666struct gsm_network {
667 /* global parameters */
Harald Welteb84e2f42008-12-28 23:42:04 +0000668 u_int16_t country_code;
669 u_int16_t network_code;
Harald Weltec6ba9c22008-12-30 18:01:02 +0000670 char *name_long;
671 char *name_short;
Harald Welte (local)69de3972009-08-12 14:42:23 +0200672 enum gsm_auth_policy auth_policy;
Harald Welte1085c092009-11-18 20:33:19 +0100673 enum gsm48_reject_value reject_cause;
Harald Welte4381cfe2009-08-30 15:47:06 +0900674 int a5_encryption;
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100675 int neci;
Harald Welte648b6ce2009-12-14 09:00:24 +0100676 int send_mm_info;
Harald Weltebc814502009-12-19 21:41:52 +0100677 struct {
678 int active;
Harald Weltef7c28b02009-12-21 13:30:17 +0100679 /* Window RXLEV averaging */
680 unsigned int win_rxlev_avg; /* number of SACCH frames */
681 /* Window RXQUAL averaging */
682 unsigned int win_rxqual_avg; /* number of SACCH frames */
683 /* Window RXLEV neighbouring cells averaging */
684 unsigned int win_rxlev_avg_neigh; /* number of SACCH frames */
685
686 /* how often should we check for power budget HO */
687 unsigned int pwr_interval; /* SACCH frames */
688 /* how much better does a neighbor cell have to be ? */
689 unsigned int pwr_hysteresis; /* dBm */
690 /* maximum distacne before we try a handover */
691 unsigned int max_distance; /* TA values */
Harald Weltebc814502009-12-19 21:41:52 +0100692 } handover;
Harald Welte52b1f982008-12-23 20:25:15 +0000693
Harald Welte24ff6ee2009-12-22 00:41:05 +0100694 struct gsmnet_stats stats;
695
Harald Welte4bfdfe72009-06-10 23:11:52 +0800696 /* layer 4 */
Harald Welte29b64e92010-12-23 01:07:46 +0100697 int (*mncc_recv) (struct gsm_network *net, struct msgb *msg);
Harald Welte4bfdfe72009-06-10 23:11:52 +0800698 struct llist_head upqueue;
699 struct llist_head trans_list;
Holger Hans Peter Freytherabcddf12010-06-14 18:20:15 +0800700 struct bsc_api *bsc_api;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800701
Harald Welte52b1f982008-12-23 20:25:15 +0000702 unsigned int num_bts;
Harald Weltee441d9c2009-06-21 16:17:15 +0200703 struct llist_head bts_list;
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100704
705 /* timer values */
706 int T3101;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100707 int T3103;
708 int T3105;
709 int T3107;
710 int T3109;
711 int T3111;
712 int T3113;
713 int T3115;
714 int T3117;
715 int T3119;
Harald Welte2862dca2010-12-23 14:39:29 +0100716 int T3122;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100717 int T3141;
Harald Welteeab84a12009-12-13 10:53:12 +0100718
719 /* Radio Resource Location Protocol (TS 04.31) */
720 struct {
721 enum rrlp_mode mode;
722 } rrlp;
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +0800723
724 /* enable the DTXu and DTXd for this network */
725 int dtx_enabled;
726
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +0800727 enum gsm_chan_t ctype_by_chreq[16];
728
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800729 /* Use a TCH for handling requests of type paging any */
730 int pag_any_tch;
731
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +0800732 /* MSC data in case we are a true BSC */
733 struct osmo_msc_data *msc_data;
Holger Hans Peter Freyther8cc59032010-11-14 21:09:08 +0100734 int hardcoded_rtp_payload;
Holger Hans Peter Freytherdaee5ca2010-12-22 12:34:39 +0100735
736 /* subscriber related features */
737 int keep_subscr;
Holger Hans Peter Freyther11b28f92010-12-24 13:48:27 +0100738 struct gsm_sms_queue *sms_queue;
Harald Welte52b1f982008-12-23 20:25:15 +0000739};
740
Harald Welte7e310b12009-03-30 20:56:32 +0000741#define SMS_HDR_SIZE 128
742#define SMS_TEXT_SIZE 256
743struct gsm_sms {
Harald Welted409be72009-11-07 00:06:19 +0900744 unsigned long long id;
Harald Welte7e310b12009-03-30 20:56:32 +0000745 struct gsm_subscriber *sender;
746 struct gsm_subscriber *receiver;
747
Harald Welteb9c758b2009-07-05 14:02:46 +0200748 unsigned long validity_minutes;
Harald Welte76042182009-08-08 16:03:15 +0200749 u_int8_t reply_path_req;
750 u_int8_t status_rep_req;
751 u_int8_t ud_hdr_ind;
752 u_int8_t protocol_id;
753 u_int8_t data_coding_scheme;
754 u_int8_t msg_ref;
755 char dest_addr[20+1]; /* DA LV is 12 bytes max, i.e. 10 bytes
756 * BCD == 20 bytes string */
757 u_int8_t user_data_len;
758 u_int8_t user_data[SMS_TEXT_SIZE];
Harald Weltef3efc592009-07-27 20:11:35 +0200759
Harald Welte7e310b12009-03-30 20:56:32 +0000760 char text[SMS_TEXT_SIZE];
761};
762
Harald Welte3606cc52009-12-05 15:13:22 +0530763
Harald Weltee441d9c2009-06-21 16:17:15 +0200764struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_code,
Harald Welte29b64e92010-12-23 01:07:46 +0100765 int (*mncc_recv)(struct gsm_network *, struct msgb *));
Harald Weltee441d9c2009-06-21 16:17:15 +0200766struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
767 u_int8_t tsc, u_int8_t bsic);
768struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
Harald Welte39315c42010-01-10 18:01:52 +0100769int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
Harald Weltee441d9c2009-06-21 16:17:15 +0200770
771struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte84874c92009-12-14 22:33:02 +0100772
773/* Get reference to a neighbor cell on a given BCCH ARFCN */
Harald Welte0b121032009-12-15 00:21:31 +0100774struct gsm_bts *gsm_bts_neighbor(const struct gsm_bts *bts,
775 u_int16_t arfcn, u_int8_t bsic);
Harald Welte84874c92009-12-14 22:33:02 +0100776
Harald Weltee441d9c2009-06-21 16:17:15 +0200777struct gsm_bts_trx *gsm_bts_trx_num(struct gsm_bts *bts, int num);
Harald Welte8470bf22008-12-25 23:28:35 +0000778
Harald Weltea72c98e2009-01-04 16:10:38 +0000779const char *gsm_pchan_name(enum gsm_phys_chan_config c);
Harald Welte65da9122009-08-07 00:32:22 +0200780enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
Harald Welte (local)ccd88452009-12-27 18:05:25 +0100781const char *gsm_lchant_name(enum gsm_chan_t c);
Harald Weltea72c98e2009-01-04 16:10:38 +0000782const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte (local)d48f4eb2009-12-28 23:14:22 +0100783char *gsm_trx_name(struct gsm_bts_trx *trx);
Harald Welte23a68632009-02-19 17:06:42 +0000784char *gsm_ts_name(struct gsm_bts_trx_ts *ts);
Harald Welte (local)19ef62a2009-12-27 18:16:36 +0100785char *gsm_lchan_name(struct gsm_lchan *lchan);
Harald Welte1887f9d2009-12-29 10:52:38 +0100786const char *gsm_lchans_name(enum gsm_lchan_state s);
Harald Weltea72c98e2009-01-04 16:10:38 +0000787
Harald Weltead384642008-12-26 10:20:07 +0000788enum gsm_e1_event {
789 EVT_E1_NONE,
Harald Welte1fa60c82009-02-09 18:13:26 +0000790 EVT_E1_TEI_UP,
791 EVT_E1_TEI_DN,
Harald Weltead384642008-12-26 10:20:07 +0000792};
793
Harald Weltecd06bfb2009-02-10 17:33:56 +0000794void set_ts_e1link(struct gsm_bts_trx_ts *ts, u_int8_t e1_nr,
795 u_int8_t e1_ts, u_int8_t e1_ts_ss);
Harald Welte1d014a52009-08-08 15:38:29 +0200796enum gsm_bts_type parse_btstype(const char *arg);
Holger Hans Peter Freyther2dceae62009-06-12 17:39:38 +0200797const char *btstype2str(enum gsm_bts_type type);
Harald Welte6e670aa2010-01-07 20:44:32 +0100798struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr);
Harald Weltebe991492009-05-23 13:56:40 +0000799struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac,
800 struct gsm_bts *start_bts);
Harald Welte32201c12009-03-10 12:15:10 +0000801
Andreas Eversberg8226fa72009-06-29 15:19:38 +0200802extern void *tall_bsc_ctx;
Harald Weltef88c8a02009-12-20 13:48:15 +0100803extern int ipacc_rtp_direct;
Harald Welte2cf161b2009-06-20 22:36:41 +0200804
Harald Welte32201c12009-03-10 12:15:10 +0000805static inline int is_ipaccess_bts(struct gsm_bts *bts)
806{
807 switch (bts->type) {
Mike Habene2d82272009-10-02 12:19:34 +0100808 case GSM_BTS_TYPE_NANOBTS:
Harald Welte32201c12009-03-10 12:15:10 +0000809 return 1;
810 default:
811 break;
812 }
813 return 0;
814}
815
Harald Welte5b570672009-08-10 10:08:01 +0200816static inline int is_siemens_bts(struct gsm_bts *bts)
817{
818 switch (bts->type) {
819 case GSM_BTS_TYPE_BS11:
820 return 1;
821 default:
822 break;
823 }
824
825 return 0;
826}
827
Harald Welte (local)69de3972009-08-12 14:42:23 +0200828
829enum gsm_auth_policy gsm_auth_policy_parse(const char *arg);
830const char *gsm_auth_policy_name(enum gsm_auth_policy policy);
831
Harald Welteeab84a12009-12-13 10:53:12 +0100832enum rrlp_mode rrlp_mode_parse(const char *arg);
833const char *rrlp_mode_name(enum rrlp_mode mode);
834
Harald Welte4511d892010-04-18 15:51:20 +0200835enum bts_gprs_mode bts_gprs_mode_parse(const char *arg);
836const char *bts_gprs_mode_name(enum bts_gprs_mode mode);
837
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +0100838void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
839
Harald Welte97a282b2010-03-14 15:37:43 +0800840int gsm48_ra_id_by_bts(u_int8_t *buf, struct gsm_bts *bts);
841void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
Harald Welted12b0fd2009-12-15 21:36:05 +0100842struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan);
843
Harald Weltef3d8e922010-06-14 22:44:42 +0200844int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat);
845int gsm_bts_has_feature(struct gsm_bts *bts, enum gsm_bts_features feat);
Harald Weltefbda4e12010-03-04 11:04:52 +0100846int gsm_bts_model_register(struct gsm_bts_model *model);
847
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800848struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan);
849void subscr_con_free(struct gsm_subscriber_connection *conn);
850
Harald Welte52b1f982008-12-23 20:25:15 +0000851#endif