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 | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 12 | #define TRX_NR_TS 8 |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 13 | #define TS_MAX_LCHAN 8 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 14 | |
| 15 | #define HARDCODED_ARFCN 123 |
| 16 | |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 17 | /* |
| 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 Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 29 | /* communications link with a BTS */ |
| 30 | struct gsm_bts_link { |
| 31 | struct gsm_bts *bts; |
| 32 | }; |
| 33 | |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 34 | enum gsm_call_type { |
| 35 | GSM_CT_NONE, |
| 36 | GSM_CT_MO, |
| 37 | GSM_CT_MT, |
| 38 | }; |
| 39 | |
| 40 | enum 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 */ |
| 48 | struct 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 Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 58 | enum 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 | |
| 68 | enum 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 Welte | e14a57c | 2008-12-29 04:08:28 +0000 | [diff] [blame] | 76 | |
| 77 | /* Channel Request reason */ |
| 78 | enum 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 Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 86 | /* |
| 87 | * LOCATION UPDATING REQUEST state |
| 88 | * |
| 89 | * Our current operation is: |
| 90 | * - Get imei/tmsi |
| 91 | * - Accept/Reject according to global policy |
| 92 | */ |
| 93 | struct 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 Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 99 | struct 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 Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 108 | |
| 109 | /* Timer started to release the channel */ |
| 110 | struct timer_list release_timer; |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 111 | |
| 112 | /* local end of a call, if any */ |
| 113 | struct gsm_call call; |
Holger Freyther | 3186bf2 | 2008-12-29 06:23:49 +0000 | [diff] [blame] | 114 | |
| 115 | /* temporary user data, to be removed... and merged into gsm_call */ |
| 116 | void *user_data; |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 117 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 118 | /* |
| 119 | * Operations that have a state and might be pending |
| 120 | */ |
| 121 | struct gsm_loc_updating_operation *loc_operation; |
| 122 | |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 123 | /* use count. how many users use this channel */ |
| 124 | unsigned int use_count; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 127 | struct 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 Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 136 | #define BTS_TRX_F_ACTIVATED 0x0001 |
| 137 | /* One Timeslot in a TRX */ |
| 138 | struct 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 Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 143 | enum gsm_phys_chan_config pchan; |
| 144 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 145 | unsigned int flags; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 146 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 147 | /* To which E1 subslot are we connected */ |
| 148 | struct gsm_e1_subslot e1_link; |
| 149 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 150 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | /* One TRX in a BTS */ |
| 154 | struct 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 Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 160 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 161 | }; |
| 162 | |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame^] | 163 | enum gsm_bts_type { |
| 164 | GSM_BTS_TYPE_UNKNOWN, |
| 165 | GSM_BTS_TYPE_BS11, |
| 166 | }; |
| 167 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 168 | /* One BTS */ |
| 169 | struct 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 Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame^] | 175 | /* type of BTS */ |
| 176 | enum gsm_bts_type type; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 177 | |
| 178 | /* Abis network management O&M handle */ |
| 179 | struct abis_nm_h *nmh; |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame^] | 180 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 181 | /* 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 Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 191 | struct gsm_network { |
| 192 | /* global parameters */ |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 193 | u_int16_t country_code; |
| 194 | u_int16_t network_code; |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 195 | char *name_long; |
| 196 | char *name_short; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 197 | |
| 198 | unsigned int num_bts; |
| 199 | /* private lists */ |
| 200 | struct gsm_bts bts[GSM_MAX_BTS+1]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 201 | }; |
| 202 | |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 203 | struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code, |
| 204 | u_int16_t network_code); |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 205 | |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 206 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
| 207 | const char *gsm_lchan_name(enum gsm_chan_t c); |
| 208 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
| 209 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 210 | enum 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 Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 218 | #endif |