blob: d9dd2d4b800114b7b253a1fdb365c6e6b9bdee3b [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001#ifndef _GSM_DATA_H
2#define _GSM_DATA_H
3
Harald Weltef142c972011-05-24 13:25:38 +02004#include <stdint.h>
Maxddee01f2016-05-24 14:23:27 +02005#include <regex.h>
6#include <sys/types.h>
Maxe6052c42016-06-30 10:25:49 +02007#include <stdbool.h>
Harald Weltef142c972011-05-24 13:25:38 +02008
9#include <osmocom/core/timer.h>
Alexander Couzens20423ea2016-07-12 15:42:02 +020010#include <osmocom/core/rate_ctr.h>
Harald Welte6be350c2011-05-25 13:10:08 +020011#include <osmocom/core/select.h>
Alexander Couzens20423ea2016-07-12 15:42:02 +020012#include <osmocom/core/stats.h>
13
Harald Welte121e9a42016-04-20 13:13:19 +020014#include <osmocom/crypt/auth.h>
Harald Weltef142c972011-05-24 13:25:38 +020015
Neels Hofmeyrc0164792017-09-04 15:15:32 +020016#include <osmocom/bsc/common.h>
17#include <osmocom/bsc/rest_octets.h>
18#include <osmocom/bsc/common_cs.h>
Harald Welteb96be392011-05-25 12:33:33 +020019
Harald Welte74b8cdb2018-01-15 19:26:06 +010020struct mgcp_client_conf;
21struct mgcp_client;
22struct mgcp_ctx;
Philipp Maier39f62bb2017-04-09 12:32:51 +020023
Holger Hans Peter Freytherd7b22c62013-04-29 09:11:02 +020024/** annotations for msgb ownership */
25#define __uses
26
Holger Hans Peter Freyther6f615552010-11-15 20:50:42 +010027#define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3]
28
Neels Hofmeyr6d804b12017-02-18 22:20:46 +010029struct bsc_subscr;
Neels Hofmeyr7b656882017-07-09 22:09:18 +020030struct gprs_ra_id;
Holger Hans Peter Freyther694c82d2011-10-26 18:37:09 +020031
Holger Hans Peter Freyther9c595b72010-06-15 11:20:52 +080032#define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3]
33
Neels Hofmeyr0e5d8072017-01-10 00:49:56 +010034#define tmsi_from_string(str) strtoul(str, NULL, 10)
35
Max70fdd242017-06-15 15:10:53 +020036/* 3-bit long values */
37#define EARFCN_PRIO_INVALID 8
38#define EARFCN_MEAS_BW_INVALID 8
39/* 5-bit long values */
40#define EARFCN_QRXLV_INVALID 32
41#define EARFCN_THRESH_LOW_INVALID 32
42
Harald Welte8e1e3ee2009-02-01 13:32:45 +000043struct msgb;
44typedef int gsm_cbfn(unsigned int hooknum,
45 unsigned int event,
46 struct msgb *msg,
47 void *data, void *param);
48
Harald Weltef7c28b02009-12-21 13:30:17 +010049/* Maximum number of neighbor cells whose average we track */
50#define MAX_NEIGH_MEAS 10
51/* Maximum size of the averaging window for neighbor cells */
52#define MAX_WIN_NEIGH_AVG 10
Andreas Eversberg98692032013-06-23 10:44:34 +020053/* Maximum number of report history we store */
54#define MAX_MEAS_REP 10
Harald Weltef7c28b02009-12-21 13:30:17 +010055
56/* processed neighbor measurements for one cell */
57struct neigh_meas_proc {
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020058 uint16_t arfcn;
59 uint8_t bsic;
60 uint8_t rxlev[MAX_WIN_NEIGH_AVG];
Harald Weltef7c28b02009-12-21 13:30:17 +010061 unsigned int rxlev_cnt;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020062 uint8_t last_seen_nr;
Harald Weltef7c28b02009-12-21 13:30:17 +010063};
64
Harald Weltea43e0b42016-06-19 18:06:02 +020065struct gsm_classmark {
66 bool classmark1_set;
67 struct gsm48_classmark1 classmark1;
68 uint8_t classmark2_len;
69 uint8_t classmark2[3];
70 uint8_t classmark3_len;
71 uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */
72};
73
Andreas Eversberg084b4212013-05-30 14:12:48 +020074/* penalty timers for handover */
75struct ho_penalty_timer {
76 struct llist_head entry;
77 uint8_t bts;
78 time_t timeout;
79};
80
Neels Hofmeyr378a4922016-05-09 21:07:43 +020081/* active radio connection of a mobile subscriber */
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +010082struct gsm_subscriber_connection {
Harald Weltea43e0b42016-06-19 18:06:02 +020083 /* global linked list of subscriber_connections */
Holger Hans Peter Freyther79f763f2010-09-16 00:53:37 +080084 struct llist_head entry;
85
Harald Weltea43e0b42016-06-19 18:06:02 +020086 /* libbsc subscriber information (if available) */
Neels Hofmeyr6d804b12017-02-18 22:20:46 +010087 struct bsc_subscr *bsub;
88
Harald Welte4a8ebc82017-12-18 18:34:41 +010089 /* SCCP connection associatd with this subscriber_connection */
90 struct osmo_bsc_sccp_con *sccp_con;
Holger Hans Peter Freyther2f9d1ef2010-09-16 20:14:01 +080091
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +010092 /* back pointers */
Neels Hofmeyr5e0b0a62016-05-09 22:33:01 +020093 struct gsm_network *network;
94
Harald Welte4a8ebc82017-12-18 18:34:41 +010095 /* the primary / currently active lchan to the BTS/subscriber */
96 struct gsm_lchan *lchan;
97 /* the future/allocated but not yet used lchan during HANDOVER */
98 struct gsm_lchan *ho_lchan;
99 /* a short-hand pointer to the BTS currently serving the subscriber,
100 * points to gsm_subscriber_connection.lchan->ts->trx->bts */
101 struct gsm_bts *bts;
Holger Hans Peter Freyther77cd95d2010-11-14 16:19:48 +0100102
Harald Welte4a8ebc82017-12-18 18:34:41 +0100103 /* timer for assignment handling */
104 struct osmo_timer_list T10;
105 /* the future allocated but not yet used lchan during ASSIGNMENT */
106 struct gsm_lchan *secondary_lchan;
Holger Hans Peter Freyther77cd95d2010-11-14 16:19:48 +0100107
Harald Welte4a8ebc82017-12-18 18:34:41 +0100108 /* buffer/cache for classmark of the ME of the subscriber */
Harald Weltea43e0b42016-06-19 18:06:02 +0200109 struct gsm_classmark classmark;
Andreas Eversberg935e5d72013-06-17 11:58:30 +0200110
111 /* Cache DTAP messages during handover/assignment (msgb_enqueue()/msgb_dequeue())*/
112 struct llist_head ho_dtap_cache;
113 unsigned int ho_dtap_cache_len;
Andreas Eversberg084b4212013-05-30 14:12:48 +0200114
115 /* penalty timers for handover */
116 struct llist_head ho_penalty_timers;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100117};
118
Harald Welte148ee362017-12-18 18:44:25 +0100119static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection *conn) {
120 return conn->bts;
121}
122
Harald Weltef142c972011-05-24 13:25:38 +0200123
Harald Welte6be350c2011-05-25 13:10:08 +0200124#include "gsm_data_shared.h"
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100125
Harald Welted82101e2017-12-09 23:07:38 +0100126enum {
127 BTS_CTR_CHREQ_TOTAL,
128 BTS_CTR_CHREQ_NO_CHANNEL,
129 BTS_CTR_CHAN_RF_FAIL,
130 BTS_CTR_CHAN_RLL_ERR,
131 BTS_CTR_BTS_OML_FAIL,
132 BTS_CTR_BTS_RSL_FAIL,
133 BTS_CTR_CODEC_AMR_F,
134 BTS_CTR_CODEC_AMR_H,
135 BTS_CTR_CODEC_EFR,
136 BTS_CTR_CODEC_V1_FR,
137 BTS_CTR_CODEC_V1_HR,
Harald Weltecf9d4312017-12-13 23:17:16 +0100138 BTS_CTR_PAGING_ATTEMPTED,
139 BTS_CTR_PAGING_ALREADY,
140 BTS_CTR_PAGING_RESPONDED,
141 BTS_CTR_PAGING_EXPIRED,
Harald Welte4f598922017-12-14 13:47:02 +0100142 BTS_CTR_CHAN_ACT_TOTAL,
143 BTS_CTR_CHAN_ACT_NACK,
Harald Welte62d9cb02017-12-14 14:00:26 +0100144 BTS_CTR_RSL_UNKNOWN,
Harald Welte581398a2017-12-14 14:29:44 +0100145 BTS_CTR_RSL_IPA_NACK,
Harald Welte00d64fd2017-12-14 14:34:16 +0100146 BTS_CTR_MODE_MODIFY_NACK,
Harald Welted82101e2017-12-09 23:07:38 +0100147};
148
149static const struct rate_ctr_desc bts_ctr_description[] = {
Harald Welte1ef46d92017-12-09 23:10:46 +0100150 [BTS_CTR_CHREQ_TOTAL] = {"chreq:total", "Received channel requests."},
151 [BTS_CTR_CHREQ_NO_CHANNEL] = {"chreq:no_channel", "Sent to MS no channel available."},
152 [BTS_CTR_CHAN_RF_FAIL] = {"chan:rf_fail", "Received a RF failure indication from BTS."},
153 [BTS_CTR_CHAN_RLL_ERR] = {"chan:rll_err", "Received a RLL failure with T200 cause from BTS."},
Harald Welted82101e2017-12-09 23:07:38 +0100154 [BTS_CTR_BTS_OML_FAIL] = {"oml_fail", "Received a TEI down on a OML link."},
155 [BTS_CTR_BTS_RSL_FAIL] = {"rsl_fail", "Received a TEI down on a OML link."},
Harald Welte1ef46d92017-12-09 23:10:46 +0100156 [BTS_CTR_CODEC_AMR_F] = {"codec:amr_f", "Count the usage of AMR/F codec by channel mode requested."},
157 [BTS_CTR_CODEC_AMR_H] = {"codec:amr_h", "Count the usage of AMR/H codec by channel mode requested."},
158 [BTS_CTR_CODEC_EFR] = {"codec:efr", "Count the usage of EFR codec by channel mode requested."},
159 [BTS_CTR_CODEC_V1_FR] = {"codec:fr", "Count the usage of FR codec by channel mode requested."},
160 [BTS_CTR_CODEC_V1_HR] = {"codec:hr", "Count the usage of HR codec by channel mode requested."},
Harald Weltecf9d4312017-12-13 23:17:16 +0100161
162 [BTS_CTR_PAGING_ATTEMPTED] = {"paging:attempted", "Paging attempts for a subscriber."},
163 [BTS_CTR_PAGING_ALREADY] = {"paging:already", "Paging attempts ignored as subsciber was already being paged."},
164 [BTS_CTR_PAGING_RESPONDED] = {"paging:responded", "Paging attempts with successful paging response."},
165 [BTS_CTR_PAGING_EXPIRED] = {"paging:expired", "Paging Request expired because of timeout T3113."},
Harald Welte4f598922017-12-14 13:47:02 +0100166 [BTS_CTR_CHAN_ACT_TOTAL] = {"chan_act:total", "Total number of Channel Activations."},
167 [BTS_CTR_CHAN_ACT_NACK] = {"chan_act:nack", "Number of Channel Activations that the BTS NACKed"},
Harald Welte62d9cb02017-12-14 14:00:26 +0100168 [BTS_CTR_RSL_UNKNOWN] = {"rsl:unknown", "Number of unknown/unsupported RSL messages received from BTS"},
Harald Welte581398a2017-12-14 14:29:44 +0100169 [BTS_CTR_RSL_IPA_NACK] = {"rsl:ipa_nack", "Number of IPA (RTP/dyn-PDCH) related NACKs received from BTS"},
Harald Welte00d64fd2017-12-14 14:34:16 +0100170 [BTS_CTR_MODE_MODIFY_NACK] = {"chan:mode_modify_nack", "Number of Channel Mode Modify NACKs received from BTS"},
Harald Welted82101e2017-12-09 23:07:38 +0100171};
172
173static const struct rate_ctr_group_desc bts_ctrg_desc = {
174 "bts",
175 "base transceiver station",
176 OSMO_STATS_CLASS_GLOBAL,
177 ARRAY_SIZE(bts_ctr_description),
178 bts_ctr_description,
179};
Holger Hans Peter Freyther5ba6f482009-10-28 14:23:39 +0100180
Alexander Couzens20423ea2016-07-12 15:42:02 +0200181enum {
Alexander Couzensb847a212016-08-02 11:34:11 +0200182 BSC_CTR_HANDOVER_ATTEMPTED,
183 BSC_CTR_HANDOVER_NO_CHANNEL,
184 BSC_CTR_HANDOVER_TIMEOUT,
185 BSC_CTR_HANDOVER_COMPLETED,
186 BSC_CTR_HANDOVER_FAILED,
187 BSC_CTR_PAGING_ATTEMPTED,
188 BSC_CTR_PAGING_DETACHED,
Harald Weltecf9d4312017-12-13 23:17:16 +0100189 BSC_CTR_PAGING_RESPONDED,
Alexander Couzensb847a212016-08-02 11:34:11 +0200190};
191
192static const struct rate_ctr_desc bsc_ctr_description[] = {
Harald Welte1ef46d92017-12-09 23:10:46 +0100193 [BSC_CTR_HANDOVER_ATTEMPTED] = {"handover:attempted", "Received handover attempts."},
194 [BSC_CTR_HANDOVER_NO_CHANNEL] = {"handover:no_channel", "Sent no channel available responses."},
195 [BSC_CTR_HANDOVER_TIMEOUT] = {"handover:timeout", "Count the amount of timeouts of timer T3103."},
196 [BSC_CTR_HANDOVER_COMPLETED] = {"handover:completed", "Received handover completed."},
197 [BSC_CTR_HANDOVER_FAILED] = {"handover:failed", "Receive HO FAIL messages."},
Harald Weltecf9d4312017-12-13 23:17:16 +0100198
199 [BSC_CTR_PAGING_ATTEMPTED] = {"paging:attempted", "Paging attempts for a subscriber."},
Harald Welte1ef46d92017-12-09 23:10:46 +0100200 [BSC_CTR_PAGING_DETACHED] = {"paging:detached", "Counts the amount of paging attempts which couldn't sent out any paging request because no responsible bts found."},
Harald Weltecf9d4312017-12-13 23:17:16 +0100201 [BSC_CTR_PAGING_RESPONDED] = {"paging:responded", "Paging attempts with successful response."},
Alexander Couzensb847a212016-08-02 11:34:11 +0200202};
203
Alexander Couzensb847a212016-08-02 11:34:11 +0200204
205
206static const struct rate_ctr_group_desc bsc_ctrg_desc = {
207 "bsc",
208 "base station controller",
209 OSMO_STATS_CLASS_GLOBAL,
210 ARRAY_SIZE(bsc_ctr_description),
211 bsc_ctr_description,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200212};
213
Harald Weltedea252d2017-12-10 19:55:18 +0100214#define GSM_T3101_DEFAULT 3 /* s */
Harald Weltea0d324b2017-07-20 01:47:39 +0200215#define GSM_T3103_DEFAULT 5 /* s */
216#define GSM_T3105_DEFAULT 100 /* ms */
217#define GSM_T3107_DEFAULT 5 /* s */
Harald Welteed23c1d2017-12-10 19:58:16 +0100218#define GSM_T3109_DEFAULT 5 /* s, must be 2s + radio_link_timeout*0.48 */
Harald Weltea0d324b2017-07-20 01:47:39 +0200219#define GSM_T3111_DEFAULT 2 /* s */
Harald Welte6e59ced2017-12-14 12:49:43 +0100220#define GSM_T3113_DEFAULT 10 /* s */
Harald Weltea0d324b2017-07-20 01:47:39 +0200221#define GSM_T3115_DEFAULT 10
222#define GSM_T3117_DEFAULT 10
223#define GSM_T3119_DEFAULT 10
Andreas Eversberg75e13a42013-02-07 11:51:16 +0100224#define GSM_T3122_DEFAULT 10
Harald Weltea0d324b2017-07-20 01:47:39 +0200225#define GSM_T3141_DEFAULT 10
Harald Welteb84ddfc2009-12-01 17:36:54 +0530226
Neels Hofmeyr73983952016-05-10 13:29:33 +0200227struct gsm_tz {
228 int override; /* if 0, use system's time zone instead. */
229 int hr; /* hour */
230 int mn; /* minute */
231 int dst; /* daylight savings */
232};
233
Harald Welte52b1f982008-12-23 20:25:15 +0000234struct gsm_network {
Neels Hofmeyrce4d88b2017-05-08 15:12:20 +0200235 /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for
236 * global settings and variables, "madly" mixing BSC and MSC stuff. Split
237 * this in e.g. struct osmo_bsc and struct osmo_msc, with the things
238 * these have in common, like country and network code, put in yet
239 * separate structs and placed as members in osmo_bsc and osmo_msc. */
240
Harald Welte52b1f982008-12-23 20:25:15 +0000241 /* global parameters */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200242 uint16_t country_code;
243 uint16_t network_code;
Harald Welte4381cfe2009-08-30 15:47:06 +0900244 int a5_encryption;
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100245 int neci;
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100246 struct handover_cfg *ho;
Harald Welte52b1f982008-12-23 20:25:15 +0000247
Alexander Couzensb847a212016-08-02 11:34:11 +0200248 struct rate_ctr_group *bsc_ctrs;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100249
Neels Hofmeyrc29505e2016-05-20 21:59:55 +0200250 /*
251 * TODO: Move the trans_list into the subscriber connection and
252 * create a pending list for MT transactions. These exist before
253 * we have a subscriber connection.
254 */
Harald Welte4bfdfe72009-06-10 23:11:52 +0800255 struct llist_head trans_list;
Holger Hans Peter Freytherabcddf12010-06-14 18:20:15 +0800256 struct bsc_api *bsc_api;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800257
Harald Welte52b1f982008-12-23 20:25:15 +0000258 unsigned int num_bts;
Harald Weltee441d9c2009-06-21 16:17:15 +0200259 struct llist_head bts_list;
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100260
261 /* timer values */
262 int T3101;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100263 int T3103;
264 int T3105;
265 int T3107;
266 int T3109;
267 int T3111;
268 int T3113;
269 int T3115;
270 int T3117;
271 int T3119;
Harald Welte2862dca2010-12-23 14:39:29 +0100272 int T3122;
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100273 int T3141;
Harald Welteeab84a12009-12-13 10:53:12 +0100274
Jan Luebbebfbdeec2012-12-27 00:27:16 +0100275 /* timer to expire old location updates */
276 struct osmo_timer_list subscr_expire_timer;
277
Alexander Couzens547c2072017-11-21 12:03:04 +0100278 enum gsm_chan_t ctype_by_chreq[_NUM_CHREQ_T];
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +0800279
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800280 /* Use a TCH for handling requests of type paging any */
281 int pag_any_tch;
282
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +0800283 /* MSC data in case we are a true BSC */
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +0200284 struct osmo_bsc_data *bsc_data;
Holger Hans Peter Freytherdaee5ca2010-12-22 12:34:39 +0100285
Daniel Willmann6fc4a982011-07-22 17:55:42 +0200286 /* control interface */
287 struct ctrl_handle *ctrl;
Neels Hofmeyr5f0c71b2016-07-23 20:15:28 +0200288
289 /* Allow or disallow TCH/F on dynamic TCH/F_TCH/H_PDCH; OS#1778 */
290 bool dyn_ts_allow_tch_f;
Neels Hofmeyrd90fa422016-05-09 21:03:12 +0200291
292 /* all active subscriber connections. */
293 struct llist_head subscr_conns;
Neels Hofmeyr73983952016-05-10 13:29:33 +0200294
295 /* if override is nonzero, this timezone data is used for all MM
296 * contexts. */
297 /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable
298 * BTS|RNC specific timezone overrides for multi-tz networks in
Neels Hofmeyrfe291de2017-02-23 21:06:12 +0100299 * OsmoMSC, this should be tied to the location area code (LAC). */
Neels Hofmeyr73983952016-05-10 13:29:33 +0200300 struct gsm_tz tz;
Neels Hofmeyr6d804b12017-02-18 22:20:46 +0100301
302 /* List of all struct bsc_subscr used in libbsc. This llist_head is
303 * allocated so that the llist_head pointer itself can serve as a
304 * talloc context (useful to not have to pass the entire gsm_network
305 * struct to the bsc_subscr_* API, and for bsc_susbscr unit tests to
306 * not require gsm_data.h). In an MSC-without-BSC environment, this
307 * pointer is NULL to indicate absence of a bsc_subscribers list. */
308 struct llist_head *bsc_subscribers;
Harald Weltea43e0b42016-06-19 18:06:02 +0200309
Neels Hofmeyrce4d88b2017-05-08 15:12:20 +0200310 /* Periodic location update default value */
311 uint8_t t3212;
Neels Hofmeyrc29505e2016-05-20 21:59:55 +0200312
313 struct {
Philipp Maier39c609b2017-09-27 15:51:34 +0200314 struct mgcp_client_conf *conf;
315 struct mgcp_client *client;
316 } mgw;
Harald Welte7e310b12009-03-30 20:56:32 +0000317};
318
Neels Hofmeyrc13e6872016-05-11 13:53:47 +0200319extern void talloc_ctx_init(void *ctx_root);
320
Harald Welte39315c42010-01-10 18:01:52 +0100321int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
Harald Weltee441d9c2009-06-21 16:17:15 +0200322
Harald Welte1d014a52009-08-08 15:38:29 +0200323enum gsm_bts_type parse_btstype(const char *arg);
Holger Hans Peter Freyther2dceae62009-06-12 17:39:38 +0200324const char *btstype2str(enum gsm_bts_type type);
Harald Weltebe991492009-05-23 13:56:40 +0000325struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac,
326 struct gsm_bts *start_bts);
Harald Welte32201c12009-03-10 12:15:10 +0000327
Andreas Eversberg8226fa72009-06-29 15:19:38 +0200328extern void *tall_bsc_ctx;
Harald Weltef88c8a02009-12-20 13:48:15 +0100329extern int ipacc_rtp_direct;
Harald Welte2cf161b2009-06-20 22:36:41 +0200330
Harald Weltef383aa12012-07-02 19:51:55 +0200331/* this actaully refers to the IPA transport, not the BTS model */
Harald Welte32201c12009-03-10 12:15:10 +0000332static inline int is_ipaccess_bts(struct gsm_bts *bts)
333{
334 switch (bts->type) {
Mike Habene2d82272009-10-02 12:19:34 +0100335 case GSM_BTS_TYPE_NANOBTS:
Maxf9685c12017-03-23 12:01:07 +0100336 case GSM_BTS_TYPE_OSMOBTS:
Harald Welte32201c12009-03-10 12:15:10 +0000337 return 1;
338 default:
339 break;
340 }
341 return 0;
342}
343
Holger Hans Peter Freyther6f6cbf72015-04-04 19:35:22 +0200344static inline int is_sysmobts_v2(struct gsm_bts *bts)
345{
346 switch (bts->type) {
Maxf9685c12017-03-23 12:01:07 +0100347 case GSM_BTS_TYPE_OSMOBTS:
Holger Hans Peter Freyther6f6cbf72015-04-04 19:35:22 +0200348 return 1;
349 default:
350 break;
351 }
352 return 0;
353}
354
Harald Welte5b570672009-08-10 10:08:01 +0200355static inline int is_siemens_bts(struct gsm_bts *bts)
356{
357 switch (bts->type) {
358 case GSM_BTS_TYPE_BS11:
359 return 1;
360 default:
361 break;
362 }
363
364 return 0;
365}
366
Andreas Eversberg7d8fa342013-12-05 13:25:06 +0100367static inline int is_nokia_bts(struct gsm_bts *bts)
368{
369 switch (bts->type) {
370 case GSM_BTS_TYPE_NOKIA_SITE:
371 return 1;
372 default:
373 break;
374 }
375
376 return 0;
377}
378
Andreas Eversbergdcf38e12013-12-05 14:37:11 +0100379static inline int is_e1_bts(struct gsm_bts *bts)
380{
381 switch (bts->type) {
382 case GSM_BTS_TYPE_BS11:
383 case GSM_BTS_TYPE_RBS2000:
384 case GSM_BTS_TYPE_NOKIA_SITE:
385 return 1;
386 default:
387 break;
388 }
389
390 return 0;
391}
392
Holger Hans Peter Freyther4e13a8f2015-01-31 22:16:00 +0100393enum bts_gprs_mode bts_gprs_mode_parse(const char *arg, int *valid);
Harald Welte4511d892010-04-18 15:51:20 +0200394const char *bts_gprs_mode_name(enum bts_gprs_mode mode);
Holger Hans Peter Freyther4e13a8f2015-01-31 22:16:00 +0100395int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode);
Harald Welte4511d892010-04-18 15:51:20 +0200396
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200397int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts);
Harald Welte97a282b2010-03-14 15:37:43 +0800398void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
Harald Welted12b0fd2009-12-15 21:36:05 +0100399
Harald Weltef3d8e922010-06-14 22:44:42 +0200400int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat);
Harald Weltefbda4e12010-03-04 11:04:52 +0100401int gsm_bts_model_register(struct gsm_bts_model *model);
402
Neels Hofmeyr42eb0142016-05-20 17:15:44 +0200403struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_lchan *lchan);
404void bsc_subscr_con_free(struct gsm_subscriber_connection *conn);
405
406struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network);
407void msc_subscr_con_free(struct gsm_subscriber_connection *conn);
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800408
Harald Welte3300c012011-06-05 13:31:33 +0200409struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net,
410 enum gsm_bts_type type,
Harald Weltea2bbc5e2015-11-20 10:43:31 +0100411 uint8_t bsic);
Harald Welte142d12d2014-12-29 17:47:08 +0100412
Harald Welte3300c012011-06-05 13:31:33 +0200413void set_ts_e1link(struct gsm_bts_trx_ts *ts, uint8_t e1_nr,
414 uint8_t e1_ts, uint8_t e1_ts_ss);
415
Maxbe356ed2017-09-07 19:10:09 +0200416void gsm_trx_lock_rf(struct gsm_bts_trx *trx, bool locked, const char *reason);
Max71d082b2017-05-30 15:03:38 +0200417bool gsm_btsmodel_has_feature(struct gsm_bts_model *model, enum gsm_bts_features feat);
Harald Welte3300c012011-06-05 13:31:33 +0200418struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr);
Holger Hans Peter Freythera49b2c02014-11-21 11:18:45 +0100419int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx);
Alexander Chemerisc36a13b2015-05-30 14:40:54 -0400420int gsm_bts_set_system_infos(struct gsm_bts *bts);
Harald Welte3300c012011-06-05 13:31:33 +0200421
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200422/* generic E1 line operations for all ISDN-based BTS. */
423extern struct e1inp_line_ops bts_isdn_e1inp_line_ops;
424
Harald Weltee555c2b2012-08-17 13:02:12 +0200425extern const struct value_string bts_type_names[_NUM_GSM_BTS_TYPE+1];
426extern const struct value_string bts_type_descs[_NUM_GSM_BTS_TYPE+1];
427
Max3d049d22017-10-09 17:12:53 +0200428char *get_model_oml_status(const struct gsm_bts *bts);
429
Max25cc4072017-10-10 14:50:35 +0200430unsigned long long bts_uptime(const struct gsm_bts *bts);
431
Holger Hans Peter Freytherf8c42192013-01-09 17:03:27 +0100432/* control interface handling */
433int bsc_base_ctrl_cmds_install(void);
434
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +0100435/* dependency handling */
436void bts_depend_mark(struct gsm_bts *bts, int dep);
437void bts_depend_clear(struct gsm_bts *bts, int dep);
438int bts_depend_check(struct gsm_bts *bts);
Holger Hans Peter Freytherf7e23c52014-12-17 15:44:32 +0100439int bts_depend_is_depedency(struct gsm_bts *base, struct gsm_bts *other);
Holger Hans Peter Freytherc22930e2014-12-17 14:46:17 +0100440
Harald Welte2f8b9d22017-06-18 11:12:13 +0300441int gsm_bts_get_radio_link_timeout(const struct gsm_bts *bts);
442void gsm_bts_set_radio_link_timeout(struct gsm_bts *bts, int value);
443
Harald Weltea43e0b42016-06-19 18:06:02 +0200444bool classmark_is_r99(struct gsm_classmark *cm);
445
Harald Welte6be350c2011-05-25 13:10:08 +0200446#endif /* _GSM_DATA_H */