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 | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame^] | 6 | enum gsm_phys_chan_config { |
| 7 | GSM_PCHAN_NONE, |
| 8 | GSM_PCHAN_CCCH, |
| 9 | GSM_PCHAN_CCCH_SDCCH4, |
| 10 | GSM_PCHAN_TCH_F, |
| 11 | GSM_PCHAN_TCH_H, |
| 12 | GSM_PCHAN_SDCCH8_SACCH8C, |
| 13 | GSM_PCHAN_UNKNOWN, |
| 14 | }; |
| 15 | |
| 16 | enum gsm_chan_t { |
| 17 | GSM_LCHAN_NONE, |
| 18 | GSM_LCHAN_SDCCH, |
| 19 | GSM_LCHAN_TCH_F, |
| 20 | GSM_LCHAN_TCH_H, |
| 21 | GSM_LCHAN_UNKNOWN, |
| 22 | }; |
| 23 | |
| 24 | |
| 25 | /* Channel Request reason */ |
| 26 | enum gsm_chreq_reason_t { |
| 27 | GSM_CHREQ_REASON_EMERG, |
| 28 | GSM_CHREQ_REASON_PAG, |
| 29 | GSM_CHREQ_REASON_CALL, |
| 30 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 31 | GSM_CHREQ_REASON_OTHER, |
| 32 | }; |
| 33 | |
Harald Welte | 255539c | 2008-12-28 02:26:27 +0000 | [diff] [blame] | 34 | #include <openbsc/timer.h> |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 35 | #include <openbsc/gsm_04_08.h> |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame^] | 36 | #include <openbsc/mncc.h> |
Harald Welte | 255539c | 2008-12-28 02:26:27 +0000 | [diff] [blame] | 37 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 38 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| 39 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 40 | #define GSM_MAX_BTS 8 |
| 41 | #define BTS_MAX_TRX 8 |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 42 | #define TRX_NR_TS 8 |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 43 | #define TS_MAX_LCHAN 8 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 44 | |
| 45 | #define HARDCODED_ARFCN 123 |
Harald Welte | 02b0e09 | 2009-02-28 13:11:07 +0000 | [diff] [blame] | 46 | #define HARDCODED_TSC 7 |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 47 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 48 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 49 | enum gsm_hooks { |
| 50 | GSM_HOOK_NM_SWLOAD, |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 51 | GSM_HOOK_RR_PAGING, |
| 52 | }; |
| 53 | |
| 54 | enum gsm_paging_event { |
| 55 | GSM_PAGING_SUCCEEDED, |
| 56 | GSM_PAGING_EXPIRED, |
Holger Freyther | 85a7b36 | 2009-04-18 13:48:55 +0200 | [diff] [blame] | 57 | GSM_PAGING_OOM, |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | struct msgb; |
| 61 | typedef int gsm_cbfn(unsigned int hooknum, |
| 62 | unsigned int event, |
| 63 | struct msgb *msg, |
| 64 | void *data, void *param); |
| 65 | |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 66 | /* |
| 67 | * Use the channel. As side effect the lchannel recycle timer |
| 68 | * will be started. |
| 69 | */ |
| 70 | #define LCHAN_RELEASE_TIMEOUT 4, 0 |
| 71 | #define use_lchan(lchan) \ |
| 72 | do { lchan->use_count++; \ |
Holger Freyther | 4f584c3 | 2009-06-02 02:55:07 +0000 | [diff] [blame] | 73 | DEBUGP(DCC, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) increases usage to: %d\n", \ |
| 74 | lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr, \ |
| 75 | lchan->nr, lchan->use_count); \ |
Harald Welte | ff117a8 | 2009-05-23 05:22:08 +0000 | [diff] [blame] | 76 | bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0); |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 77 | |
| 78 | #define put_lchan(lchan) \ |
Holger Freyther | 4f584c3 | 2009-06-02 02:55:07 +0000 | [diff] [blame] | 79 | do { lchan->use_count--; \ |
| 80 | DEBUGP(DCC, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) decreases usage to: %d\n", \ |
| 81 | lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr, \ |
| 82 | lchan->nr, lchan->use_count); \ |
| 83 | } while(0); |
| 84 | |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 85 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 86 | /* communications link with a BTS */ |
| 87 | struct gsm_bts_link { |
| 88 | struct gsm_bts *bts; |
| 89 | }; |
| 90 | |
Harald Welte | 49f48b8 | 2009-02-17 15:29:33 +0000 | [diff] [blame] | 91 | struct gsm_lchan; |
| 92 | struct gsm_subscriber; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame^] | 93 | struct gsm_mncc; |
Harald Welte | 49f48b8 | 2009-02-17 15:29:33 +0000 | [diff] [blame] | 94 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame^] | 95 | /* One transaction */ |
| 96 | struct gsm_trans { |
| 97 | /* Entry in list of all transactions */ |
| 98 | struct llist_head entry; |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 99 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame^] | 100 | /* Network */ |
| 101 | struct gsm_network *network; |
Harald Welte | 49f48b8 | 2009-02-17 15:29:33 +0000 | [diff] [blame] | 102 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame^] | 103 | /* The current transaction ID */ |
| 104 | u_int8_t transaction_id; |
| 105 | |
| 106 | /* The LCHAN that we're part of */ |
| 107 | struct gsm_lchan *lchan; |
| 108 | |
| 109 | /* To whom we are allocated at the moment */ |
| 110 | struct gsm_subscriber *subscr; |
| 111 | |
| 112 | /* reference */ |
| 113 | u_int32_t callref; |
| 114 | |
| 115 | /* current call state */ |
| 116 | int state; |
| 117 | |
| 118 | /* current timer and message queue */ |
| 119 | int Tcurrent; /* current CC timer */ |
| 120 | int T308_second; /* used to send release again */ |
| 121 | struct timer_list cc_timer; |
| 122 | struct gsm_mncc cc_msg; /* stores setup/disconnect/release message */ |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 126 | /* Network Management State */ |
| 127 | struct gsm_nm_state { |
| 128 | u_int8_t operational; |
| 129 | u_int8_t administrative; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 130 | u_int8_t availability; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 131 | }; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 132 | struct gsm_attr { |
| 133 | u_int8_t len; |
| 134 | u_int8_t data[0]; |
| 135 | }; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 136 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 137 | /* |
| 138 | * LOCATION UPDATING REQUEST state |
| 139 | * |
| 140 | * Our current operation is: |
| 141 | * - Get imei/tmsi |
| 142 | * - Accept/Reject according to global policy |
| 143 | */ |
| 144 | struct gsm_loc_updating_operation { |
| 145 | struct timer_list updating_timer; |
| 146 | int waiting_for_imsi : 1; |
| 147 | int waiting_for_imei : 1; |
| 148 | }; |
| 149 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 150 | struct gsm_lchan { |
| 151 | /* The TS that we're part of */ |
| 152 | struct gsm_bts_trx_ts *ts; |
| 153 | /* The logical subslot number in the TS */ |
| 154 | u_int8_t nr; |
Harald Welte | 45b407a | 2009-05-23 15:51:12 +0000 | [diff] [blame] | 155 | /* The logical channel type */ |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 156 | enum gsm_chan_t type; |
Harald Welte | 45b407a | 2009-05-23 15:51:12 +0000 | [diff] [blame] | 157 | /* If TCH, traffic channel mode */ |
| 158 | enum gsm_chan_t tch_mode; |
Harald Welte | d4c9bf3 | 2009-02-15 16:56:18 +0000 | [diff] [blame] | 159 | /* Power levels for MS and BTS */ |
| 160 | u_int8_t bs_power; |
| 161 | u_int8_t ms_power; |
| 162 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 163 | /* To whom we are allocated at the moment */ |
| 164 | struct gsm_subscriber *subscr; |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 165 | |
| 166 | /* Timer started to release the channel */ |
| 167 | struct timer_list release_timer; |
Harald Welte | a3d0438 | 2008-12-27 17:02:56 +0000 | [diff] [blame] | 168 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 169 | /* |
| 170 | * Operations that have a state and might be pending |
| 171 | */ |
| 172 | struct gsm_loc_updating_operation *loc_operation; |
| 173 | |
Holger Freyther | b7193e4 | 2008-12-29 17:44:08 +0000 | [diff] [blame] | 174 | /* use count. how many users use this channel */ |
| 175 | unsigned int use_count; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 176 | }; |
| 177 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 178 | struct gsm_e1_subslot { |
| 179 | /* Number of E1 link */ |
| 180 | u_int8_t e1_nr; |
| 181 | /* Number of E1 TS inside E1 link */ |
| 182 | u_int8_t e1_ts; |
| 183 | /* Sub-slot within the E1 TS, 0xff if full TS */ |
| 184 | u_int8_t e1_ts_ss; |
| 185 | }; |
| 186 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 187 | #define BTS_TRX_F_ACTIVATED 0x0001 |
| 188 | /* One Timeslot in a TRX */ |
| 189 | struct gsm_bts_trx_ts { |
| 190 | struct gsm_bts_trx *trx; |
| 191 | /* number of this timeslot at the TRX */ |
| 192 | u_int8_t nr; |
| 193 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 194 | enum gsm_phys_chan_config pchan; |
| 195 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 196 | unsigned int flags; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 197 | struct gsm_nm_state nm_state; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 198 | struct gsm_attr *nm_attr; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 199 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 200 | /* To which E1 subslot are we connected */ |
| 201 | struct gsm_e1_subslot e1_link; |
Harald Welte | 7509926 | 2009-02-16 21:12:08 +0000 | [diff] [blame] | 202 | struct { |
| 203 | u_int32_t bound_ip; |
| 204 | u_int16_t bound_port; |
| 205 | u_int8_t attr_fc; |
| 206 | u_int16_t attr_f8; |
| 207 | } abis_ip; |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 208 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 209 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 210 | }; |
| 211 | |
| 212 | /* One TRX in a BTS */ |
| 213 | struct gsm_bts_trx { |
| 214 | struct gsm_bts *bts; |
| 215 | /* number of this TRX in the BTS */ |
| 216 | u_int8_t nr; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 217 | /* how do we talk RSL with this TRX? */ |
| 218 | struct e1inp_sign_link *rsl_link; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 219 | struct gsm_nm_state nm_state; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 220 | struct gsm_attr *nm_attr; |
| 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 | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 226 | |
| 227 | union { |
| 228 | struct { |
| 229 | struct { |
| 230 | struct gsm_nm_state nm_state; |
| 231 | } bbsig; |
| 232 | struct { |
| 233 | struct gsm_nm_state nm_state; |
| 234 | } pa; |
| 235 | } bs11; |
| 236 | }; |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 237 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 238 | }; |
| 239 | |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 240 | enum gsm_bts_type { |
| 241 | GSM_BTS_TYPE_UNKNOWN, |
| 242 | GSM_BTS_TYPE_BS11, |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 243 | GSM_BTS_TYPE_NANOBTS_900, |
| 244 | GSM_BTS_TYPE_NANOBTS_1800, |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 245 | }; |
| 246 | |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 247 | /** |
| 248 | * A pending paging request |
| 249 | */ |
| 250 | struct gsm_paging_request { |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 251 | /* list_head for list of all paging requests */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 252 | struct llist_head entry; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 253 | /* the subscriber which we're paging. Later gsm_paging_request |
| 254 | * should probably become a part of the gsm_subscriber struct? */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 255 | struct gsm_subscriber *subscr; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 256 | /* back-pointer to the BTS on which we are paging */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 257 | struct gsm_bts *bts; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 258 | /* what kind of channel type do we ask the MS to establish */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 259 | int chan_type; |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 260 | |
| 261 | /* Timer 3113: how long do we try to page? */ |
| 262 | struct timer_list T3113; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 263 | |
| 264 | /* callback to be called in case paging completes */ |
| 265 | gsm_cbfn *cbfn; |
| 266 | void *cbfn_param; |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 267 | }; |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 268 | #define T3113_VALUE 60, 0 |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 269 | |
| 270 | /* |
| 271 | * This keeps track of the paging status of one BTS. It |
| 272 | * includes a number of pending requests, a back pointer |
| 273 | * to the gsm_bts, a timer and some more state. |
| 274 | */ |
| 275 | struct gsm_bts_paging_state { |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 276 | /* pending requests */ |
| 277 | struct llist_head pending_requests; |
| 278 | struct gsm_paging_request *last_request; |
| 279 | struct gsm_bts *bts; |
| 280 | |
Harald Welte | 75a1fa8 | 2009-02-17 01:39:41 +0000 | [diff] [blame] | 281 | struct timer_list work_timer; |
| 282 | |
Holger Freyther | 392209c | 2009-02-10 00:06:19 +0000 | [diff] [blame] | 283 | /* load */ |
| 284 | u_int16_t available_slots; |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 285 | }; |
| 286 | |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 287 | struct gsm_envabtse { |
| 288 | struct gsm_nm_state nm_state; |
| 289 | }; |
| 290 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 291 | /* One BTS */ |
| 292 | struct gsm_bts { |
| 293 | struct gsm_network *network; |
| 294 | /* number of ths BTS in network */ |
| 295 | u_int8_t nr; |
| 296 | /* location area code of this BTS */ |
| 297 | u_int8_t location_area_code; |
Harald Welte | 02b0e09 | 2009-02-28 13:11:07 +0000 | [diff] [blame] | 298 | /* Training Sequence Code */ |
| 299 | u_int8_t tsc; |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 300 | /* Base Station Identification Code (BSIC) */ |
| 301 | u_int8_t bsic; |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 302 | /* type of BTS */ |
| 303 | enum gsm_bts_type type; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 304 | /* how do we talk OML with this TRX? */ |
| 305 | struct e1inp_sign_link *oml_link; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 306 | |
| 307 | /* Abis network management O&M handle */ |
| 308 | struct abis_nm_h *nmh; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 309 | struct gsm_nm_state nm_state; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 310 | struct gsm_attr *nm_attr; |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 311 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 312 | /* number of this BTS on given E1 link */ |
| 313 | u_int8_t bts_nr; |
| 314 | |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 315 | struct gsm48_control_channel_descr chan_desc; |
| 316 | |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 317 | /* paging state and control */ |
| 318 | struct gsm_bts_paging_state paging; |
| 319 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 320 | /* CCCH is on C0 */ |
| 321 | struct gsm_bts_trx *c0; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 322 | |
| 323 | struct { |
| 324 | struct gsm_nm_state nm_state; |
| 325 | } site_mgr; |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 326 | |
| 327 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 328 | union { |
| 329 | struct { |
| 330 | u_int16_t site_id; |
| 331 | u_int16_t bts_id; |
| 332 | } ip_access; |
| 333 | struct { |
| 334 | struct { |
| 335 | struct gsm_nm_state nm_state; |
| 336 | } cclk; |
| 337 | struct { |
| 338 | struct gsm_nm_state nm_state; |
| 339 | } rack; |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 340 | struct gsm_envabtse envabtse[4]; |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 341 | } bs11; |
| 342 | }; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 343 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 344 | /* transceivers */ |
| 345 | int num_trx; |
| 346 | struct gsm_bts_trx trx[BTS_MAX_TRX+1]; |
| 347 | }; |
| 348 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 349 | struct gsm_network { |
| 350 | /* global parameters */ |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 351 | u_int16_t country_code; |
| 352 | u_int16_t network_code; |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 353 | char *name_long; |
| 354 | char *name_short; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 355 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame^] | 356 | /* layer 4 */ |
| 357 | int (*mncc_recv) (struct gsm_network *net, int msg_type, void *arg); |
| 358 | struct llist_head upqueue; |
| 359 | struct llist_head trans_list; |
| 360 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 361 | unsigned int num_bts; |
| 362 | /* private lists */ |
| 363 | struct gsm_bts bts[GSM_MAX_BTS+1]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 364 | }; |
| 365 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 366 | #define SMS_HDR_SIZE 128 |
| 367 | #define SMS_TEXT_SIZE 256 |
| 368 | struct gsm_sms { |
| 369 | u_int64_t id; |
| 370 | struct gsm_subscriber *sender; |
| 371 | struct gsm_subscriber *receiver; |
| 372 | |
| 373 | unsigned char header[SMS_HDR_SIZE]; |
| 374 | char text[SMS_TEXT_SIZE]; |
| 375 | }; |
| 376 | |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 377 | struct gsm_network *gsm_network_init(unsigned int num_bts, enum gsm_bts_type bts_type, |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame^] | 378 | u_int16_t country_code, u_int16_t network_code, |
| 379 | int (*mncc_recv)(struct gsm_network *, int, void *)); |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 380 | |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 381 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
| 382 | const char *gsm_lchan_name(enum gsm_chan_t c); |
| 383 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
Harald Welte | 23a6863 | 2009-02-19 17:06:42 +0000 | [diff] [blame] | 384 | char *gsm_ts_name(struct gsm_bts_trx_ts *ts); |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 385 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 386 | enum gsm_e1_event { |
| 387 | EVT_E1_NONE, |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 388 | EVT_E1_TEI_UP, |
| 389 | EVT_E1_TEI_DN, |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 390 | }; |
| 391 | |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 392 | void set_ts_e1link(struct gsm_bts_trx_ts *ts, u_int8_t e1_nr, |
| 393 | u_int8_t e1_ts, u_int8_t e1_ts_ss); |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 394 | enum gsm_bts_type parse_btstype(char *arg); |
| 395 | char *btstype2str(enum gsm_bts_type type); |
Harald Welte | be99149 | 2009-05-23 13:56:40 +0000 | [diff] [blame] | 396 | struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac, |
| 397 | struct gsm_bts *start_bts); |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 398 | |
| 399 | static inline int is_ipaccess_bts(struct gsm_bts *bts) |
| 400 | { |
| 401 | switch (bts->type) { |
| 402 | case GSM_BTS_TYPE_NANOBTS_900: |
| 403 | case GSM_BTS_TYPE_NANOBTS_1800: |
| 404 | return 1; |
| 405 | default: |
| 406 | break; |
| 407 | } |
| 408 | return 0; |
| 409 | } |
| 410 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 411 | #endif |