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