blob: 65646f57322fa3c627669ae3fa52f9e1d0f79471 [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001#ifndef _GSM_DATA_H
2#define _GSM_DATA_H
3
4#include <sys/types.h>
5
Harald Welte255539c2008-12-28 02:26:27 +00006#include <openbsc/timer.h>
7
Harald Welte8470bf22008-12-25 23:28:35 +00008#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
9
Harald Welte52b1f982008-12-23 20:25:15 +000010#define GSM_MAX_BTS 8
11#define BTS_MAX_TRX 8
Harald Welte85770c72009-01-18 17:47:32 +000012#define TRX_NR_TS 8
Harald Welte8470bf22008-12-25 23:28:35 +000013#define TS_MAX_LCHAN 8
Harald Welte52b1f982008-12-23 20:25:15 +000014
15#define HARDCODED_ARFCN 123
16
Holger Freytherc6ea9db2008-12-30 19:18:21 +000017/*
18 * Use the channel. As side effect the lchannel recycle timer
19 * will be started.
20 */
21#define LCHAN_RELEASE_TIMEOUT 4, 0
22#define use_lchan(lchan) \
23 do { lchan->use_count++; \
24 schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0);
25
26#define put_lchan(lchan) \
27 do { lchan->use_count--; } while(0);
28
Harald Welte52b1f982008-12-23 20:25:15 +000029/* communications link with a BTS */
30struct gsm_bts_link {
31 struct gsm_bts *bts;
32};
33
Harald Weltea3d04382008-12-27 17:02:56 +000034enum gsm_call_type {
35 GSM_CT_NONE,
36 GSM_CT_MO,
37 GSM_CT_MT,
38};
39
40enum gsm_call_state {
41 GSM_CSTATE_NULL,
42 GSM_CSTATE_INITIATED,
43 GSM_CSTATE_ACTIVE,
44 GSM_CSTATE_RELEASE_REQ,
45};
46
47/* One end of a call */
48struct gsm_call {
49 enum gsm_call_type type;
50 enum gsm_call_state state;
51 u_int8_t transaction_id; /* 10.3.2 */
52
53 /* the 'local' subscriber */
54 struct gsm_subscriber *subscr;
55};
56
57
Harald Welte8470bf22008-12-25 23:28:35 +000058enum gsm_phys_chan_config {
59 GSM_PCHAN_NONE,
60 GSM_PCHAN_CCCH,
61 GSM_PCHAN_CCCH_SDCCH4,
62 GSM_PCHAN_TCH_F,
63 GSM_PCHAN_TCH_H,
64 GSM_PCHAN_SDCCH8_SACCH8C,
65 GSM_PCHAN_UNKNOWN,
66};
67
68enum gsm_chan_t {
69 GSM_LCHAN_NONE,
70 GSM_LCHAN_SDCCH,
71 GSM_LCHAN_TCH_F,
72 GSM_LCHAN_TCH_H,
73 GSM_LCHAN_UNKNOWN,
74};
75
Harald Weltee14a57c2008-12-29 04:08:28 +000076
77/* Channel Request reason */
78enum gsm_chreq_reason_t {
79 GSM_CHREQ_REASON_EMERG,
80 GSM_CHREQ_REASON_PAG,
81 GSM_CHREQ_REASON_CALL,
82 GSM_CHREQ_REASON_LOCATION_UPD,
83 GSM_CHREQ_REASON_OTHER,
84};
85
Holger Freyther73487a22008-12-31 18:53:57 +000086/*
87 * LOCATION UPDATING REQUEST state
88 *
89 * Our current operation is:
90 * - Get imei/tmsi
91 * - Accept/Reject according to global policy
92 */
93struct gsm_loc_updating_operation {
94 struct timer_list updating_timer;
95 int waiting_for_imsi : 1;
96 int waiting_for_imei : 1;
97};
98
Harald Welte8470bf22008-12-25 23:28:35 +000099struct gsm_lchan {
100 /* The TS that we're part of */
101 struct gsm_bts_trx_ts *ts;
102 /* The logical subslot number in the TS */
103 u_int8_t nr;
104 /* The lotical channel type */
105 enum gsm_chan_t type;
106 /* To whom we are allocated at the moment */
107 struct gsm_subscriber *subscr;
Holger Freytherc6ea9db2008-12-30 19:18:21 +0000108
109 /* Timer started to release the channel */
110 struct timer_list release_timer;
Harald Weltea3d04382008-12-27 17:02:56 +0000111
112 /* local end of a call, if any */
113 struct gsm_call call;
Holger Freyther3186bf22008-12-29 06:23:49 +0000114
115 /* temporary user data, to be removed... and merged into gsm_call */
116 void *user_data;
Holger Freytherb7193e42008-12-29 17:44:08 +0000117
Holger Freyther73487a22008-12-31 18:53:57 +0000118 /*
119 * Operations that have a state and might be pending
120 */
121 struct gsm_loc_updating_operation *loc_operation;
122
Holger Freytherb7193e42008-12-29 17:44:08 +0000123 /* use count. how many users use this channel */
124 unsigned int use_count;
Harald Welte8470bf22008-12-25 23:28:35 +0000125};
126
Harald Welte85770c72009-01-18 17:47:32 +0000127struct gsm_e1_subslot {
128 /* Number of E1 link */
129 u_int8_t e1_nr;
130 /* Number of E1 TS inside E1 link */
131 u_int8_t e1_ts;
132 /* Sub-slot within the E1 TS, 0xff if full TS */
133 u_int8_t e1_ts_ss;
134};
135
Harald Welte52b1f982008-12-23 20:25:15 +0000136#define BTS_TRX_F_ACTIVATED 0x0001
137/* One Timeslot in a TRX */
138struct gsm_bts_trx_ts {
139 struct gsm_bts_trx *trx;
140 /* number of this timeslot at the TRX */
141 u_int8_t nr;
142
Harald Welte8470bf22008-12-25 23:28:35 +0000143 enum gsm_phys_chan_config pchan;
144
Harald Welte52b1f982008-12-23 20:25:15 +0000145 unsigned int flags;
Harald Welte8470bf22008-12-25 23:28:35 +0000146
Harald Welte85770c72009-01-18 17:47:32 +0000147 /* To which E1 subslot are we connected */
148 struct gsm_e1_subslot e1_link;
149
Harald Welte8470bf22008-12-25 23:28:35 +0000150 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +0000151};
152
153/* One TRX in a BTS */
154struct gsm_bts_trx {
155 struct gsm_bts *bts;
156 /* number of this TRX in the BTS */
157 u_int8_t nr;
158
159 u_int16_t arfcn;
Harald Welte85770c72009-01-18 17:47:32 +0000160 struct gsm_bts_trx_ts ts[TRX_NR_TS];
Harald Welte52b1f982008-12-23 20:25:15 +0000161};
162
Harald Welte978cb422009-01-18 17:57:27 +0000163enum gsm_bts_type {
164 GSM_BTS_TYPE_UNKNOWN,
165 GSM_BTS_TYPE_BS11,
166};
167
Harald Welte52b1f982008-12-23 20:25:15 +0000168/* One BTS */
169struct gsm_bts {
170 struct gsm_network *network;
171 /* number of ths BTS in network */
172 u_int8_t nr;
173 /* location area code of this BTS */
174 u_int8_t location_area_code;
Harald Welte978cb422009-01-18 17:57:27 +0000175 /* type of BTS */
176 enum gsm_bts_type type;
Harald Welte52b1f982008-12-23 20:25:15 +0000177
178 /* Abis network management O&M handle */
179 struct abis_nm_h *nmh;
Harald Welte978cb422009-01-18 17:57:27 +0000180
Harald Welte52b1f982008-12-23 20:25:15 +0000181 /* number of this BTS on given E1 link */
182 u_int8_t bts_nr;
183
184 /* CCCH is on C0 */
185 struct gsm_bts_trx *c0;
186 /* transceivers */
187 int num_trx;
188 struct gsm_bts_trx trx[BTS_MAX_TRX+1];
189};
190
Harald Welte52b1f982008-12-23 20:25:15 +0000191struct gsm_network {
192 /* global parameters */
Harald Welteb84e2f42008-12-28 23:42:04 +0000193 u_int16_t country_code;
194 u_int16_t network_code;
Harald Weltec6ba9c22008-12-30 18:01:02 +0000195 char *name_long;
196 char *name_short;
Harald Welte52b1f982008-12-23 20:25:15 +0000197
198 unsigned int num_bts;
199 /* private lists */
200 struct gsm_bts bts[GSM_MAX_BTS+1];
Harald Welte52b1f982008-12-23 20:25:15 +0000201};
202
Harald Welteb84e2f42008-12-28 23:42:04 +0000203struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code,
204 u_int16_t network_code);
Harald Welte8470bf22008-12-25 23:28:35 +0000205
Harald Weltea72c98e2009-01-04 16:10:38 +0000206const char *gsm_pchan_name(enum gsm_phys_chan_config c);
207const char *gsm_lchan_name(enum gsm_chan_t c);
208const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
209
Harald Weltead384642008-12-26 10:20:07 +0000210enum gsm_e1_event {
211 EVT_E1_NONE,
212 EVT_E1_OML_UP,
213 EVT_E1_RSL_UP,
214 EVT_E1_OML_DN,
215 EVT_E1_RSL_DN,
216};
217
Harald Welte52b1f982008-12-23 20:25:15 +0000218#endif