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 | |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 16 | /* |
| 17 | * Use the channel. As side effect the lchannel recycle timer |
| 18 | * will be started. |
| 19 | */ |
| 20 | #define LCHAN_RELEASE_TIMEOUT 4, 0 |
| 21 | #define use_lchan(lchan) \ |
| 22 | do { lchan->use_count++; \ |
| 23 | schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0); |
| 24 | |
| 25 | #define put_lchan(lchan) \ |
| 26 | do { lchan->use_count--; } while(0); |
| 27 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 28 | /* communications link with a BTS */ |
| 29 | struct gsm_bts_link { |
| 30 | struct gsm_bts *bts; |
| 31 | }; |
| 32 | |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 33 | enum gsm_call_type { |
| 34 | GSM_CT_NONE, |
| 35 | GSM_CT_MO, |
| 36 | GSM_CT_MT, |
| 37 | }; |
| 38 | |
| 39 | enum gsm_call_state { |
| 40 | GSM_CSTATE_NULL, |
| 41 | GSM_CSTATE_INITIATED, |
| 42 | GSM_CSTATE_ACTIVE, |
| 43 | GSM_CSTATE_RELEASE_REQ, |
| 44 | }; |
| 45 | |
| 46 | /* One end of a call */ |
| 47 | struct gsm_call { |
| 48 | enum gsm_call_type type; |
| 49 | enum gsm_call_state state; |
| 50 | u_int8_t transaction_id; /* 10.3.2 */ |
| 51 | |
| 52 | /* the 'local' subscriber */ |
| 53 | struct gsm_subscriber *subscr; |
| 54 | }; |
| 55 | |
| 56 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 57 | enum gsm_phys_chan_config { |
| 58 | GSM_PCHAN_NONE, |
| 59 | GSM_PCHAN_CCCH, |
| 60 | GSM_PCHAN_CCCH_SDCCH4, |
| 61 | GSM_PCHAN_TCH_F, |
| 62 | GSM_PCHAN_TCH_H, |
| 63 | GSM_PCHAN_SDCCH8_SACCH8C, |
| 64 | GSM_PCHAN_UNKNOWN, |
| 65 | }; |
| 66 | |
| 67 | enum gsm_chan_t { |
| 68 | GSM_LCHAN_NONE, |
| 69 | GSM_LCHAN_SDCCH, |
| 70 | GSM_LCHAN_TCH_F, |
| 71 | GSM_LCHAN_TCH_H, |
| 72 | GSM_LCHAN_UNKNOWN, |
| 73 | }; |
| 74 | |
Harald Welte | e14a57c | 2008-12-29 04:08:28 +0000 | [diff] [blame] | 75 | |
| 76 | /* Channel Request reason */ |
| 77 | enum gsm_chreq_reason_t { |
| 78 | GSM_CHREQ_REASON_EMERG, |
| 79 | GSM_CHREQ_REASON_PAG, |
| 80 | GSM_CHREQ_REASON_CALL, |
| 81 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 82 | GSM_CHREQ_REASON_OTHER, |
| 83 | }; |
| 84 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 85 | /* |
| 86 | * LOCATION UPDATING REQUEST state |
| 87 | * |
| 88 | * Our current operation is: |
| 89 | * - Get imei/tmsi |
| 90 | * - Accept/Reject according to global policy |
| 91 | */ |
| 92 | struct gsm_loc_updating_operation { |
| 93 | struct timer_list updating_timer; |
| 94 | int waiting_for_imsi : 1; |
| 95 | int waiting_for_imei : 1; |
| 96 | }; |
| 97 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 98 | struct gsm_lchan { |
| 99 | /* The TS that we're part of */ |
| 100 | struct gsm_bts_trx_ts *ts; |
| 101 | /* The logical subslot number in the TS */ |
| 102 | u_int8_t nr; |
| 103 | /* The lotical channel type */ |
| 104 | enum gsm_chan_t type; |
| 105 | /* To whom we are allocated at the moment */ |
| 106 | struct gsm_subscriber *subscr; |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 107 | |
| 108 | /* Timer started to release the channel */ |
| 109 | struct timer_list release_timer; |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 110 | |
| 111 | /* local end of a call, if any */ |
| 112 | struct gsm_call call; |
Holger Freyther | 3186bf2 | 2008-12-29 06:23:49 +0000 | [diff] [blame] | 113 | |
| 114 | /* temporary user data, to be removed... and merged into gsm_call */ |
| 115 | void *user_data; |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 116 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 117 | /* |
| 118 | * Operations that have a state and might be pending |
| 119 | */ |
| 120 | struct gsm_loc_updating_operation *loc_operation; |
| 121 | |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 122 | /* use count. how many users use this channel */ |
| 123 | unsigned int use_count; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 124 | }; |
| 125 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 126 | #define BTS_TRX_F_ACTIVATED 0x0001 |
| 127 | /* One Timeslot in a TRX */ |
| 128 | struct gsm_bts_trx_ts { |
| 129 | struct gsm_bts_trx *trx; |
| 130 | /* number of this timeslot at the TRX */ |
| 131 | u_int8_t nr; |
| 132 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 133 | enum gsm_phys_chan_config pchan; |
| 134 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 135 | unsigned int flags; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 136 | |
| 137 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | /* One TRX in a BTS */ |
| 141 | struct gsm_bts_trx { |
| 142 | struct gsm_bts *bts; |
| 143 | /* number of this TRX in the BTS */ |
| 144 | u_int8_t nr; |
| 145 | |
| 146 | u_int16_t arfcn; |
| 147 | struct gsm_bts_trx_ts ts[8]; |
| 148 | }; |
| 149 | |
| 150 | /* One BTS */ |
| 151 | struct gsm_bts { |
| 152 | struct gsm_network *network; |
| 153 | /* number of ths BTS in network */ |
| 154 | u_int8_t nr; |
| 155 | /* location area code of this BTS */ |
| 156 | u_int8_t location_area_code; |
| 157 | |
| 158 | /* Abis network management O&M handle */ |
| 159 | struct abis_nm_h *nmh; |
| 160 | /* number of this BTS on given E1 link */ |
| 161 | u_int8_t bts_nr; |
| 162 | |
| 163 | /* CCCH is on C0 */ |
| 164 | struct gsm_bts_trx *c0; |
| 165 | /* transceivers */ |
| 166 | int num_trx; |
| 167 | struct gsm_bts_trx trx[BTS_MAX_TRX+1]; |
| 168 | }; |
| 169 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 170 | struct gsm_network { |
| 171 | /* global parameters */ |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 172 | u_int16_t country_code; |
| 173 | u_int16_t network_code; |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 174 | char *name_long; |
| 175 | char *name_short; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 176 | |
| 177 | unsigned int num_bts; |
| 178 | /* private lists */ |
| 179 | struct gsm_bts bts[GSM_MAX_BTS+1]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 180 | }; |
| 181 | |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 182 | struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code, |
| 183 | u_int16_t network_code); |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 184 | |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 185 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
| 186 | const char *gsm_lchan_name(enum gsm_chan_t c); |
| 187 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
| 188 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 189 | enum gsm_e1_event { |
| 190 | EVT_E1_NONE, |
| 191 | EVT_E1_OML_UP, |
| 192 | EVT_E1_RSL_UP, |
| 193 | EVT_E1_OML_DN, |
| 194 | EVT_E1_RSL_DN, |
| 195 | }; |
| 196 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 197 | #endif |