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 | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 6 | enum gsm_band { |
| 7 | GSM_BAND_400, |
| 8 | GSM_BAND_850, |
| 9 | GSM_BAND_900, |
| 10 | GSM_BAND_1800, |
| 11 | GSM_BAND_1900, |
| 12 | }; |
| 13 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 14 | enum gsm_phys_chan_config { |
| 15 | GSM_PCHAN_NONE, |
| 16 | GSM_PCHAN_CCCH, |
| 17 | GSM_PCHAN_CCCH_SDCCH4, |
| 18 | GSM_PCHAN_TCH_F, |
| 19 | GSM_PCHAN_TCH_H, |
| 20 | GSM_PCHAN_SDCCH8_SACCH8C, |
| 21 | GSM_PCHAN_UNKNOWN, |
| 22 | }; |
| 23 | |
| 24 | enum gsm_chan_t { |
| 25 | GSM_LCHAN_NONE, |
| 26 | GSM_LCHAN_SDCCH, |
| 27 | GSM_LCHAN_TCH_F, |
| 28 | GSM_LCHAN_TCH_H, |
| 29 | GSM_LCHAN_UNKNOWN, |
| 30 | }; |
| 31 | |
| 32 | |
| 33 | /* Channel Request reason */ |
| 34 | enum gsm_chreq_reason_t { |
| 35 | GSM_CHREQ_REASON_EMERG, |
| 36 | GSM_CHREQ_REASON_PAG, |
| 37 | GSM_CHREQ_REASON_CALL, |
| 38 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 39 | GSM_CHREQ_REASON_OTHER, |
| 40 | }; |
| 41 | |
Harald Welte | 255539c | 2008-12-28 02:26:27 +0000 | [diff] [blame] | 42 | #include <openbsc/timer.h> |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 43 | #include <openbsc/gsm_04_08.h> |
Harald Welte | 9943c5b | 2009-07-29 15:41:29 +0200 | [diff] [blame] | 44 | #include <openbsc/abis_rsl.h> |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 45 | #include <openbsc/mncc.h> |
Harald Welte | 93e9d17 | 2009-06-20 19:04:31 +0200 | [diff] [blame] | 46 | #include <openbsc/tlv.h> |
Harald Welte | 255539c | 2008-12-28 02:26:27 +0000 | [diff] [blame] | 47 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 48 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| 49 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 50 | #define TRX_NR_TS 8 |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 51 | #define TS_MAX_LCHAN 8 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 52 | |
| 53 | #define HARDCODED_ARFCN 123 |
Harald Welte | 02b0e09 | 2009-02-28 13:11:07 +0000 | [diff] [blame] | 54 | #define HARDCODED_TSC 7 |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 55 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 56 | |
Harald Welte | 63589be | 2009-08-06 17:38:10 +0200 | [diff] [blame] | 57 | /* for multi-drop config */ |
| 58 | #define HARDCODED_BTS0_TS 1 |
| 59 | #define HARDCODED_BTS1_TS 6 |
| 60 | #define HARDCODED_BTS2_TS 11 |
| 61 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 62 | enum gsm_hooks { |
| 63 | GSM_HOOK_NM_SWLOAD, |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 64 | GSM_HOOK_RR_PAGING, |
| 65 | }; |
| 66 | |
| 67 | enum gsm_paging_event { |
| 68 | GSM_PAGING_SUCCEEDED, |
| 69 | GSM_PAGING_EXPIRED, |
Holger Freyther | 85a7b36 | 2009-04-18 13:48:55 +0200 | [diff] [blame] | 70 | GSM_PAGING_OOM, |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | struct msgb; |
| 74 | typedef int gsm_cbfn(unsigned int hooknum, |
| 75 | unsigned int event, |
| 76 | struct msgb *msg, |
| 77 | void *data, void *param); |
| 78 | |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 79 | /* |
| 80 | * Use the channel. As side effect the lchannel recycle timer |
| 81 | * will be started. |
| 82 | */ |
Harald Welte | b9c758b | 2009-07-05 14:02:46 +0200 | [diff] [blame] | 83 | #define LCHAN_RELEASE_TIMEOUT 20, 0 |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 84 | #define use_lchan(lchan) \ |
| 85 | do { lchan->use_count++; \ |
Holger Freyther | 4f584c3 | 2009-06-02 02:55:07 +0000 | [diff] [blame] | 86 | DEBUGP(DCC, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) increases usage to: %d\n", \ |
| 87 | lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr, \ |
| 88 | lchan->nr, lchan->use_count); \ |
Harald Welte | ff117a8 | 2009-05-23 05:22:08 +0000 | [diff] [blame] | 89 | bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0); |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 90 | |
| 91 | #define put_lchan(lchan) \ |
Holger Freyther | 4f584c3 | 2009-06-02 02:55:07 +0000 | [diff] [blame] | 92 | do { lchan->use_count--; \ |
| 93 | DEBUGP(DCC, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) decreases usage to: %d\n", \ |
| 94 | lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr, \ |
| 95 | lchan->nr, lchan->use_count); \ |
| 96 | } while(0); |
| 97 | |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 98 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 99 | /* communications link with a BTS */ |
| 100 | struct gsm_bts_link { |
| 101 | struct gsm_bts *bts; |
| 102 | }; |
| 103 | |
Harald Welte | 49f48b8 | 2009-02-17 15:29:33 +0000 | [diff] [blame] | 104 | struct gsm_lchan; |
| 105 | struct gsm_subscriber; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 106 | struct gsm_mncc; |
Harald Welte | 805f644 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 107 | struct rtp_socket; |
Harald Welte | 49f48b8 | 2009-02-17 15:29:33 +0000 | [diff] [blame] | 108 | |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 109 | /* Network Management State */ |
| 110 | struct gsm_nm_state { |
| 111 | u_int8_t operational; |
| 112 | u_int8_t administrative; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 113 | u_int8_t availability; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 114 | }; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 115 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 116 | /* |
| 117 | * LOCATION UPDATING REQUEST state |
| 118 | * |
| 119 | * Our current operation is: |
| 120 | * - Get imei/tmsi |
| 121 | * - Accept/Reject according to global policy |
| 122 | */ |
| 123 | struct gsm_loc_updating_operation { |
| 124 | struct timer_list updating_timer; |
| 125 | int waiting_for_imsi : 1; |
| 126 | int waiting_for_imei : 1; |
| 127 | }; |
| 128 | |
Harald Welte | 08d91a5 | 2009-08-30 15:37:11 +0900 | [diff] [blame] | 129 | #define MAX_A5_KEY_LEN (128/8) |
| 130 | #define RSL_ENC_ALG_A5(x) (x+1) |
| 131 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 132 | struct gsm_lchan { |
| 133 | /* The TS that we're part of */ |
| 134 | struct gsm_bts_trx_ts *ts; |
| 135 | /* The logical subslot number in the TS */ |
| 136 | u_int8_t nr; |
Harald Welte | 45b407a | 2009-05-23 15:51:12 +0000 | [diff] [blame] | 137 | /* The logical channel type */ |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 138 | enum gsm_chan_t type; |
Harald Welte | 9943c5b | 2009-07-29 15:41:29 +0200 | [diff] [blame] | 139 | /* RSL channel mode */ |
| 140 | enum rsl_cmod_spd rsl_cmode; |
Harald Welte | 45b407a | 2009-05-23 15:51:12 +0000 | [diff] [blame] | 141 | /* If TCH, traffic channel mode */ |
Harald Welte | 9943c5b | 2009-07-29 15:41:29 +0200 | [diff] [blame] | 142 | enum gsm48_chan_mode tch_mode; |
Harald Welte | d4c9bf3 | 2009-02-15 16:56:18 +0000 | [diff] [blame] | 143 | /* Power levels for MS and BTS */ |
| 144 | u_int8_t bs_power; |
| 145 | u_int8_t ms_power; |
Harald Welte | 08d91a5 | 2009-08-30 15:37:11 +0900 | [diff] [blame] | 146 | /* Encryption information */ |
| 147 | struct { |
| 148 | u_int8_t alg_id; |
| 149 | u_int8_t key_len; |
| 150 | u_int8_t key[MAX_A5_KEY_LEN]; |
| 151 | } encr; |
Harald Welte | d4c9bf3 | 2009-02-15 16:56:18 +0000 | [diff] [blame] | 152 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 153 | /* To whom we are allocated at the moment */ |
| 154 | struct gsm_subscriber *subscr; |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 155 | |
| 156 | /* Timer started to release the channel */ |
| 157 | struct timer_list release_timer; |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 158 | |
Harald Welte | b7e8116 | 2009-08-10 00:26:10 +0200 | [diff] [blame] | 159 | struct timer_list T3101; |
| 160 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 161 | /* |
| 162 | * Operations that have a state and might be pending |
| 163 | */ |
| 164 | struct gsm_loc_updating_operation *loc_operation; |
| 165 | |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 166 | /* use count. how many users use this channel */ |
| 167 | unsigned int use_count; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 168 | }; |
| 169 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 170 | struct gsm_e1_subslot { |
| 171 | /* Number of E1 link */ |
| 172 | u_int8_t e1_nr; |
| 173 | /* Number of E1 TS inside E1 link */ |
| 174 | u_int8_t e1_ts; |
| 175 | /* Sub-slot within the E1 TS, 0xff if full TS */ |
| 176 | u_int8_t e1_ts_ss; |
| 177 | }; |
| 178 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 179 | #define BTS_TRX_F_ACTIVATED 0x0001 |
| 180 | /* One Timeslot in a TRX */ |
| 181 | struct gsm_bts_trx_ts { |
| 182 | struct gsm_bts_trx *trx; |
| 183 | /* number of this timeslot at the TRX */ |
| 184 | u_int8_t nr; |
| 185 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 186 | enum gsm_phys_chan_config pchan; |
| 187 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 188 | unsigned int flags; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 189 | struct gsm_nm_state nm_state; |
Harald Welte | 93e9d17 | 2009-06-20 19:04:31 +0200 | [diff] [blame] | 190 | struct tlv_parsed nm_attr; |
Harald Welte | 39c7deb | 2009-08-09 21:49:48 +0200 | [diff] [blame] | 191 | u_int8_t nm_chan_comb; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 192 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 193 | /* To which E1 subslot are we connected */ |
| 194 | struct gsm_e1_subslot e1_link; |
Harald Welte | 7509926 | 2009-02-16 21:12:08 +0000 | [diff] [blame] | 195 | struct { |
| 196 | u_int32_t bound_ip; |
| 197 | u_int16_t bound_port; |
Harald Welte | 2085554 | 2009-07-12 09:50:35 +0200 | [diff] [blame] | 198 | u_int8_t rtp_payload2; |
| 199 | u_int16_t conn_id; |
Harald Welte | 805f644 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 200 | struct rtp_socket *rtp_socket; |
Harald Welte | 7509926 | 2009-02-16 21:12:08 +0000 | [diff] [blame] | 201 | } abis_ip; |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 202 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 203 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | /* One TRX in a BTS */ |
| 207 | struct gsm_bts_trx { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 208 | /* list header in bts->trx_list */ |
| 209 | struct llist_head list; |
| 210 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 211 | struct gsm_bts *bts; |
| 212 | /* number of this TRX in the BTS */ |
| 213 | u_int8_t nr; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 214 | /* how do we talk RSL with this TRX? */ |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 215 | struct gsm_e1_subslot rsl_e1_link; |
| 216 | u_int8_t rsl_tei; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 217 | struct e1inp_sign_link *rsl_link; |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 218 | |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 219 | struct gsm_nm_state nm_state; |
Harald Welte | 93e9d17 | 2009-06-20 19:04:31 +0200 | [diff] [blame] | 220 | struct tlv_parsed nm_attr; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 221 | struct { |
| 222 | struct gsm_nm_state nm_state; |
| 223 | } bb_transc; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 224 | |
| 225 | u_int16_t arfcn; |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 226 | int nominal_power; /* in dBm */ |
| 227 | unsigned int max_power_red; /* in actual dB */ |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 228 | |
| 229 | union { |
| 230 | struct { |
| 231 | struct { |
| 232 | struct gsm_nm_state nm_state; |
| 233 | } bbsig; |
| 234 | struct { |
| 235 | struct gsm_nm_state nm_state; |
| 236 | } pa; |
| 237 | } bs11; |
| 238 | }; |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 239 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 240 | }; |
| 241 | |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 242 | enum gsm_bts_type { |
| 243 | GSM_BTS_TYPE_UNKNOWN, |
| 244 | GSM_BTS_TYPE_BS11, |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 245 | GSM_BTS_TYPE_NANOBTS_900, |
| 246 | GSM_BTS_TYPE_NANOBTS_1800, |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 247 | }; |
| 248 | |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 249 | /** |
| 250 | * A pending paging request |
| 251 | */ |
| 252 | struct gsm_paging_request { |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 253 | /* list_head for list of all paging requests */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 254 | struct llist_head entry; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 255 | /* the subscriber which we're paging. Later gsm_paging_request |
| 256 | * should probably become a part of the gsm_subscriber struct? */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 257 | struct gsm_subscriber *subscr; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 258 | /* back-pointer to the BTS on which we are paging */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 259 | struct gsm_bts *bts; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 260 | /* what kind of channel type do we ask the MS to establish */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 261 | int chan_type; |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 262 | |
| 263 | /* Timer 3113: how long do we try to page? */ |
| 264 | struct timer_list T3113; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 265 | |
| 266 | /* callback to be called in case paging completes */ |
| 267 | gsm_cbfn *cbfn; |
| 268 | void *cbfn_param; |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 269 | }; |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 270 | #define T3113_VALUE 60, 0 |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 271 | |
| 272 | /* |
| 273 | * This keeps track of the paging status of one BTS. It |
| 274 | * includes a number of pending requests, a back pointer |
| 275 | * to the gsm_bts, a timer and some more state. |
| 276 | */ |
| 277 | struct gsm_bts_paging_state { |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 278 | /* pending requests */ |
| 279 | struct llist_head pending_requests; |
| 280 | struct gsm_paging_request *last_request; |
| 281 | struct gsm_bts *bts; |
| 282 | |
Harald Welte | 75a1fa8 | 2009-02-17 01:39:41 +0000 | [diff] [blame] | 283 | struct timer_list work_timer; |
| 284 | |
Holger Freyther | 392209c | 2009-02-10 00:06:19 +0000 | [diff] [blame] | 285 | /* load */ |
| 286 | u_int16_t available_slots; |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 287 | }; |
| 288 | |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 289 | struct gsm_envabtse { |
| 290 | struct gsm_nm_state nm_state; |
| 291 | }; |
| 292 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 293 | /* One BTS */ |
| 294 | struct gsm_bts { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 295 | /* list header in net->bts_list */ |
| 296 | struct llist_head list; |
| 297 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 298 | struct gsm_network *network; |
| 299 | /* number of ths BTS in network */ |
| 300 | u_int8_t nr; |
Holger Hans Peter Freyther | c4a49e3 | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 301 | /* Cell Identity */ |
| 302 | u_int16_t cell_identity; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 303 | /* location area code of this BTS */ |
Holger Hans Peter Freyther | 0b7f4b3 | 2009-09-29 14:02:33 +0200 | [diff] [blame^] | 304 | u_int16_t location_area_code; |
Harald Welte | 02b0e09 | 2009-02-28 13:11:07 +0000 | [diff] [blame] | 305 | /* Training Sequence Code */ |
| 306 | u_int8_t tsc; |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 307 | /* Base Station Identification Code (BSIC) */ |
| 308 | u_int8_t bsic; |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 309 | /* type of BTS */ |
| 310 | enum gsm_bts_type type; |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 311 | enum gsm_band band; |
Harald Welte | fc0d952 | 2009-08-10 13:46:55 +0200 | [diff] [blame] | 312 | /* should the channel allocator allocate channels from high TRX to TRX0, |
| 313 | * rather than starting from TRX0 and go upwards? */ |
| 314 | int chan_alloc_reverse; |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 315 | int cell_barred; |
Harald Welte (local) | 0e451d0 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 316 | /* maximum Tx power that the MS is permitted to use in this cell */ |
| 317 | int ms_max_power; |
Harald Welte | fc0d952 | 2009-08-10 13:46:55 +0200 | [diff] [blame] | 318 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 319 | /* how do we talk OML with this TRX? */ |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 320 | struct gsm_e1_subslot oml_e1_link; |
| 321 | u_int8_t oml_tei; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 322 | struct e1inp_sign_link *oml_link; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 323 | |
| 324 | /* Abis network management O&M handle */ |
| 325 | struct abis_nm_h *nmh; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 326 | struct gsm_nm_state nm_state; |
Harald Welte | 93e9d17 | 2009-06-20 19:04:31 +0200 | [diff] [blame] | 327 | struct tlv_parsed nm_attr; |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 328 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 329 | /* number of this BTS on given E1 link */ |
| 330 | u_int8_t bts_nr; |
| 331 | |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 332 | struct gsm48_control_channel_descr chan_desc; |
| 333 | |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 334 | /* paging state and control */ |
| 335 | struct gsm_bts_paging_state paging; |
| 336 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 337 | /* CCCH is on C0 */ |
| 338 | struct gsm_bts_trx *c0; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 339 | |
| 340 | struct { |
| 341 | struct gsm_nm_state nm_state; |
| 342 | } site_mgr; |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 343 | |
| 344 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 345 | union { |
| 346 | struct { |
| 347 | u_int16_t site_id; |
| 348 | u_int16_t bts_id; |
| 349 | } ip_access; |
| 350 | struct { |
| 351 | struct { |
| 352 | struct gsm_nm_state nm_state; |
| 353 | } cclk; |
| 354 | struct { |
| 355 | struct gsm_nm_state nm_state; |
| 356 | } rack; |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 357 | struct gsm_envabtse envabtse[4]; |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 358 | } bs11; |
| 359 | }; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 360 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 361 | /* transceivers */ |
| 362 | int num_trx; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 363 | struct llist_head trx_list; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 364 | }; |
| 365 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 366 | enum gsm_auth_policy { |
| 367 | GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */ |
| 368 | GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */ |
| 369 | GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */ |
| 370 | }; |
| 371 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 372 | struct gsm_network { |
| 373 | /* global parameters */ |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 374 | u_int16_t country_code; |
| 375 | u_int16_t network_code; |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 376 | char *name_long; |
| 377 | char *name_short; |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 378 | enum gsm_auth_policy auth_policy; |
Harald Welte | 4381cfe | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 379 | int a5_encryption; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 380 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 381 | /* layer 4 */ |
| 382 | int (*mncc_recv) (struct gsm_network *net, int msg_type, void *arg); |
| 383 | struct llist_head upqueue; |
| 384 | struct llist_head trans_list; |
| 385 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 386 | unsigned int num_bts; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 387 | struct llist_head bts_list; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 388 | }; |
| 389 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 390 | #define SMS_HDR_SIZE 128 |
| 391 | #define SMS_TEXT_SIZE 256 |
| 392 | struct gsm_sms { |
| 393 | u_int64_t id; |
| 394 | struct gsm_subscriber *sender; |
| 395 | struct gsm_subscriber *receiver; |
| 396 | |
Harald Welte | b9c758b | 2009-07-05 14:02:46 +0200 | [diff] [blame] | 397 | unsigned long validity_minutes; |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 398 | u_int8_t reply_path_req; |
| 399 | u_int8_t status_rep_req; |
| 400 | u_int8_t ud_hdr_ind; |
| 401 | u_int8_t protocol_id; |
| 402 | u_int8_t data_coding_scheme; |
| 403 | u_int8_t msg_ref; |
| 404 | char dest_addr[20+1]; /* DA LV is 12 bytes max, i.e. 10 bytes |
| 405 | * BCD == 20 bytes string */ |
| 406 | u_int8_t user_data_len; |
| 407 | u_int8_t user_data[SMS_TEXT_SIZE]; |
Harald Welte | f3efc59 | 2009-07-27 20:11:35 +0200 | [diff] [blame] | 408 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 409 | char text[SMS_TEXT_SIZE]; |
| 410 | }; |
| 411 | |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 412 | struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_code, |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 413 | int (*mncc_recv)(struct gsm_network *, int, void *)); |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 414 | struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type, |
| 415 | u_int8_t tsc, u_int8_t bsic); |
| 416 | struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts); |
| 417 | |
| 418 | struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num); |
| 419 | struct gsm_bts_trx *gsm_bts_trx_num(struct gsm_bts *bts, int num); |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 420 | |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 421 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
Harald Welte | 65da912 | 2009-08-07 00:32:22 +0200 | [diff] [blame] | 422 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 423 | const char *gsm_lchan_name(enum gsm_chan_t c); |
| 424 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
Harald Welte | 23a6863 | 2009-02-19 17:06:42 +0000 | [diff] [blame] | 425 | char *gsm_ts_name(struct gsm_bts_trx_ts *ts); |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 426 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 427 | enum gsm_e1_event { |
| 428 | EVT_E1_NONE, |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 429 | EVT_E1_TEI_UP, |
| 430 | EVT_E1_TEI_DN, |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 431 | }; |
| 432 | |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 433 | void set_ts_e1link(struct gsm_bts_trx_ts *ts, u_int8_t e1_nr, |
| 434 | u_int8_t e1_ts, u_int8_t e1_ts_ss); |
Harald Welte | 1d014a5 | 2009-08-08 15:38:29 +0200 | [diff] [blame] | 435 | enum gsm_bts_type parse_btstype(const char *arg); |
Holger Hans Peter Freyther | 2dceae6 | 2009-06-12 17:39:38 +0200 | [diff] [blame] | 436 | const char *btstype2str(enum gsm_bts_type type); |
Harald Welte | be99149 | 2009-05-23 13:56:40 +0000 | [diff] [blame] | 437 | struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac, |
| 438 | struct gsm_bts *start_bts); |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 439 | |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 440 | char *gsm_band_name(enum gsm_band band); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 441 | enum gsm_band gsm_band_parse(const char *mhz); |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 442 | |
Andreas Eversberg | 8226fa7 | 2009-06-29 15:19:38 +0200 | [diff] [blame] | 443 | extern void *tall_bsc_ctx; |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 444 | |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 445 | static inline int is_ipaccess_bts(struct gsm_bts *bts) |
| 446 | { |
| 447 | switch (bts->type) { |
| 448 | case GSM_BTS_TYPE_NANOBTS_900: |
| 449 | case GSM_BTS_TYPE_NANOBTS_1800: |
| 450 | return 1; |
| 451 | default: |
| 452 | break; |
| 453 | } |
| 454 | return 0; |
| 455 | } |
| 456 | |
Harald Welte | 5b57067 | 2009-08-10 10:08:01 +0200 | [diff] [blame] | 457 | static inline int is_siemens_bts(struct gsm_bts *bts) |
| 458 | { |
| 459 | switch (bts->type) { |
| 460 | case GSM_BTS_TYPE_BS11: |
| 461 | return 1; |
| 462 | default: |
| 463 | break; |
| 464 | } |
| 465 | |
| 466 | return 0; |
| 467 | } |
| 468 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 469 | |
| 470 | enum gsm_auth_policy gsm_auth_policy_parse(const char *arg); |
| 471 | const char *gsm_auth_policy_name(enum gsm_auth_policy policy); |
| 472 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 473 | #endif |