blob: e308ca4d7e968998f87cd3f58ff299ce63549569 [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;
Holger Hans Peter Freyther182c81f2010-12-29 16:28:33 +0100255 int put_channel;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100256
Holger Hans Peter Freyther2f9d1ef2010-09-16 20:14:01 +0800257 /* bsc structures */
258 struct osmo_bsc_sccp_con *sccp_con;
259
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +0100260 /* back pointers */
Holger Hans Peter Freyther40494552010-06-28 17:09:29 +0800261 int in_release;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100262 struct gsm_lchan *lchan;
Holger Hans Peter Freythere071ab72010-06-30 12:40:10 +0800263 struct gsm_lchan *ho_lchan;
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +0100264 struct gsm_bts *bts;
Holger Hans Peter Freyther77cd95d2010-11-14 16:19:48 +0100265
266 /* for assignment handling */
267 struct timer_list T10;
268 struct gsm_lchan *secondary_lchan;
269
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100270};
271
Harald Welte8470bf22008-12-25 23:28:35 +0000272struct gsm_lchan {
273 /* The TS that we're part of */
274 struct gsm_bts_trx_ts *ts;
275 /* The logical subslot number in the TS */
276 u_int8_t nr;
Harald Welte45b407a2009-05-23 15:51:12 +0000277 /* The logical channel type */
Harald Welte8470bf22008-12-25 23:28:35 +0000278 enum gsm_chan_t type;
Harald Welte9943c5b2009-07-29 15:41:29 +0200279 /* RSL channel mode */
280 enum rsl_cmod_spd rsl_cmode;
Harald Welte45b407a2009-05-23 15:51:12 +0000281 /* If TCH, traffic channel mode */
Harald Welte9943c5b2009-07-29 15:41:29 +0200282 enum gsm48_chan_mode tch_mode;
Harald Welteb8bfc562009-12-21 13:27:11 +0100283 /* State */
284 enum gsm_lchan_state state;
Harald Welted4c9bf32009-02-15 16:56:18 +0000285 /* Power levels for MS and BTS */
286 u_int8_t bs_power;
287 u_int8_t ms_power;
Harald Welte08d91a52009-08-30 15:37:11 +0900288 /* Encryption information */
289 struct {
290 u_int8_t alg_id;
291 u_int8_t key_len;
292 u_int8_t key[MAX_A5_KEY_LEN];
293 } encr;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100294
295 struct timer_list T3101;
Holger Hans Peter Freytherf30c0dc2010-05-31 21:33:15 +0800296 struct timer_list T3111;
Holger Hans Peter Freyther4b4dd102010-05-31 21:38:24 +0800297 struct timer_list error_timer;
Holger Hans Peter Freytherea528022009-11-18 22:57:02 +0100298
299 /* AMR bits */
300 struct gsm48_multi_rate_conf mr_conf;
Harald Welted4c9bf32009-02-15 16:56:18 +0000301
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100302 /* Established data link layer services */
303 u_int8_t sapis[8];
Holger Hans Peter Freyther4b85a322010-07-29 17:09:36 +0800304 int sach_deact;
305 int release_reason;
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100306
Holger Hans Peter Freyther5ba05f42010-06-22 12:11:59 +0800307 /* GSM Random Access data */
308 struct gsm48_req_ref *rqd_ref;
309 uint8_t rqd_ta;
310
Harald Welted12b0fd2009-12-15 21:36:05 +0100311 /* cache of last measurement reports on this lchan */
312 struct gsm_meas_rep meas_rep[6];
313 int meas_rep_idx;
314
Harald Weltef7c28b02009-12-21 13:30:17 +0100315 /* table of neighbor cell measurements */
316 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
317
Harald Welte2c828992009-12-02 01:56:49 +0530318 struct {
319 u_int32_t bound_ip;
Harald Welte5e3d91b2009-12-19 16:42:06 +0100320 u_int32_t connect_ip;
Harald Welte2c828992009-12-02 01:56:49 +0530321 u_int16_t bound_port;
Harald Welte5e3d91b2009-12-19 16:42:06 +0100322 u_int16_t connect_port;
Harald Welte2c828992009-12-02 01:56:49 +0530323 u_int16_t conn_id;
Sylvain Munautb54dda42009-12-20 22:06:40 +0100324 u_int8_t rtp_payload;
Harald Welte5e3d91b2009-12-19 16:42:06 +0100325 u_int8_t rtp_payload2;
326 u_int8_t speech_mode;
Harald Welte2c828992009-12-02 01:56:49 +0530327 struct rtp_socket *rtp_socket;
328 } abis_ip;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100329
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800330 struct gsm_subscriber_connection *conn;
Harald Welte8470bf22008-12-25 23:28:35 +0000331};
332
Harald Welte85770c72009-01-18 17:47:32 +0000333struct gsm_e1_subslot {
334 /* Number of E1 link */
335 u_int8_t e1_nr;
336 /* Number of E1 TS inside E1 link */
337 u_int8_t e1_ts;
338 /* Sub-slot within the E1 TS, 0xff if full TS */
339 u_int8_t e1_ts_ss;
340};
341
Harald Welte4563eab2010-03-28 14:42:09 +0800342#define TS_F_PDCH_MODE 0x1000
Harald Welte52b1f982008-12-23 20:25:15 +0000343/* One Timeslot in a TRX */
344struct gsm_bts_trx_ts {
345 struct gsm_bts_trx *trx;
346 /* number of this timeslot at the TRX */
347 u_int8_t nr;
348
Harald Welte8470bf22008-12-25 23:28:35 +0000349 enum gsm_phys_chan_config pchan;
350
Harald Welte52b1f982008-12-23 20:25:15 +0000351 unsigned int flags;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000352 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200353 struct tlv_parsed nm_attr;
Harald Welte39c7deb2009-08-09 21:49:48 +0200354 u_int8_t nm_chan_comb;
Harald Welte8470bf22008-12-25 23:28:35 +0000355
Harald Welte6e0cd042009-09-12 13:05:33 +0200356 struct {
Harald Weltefd370892010-06-15 08:52:12 +0200357 /* Parameters below are configured by VTY */
Harald Weltea39b0f22010-06-14 22:26:10 +0200358 int enabled;
Harald Welte6e0cd042009-09-12 13:05:33 +0200359 u_int8_t maio;
360 u_int8_t hsn;
Harald Weltea39b0f22010-06-14 22:26:10 +0200361 struct bitvec arfcns;
362 u_int8_t arfcns_data[1024/8];
Harald Weltefd370892010-06-15 08:52:12 +0200363 /* This is the pre-computed MA for channel assignments */
364 struct bitvec ma;
Harald Welte29aca172010-06-15 16:45:51 +0200365 u_int8_t ma_len; /* part of ma_data that is used */
Harald Weltefd370892010-06-15 08:52:12 +0200366 u_int8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
Harald Welte6e0cd042009-09-12 13:05:33 +0200367 } hopping;
368
Harald Welte85770c72009-01-18 17:47:32 +0000369 /* To which E1 subslot are we connected */
370 struct gsm_e1_subslot e1_link;
371
Harald Welte8470bf22008-12-25 23:28:35 +0000372 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +0000373};
374
375/* One TRX in a BTS */
376struct gsm_bts_trx {
Harald Weltee441d9c2009-06-21 16:17:15 +0200377 /* list header in bts->trx_list */
378 struct llist_head list;
379
Harald Welte52b1f982008-12-23 20:25:15 +0000380 struct gsm_bts *bts;
381 /* number of this TRX in the BTS */
382 u_int8_t nr;
Harald Welte197dea92010-05-14 17:59:53 +0200383 /* human readable name / description */
384 char *description;
Harald Welte1fa60c82009-02-09 18:13:26 +0000385 /* how do we talk RSL with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200386 struct gsm_e1_subslot rsl_e1_link;
387 u_int8_t rsl_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000388 struct e1inp_sign_link *rsl_link;
Harald Welte42581822009-08-08 16:12:58 +0200389
Harald Weltebbcc7a52009-02-14 19:45:44 +0000390 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200391 struct tlv_parsed nm_attr;
Harald Welte8c1d0e42009-02-15 03:38:12 +0000392 struct {
393 struct gsm_nm_state nm_state;
394 } bb_transc;
Harald Welte52b1f982008-12-23 20:25:15 +0000395
396 u_int16_t arfcn;
Harald Weltefcd24452009-06-20 18:15:19 +0200397 int nominal_power; /* in dBm */
398 unsigned int max_power_red; /* in actual dB */
Harald Welte8b697c72009-06-05 19:18:45 +0000399
400 union {
401 struct {
402 struct {
403 struct gsm_nm_state nm_state;
404 } bbsig;
405 struct {
406 struct gsm_nm_state nm_state;
407 } pa;
408 } bs11;
Harald Welte549faad2010-03-05 19:36:20 +0100409 struct {
410 unsigned int test_state;
Harald Weltea0b0f362010-03-09 22:35:37 +0100411 u_int8_t test_nr;
Harald Welte887deab2010-03-06 11:38:05 +0100412 struct rxlev_stats rxlev_stat;
Harald Welte549faad2010-03-05 19:36:20 +0100413 } ipaccess;
Harald Welte8b697c72009-06-05 19:18:45 +0000414 };
Harald Welte85770c72009-01-18 17:47:32 +0000415 struct gsm_bts_trx_ts ts[TRX_NR_TS];
Harald Welte52b1f982008-12-23 20:25:15 +0000416};
417
Harald Welte7401ae62010-06-15 16:44:12 +0200418#define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i])
419
Harald Welte978cb422009-01-18 17:57:27 +0000420enum gsm_bts_type {
421 GSM_BTS_TYPE_UNKNOWN,
422 GSM_BTS_TYPE_BS11,
Mike Habene2d82272009-10-02 12:19:34 +0100423 GSM_BTS_TYPE_NANOBTS,
Harald Welte978cb422009-01-18 17:57:27 +0000424};
425
Harald Welte39315c42010-01-10 18:01:52 +0100426struct gsm_bts_model {
427 struct llist_head list;
428
429 enum gsm_bts_type type;
430 const char *name;
431
Harald Welte09cefee2011-02-12 12:29:21 +0100432 int (*oml_rcvmsg)(struct msgb *msg);
433
Harald Welte39315c42010-01-10 18:01:52 +0100434 struct tlv_definition nm_att_tlvdef;
Harald Weltef3d8e922010-06-14 22:44:42 +0200435
436 struct bitvec features;
437 uint8_t _features_data[128/8];
438};
439
440enum gsm_bts_features {
441 BTS_FEAT_HSCSD,
442 BTS_FEAT_GPRS,
443 BTS_FEAT_EGPRS,
444 BTS_FEAT_ECSD,
445 BTS_FEAT_HOPPING,
Harald Welte39315c42010-01-10 18:01:52 +0100446};
447
Holger Freytherceb59b72009-02-06 18:54:00 +0000448/*
449 * This keeps track of the paging status of one BTS. It
450 * includes a number of pending requests, a back pointer
451 * to the gsm_bts, a timer and some more state.
452 */
453struct gsm_bts_paging_state {
Holger Freytherceb59b72009-02-06 18:54:00 +0000454 /* pending requests */
455 struct llist_head pending_requests;
Holger Freytherceb59b72009-02-06 18:54:00 +0000456 struct gsm_bts *bts;
457
Harald Welte75a1fa82009-02-17 01:39:41 +0000458 struct timer_list work_timer;
Holger Hans Peter Freyther6410d932010-04-19 19:41:26 +0800459 struct timer_list credit_timer;
Harald Welte75a1fa82009-02-17 01:39:41 +0000460
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800461 /* free chans needed */
462 int free_chans_need;
463
Holger Freyther392209c2009-02-10 00:06:19 +0000464 /* load */
465 u_int16_t available_slots;
Holger Freytherceb59b72009-02-06 18:54:00 +0000466};
467
Harald Welte8b697c72009-06-05 19:18:45 +0000468struct gsm_envabtse {
469 struct gsm_nm_state nm_state;
470};
471
Harald Welte55dd4432009-10-24 10:19:14 +0200472struct gsm_bts_gprs_nsvc {
473 struct gsm_bts *bts;
Harald Welteab88a622010-03-18 00:01:23 +0800474 /* data read via VTY config file, to configure the BTS
475 * via OML from BSC */
Harald Welte55dd4432009-10-24 10:19:14 +0200476 int id;
Harald Welte97a282b2010-03-14 15:37:43 +0800477 u_int16_t nsvci;
Harald Welteab88a622010-03-18 00:01:23 +0800478 u_int16_t local_port; /* on the BTS */
479 u_int16_t remote_port; /* on the SGSN */
480 u_int32_t remote_ip; /* on the SGSN */
481
Harald Welte55dd4432009-10-24 10:19:14 +0200482 struct gsm_nm_state nm_state;
483};
484
Harald Welte52b1f982008-12-23 20:25:15 +0000485/* One BTS */
486struct gsm_bts {
Harald Weltee441d9c2009-06-21 16:17:15 +0200487 /* list header in net->bts_list */
488 struct llist_head list;
489
Harald Welte52b1f982008-12-23 20:25:15 +0000490 struct gsm_network *network;
491 /* number of ths BTS in network */
492 u_int8_t nr;
Harald Welte197dea92010-05-14 17:59:53 +0200493 /* human readable name / description */
494 char *description;
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200495 /* Cell Identity */
496 u_int16_t cell_identity;
Harald Welte52b1f982008-12-23 20:25:15 +0000497 /* location area code of this BTS */
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +0200498 u_int16_t location_area_code;
Harald Welte02b0e092009-02-28 13:11:07 +0000499 /* Training Sequence Code */
500 u_int8_t tsc;
Harald Welte78f2f502009-05-23 16:56:52 +0000501 /* Base Station Identification Code (BSIC) */
502 u_int8_t bsic;
Harald Welte978cb422009-01-18 17:57:27 +0000503 /* type of BTS */
504 enum gsm_bts_type type;
Harald Welte39315c42010-01-10 18:01:52 +0100505 struct gsm_bts_model *model;
Harald Weltefcd24452009-06-20 18:15:19 +0200506 enum gsm_band band;
Harald Weltefc0d9522009-08-10 13:46:55 +0200507 /* should the channel allocator allocate channels from high TRX to TRX0,
508 * rather than starting from TRX0 and go upwards? */
509 int chan_alloc_reverse;
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200510 /* maximum Tx power that the MS is permitted to use in this cell */
511 int ms_max_power;
Harald Weltefc0d9522009-08-10 13:46:55 +0200512
Harald Welte1fa60c82009-02-09 18:13:26 +0000513 /* how do we talk OML with this TRX? */
Harald Welte42581822009-08-08 16:12:58 +0200514 struct gsm_e1_subslot oml_e1_link;
515 u_int8_t oml_tei;
Harald Welte1fa60c82009-02-09 18:13:26 +0000516 struct e1inp_sign_link *oml_link;
Harald Welte52b1f982008-12-23 20:25:15 +0000517
518 /* Abis network management O&M handle */
519 struct abis_nm_h *nmh;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000520 struct gsm_nm_state nm_state;
Harald Welte93e9d172009-06-20 19:04:31 +0200521 struct tlv_parsed nm_attr;
Harald Welte978cb422009-01-18 17:57:27 +0000522
Harald Welte52b1f982008-12-23 20:25:15 +0000523 /* number of this BTS on given E1 link */
524 u_int8_t bts_nr;
525
Holger Freytherceb59b72009-02-06 18:54:00 +0000526 /* paging state and control */
527 struct gsm_bts_paging_state paging;
528
Harald Welte52b1f982008-12-23 20:25:15 +0000529 /* CCCH is on C0 */
530 struct gsm_bts_trx *c0;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000531
532 struct {
533 struct gsm_nm_state nm_state;
534 } site_mgr;
Harald Welteedb37782009-05-01 14:59:07 +0000535
Harald Welte32c09622011-01-11 23:44:56 +0100536 int neigh_list_manual_mode;
Harald Weltea43f7892009-12-01 18:04:30 +0530537 /* parameters from which we build SYSTEM INFORMATION */
538 struct {
539 struct gsm48_rach_control rach_control;
540 u_int8_t ncc_permitted;
541 struct gsm48_cell_sel_par cell_sel_par;
Sylvain Munaute0b06b02010-11-28 18:17:28 +0100542 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
Harald Weltea43f7892009-12-01 18:04:30 +0530543 struct gsm48_cell_options cell_options;
544 struct gsm48_control_channel_descr chan_desc;
Harald Welte6c40def2009-12-14 22:07:14 +0100545 struct bitvec neigh_list;
546 struct bitvec cell_alloc;
547 struct {
548 /* bitmask large enough for all possible ARFCN's */
549 u_int8_t neigh_list[1024/8];
550 u_int8_t cell_alloc[1024/8];
551 } data;
Harald Weltea43f7892009-12-01 18:04:30 +0530552 } si_common;
553
Harald Welte9fbff4a2010-07-30 11:50:09 +0200554 /* do we use static (user-defined) system information messages? (bitmask) */
555 uint32_t si_mode_static;
556 /* bitmask of all SI that are present/valid in si_buf */
557 uint32_t si_valid;
Harald Welte7401ae62010-06-15 16:44:12 +0200558 /* buffers where we put the pre-computed SI */
559 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
560
Harald Welteedb37782009-05-01 14:59:07 +0000561 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
Harald Welte7b26bcb2009-05-28 11:39:21 +0000562 union {
563 struct {
564 u_int16_t site_id;
565 u_int16_t bts_id;
Harald Welte88a412a2009-12-16 17:32:37 +0100566 u_int32_t flags;
Harald Welte7b26bcb2009-05-28 11:39:21 +0000567 } ip_access;
568 struct {
569 struct {
570 struct gsm_nm_state nm_state;
571 } cclk;
572 struct {
573 struct gsm_nm_state nm_state;
574 } rack;
Harald Welte8b697c72009-06-05 19:18:45 +0000575 struct gsm_envabtse envabtse[4];
Harald Welte7b26bcb2009-05-28 11:39:21 +0000576 } bs11;
577 };
Harald Welte55dd4432009-10-24 10:19:14 +0200578
579 /* Not entirely sure how ip.access specific this is */
580 struct {
Harald Welte4511d892010-04-18 15:51:20 +0200581 enum bts_gprs_mode mode;
Harald Welte55dd4432009-10-24 10:19:14 +0200582 struct {
583 struct gsm_nm_state nm_state;
Harald Weltea5731cf2010-03-22 11:48:36 +0800584 u_int16_t nsei;
Harald Welte615e9562010-05-11 23:50:21 +0200585 uint8_t timer[7];
Harald Welte55dd4432009-10-24 10:19:14 +0200586 } nse;
587 struct {
588 struct gsm_nm_state nm_state;
Harald Welte97a282b2010-03-14 15:37:43 +0800589 u_int16_t bvci;
Harald Welte615e9562010-05-11 23:50:21 +0200590 uint8_t timer[11];
Harald Welte55dd4432009-10-24 10:19:14 +0200591 } cell;
592 struct gsm_bts_gprs_nsvc nsvc[2];
Harald Welte97a282b2010-03-14 15:37:43 +0800593 u_int8_t rac;
Harald Welte55dd4432009-10-24 10:19:14 +0200594 } gprs;
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +0800595
596 /* RACH NM values */
597 int rach_b_thresh;
598 int rach_ldavg_slots;
Harald Weltebbcc7a52009-02-14 19:45:44 +0000599
Harald Welte52b1f982008-12-23 20:25:15 +0000600 /* transceivers */
601 int num_trx;
Harald Weltee441d9c2009-06-21 16:17:15 +0200602 struct llist_head trx_list;
Holger Hans Peter Freyther6f615552010-11-15 20:50:42 +0100603
604 /* Abis NM queue */
605 struct llist_head abis_queue;
606 int abis_nm_pend;
Harald Welte52b1f982008-12-23 20:25:15 +0000607};
608
Harald Welte24ff6ee2009-12-22 00:41:05 +0100609/* Some statistics of our network */
610struct gsmnet_stats {
611 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100612 struct counter *total;
613 struct counter *no_channel;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100614 } chreq;
615 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100616 struct counter *attempted;
617 struct counter *no_channel; /* no channel available */
618 struct counter *timeout; /* T3103 timeout */
619 struct counter *completed; /* HO COMPL received */
620 struct counter *failed; /* HO FAIL received */
Harald Welte24ff6ee2009-12-22 00:41:05 +0100621 } handover;
622 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100623 struct counter *attach;
624 struct counter *normal;
625 struct counter *periodic;
626 struct counter *detach;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100627 } loc_upd_type;
628 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100629 struct counter *reject;
630 struct counter *accept;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100631 } loc_upd_resp;
632 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100633 struct counter *attempted;
634 struct counter *detached;
635 struct counter *completed;
636 struct counter *expired;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100637 } paging;
638 struct {
Harald Welteffa55a42009-12-22 19:07:32 +0100639 struct counter *submitted; /* MO SMS submissions */
640 struct counter *no_receiver;
641 struct counter *delivered; /* MT SMS deliveries */
642 struct counter *rp_err_mem;
643 struct counter *rp_err_other;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100644 } sms;
645 struct {
Harald Weltea29e43a2010-12-24 16:06:33 +0100646 struct counter *mo_setup;
647 struct counter *mo_connect_ack;
648 struct counter *mt_setup;
649 struct counter *mt_connect;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100650 } call;
Holger Hans Peter Freyther3ba36d52010-04-17 06:48:29 +0200651 struct {
652 struct counter *rf_fail;
653 struct counter *rll_err;
654 } chan;
Holger Hans Peter Freytherbb110f92010-04-12 10:45:52 +0200655 struct {
656 struct counter *oml_fail;
657 struct counter *rsl_fail;
658 } bts;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100659};
660
Harald Welte (local)69de3972009-08-12 14:42:23 +0200661enum gsm_auth_policy {
662 GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */
663 GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */
664 GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */
665};
666
Harald Welteb84ddfc2009-12-01 17:36:54 +0530667#define GSM_T3101_DEFAULT 10
668#define GSM_T3113_DEFAULT 60
669
Harald Welte52b1f982008-12-23 20:25:15 +0000670struct gsm_network {
671 /* global parameters */
Harald Welteb84e2f42008-12-28 23:42:04 +0000672 u_int16_t country_code;
673 u_int16_t network_code;
Harald Weltec6ba9c22008-12-30 18:01:02 +0000674 char *name_long;
675 char *name_short;
Harald Welte (local)69de3972009-08-12 14:42:23 +0200676 enum gsm_auth_policy auth_policy;
Harald Welte1085c092009-11-18 20:33:19 +0100677 enum gsm48_reject_value reject_cause;
Harald Welte4381cfe2009-08-30 15:47:06 +0900678 int a5_encryption;
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100679 int neci;
Harald Welte648b6ce2009-12-14 09:00:24 +0100680 int send_mm_info;
Harald Weltebc814502009-12-19 21:41:52 +0100681 struct {
682 int active;
Harald Weltef7c28b02009-12-21 13:30:17 +0100683 /* Window RXLEV averaging */
684 unsigned int win_rxlev_avg; /* number of SACCH frames */
685 /* Window RXQUAL averaging */
686 unsigned int win_rxqual_avg; /* number of SACCH frames */
687 /* Window RXLEV neighbouring cells averaging */
688 unsigned int win_rxlev_avg_neigh; /* number of SACCH frames */
689
690 /* how often should we check for power budget HO */
691 unsigned int pwr_interval; /* SACCH frames */
692 /* how much better does a neighbor cell have to be ? */
693 unsigned int pwr_hysteresis; /* dBm */
694 /* maximum distacne before we try a handover */
695 unsigned int max_distance; /* TA values */
Harald Weltebc814502009-12-19 21:41:52 +0100696 } handover;
Harald Welte52b1f982008-12-23 20:25:15 +0000697
Harald Welte24ff6ee2009-12-22 00:41:05 +0100698 struct gsmnet_stats stats;
699
Harald Welte4bfdfe72009-06-10 23:11:52 +0800700 /* layer 4 */
Harald Welte29b64e92010-12-23 01:07:46 +0100701 int (*mncc_recv) (struct gsm_network *net, struct msgb *msg);
Harald Welte4bfdfe72009-06-10 23:11:52 +0800702 struct llist_head upqueue;
703 struct llist_head trans_list;
Holger Hans Peter Freytherabcddf12010-06-14 18:20:15 +0800704 struct bsc_api *bsc_api;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800705
Harald Welte52b1f982008-12-23 20:25:15 +0000706 unsigned int num_bts;
Harald Weltee441d9c2009-06-21 16:17:15 +0200707 struct llist_head bts_list;
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100708
709 /* timer values */
710 int T3101;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100711 int T3103;
712 int T3105;
713 int T3107;
714 int T3109;
715 int T3111;
716 int T3113;
717 int T3115;
718 int T3117;
719 int T3119;
Harald Welte2862dca2010-12-23 14:39:29 +0100720 int T3122;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100721 int T3141;
Harald Welteeab84a12009-12-13 10:53:12 +0100722
723 /* Radio Resource Location Protocol (TS 04.31) */
724 struct {
725 enum rrlp_mode mode;
726 } rrlp;
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +0800727
728 /* enable the DTXu and DTXd for this network */
729 int dtx_enabled;
730
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +0800731 enum gsm_chan_t ctype_by_chreq[16];
732
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800733 /* Use a TCH for handling requests of type paging any */
734 int pag_any_tch;
735
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +0800736 /* MSC data in case we are a true BSC */
737 struct osmo_msc_data *msc_data;
Holger Hans Peter Freyther8cc59032010-11-14 21:09:08 +0100738 int hardcoded_rtp_payload;
Holger Hans Peter Freytherdaee5ca2010-12-22 12:34:39 +0100739
740 /* subscriber related features */
741 int keep_subscr;
Holger Hans Peter Freyther11b28f92010-12-24 13:48:27 +0100742 struct gsm_sms_queue *sms_queue;
Harald Welte52b1f982008-12-23 20:25:15 +0000743};
744
Harald Welte7e310b12009-03-30 20:56:32 +0000745#define SMS_HDR_SIZE 128
746#define SMS_TEXT_SIZE 256
747struct gsm_sms {
Harald Welted409be72009-11-07 00:06:19 +0900748 unsigned long long id;
Harald Welte7e310b12009-03-30 20:56:32 +0000749 struct gsm_subscriber *sender;
750 struct gsm_subscriber *receiver;
751
Harald Welteb9c758b2009-07-05 14:02:46 +0200752 unsigned long validity_minutes;
Harald Welte76042182009-08-08 16:03:15 +0200753 u_int8_t reply_path_req;
754 u_int8_t status_rep_req;
755 u_int8_t ud_hdr_ind;
756 u_int8_t protocol_id;
757 u_int8_t data_coding_scheme;
758 u_int8_t msg_ref;
759 char dest_addr[20+1]; /* DA LV is 12 bytes max, i.e. 10 bytes
760 * BCD == 20 bytes string */
761 u_int8_t user_data_len;
762 u_int8_t user_data[SMS_TEXT_SIZE];
Harald Weltef3efc592009-07-27 20:11:35 +0200763
Harald Welte7e310b12009-03-30 20:56:32 +0000764 char text[SMS_TEXT_SIZE];
765};
766
Harald Welte3606cc52009-12-05 15:13:22 +0530767
Harald Weltee441d9c2009-06-21 16:17:15 +0200768struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_code,
Harald Welte29b64e92010-12-23 01:07:46 +0100769 int (*mncc_recv)(struct gsm_network *, struct msgb *));
Harald Weltee441d9c2009-06-21 16:17:15 +0200770struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
771 u_int8_t tsc, u_int8_t bsic);
772struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
Harald Welte39315c42010-01-10 18:01:52 +0100773int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
Harald Weltee441d9c2009-06-21 16:17:15 +0200774
775struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
Harald Welte84874c92009-12-14 22:33:02 +0100776
777/* Get reference to a neighbor cell on a given BCCH ARFCN */
Harald Welte0b121032009-12-15 00:21:31 +0100778struct gsm_bts *gsm_bts_neighbor(const struct gsm_bts *bts,
779 u_int16_t arfcn, u_int8_t bsic);
Harald Welte84874c92009-12-14 22:33:02 +0100780
Harald Weltee441d9c2009-06-21 16:17:15 +0200781struct gsm_bts_trx *gsm_bts_trx_num(struct gsm_bts *bts, int num);
Harald Welte8470bf22008-12-25 23:28:35 +0000782
Harald Weltea72c98e2009-01-04 16:10:38 +0000783const char *gsm_pchan_name(enum gsm_phys_chan_config c);
Harald Welte65da9122009-08-07 00:32:22 +0200784enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
Harald Welte (local)ccd88452009-12-27 18:05:25 +0100785const char *gsm_lchant_name(enum gsm_chan_t c);
Harald Weltea72c98e2009-01-04 16:10:38 +0000786const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte (local)d48f4eb2009-12-28 23:14:22 +0100787char *gsm_trx_name(struct gsm_bts_trx *trx);
Harald Welte23a68632009-02-19 17:06:42 +0000788char *gsm_ts_name(struct gsm_bts_trx_ts *ts);
Harald Welte (local)19ef62a2009-12-27 18:16:36 +0100789char *gsm_lchan_name(struct gsm_lchan *lchan);
Harald Welte1887f9d2009-12-29 10:52:38 +0100790const char *gsm_lchans_name(enum gsm_lchan_state s);
Harald Weltea72c98e2009-01-04 16:10:38 +0000791
Harald Weltecd06bfb2009-02-10 17:33:56 +0000792void set_ts_e1link(struct gsm_bts_trx_ts *ts, u_int8_t e1_nr,
793 u_int8_t e1_ts, u_int8_t e1_ts_ss);
Harald Welte1d014a52009-08-08 15:38:29 +0200794enum gsm_bts_type parse_btstype(const char *arg);
Holger Hans Peter Freyther2dceae62009-06-12 17:39:38 +0200795const char *btstype2str(enum gsm_bts_type type);
Harald Welte6e670aa2010-01-07 20:44:32 +0100796struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr);
Harald Weltebe991492009-05-23 13:56:40 +0000797struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac,
798 struct gsm_bts *start_bts);
Harald Welte32201c12009-03-10 12:15:10 +0000799
Andreas Eversberg8226fa72009-06-29 15:19:38 +0200800extern void *tall_bsc_ctx;
Harald Weltef88c8a02009-12-20 13:48:15 +0100801extern int ipacc_rtp_direct;
Harald Welte2cf161b2009-06-20 22:36:41 +0200802
Harald Welte32201c12009-03-10 12:15:10 +0000803static inline int is_ipaccess_bts(struct gsm_bts *bts)
804{
805 switch (bts->type) {
Mike Habene2d82272009-10-02 12:19:34 +0100806 case GSM_BTS_TYPE_NANOBTS:
Harald Welte32201c12009-03-10 12:15:10 +0000807 return 1;
808 default:
809 break;
810 }
811 return 0;
812}
813
Harald Welte5b570672009-08-10 10:08:01 +0200814static inline int is_siemens_bts(struct gsm_bts *bts)
815{
816 switch (bts->type) {
817 case GSM_BTS_TYPE_BS11:
818 return 1;
819 default:
820 break;
821 }
822
823 return 0;
824}
825
Harald Welte (local)69de3972009-08-12 14:42:23 +0200826
827enum gsm_auth_policy gsm_auth_policy_parse(const char *arg);
828const char *gsm_auth_policy_name(enum gsm_auth_policy policy);
829
Harald Welteeab84a12009-12-13 10:53:12 +0100830enum rrlp_mode rrlp_mode_parse(const char *arg);
831const char *rrlp_mode_name(enum rrlp_mode mode);
832
Harald Welte4511d892010-04-18 15:51:20 +0200833enum bts_gprs_mode bts_gprs_mode_parse(const char *arg);
834const char *bts_gprs_mode_name(enum bts_gprs_mode mode);
835
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +0100836void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked);
837
Harald Welte97a282b2010-03-14 15:37:43 +0800838int gsm48_ra_id_by_bts(u_int8_t *buf, struct gsm_bts *bts);
839void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
Harald Welted12b0fd2009-12-15 21:36:05 +0100840struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan);
841
Harald Weltef3d8e922010-06-14 22:44:42 +0200842int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat);
843int gsm_bts_has_feature(struct gsm_bts *bts, enum gsm_bts_features feat);
Harald Weltefbda4e12010-03-04 11:04:52 +0100844int gsm_bts_model_register(struct gsm_bts_model *model);
845
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800846struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan);
847void subscr_con_free(struct gsm_subscriber_connection *conn);
848
Harald Welte52b1f982008-12-23 20:25:15 +0000849#endif