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