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, |
Harald Welte | a1499d0 | 2009-10-24 10:25:50 +0200 | [diff] [blame] | 13 | GSM_PCHAN_PDCH, /* GPRS PDCH */ |
| 14 | GSM_PCHAN_TCH_F_PDCH, /* TCH/F if used, PDCH otherwise */ |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 15 | GSM_PCHAN_UNKNOWN, |
| 16 | }; |
| 17 | |
| 18 | enum gsm_chan_t { |
| 19 | GSM_LCHAN_NONE, |
| 20 | GSM_LCHAN_SDCCH, |
| 21 | GSM_LCHAN_TCH_F, |
| 22 | GSM_LCHAN_TCH_H, |
| 23 | GSM_LCHAN_UNKNOWN, |
| 24 | }; |
| 25 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 26 | /* RRLP mode of operation */ |
| 27 | enum rrlp_mode { |
| 28 | RRLP_MODE_NONE, |
| 29 | RRLP_MODE_MS_BASED, |
| 30 | RRLP_MODE_MS_PREF, |
| 31 | RRLP_MODE_ASS_PREF, |
| 32 | }; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 33 | |
| 34 | /* Channel Request reason */ |
| 35 | enum gsm_chreq_reason_t { |
| 36 | GSM_CHREQ_REASON_EMERG, |
| 37 | GSM_CHREQ_REASON_PAG, |
| 38 | GSM_CHREQ_REASON_CALL, |
| 39 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 40 | GSM_CHREQ_REASON_OTHER, |
| 41 | }; |
| 42 | |
Harald Welte | dfe6c7d | 2010-02-20 16:24:02 +0100 | [diff] [blame] | 43 | #include <osmocore/timer.h> |
Holger Freyther | 1adb4ff | 2009-02-04 00:04:52 +0000 | [diff] [blame] | 44 | #include <openbsc/gsm_04_08.h> |
Harald Welte | 9943c5b | 2009-07-29 15:41:29 +0200 | [diff] [blame] | 45 | #include <openbsc/abis_rsl.h> |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 46 | #include <openbsc/mncc.h> |
Harald Welte | dfe6c7d | 2010-02-20 16:24:02 +0100 | [diff] [blame] | 47 | #include <osmocore/tlv.h> |
| 48 | #include <osmocore/bitvec.h> |
| 49 | #include <osmocore/statistics.h> |
| 50 | #include <osmocore/gsm_utils.h> |
| 51 | #include <osmocore/utils.h> |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 52 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 53 | #define TRX_NR_TS 8 |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 54 | #define TS_MAX_LCHAN 8 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 55 | |
| 56 | #define HARDCODED_ARFCN 123 |
Harald Welte | 02b0e09 | 2009-02-28 13:11:07 +0000 | [diff] [blame] | 57 | #define HARDCODED_TSC 7 |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 58 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 59 | |
Harald Welte | 63589be | 2009-08-06 17:38:10 +0200 | [diff] [blame] | 60 | /* for multi-drop config */ |
| 61 | #define HARDCODED_BTS0_TS 1 |
| 62 | #define HARDCODED_BTS1_TS 6 |
| 63 | #define HARDCODED_BTS2_TS 11 |
| 64 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 65 | enum gsm_hooks { |
| 66 | GSM_HOOK_NM_SWLOAD, |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 67 | GSM_HOOK_RR_PAGING, |
| 68 | }; |
| 69 | |
| 70 | enum gsm_paging_event { |
| 71 | GSM_PAGING_SUCCEEDED, |
| 72 | GSM_PAGING_EXPIRED, |
Holger Freyther | 85a7b36 | 2009-04-18 13:48:55 +0200 | [diff] [blame] | 73 | GSM_PAGING_OOM, |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 76 | enum bts_gprs_mode { |
| 77 | BTS_GPRS_NONE = 0, |
| 78 | BTS_GPRS_GPRS = 1, |
| 79 | BTS_GPRS_EGPRS = 2, |
| 80 | }; |
| 81 | |
Harald Welte | 0809d79 | 2010-04-30 14:36:25 +0200 | [diff] [blame] | 82 | /* the data structure stored in msgb->cb for openbsc apps */ |
| 83 | struct openbsc_msgb_cb { |
Harald Welte | fd3fa1d | 2010-05-02 09:50:42 +0200 | [diff] [blame] | 84 | unsigned char *bssgph; |
| 85 | unsigned char *llch; |
Harald Welte | 44f1c27 | 2010-04-30 19:54:29 +0200 | [diff] [blame] | 86 | |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame^] | 87 | /* Identifiers of a BTS, equal to 'struct bssgp_bts_ctx' */ |
Harald Welte | 44f1c27 | 2010-04-30 19:54:29 +0200 | [diff] [blame] | 88 | u_int16_t nsei; |
| 89 | u_int16_t bvci; |
| 90 | |
Harald Welte | e6afd60 | 2010-05-02 11:19:37 +0200 | [diff] [blame^] | 91 | /* Identifier of a MS (inside BTS), equal to 'struct sgsn_mm_ctx' */ |
Harald Welte | 0809d79 | 2010-04-30 14:36:25 +0200 | [diff] [blame] | 92 | u_int32_t tlli; |
Harald Welte | 44f1c27 | 2010-04-30 19:54:29 +0200 | [diff] [blame] | 93 | } __attribute__((packed)); |
Harald Welte | 0809d79 | 2010-04-30 14:36:25 +0200 | [diff] [blame] | 94 | #define OBSC_MSGB_CB(__msgb) ((struct openbsc_msgb_cb *)&((__msgb)->cb[0])) |
Harald Welte | 943c5bc | 2010-04-30 16:33:12 +0200 | [diff] [blame] | 95 | #define msgb_tlli(__x) OBSC_MSGB_CB(__x)->tlli |
Harald Welte | 44f1c27 | 2010-04-30 19:54:29 +0200 | [diff] [blame] | 96 | #define msgb_nsei(__x) OBSC_MSGB_CB(__x)->nsei |
| 97 | #define msgb_bvci(__x) OBSC_MSGB_CB(__x)->bvci |
Harald Welte | fd3fa1d | 2010-05-02 09:50:42 +0200 | [diff] [blame] | 98 | #define msgb_gmmh(__x) (__x)->l3h |
| 99 | #define msgb_bssgph(__x) OBSC_MSGB_CB(__x)->bssgph |
| 100 | #define msgb_llch(__x) OBSC_MSGB_CB(__x)->llch |
Harald Welte | 0809d79 | 2010-04-30 14:36:25 +0200 | [diff] [blame] | 101 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 102 | struct msgb; |
| 103 | typedef int gsm_cbfn(unsigned int hooknum, |
| 104 | unsigned int event, |
| 105 | struct msgb *msg, |
| 106 | void *data, void *param); |
| 107 | |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 108 | /* |
| 109 | * Use the channel. As side effect the lchannel recycle timer |
| 110 | * will be started. |
| 111 | */ |
Harald Welte | b9c758b | 2009-07-05 14:02:46 +0200 | [diff] [blame] | 112 | #define LCHAN_RELEASE_TIMEOUT 20, 0 |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 113 | #define use_subscr_con(con) \ |
| 114 | do { (con)->use_count++; \ |
Harald Welte | d0c1914 | 2009-12-24 11:46:44 +0100 | [diff] [blame] | 115 | DEBUGP(DREF, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) increases usage to: %d\n", \ |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 116 | (con)->lchan->ts->trx->bts->nr, (con)->lchan->ts->trx->nr, (con)->lchan->ts->nr, \ |
| 117 | (con)->lchan->nr, (con)->use_count); \ |
| 118 | bsc_schedule_timer(&(con)->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0); |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 119 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 120 | #define put_subscr_con(con) \ |
| 121 | do { (con)->use_count--; \ |
Harald Welte | d0c1914 | 2009-12-24 11:46:44 +0100 | [diff] [blame] | 122 | DEBUGP(DREF, "lchan (bts=%d,trx=%d,ts=%d,ch=%d) decreases usage to: %d\n", \ |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 123 | (con)->lchan->ts->trx->bts->nr, (con)->lchan->ts->trx->nr, (con)->lchan->ts->nr, \ |
| 124 | (con)->lchan->nr, (con)->use_count); \ |
Holger Freyther | 4f584c3 | 2009-06-02 02:55:07 +0000 | [diff] [blame] | 125 | } while(0); |
| 126 | |
Holger Freyther | c6ea9db | 2008-12-30 19:18:21 +0000 | [diff] [blame] | 127 | |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 128 | /* Real authentication information containing Ki */ |
| 129 | enum gsm_auth_algo { |
| 130 | AUTH_ALGO_NONE, |
| 131 | AUTH_ALGO_XOR, |
| 132 | AUTH_ALGO_COMP128v1, |
| 133 | }; |
| 134 | |
| 135 | struct gsm_auth_info { |
| 136 | enum gsm_auth_algo auth_algo; |
| 137 | unsigned int a3a8_ki_len; |
| 138 | u_int8_t a3a8_ki[16]; |
| 139 | }; |
| 140 | |
| 141 | struct gsm_auth_tuple { |
| 142 | int use_count; |
| 143 | int key_seq; |
| 144 | u_int8_t rand[16]; |
| 145 | u_int8_t sres[4]; |
| 146 | u_int8_t kc[8]; |
| 147 | }; |
| 148 | |
| 149 | |
Harald Welte | 49f48b8 | 2009-02-17 15:29:33 +0000 | [diff] [blame] | 150 | struct gsm_lchan; |
| 151 | struct gsm_subscriber; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 152 | struct gsm_mncc; |
Harald Welte | 805f644 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 153 | struct rtp_socket; |
Harald Welte | 49f48b8 | 2009-02-17 15:29:33 +0000 | [diff] [blame] | 154 | |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 155 | /* Network Management State */ |
| 156 | struct gsm_nm_state { |
| 157 | u_int8_t operational; |
| 158 | u_int8_t administrative; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 159 | u_int8_t availability; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 160 | }; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 161 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 162 | /* |
| 163 | * LOCATION UPDATING REQUEST state |
| 164 | * |
| 165 | * Our current operation is: |
| 166 | * - Get imei/tmsi |
| 167 | * - Accept/Reject according to global policy |
| 168 | */ |
| 169 | struct gsm_loc_updating_operation { |
| 170 | struct timer_list updating_timer; |
Holger Hans Peter Freyther | 251aa91 | 2009-10-27 10:42:28 +0100 | [diff] [blame] | 171 | unsigned int waiting_for_imsi : 1; |
| 172 | unsigned int waiting_for_imei : 1; |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 173 | }; |
| 174 | |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 175 | /* Maximum number of neighbor cells whose average we track */ |
| 176 | #define MAX_NEIGH_MEAS 10 |
| 177 | /* Maximum size of the averaging window for neighbor cells */ |
| 178 | #define MAX_WIN_NEIGH_AVG 10 |
| 179 | |
| 180 | /* processed neighbor measurements for one cell */ |
| 181 | struct neigh_meas_proc { |
| 182 | u_int16_t arfcn; |
| 183 | u_int8_t bsic; |
| 184 | u_int8_t rxlev[MAX_WIN_NEIGH_AVG]; |
| 185 | unsigned int rxlev_cnt; |
| 186 | u_int8_t last_seen_nr; |
| 187 | }; |
| 188 | |
Harald Welte | 08d91a5 | 2009-08-30 15:37:11 +0900 | [diff] [blame] | 189 | #define MAX_A5_KEY_LEN (128/8) |
| 190 | #define RSL_ENC_ALG_A5(x) (x+1) |
| 191 | |
Holger Hans Peter Freyther | 5ba6f48 | 2009-10-28 14:23:39 +0100 | [diff] [blame] | 192 | /* is the data link established? who established it? */ |
| 193 | #define LCHAN_SAPI_UNUSED 0 |
| 194 | #define LCHAN_SAPI_MS 1 |
| 195 | #define LCHAN_SAPI_NET 2 |
| 196 | |
Harald Welte | b8bfc56 | 2009-12-21 13:27:11 +0100 | [diff] [blame] | 197 | /* state of a logical channel */ |
| 198 | enum gsm_lchan_state { |
| 199 | LCHAN_S_NONE, /* channel is not active */ |
Harald Welte (local) | 3e46031 | 2009-12-27 18:12:29 +0100 | [diff] [blame] | 200 | LCHAN_S_ACT_REQ, /* channel activatin requested */ |
Harald Welte | b8bfc56 | 2009-12-21 13:27:11 +0100 | [diff] [blame] | 201 | LCHAN_S_ACTIVE, /* channel is active and operational */ |
Harald Welte | 8e93b79 | 2009-12-29 10:44:17 +0100 | [diff] [blame] | 202 | LCHAN_S_REL_REQ, /* channel release has been requested */ |
Harald Welte | b8bfc56 | 2009-12-21 13:27:11 +0100 | [diff] [blame] | 203 | LCHAN_S_INACTIVE, /* channel is set inactive */ |
| 204 | }; |
| 205 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 206 | /* the per subscriber data for lchan */ |
| 207 | struct gsm_subscriber_connection { |
| 208 | /* To whom we are allocated at the moment */ |
| 209 | struct gsm_subscriber *subscr; |
| 210 | |
| 211 | /* Timer started to release the channel */ |
| 212 | struct timer_list release_timer; |
| 213 | |
| 214 | /* |
| 215 | * Operations that have a state and might be pending |
| 216 | */ |
| 217 | struct gsm_loc_updating_operation *loc_operation; |
| 218 | |
| 219 | /* use count. how many users use this channel */ |
| 220 | unsigned int use_count; |
| 221 | |
| 222 | /* Are we part of a special "silent" call */ |
| 223 | int silent_call; |
| 224 | |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 225 | /* back pointers */ |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 226 | struct gsm_lchan *lchan; |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 227 | struct gsm_bts *bts; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 228 | }; |
| 229 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 230 | struct gsm_lchan { |
| 231 | /* The TS that we're part of */ |
| 232 | struct gsm_bts_trx_ts *ts; |
| 233 | /* The logical subslot number in the TS */ |
| 234 | u_int8_t nr; |
Harald Welte | 45b407a | 2009-05-23 15:51:12 +0000 | [diff] [blame] | 235 | /* The logical channel type */ |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 236 | enum gsm_chan_t type; |
Harald Welte | 9943c5b | 2009-07-29 15:41:29 +0200 | [diff] [blame] | 237 | /* RSL channel mode */ |
| 238 | enum rsl_cmod_spd rsl_cmode; |
Harald Welte | 45b407a | 2009-05-23 15:51:12 +0000 | [diff] [blame] | 239 | /* If TCH, traffic channel mode */ |
Harald Welte | 9943c5b | 2009-07-29 15:41:29 +0200 | [diff] [blame] | 240 | enum gsm48_chan_mode tch_mode; |
Harald Welte | b8bfc56 | 2009-12-21 13:27:11 +0100 | [diff] [blame] | 241 | /* State */ |
| 242 | enum gsm_lchan_state state; |
Harald Welte | d4c9bf3 | 2009-02-15 16:56:18 +0000 | [diff] [blame] | 243 | /* Power levels for MS and BTS */ |
| 244 | u_int8_t bs_power; |
| 245 | u_int8_t ms_power; |
Harald Welte | 08d91a5 | 2009-08-30 15:37:11 +0900 | [diff] [blame] | 246 | /* Encryption information */ |
| 247 | struct { |
| 248 | u_int8_t alg_id; |
| 249 | u_int8_t key_len; |
| 250 | u_int8_t key[MAX_A5_KEY_LEN]; |
| 251 | } encr; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 252 | |
| 253 | struct timer_list T3101; |
Holger Hans Peter Freyther | ea52802 | 2009-11-18 22:57:02 +0100 | [diff] [blame] | 254 | |
| 255 | /* AMR bits */ |
| 256 | struct gsm48_multi_rate_conf mr_conf; |
Harald Welte | d4c9bf3 | 2009-02-15 16:56:18 +0000 | [diff] [blame] | 257 | |
Holger Hans Peter Freyther | 5ba6f48 | 2009-10-28 14:23:39 +0100 | [diff] [blame] | 258 | /* Established data link layer services */ |
| 259 | u_int8_t sapis[8]; |
| 260 | |
Harald Welte | d12b0fd | 2009-12-15 21:36:05 +0100 | [diff] [blame] | 261 | /* cache of last measurement reports on this lchan */ |
| 262 | struct gsm_meas_rep meas_rep[6]; |
| 263 | int meas_rep_idx; |
| 264 | |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 265 | /* table of neighbor cell measurements */ |
| 266 | struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS]; |
| 267 | |
Harald Welte | 2c82899 | 2009-12-02 01:56:49 +0530 | [diff] [blame] | 268 | struct { |
| 269 | u_int32_t bound_ip; |
Harald Welte | 5e3d91b | 2009-12-19 16:42:06 +0100 | [diff] [blame] | 270 | u_int32_t connect_ip; |
Harald Welte | 2c82899 | 2009-12-02 01:56:49 +0530 | [diff] [blame] | 271 | u_int16_t bound_port; |
Harald Welte | 5e3d91b | 2009-12-19 16:42:06 +0100 | [diff] [blame] | 272 | u_int16_t connect_port; |
Harald Welte | 2c82899 | 2009-12-02 01:56:49 +0530 | [diff] [blame] | 273 | u_int16_t conn_id; |
Sylvain Munaut | b54dda4 | 2009-12-20 22:06:40 +0100 | [diff] [blame] | 274 | u_int8_t rtp_payload; |
Harald Welte | 5e3d91b | 2009-12-19 16:42:06 +0100 | [diff] [blame] | 275 | u_int8_t rtp_payload2; |
| 276 | u_int8_t speech_mode; |
Harald Welte | 2c82899 | 2009-12-02 01:56:49 +0530 | [diff] [blame] | 277 | struct rtp_socket *rtp_socket; |
| 278 | } abis_ip; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 279 | |
| 280 | struct gsm_subscriber_connection conn; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 281 | }; |
| 282 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 283 | struct gsm_e1_subslot { |
| 284 | /* Number of E1 link */ |
| 285 | u_int8_t e1_nr; |
| 286 | /* Number of E1 TS inside E1 link */ |
| 287 | u_int8_t e1_ts; |
| 288 | /* Sub-slot within the E1 TS, 0xff if full TS */ |
| 289 | u_int8_t e1_ts_ss; |
| 290 | }; |
| 291 | |
Harald Welte | 4563eab | 2010-03-28 14:42:09 +0800 | [diff] [blame] | 292 | #define TS_F_PDCH_MODE 0x1000 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 293 | /* One Timeslot in a TRX */ |
| 294 | struct gsm_bts_trx_ts { |
| 295 | struct gsm_bts_trx *trx; |
| 296 | /* number of this timeslot at the TRX */ |
| 297 | u_int8_t nr; |
| 298 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 299 | enum gsm_phys_chan_config pchan; |
| 300 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 301 | unsigned int flags; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 302 | struct gsm_nm_state nm_state; |
Harald Welte | 93e9d17 | 2009-06-20 19:04:31 +0200 | [diff] [blame] | 303 | struct tlv_parsed nm_attr; |
Harald Welte | 39c7deb | 2009-08-09 21:49:48 +0200 | [diff] [blame] | 304 | u_int8_t nm_chan_comb; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 305 | |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 306 | /* To which E1 subslot are we connected */ |
| 307 | struct gsm_e1_subslot e1_link; |
| 308 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 309 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | /* One TRX in a BTS */ |
| 313 | struct gsm_bts_trx { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 314 | /* list header in bts->trx_list */ |
| 315 | struct llist_head list; |
| 316 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 317 | struct gsm_bts *bts; |
| 318 | /* number of this TRX in the BTS */ |
| 319 | u_int8_t nr; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 320 | /* how do we talk RSL with this TRX? */ |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 321 | struct gsm_e1_subslot rsl_e1_link; |
| 322 | u_int8_t rsl_tei; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 323 | struct e1inp_sign_link *rsl_link; |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 324 | |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 325 | struct gsm_nm_state nm_state; |
Harald Welte | 93e9d17 | 2009-06-20 19:04:31 +0200 | [diff] [blame] | 326 | struct tlv_parsed nm_attr; |
Harald Welte | 8c1d0e4 | 2009-02-15 03:38:12 +0000 | [diff] [blame] | 327 | struct { |
| 328 | struct gsm_nm_state nm_state; |
| 329 | } bb_transc; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 330 | |
| 331 | u_int16_t arfcn; |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 332 | int nominal_power; /* in dBm */ |
| 333 | unsigned int max_power_red; /* in actual dB */ |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 334 | |
| 335 | union { |
| 336 | struct { |
| 337 | struct { |
| 338 | struct gsm_nm_state nm_state; |
| 339 | } bbsig; |
| 340 | struct { |
| 341 | struct gsm_nm_state nm_state; |
| 342 | } pa; |
| 343 | } bs11; |
| 344 | }; |
Harald Welte | 85770c7 | 2009-01-18 17:47:32 +0000 | [diff] [blame] | 345 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 346 | }; |
| 347 | |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 348 | enum gsm_bts_type { |
| 349 | GSM_BTS_TYPE_UNKNOWN, |
| 350 | GSM_BTS_TYPE_BS11, |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 351 | GSM_BTS_TYPE_NANOBTS, |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 352 | }; |
| 353 | |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 354 | struct gsm_bts_model { |
| 355 | struct llist_head list; |
| 356 | |
| 357 | enum gsm_bts_type type; |
| 358 | const char *name; |
| 359 | |
| 360 | struct tlv_definition nm_att_tlvdef; |
| 361 | }; |
| 362 | |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 363 | /** |
| 364 | * A pending paging request |
| 365 | */ |
| 366 | struct gsm_paging_request { |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 367 | /* list_head for list of all paging requests */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 368 | struct llist_head entry; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 369 | /* the subscriber which we're paging. Later gsm_paging_request |
| 370 | * should probably become a part of the gsm_subscriber struct? */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 371 | struct gsm_subscriber *subscr; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 372 | /* back-pointer to the BTS on which we are paging */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 373 | struct gsm_bts *bts; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 374 | /* what kind of channel type do we ask the MS to establish */ |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 375 | int chan_type; |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 376 | |
| 377 | /* Timer 3113: how long do we try to page? */ |
| 378 | struct timer_list T3113; |
Harald Welte | 0932d1e | 2009-02-16 22:53:52 +0000 | [diff] [blame] | 379 | |
| 380 | /* callback to be called in case paging completes */ |
| 381 | gsm_cbfn *cbfn; |
| 382 | void *cbfn_param; |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 383 | }; |
| 384 | |
| 385 | /* |
| 386 | * This keeps track of the paging status of one BTS. It |
| 387 | * includes a number of pending requests, a back pointer |
| 388 | * to the gsm_bts, a timer and some more state. |
| 389 | */ |
| 390 | struct gsm_bts_paging_state { |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 391 | /* pending requests */ |
| 392 | struct llist_head pending_requests; |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 393 | struct gsm_bts *bts; |
| 394 | |
Harald Welte | 75a1fa8 | 2009-02-17 01:39:41 +0000 | [diff] [blame] | 395 | struct timer_list work_timer; |
| 396 | |
Holger Freyther | 392209c | 2009-02-10 00:06:19 +0000 | [diff] [blame] | 397 | /* load */ |
| 398 | u_int16_t available_slots; |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 399 | }; |
| 400 | |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 401 | struct gsm_envabtse { |
| 402 | struct gsm_nm_state nm_state; |
| 403 | }; |
| 404 | |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 405 | struct gsm_bts_gprs_nsvc { |
| 406 | struct gsm_bts *bts; |
Harald Welte | ab88a62 | 2010-03-18 00:01:23 +0800 | [diff] [blame] | 407 | /* data read via VTY config file, to configure the BTS |
| 408 | * via OML from BSC */ |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 409 | int id; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 410 | u_int16_t nsvci; |
Harald Welte | ab88a62 | 2010-03-18 00:01:23 +0800 | [diff] [blame] | 411 | u_int16_t local_port; /* on the BTS */ |
| 412 | u_int16_t remote_port; /* on the SGSN */ |
| 413 | u_int32_t remote_ip; /* on the SGSN */ |
| 414 | |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 415 | struct gsm_nm_state nm_state; |
| 416 | }; |
| 417 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 418 | /* One BTS */ |
| 419 | struct gsm_bts { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 420 | /* list header in net->bts_list */ |
| 421 | struct llist_head list; |
| 422 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 423 | struct gsm_network *network; |
| 424 | /* number of ths BTS in network */ |
| 425 | u_int8_t nr; |
Holger Hans Peter Freyther | c4a49e3 | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 426 | /* Cell Identity */ |
| 427 | u_int16_t cell_identity; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 428 | /* location area code of this BTS */ |
Holger Hans Peter Freyther | 0b7f4b3 | 2009-09-29 14:02:33 +0200 | [diff] [blame] | 429 | u_int16_t location_area_code; |
Harald Welte | 02b0e09 | 2009-02-28 13:11:07 +0000 | [diff] [blame] | 430 | /* Training Sequence Code */ |
| 431 | u_int8_t tsc; |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 432 | /* Base Station Identification Code (BSIC) */ |
| 433 | u_int8_t bsic; |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 434 | /* type of BTS */ |
| 435 | enum gsm_bts_type type; |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 436 | struct gsm_bts_model *model; |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 437 | enum gsm_band band; |
Harald Welte | fc0d952 | 2009-08-10 13:46:55 +0200 | [diff] [blame] | 438 | /* should the channel allocator allocate channels from high TRX to TRX0, |
| 439 | * rather than starting from TRX0 and go upwards? */ |
| 440 | int chan_alloc_reverse; |
Harald Welte (local) | 0e451d0 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 441 | /* maximum Tx power that the MS is permitted to use in this cell */ |
| 442 | int ms_max_power; |
Harald Welte | fc0d952 | 2009-08-10 13:46:55 +0200 | [diff] [blame] | 443 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 444 | /* how do we talk OML with this TRX? */ |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 445 | struct gsm_e1_subslot oml_e1_link; |
| 446 | u_int8_t oml_tei; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 447 | struct e1inp_sign_link *oml_link; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 448 | |
| 449 | /* Abis network management O&M handle */ |
| 450 | struct abis_nm_h *nmh; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 451 | struct gsm_nm_state nm_state; |
Harald Welte | 93e9d17 | 2009-06-20 19:04:31 +0200 | [diff] [blame] | 452 | struct tlv_parsed nm_attr; |
Harald Welte | 978cb42 | 2009-01-18 17:57:27 +0000 | [diff] [blame] | 453 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 454 | /* number of this BTS on given E1 link */ |
| 455 | u_int8_t bts_nr; |
| 456 | |
Holger Freyther | ceb59b7 | 2009-02-06 18:54:00 +0000 | [diff] [blame] | 457 | /* paging state and control */ |
| 458 | struct gsm_bts_paging_state paging; |
| 459 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 460 | /* CCCH is on C0 */ |
| 461 | struct gsm_bts_trx *c0; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 462 | |
| 463 | struct { |
| 464 | struct gsm_nm_state nm_state; |
| 465 | } site_mgr; |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 466 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 467 | /* parameters from which we build SYSTEM INFORMATION */ |
| 468 | struct { |
| 469 | struct gsm48_rach_control rach_control; |
| 470 | u_int8_t ncc_permitted; |
| 471 | struct gsm48_cell_sel_par cell_sel_par; |
| 472 | struct gsm48_cell_options cell_options; |
| 473 | struct gsm48_control_channel_descr chan_desc; |
Harald Welte | 6c40def | 2009-12-14 22:07:14 +0100 | [diff] [blame] | 474 | struct bitvec neigh_list; |
| 475 | struct bitvec cell_alloc; |
| 476 | struct { |
| 477 | /* bitmask large enough for all possible ARFCN's */ |
| 478 | u_int8_t neigh_list[1024/8]; |
| 479 | u_int8_t cell_alloc[1024/8]; |
| 480 | } data; |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 481 | } si_common; |
| 482 | |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 483 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 484 | union { |
| 485 | struct { |
| 486 | u_int16_t site_id; |
| 487 | u_int16_t bts_id; |
Harald Welte | 88a412a | 2009-12-16 17:32:37 +0100 | [diff] [blame] | 488 | u_int32_t flags; |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 489 | } ip_access; |
| 490 | struct { |
| 491 | struct { |
| 492 | struct gsm_nm_state nm_state; |
| 493 | } cclk; |
| 494 | struct { |
| 495 | struct gsm_nm_state nm_state; |
| 496 | } rack; |
Harald Welte | 8b697c7 | 2009-06-05 19:18:45 +0000 | [diff] [blame] | 497 | struct gsm_envabtse envabtse[4]; |
Harald Welte | 7b26bcb | 2009-05-28 11:39:21 +0000 | [diff] [blame] | 498 | } bs11; |
| 499 | }; |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 500 | |
| 501 | /* Not entirely sure how ip.access specific this is */ |
| 502 | struct { |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 503 | enum bts_gprs_mode mode; |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 504 | struct { |
| 505 | struct gsm_nm_state nm_state; |
Harald Welte | a5731cf | 2010-03-22 11:48:36 +0800 | [diff] [blame] | 506 | u_int16_t nsei; |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 507 | } nse; |
| 508 | struct { |
| 509 | struct gsm_nm_state nm_state; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 510 | u_int16_t bvci; |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 511 | } cell; |
| 512 | struct gsm_bts_gprs_nsvc nsvc[2]; |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 513 | u_int8_t rac; |
Harald Welte | 55dd443 | 2009-10-24 10:19:14 +0200 | [diff] [blame] | 514 | } gprs; |
Holger Hans Peter Freyther | 95c2290 | 2010-04-25 23:08:39 +0800 | [diff] [blame] | 515 | |
| 516 | /* RACH NM values */ |
| 517 | int rach_b_thresh; |
| 518 | int rach_ldavg_slots; |
Harald Welte | bbcc7a5 | 2009-02-14 19:45:44 +0000 | [diff] [blame] | 519 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 520 | /* transceivers */ |
| 521 | int num_trx; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 522 | struct llist_head trx_list; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 523 | }; |
| 524 | |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 525 | /* Some statistics of our network */ |
| 526 | struct gsmnet_stats { |
| 527 | struct { |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 528 | struct counter *total; |
| 529 | struct counter *no_channel; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 530 | } chreq; |
| 531 | struct { |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 532 | struct counter *attempted; |
| 533 | struct counter *no_channel; /* no channel available */ |
| 534 | struct counter *timeout; /* T3103 timeout */ |
| 535 | struct counter *completed; /* HO COMPL received */ |
| 536 | struct counter *failed; /* HO FAIL received */ |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 537 | } handover; |
| 538 | struct { |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 539 | struct counter *attach; |
| 540 | struct counter *normal; |
| 541 | struct counter *periodic; |
| 542 | struct counter *detach; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 543 | } loc_upd_type; |
| 544 | struct { |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 545 | struct counter *reject; |
| 546 | struct counter *accept; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 547 | } loc_upd_resp; |
| 548 | struct { |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 549 | struct counter *attempted; |
| 550 | struct counter *detached; |
| 551 | struct counter *completed; |
| 552 | struct counter *expired; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 553 | } paging; |
| 554 | struct { |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 555 | struct counter *submitted; /* MO SMS submissions */ |
| 556 | struct counter *no_receiver; |
| 557 | struct counter *delivered; /* MT SMS deliveries */ |
| 558 | struct counter *rp_err_mem; |
| 559 | struct counter *rp_err_other; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 560 | } sms; |
| 561 | struct { |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame] | 562 | struct counter *dialled; /* total number of dialled calls */ |
| 563 | struct counter *alerted; /* we alerted the other end */ |
| 564 | struct counter *connected;/* how many calls were accepted */ |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 565 | } call; |
Holger Hans Peter Freyther | 3ba36d5 | 2010-04-17 06:48:29 +0200 | [diff] [blame] | 566 | struct { |
| 567 | struct counter *rf_fail; |
| 568 | struct counter *rll_err; |
| 569 | } chan; |
Holger Hans Peter Freyther | bb110f9 | 2010-04-12 10:45:52 +0200 | [diff] [blame] | 570 | struct { |
| 571 | struct counter *oml_fail; |
| 572 | struct counter *rsl_fail; |
| 573 | } bts; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 574 | }; |
| 575 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 576 | enum gsm_auth_policy { |
| 577 | GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */ |
| 578 | GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */ |
| 579 | GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */ |
| 580 | }; |
| 581 | |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 582 | #define GSM_T3101_DEFAULT 10 |
| 583 | #define GSM_T3113_DEFAULT 60 |
| 584 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 585 | struct gsm_network { |
| 586 | /* global parameters */ |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 587 | u_int16_t country_code; |
| 588 | u_int16_t network_code; |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 589 | char *name_long; |
| 590 | char *name_short; |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 591 | enum gsm_auth_policy auth_policy; |
Harald Welte | 1085c09 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 592 | enum gsm48_reject_value reject_cause; |
Harald Welte | 4381cfe | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 593 | int a5_encryption; |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 594 | int neci; |
Harald Welte | 648b6ce | 2009-12-14 09:00:24 +0100 | [diff] [blame] | 595 | int send_mm_info; |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 596 | struct { |
| 597 | int active; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 598 | /* Window RXLEV averaging */ |
| 599 | unsigned int win_rxlev_avg; /* number of SACCH frames */ |
| 600 | /* Window RXQUAL averaging */ |
| 601 | unsigned int win_rxqual_avg; /* number of SACCH frames */ |
| 602 | /* Window RXLEV neighbouring cells averaging */ |
| 603 | unsigned int win_rxlev_avg_neigh; /* number of SACCH frames */ |
| 604 | |
| 605 | /* how often should we check for power budget HO */ |
| 606 | unsigned int pwr_interval; /* SACCH frames */ |
| 607 | /* how much better does a neighbor cell have to be ? */ |
| 608 | unsigned int pwr_hysteresis; /* dBm */ |
| 609 | /* maximum distacne before we try a handover */ |
| 610 | unsigned int max_distance; /* TA values */ |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 611 | } handover; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 612 | |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 613 | struct gsmnet_stats stats; |
| 614 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 615 | /* layer 4 */ |
| 616 | int (*mncc_recv) (struct gsm_network *net, int msg_type, void *arg); |
| 617 | struct llist_head upqueue; |
| 618 | struct llist_head trans_list; |
| 619 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 620 | unsigned int num_bts; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 621 | struct llist_head bts_list; |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 622 | |
| 623 | /* timer values */ |
| 624 | int T3101; |
Holger Hans Peter Freyther | 23975e7 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 625 | int T3103; |
| 626 | int T3105; |
| 627 | int T3107; |
| 628 | int T3109; |
| 629 | int T3111; |
| 630 | int T3113; |
| 631 | int T3115; |
| 632 | int T3117; |
| 633 | int T3119; |
| 634 | int T3141; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 635 | |
| 636 | /* Radio Resource Location Protocol (TS 04.31) */ |
| 637 | struct { |
| 638 | enum rrlp_mode mode; |
| 639 | } rrlp; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 640 | }; |
| 641 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 642 | #define SMS_HDR_SIZE 128 |
| 643 | #define SMS_TEXT_SIZE 256 |
| 644 | struct gsm_sms { |
Harald Welte | d409be7 | 2009-11-07 00:06:19 +0900 | [diff] [blame] | 645 | unsigned long long id; |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 646 | struct gsm_subscriber *sender; |
| 647 | struct gsm_subscriber *receiver; |
| 648 | |
Harald Welte | b9c758b | 2009-07-05 14:02:46 +0200 | [diff] [blame] | 649 | unsigned long validity_minutes; |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 650 | u_int8_t reply_path_req; |
| 651 | u_int8_t status_rep_req; |
| 652 | u_int8_t ud_hdr_ind; |
| 653 | u_int8_t protocol_id; |
| 654 | u_int8_t data_coding_scheme; |
| 655 | u_int8_t msg_ref; |
| 656 | char dest_addr[20+1]; /* DA LV is 12 bytes max, i.e. 10 bytes |
| 657 | * BCD == 20 bytes string */ |
| 658 | u_int8_t user_data_len; |
| 659 | u_int8_t user_data[SMS_TEXT_SIZE]; |
Harald Welte | f3efc59 | 2009-07-27 20:11:35 +0200 | [diff] [blame] | 660 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 661 | char text[SMS_TEXT_SIZE]; |
| 662 | }; |
| 663 | |
Harald Welte | 3606cc5 | 2009-12-05 15:13:22 +0530 | [diff] [blame] | 664 | |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 665 | 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] | 666 | int (*mncc_recv)(struct gsm_network *, int, void *)); |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 667 | struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type, |
| 668 | u_int8_t tsc, u_int8_t bsic); |
| 669 | struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts); |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 670 | int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 671 | |
| 672 | struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num); |
Harald Welte | 84874c9 | 2009-12-14 22:33:02 +0100 | [diff] [blame] | 673 | |
| 674 | /* Get reference to a neighbor cell on a given BCCH ARFCN */ |
Harald Welte | 0b12103 | 2009-12-15 00:21:31 +0100 | [diff] [blame] | 675 | struct gsm_bts *gsm_bts_neighbor(const struct gsm_bts *bts, |
| 676 | u_int16_t arfcn, u_int8_t bsic); |
Harald Welte | 84874c9 | 2009-12-14 22:33:02 +0100 | [diff] [blame] | 677 | |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 678 | 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] | 679 | |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 680 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
Harald Welte | 65da912 | 2009-08-07 00:32:22 +0200 | [diff] [blame] | 681 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
Harald Welte (local) | ccd8845 | 2009-12-27 18:05:25 +0100 | [diff] [blame] | 682 | const char *gsm_lchant_name(enum gsm_chan_t c); |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 683 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
Harald Welte (local) | d48f4eb | 2009-12-28 23:14:22 +0100 | [diff] [blame] | 684 | char *gsm_trx_name(struct gsm_bts_trx *trx); |
Harald Welte | 23a6863 | 2009-02-19 17:06:42 +0000 | [diff] [blame] | 685 | char *gsm_ts_name(struct gsm_bts_trx_ts *ts); |
Harald Welte (local) | 19ef62a | 2009-12-27 18:16:36 +0100 | [diff] [blame] | 686 | char *gsm_lchan_name(struct gsm_lchan *lchan); |
Harald Welte | 1887f9d | 2009-12-29 10:52:38 +0100 | [diff] [blame] | 687 | const char *gsm_lchans_name(enum gsm_lchan_state s); |
Harald Welte | a72c98e | 2009-01-04 16:10:38 +0000 | [diff] [blame] | 688 | |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 689 | enum gsm_e1_event { |
| 690 | EVT_E1_NONE, |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 691 | EVT_E1_TEI_UP, |
| 692 | EVT_E1_TEI_DN, |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 693 | }; |
| 694 | |
Harald Welte | cd06bfb | 2009-02-10 17:33:56 +0000 | [diff] [blame] | 695 | void set_ts_e1link(struct gsm_bts_trx_ts *ts, u_int8_t e1_nr, |
| 696 | u_int8_t e1_ts, u_int8_t e1_ts_ss); |
Harald Welte | 1d014a5 | 2009-08-08 15:38:29 +0200 | [diff] [blame] | 697 | enum gsm_bts_type parse_btstype(const char *arg); |
Holger Hans Peter Freyther | 2dceae6 | 2009-06-12 17:39:38 +0200 | [diff] [blame] | 698 | const char *btstype2str(enum gsm_bts_type type); |
Harald Welte | 6e670aa | 2010-01-07 20:44:32 +0100 | [diff] [blame] | 699 | struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr); |
Harald Welte | be99149 | 2009-05-23 13:56:40 +0000 | [diff] [blame] | 700 | struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac, |
| 701 | struct gsm_bts *start_bts); |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 702 | |
Andreas Eversberg | 8226fa7 | 2009-06-29 15:19:38 +0200 | [diff] [blame] | 703 | extern void *tall_bsc_ctx; |
Harald Welte | f88c8a0 | 2009-12-20 13:48:15 +0100 | [diff] [blame] | 704 | extern int ipacc_rtp_direct; |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 705 | |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 706 | static inline int is_ipaccess_bts(struct gsm_bts *bts) |
| 707 | { |
| 708 | switch (bts->type) { |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 709 | case GSM_BTS_TYPE_NANOBTS: |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 710 | return 1; |
| 711 | default: |
| 712 | break; |
| 713 | } |
| 714 | return 0; |
| 715 | } |
| 716 | |
Harald Welte | 5b57067 | 2009-08-10 10:08:01 +0200 | [diff] [blame] | 717 | static inline int is_siemens_bts(struct gsm_bts *bts) |
| 718 | { |
| 719 | switch (bts->type) { |
| 720 | case GSM_BTS_TYPE_BS11: |
| 721 | return 1; |
| 722 | default: |
| 723 | break; |
| 724 | } |
| 725 | |
| 726 | return 0; |
| 727 | } |
| 728 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 729 | |
| 730 | enum gsm_auth_policy gsm_auth_policy_parse(const char *arg); |
| 731 | const char *gsm_auth_policy_name(enum gsm_auth_policy policy); |
| 732 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 733 | enum rrlp_mode rrlp_mode_parse(const char *arg); |
| 734 | const char *rrlp_mode_name(enum rrlp_mode mode); |
| 735 | |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 736 | enum bts_gprs_mode bts_gprs_mode_parse(const char *arg); |
| 737 | const char *bts_gprs_mode_name(enum bts_gprs_mode mode); |
| 738 | |
Holger Hans Peter Freyther | 2d501ea | 2009-11-11 11:54:24 +0100 | [diff] [blame] | 739 | void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked); |
| 740 | |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 741 | int gsm48_ra_id_by_bts(u_int8_t *buf, struct gsm_bts *bts); |
| 742 | void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts); |
Harald Welte | d12b0fd | 2009-12-15 21:36:05 +0100 | [diff] [blame] | 743 | struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan); |
| 744 | |
Harald Welte | fbda4e1 | 2010-03-04 11:04:52 +0100 | [diff] [blame] | 745 | int gsm_bts_model_register(struct gsm_bts_model *model); |
| 746 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 747 | #endif |