blob: 8f21524ebb234e19a1dfb296b98d0fb83cd345b4 [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 Welte8470bf22008-12-25 23:28:35 +000012#define TS_MAX_LCHAN 8
Harald Welte52b1f982008-12-23 20:25:15 +000013
14#define HARDCODED_ARFCN 123
15
16/* communications link with a BTS */
17struct gsm_bts_link {
18 struct gsm_bts *bts;
19};
20
Harald Weltea3d04382008-12-27 17:02:56 +000021enum gsm_call_type {
22 GSM_CT_NONE,
23 GSM_CT_MO,
24 GSM_CT_MT,
25};
26
27enum gsm_call_state {
28 GSM_CSTATE_NULL,
29 GSM_CSTATE_INITIATED,
30 GSM_CSTATE_ACTIVE,
31 GSM_CSTATE_RELEASE_REQ,
32};
33
34/* One end of a call */
35struct gsm_call {
36 enum gsm_call_type type;
37 enum gsm_call_state state;
38 u_int8_t transaction_id; /* 10.3.2 */
39
40 /* the 'local' subscriber */
41 struct gsm_subscriber *subscr;
42};
43
44
Harald Welte8470bf22008-12-25 23:28:35 +000045enum gsm_phys_chan_config {
46 GSM_PCHAN_NONE,
47 GSM_PCHAN_CCCH,
48 GSM_PCHAN_CCCH_SDCCH4,
49 GSM_PCHAN_TCH_F,
50 GSM_PCHAN_TCH_H,
51 GSM_PCHAN_SDCCH8_SACCH8C,
52 GSM_PCHAN_UNKNOWN,
53};
54
55enum gsm_chan_t {
56 GSM_LCHAN_NONE,
57 GSM_LCHAN_SDCCH,
58 GSM_LCHAN_TCH_F,
59 GSM_LCHAN_TCH_H,
60 GSM_LCHAN_UNKNOWN,
61};
62
Harald Weltee14a57c2008-12-29 04:08:28 +000063
64/* Channel Request reason */
65enum gsm_chreq_reason_t {
66 GSM_CHREQ_REASON_EMERG,
67 GSM_CHREQ_REASON_PAG,
68 GSM_CHREQ_REASON_CALL,
69 GSM_CHREQ_REASON_LOCATION_UPD,
70 GSM_CHREQ_REASON_OTHER,
71};
72
Harald Welte8470bf22008-12-25 23:28:35 +000073struct gsm_lchan {
74 /* The TS that we're part of */
75 struct gsm_bts_trx_ts *ts;
76 /* The logical subslot number in the TS */
77 u_int8_t nr;
78 /* The lotical channel type */
79 enum gsm_chan_t type;
80 /* To whom we are allocated at the moment */
81 struct gsm_subscriber *subscr;
Harald Welte255539c2008-12-28 02:26:27 +000082 /* Universal timer, undefined use ;) */
83 struct timer_list timer;
Harald Weltea3d04382008-12-27 17:02:56 +000084
85 /* local end of a call, if any */
86 struct gsm_call call;
Harald Welte8470bf22008-12-25 23:28:35 +000087};
88
Harald Welte52b1f982008-12-23 20:25:15 +000089#define BTS_TRX_F_ACTIVATED 0x0001
90/* One Timeslot in a TRX */
91struct gsm_bts_trx_ts {
92 struct gsm_bts_trx *trx;
93 /* number of this timeslot at the TRX */
94 u_int8_t nr;
95
Harald Welte8470bf22008-12-25 23:28:35 +000096 enum gsm_phys_chan_config pchan;
97
Harald Welte52b1f982008-12-23 20:25:15 +000098 unsigned int flags;
Harald Welte8470bf22008-12-25 23:28:35 +000099
100 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +0000101};
102
103/* One TRX in a BTS */
104struct gsm_bts_trx {
105 struct gsm_bts *bts;
106 /* number of this TRX in the BTS */
107 u_int8_t nr;
108
109 u_int16_t arfcn;
110 struct gsm_bts_trx_ts ts[8];
111};
112
113/* One BTS */
114struct gsm_bts {
115 struct gsm_network *network;
116 /* number of ths BTS in network */
117 u_int8_t nr;
118 /* location area code of this BTS */
119 u_int8_t location_area_code;
120
121 /* Abis network management O&M handle */
122 struct abis_nm_h *nmh;
123 /* number of this BTS on given E1 link */
124 u_int8_t bts_nr;
125
126 /* CCCH is on C0 */
127 struct gsm_bts_trx *c0;
128 /* transceivers */
129 int num_trx;
130 struct gsm_bts_trx trx[BTS_MAX_TRX+1];
131};
132
133struct gsm_ms {
134 unsigned long imei;
135};
136
137struct gsm_network {
138 /* global parameters */
Harald Welteb84e2f42008-12-28 23:42:04 +0000139 u_int16_t country_code;
140 u_int16_t network_code;
Harald Welte52b1f982008-12-23 20:25:15 +0000141
142 unsigned int num_bts;
143 /* private lists */
144 struct gsm_bts bts[GSM_MAX_BTS+1];
145 struct gsm_ms *ms;
146 struct gsm_subscriber *subscriber;
Holger Freyther07cc8d82008-12-29 06:23:46 +0000147
148 void (*update_request_accepted)(struct gsm_bts *, u_int32_t);
Harald Welte52b1f982008-12-23 20:25:15 +0000149};
150
Harald Welteb84e2f42008-12-28 23:42:04 +0000151struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code,
152 u_int16_t network_code);
Harald Welte8470bf22008-12-25 23:28:35 +0000153
Harald Weltead384642008-12-26 10:20:07 +0000154enum gsm_e1_event {
155 EVT_E1_NONE,
156 EVT_E1_OML_UP,
157 EVT_E1_RSL_UP,
158 EVT_E1_OML_DN,
159 EVT_E1_RSL_DN,
160};
161
Harald Welte52b1f982008-12-23 20:25:15 +0000162#endif