blob: 8a04b7b9e159d95a43f99f325600cb4baddbbf58 [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 Welte8470bf22008-12-25 23:28:35 +00006#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
7
Harald Welte52b1f982008-12-23 20:25:15 +00008#define GSM_MAX_BTS 8
9#define BTS_MAX_TRX 8
Harald Welte8470bf22008-12-25 23:28:35 +000010#define TS_MAX_LCHAN 8
Harald Welte52b1f982008-12-23 20:25:15 +000011
12#define HARDCODED_ARFCN 123
13
14/* communications link with a BTS */
15struct gsm_bts_link {
16 struct gsm_bts *bts;
17};
18
Harald Weltea3d04382008-12-27 17:02:56 +000019enum gsm_call_type {
20 GSM_CT_NONE,
21 GSM_CT_MO,
22 GSM_CT_MT,
23};
24
25enum gsm_call_state {
26 GSM_CSTATE_NULL,
27 GSM_CSTATE_INITIATED,
28 GSM_CSTATE_ACTIVE,
29 GSM_CSTATE_RELEASE_REQ,
30};
31
32/* One end of a call */
33struct gsm_call {
34 enum gsm_call_type type;
35 enum gsm_call_state state;
36 u_int8_t transaction_id; /* 10.3.2 */
37
38 /* the 'local' subscriber */
39 struct gsm_subscriber *subscr;
40};
41
42
Harald Welte8470bf22008-12-25 23:28:35 +000043enum gsm_phys_chan_config {
44 GSM_PCHAN_NONE,
45 GSM_PCHAN_CCCH,
46 GSM_PCHAN_CCCH_SDCCH4,
47 GSM_PCHAN_TCH_F,
48 GSM_PCHAN_TCH_H,
49 GSM_PCHAN_SDCCH8_SACCH8C,
50 GSM_PCHAN_UNKNOWN,
51};
52
53enum gsm_chan_t {
54 GSM_LCHAN_NONE,
55 GSM_LCHAN_SDCCH,
56 GSM_LCHAN_TCH_F,
57 GSM_LCHAN_TCH_H,
58 GSM_LCHAN_UNKNOWN,
59};
60
61struct gsm_lchan {
62 /* The TS that we're part of */
63 struct gsm_bts_trx_ts *ts;
64 /* The logical subslot number in the TS */
65 u_int8_t nr;
66 /* The lotical channel type */
67 enum gsm_chan_t type;
68 /* To whom we are allocated at the moment */
69 struct gsm_subscriber *subscr;
Harald Weltea3d04382008-12-27 17:02:56 +000070
71 /* local end of a call, if any */
72 struct gsm_call call;
Harald Welte8470bf22008-12-25 23:28:35 +000073};
74
Harald Welte52b1f982008-12-23 20:25:15 +000075#define BTS_TRX_F_ACTIVATED 0x0001
76/* One Timeslot in a TRX */
77struct gsm_bts_trx_ts {
78 struct gsm_bts_trx *trx;
79 /* number of this timeslot at the TRX */
80 u_int8_t nr;
81
Harald Welte8470bf22008-12-25 23:28:35 +000082 enum gsm_phys_chan_config pchan;
83
Harald Welte52b1f982008-12-23 20:25:15 +000084 unsigned int flags;
Harald Welte8470bf22008-12-25 23:28:35 +000085
86 struct gsm_lchan lchan[TS_MAX_LCHAN];
Harald Welte52b1f982008-12-23 20:25:15 +000087};
88
89/* One TRX in a BTS */
90struct gsm_bts_trx {
91 struct gsm_bts *bts;
92 /* number of this TRX in the BTS */
93 u_int8_t nr;
94
95 u_int16_t arfcn;
96 struct gsm_bts_trx_ts ts[8];
97};
98
99/* One BTS */
100struct gsm_bts {
101 struct gsm_network *network;
102 /* number of ths BTS in network */
103 u_int8_t nr;
104 /* location area code of this BTS */
105 u_int8_t location_area_code;
106
107 /* Abis network management O&M handle */
108 struct abis_nm_h *nmh;
109 /* number of this BTS on given E1 link */
110 u_int8_t bts_nr;
111
112 /* CCCH is on C0 */
113 struct gsm_bts_trx *c0;
114 /* transceivers */
115 int num_trx;
116 struct gsm_bts_trx trx[BTS_MAX_TRX+1];
117};
118
119struct gsm_ms {
120 unsigned long imei;
121};
122
123struct gsm_network {
124 /* global parameters */
125 u_int8_t country_code;
126 u_int8_t network_code;
127
128 unsigned int num_bts;
129 /* private lists */
130 struct gsm_bts bts[GSM_MAX_BTS+1];
131 struct gsm_ms *ms;
132 struct gsm_subscriber *subscriber;
133};
134
135struct gsm_network *gsm_network_init(unsigned int num_bts, u_int8_t country_code,
136 u_int8_t network_code);
Harald Welte8470bf22008-12-25 23:28:35 +0000137
Harald Weltead384642008-12-26 10:20:07 +0000138enum gsm_e1_event {
139 EVT_E1_NONE,
140 EVT_E1_OML_UP,
141 EVT_E1_RSL_UP,
142 EVT_E1_OML_DN,
143 EVT_E1_RSL_DN,
144};
145
Harald Welte52b1f982008-12-23 20:25:15 +0000146#endif