Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | #ifndef _GSM_DATA_H |
| 2 | #define _GSM_DATA_H |
| 3 | |
| 4 | #include <sys/types.h> |
| 5 | |
Harald Welte | 255539c | 2008-12-28 02:26:27 +0000 | [diff] [blame] | 6 | #include <openbsc/timer.h> |
| 7 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 8 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| 9 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 10 | #define GSM_MAX_BTS 8 |
| 11 | #define BTS_MAX_TRX 8 |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 12 | #define TS_MAX_LCHAN 8 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 13 | |
| 14 | #define HARDCODED_ARFCN 123 |
| 15 | |
| 16 | /* communications link with a BTS */ |
| 17 | struct gsm_bts_link { |
| 18 | struct gsm_bts *bts; |
| 19 | }; |
| 20 | |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 21 | enum gsm_call_type { |
| 22 | GSM_CT_NONE, |
| 23 | GSM_CT_MO, |
| 24 | GSM_CT_MT, |
| 25 | }; |
| 26 | |
| 27 | enum 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 */ |
| 35 | struct 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 Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 45 | enum 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 | |
| 55 | enum 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 Welte | e14a57c | 2008-12-29 04:08:28 +0000 | [diff] [blame] | 63 | |
| 64 | /* Channel Request reason */ |
| 65 | enum 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 Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 73 | struct 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 Welte | 255539c | 2008-12-28 02:26:27 +0000 | [diff] [blame] | 82 | /* Universal timer, undefined use ;) */ |
| 83 | struct timer_list timer; |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 84 | |
| 85 | /* local end of a call, if any */ |
| 86 | struct gsm_call call; |
Holger Freyther | 3186bf2 | 2008-12-29 06:23:49 +0000 | [diff] [blame] | 87 | |
| 88 | /* temporary user data, to be removed... and merged into gsm_call */ |
| 89 | void *user_data; |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 90 | |
| 91 | /* use count. how many users use this channel */ |
| 92 | unsigned int use_count; |
| 93 | unsigned int pending_update_request : 1; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 96 | #define BTS_TRX_F_ACTIVATED 0x0001 |
| 97 | /* One Timeslot in a TRX */ |
| 98 | struct gsm_bts_trx_ts { |
| 99 | struct gsm_bts_trx *trx; |
| 100 | /* number of this timeslot at the TRX */ |
| 101 | u_int8_t nr; |
| 102 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 103 | enum gsm_phys_chan_config pchan; |
| 104 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 105 | unsigned int flags; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 106 | |
| 107 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | /* One TRX in a BTS */ |
| 111 | struct gsm_bts_trx { |
| 112 | struct gsm_bts *bts; |
| 113 | /* number of this TRX in the BTS */ |
| 114 | u_int8_t nr; |
| 115 | |
| 116 | u_int16_t arfcn; |
| 117 | struct gsm_bts_trx_ts ts[8]; |
| 118 | }; |
| 119 | |
| 120 | /* One BTS */ |
| 121 | struct gsm_bts { |
| 122 | struct gsm_network *network; |
| 123 | /* number of ths BTS in network */ |
| 124 | u_int8_t nr; |
| 125 | /* location area code of this BTS */ |
| 126 | u_int8_t location_area_code; |
| 127 | |
| 128 | /* Abis network management O&M handle */ |
| 129 | struct abis_nm_h *nmh; |
| 130 | /* number of this BTS on given E1 link */ |
| 131 | u_int8_t bts_nr; |
| 132 | |
| 133 | /* CCCH is on C0 */ |
| 134 | struct gsm_bts_trx *c0; |
| 135 | /* transceivers */ |
| 136 | int num_trx; |
| 137 | struct gsm_bts_trx trx[BTS_MAX_TRX+1]; |
| 138 | }; |
| 139 | |
| 140 | struct gsm_ms { |
| 141 | unsigned long imei; |
| 142 | }; |
| 143 | |
| 144 | struct gsm_network { |
| 145 | /* global parameters */ |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 146 | u_int16_t country_code; |
| 147 | u_int16_t network_code; |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 148 | char *name_long; |
| 149 | char *name_short; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 150 | |
| 151 | unsigned int num_bts; |
| 152 | /* private lists */ |
| 153 | struct gsm_bts bts[GSM_MAX_BTS+1]; |
| 154 | struct gsm_ms *ms; |
| 155 | struct gsm_subscriber *subscriber; |
Holger Freyther | 07cc8d8 | 2008-12-29 06:23:46 +0000 | [diff] [blame] | 156 | |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 157 | /* management of the lower layers to allow the bsc to hook into it */ |
| 158 | void (*update_request)(struct gsm_bts *, u_int32_t tmsi, int accepted); |
Holger Freyther | 3186bf2 | 2008-12-29 06:23:49 +0000 | [diff] [blame] | 159 | void (*channel_allocated)(struct gsm_lchan *bts, enum gsm_chreq_reason_t); |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 160 | void (*channel_deallocated)(struct gsm_lchan *bts); |
Holger Freyther | 88ea832 | 2008-12-29 06:23:52 +0000 | [diff] [blame] | 161 | void (*channel_response)(struct gsm_lchan *, int acked); |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 162 | void (*channel_subscriber_assigned)(struct gsm_lchan *); |
| 163 | void (*call_state_changed)(struct gsm_lchan *, enum gsm_call_state new_state); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 164 | }; |
| 165 | |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 166 | struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code, |
| 167 | u_int16_t network_code); |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 168 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 169 | enum gsm_e1_event { |
| 170 | EVT_E1_NONE, |
| 171 | EVT_E1_OML_UP, |
| 172 | EVT_E1_RSL_UP, |
| 173 | EVT_E1_OML_DN, |
| 174 | EVT_E1_RSL_DN, |
| 175 | }; |
| 176 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 177 | #endif |