blob: 2d0c3c53ba648ee2781cbe73ad726944460c749e [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
63struct gsm_lchan {
64 /* The TS that we're part of */
65 struct gsm_bts_trx_ts *ts;
66 /* The logical subslot number in the TS */
67 u_int8_t nr;
68 /* The lotical channel type */
69 enum gsm_chan_t type;
70 /* To whom we are allocated at the moment */
71 struct gsm_subscriber *subscr;
Harald Welte255539c2008-12-28 02:26:27 +000072 /* Universal timer, undefined use ;) */
73 struct timer_list timer;
Harald Weltea3d04382008-12-27 17:02:56 +000074
75 /* local end of a call, if any */
76 struct gsm_call call;
Harald Welte8470bf22008-12-25 23:28:35 +000077};
78
Harald Welte52b1f982008-12-23 20:25:15 +000079#define BTS_TRX_F_ACTIVATED 0x0001
80/* One Timeslot in a TRX */
81struct gsm_bts_trx_ts {
82 struct gsm_bts_trx *trx;
83 /* number of this timeslot at the TRX */
84 u_int8_t nr;
85
Harald Welte8470bf22008-12-25 23:28:35 +000086 enum gsm_phys_chan_config pchan;
87
Harald Welte52b1f982008-12-23 20:25:15 +000088 unsigned int flags;
Harald Welte8470bf22008-12-25 23:28:35 +000089
90 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +000091};
92
93/* One TRX in a BTS */
94struct gsm_bts_trx {
95 struct gsm_bts *bts;
96 /* number of this TRX in the BTS */
97 u_int8_t nr;
98
99 u_int16_t arfcn;
100 struct gsm_bts_trx_ts ts[8];
101};
102
103/* One BTS */
104struct gsm_bts {
105 struct gsm_network *network;
106 /* number of ths BTS in network */
107 u_int8_t nr;
108 /* location area code of this BTS */
109 u_int8_t location_area_code;
110
111 /* Abis network management O&M handle */
112 struct abis_nm_h *nmh;
113 /* number of this BTS on given E1 link */
114 u_int8_t bts_nr;
115
116 /* CCCH is on C0 */
117 struct gsm_bts_trx *c0;
118 /* transceivers */
119 int num_trx;
120 struct gsm_bts_trx trx[BTS_MAX_TRX+1];
121};
122
123struct gsm_ms {
124 unsigned long imei;
125};
126
127struct gsm_network {
128 /* global parameters */
129 u_int8_t country_code;
130 u_int8_t network_code;
131
132 unsigned int num_bts;
133 /* private lists */
134 struct gsm_bts bts[GSM_MAX_BTS+1];
135 struct gsm_ms *ms;
136 struct gsm_subscriber *subscriber;
137};
138
139struct gsm_network *gsm_network_init(unsigned int num_bts, u_int8_t country_code,
140 u_int8_t network_code);
Harald Welte8470bf22008-12-25 23:28:35 +0000141
Harald Weltead384642008-12-26 10:20:07 +0000142enum gsm_e1_event {
143 EVT_E1_NONE,
144 EVT_E1_OML_UP,
145 EVT_E1_RSL_UP,
146 EVT_E1_OML_DN,
147 EVT_E1_RSL_DN,
148};
149
Harald Welte52b1f982008-12-23 20:25:15 +0000150#endif