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