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 | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
| 5 | |
| 6 | #include <osmocom/core/timer.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 7 | #include <osmocom/core/select.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 8 | |
Harald Welte | b96be39 | 2011-05-25 12:33:33 +0200 | [diff] [blame] | 9 | #include <openbsc/rest_octets.h> |
| 10 | |
Holger Hans Peter Freyther | d7b22c6 | 2013-04-29 09:11:02 +0200 | [diff] [blame] | 11 | /** annotations for msgb ownership */ |
| 12 | #define __uses |
| 13 | |
Holger Hans Peter Freyther | 6f61555 | 2010-11-15 20:50:42 +0100 | [diff] [blame] | 14 | #define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3] |
| 15 | |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 16 | struct mncc_sock_state; |
Jacob Erlbeck | 1e30a28 | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 17 | struct gsm_subscriber_group; |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 18 | |
Holger Hans Peter Freyther | 9c595b7 | 2010-06-15 11:20:52 +0800 | [diff] [blame] | 19 | #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] |
| 20 | |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 21 | enum gsm_security_event { |
| 22 | GSM_SECURITY_NOAVAIL, |
| 23 | GSM_SECURITY_AUTH_FAILED, |
| 24 | GSM_SECURITY_SUCCEEDED, |
Andreas Eversberg | 641475c | 2013-07-10 08:58:03 +0200 | [diff] [blame] | 25 | GSM_SECURITY_ALREADY, |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 26 | }; |
| 27 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 28 | struct msgb; |
| 29 | typedef int gsm_cbfn(unsigned int hooknum, |
| 30 | unsigned int event, |
| 31 | struct msgb *msg, |
| 32 | void *data, void *param); |
| 33 | |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 34 | /* Real authentication information containing Ki */ |
| 35 | enum gsm_auth_algo { |
| 36 | AUTH_ALGO_NONE, |
| 37 | AUTH_ALGO_XOR, |
| 38 | AUTH_ALGO_COMP128v1, |
| 39 | }; |
| 40 | |
| 41 | struct gsm_auth_info { |
| 42 | enum gsm_auth_algo auth_algo; |
| 43 | unsigned int a3a8_ki_len; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 44 | uint8_t a3a8_ki[16]; |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | struct gsm_auth_tuple { |
| 48 | int use_count; |
| 49 | int key_seq; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 50 | uint8_t rand[16]; |
| 51 | uint8_t sres[4]; |
| 52 | uint8_t kc[8]; |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 53 | }; |
Sylvain Munaut | b48216f | 2010-06-09 12:45:37 +0200 | [diff] [blame] | 54 | #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] | 55 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 56 | /* |
| 57 | * LOCATION UPDATING REQUEST state |
| 58 | * |
| 59 | * Our current operation is: |
| 60 | * - Get imei/tmsi |
| 61 | * - Accept/Reject according to global policy |
| 62 | */ |
| 63 | struct gsm_loc_updating_operation { |
Pablo Neira Ayuso | bf540cb | 2011-05-06 12:11:06 +0200 | [diff] [blame] | 64 | struct osmo_timer_list updating_timer; |
Holger Hans Peter Freyther | 251aa91 | 2009-10-27 10:42:28 +0100 | [diff] [blame] | 65 | unsigned int waiting_for_imsi : 1; |
| 66 | unsigned int waiting_for_imei : 1; |
Sylvain Munaut | 2030a2a | 2010-06-10 13:36:59 +0200 | [diff] [blame] | 67 | unsigned int key_seq : 4; |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 70 | /* |
| 71 | * AUTHENTICATION/CIPHERING state |
| 72 | */ |
| 73 | struct gsm_security_operation { |
| 74 | struct gsm_auth_tuple atuple; |
| 75 | gsm_cbfn *cb; |
| 76 | void *cb_data; |
| 77 | }; |
| 78 | |
Holger Hans Peter Freyther | 02d39b2 | 2010-07-05 15:34:16 +0800 | [diff] [blame] | 79 | /* |
| 80 | * A dummy to keep a connection up for at least |
| 81 | * a couple of seconds to work around MSC issues. |
| 82 | */ |
| 83 | struct gsm_anchor_operation { |
Pablo Neira Ayuso | bf540cb | 2011-05-06 12:11:06 +0200 | [diff] [blame] | 84 | struct osmo_timer_list timeout; |
Holger Hans Peter Freyther | 02d39b2 | 2010-07-05 15:34:16 +0800 | [diff] [blame] | 85 | }; |
| 86 | |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 87 | /* Maximum number of neighbor cells whose average we track */ |
| 88 | #define MAX_NEIGH_MEAS 10 |
| 89 | /* Maximum size of the averaging window for neighbor cells */ |
| 90 | #define MAX_WIN_NEIGH_AVG 10 |
| 91 | |
| 92 | /* processed neighbor measurements for one cell */ |
| 93 | struct neigh_meas_proc { |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 94 | uint16_t arfcn; |
| 95 | uint8_t bsic; |
| 96 | uint8_t rxlev[MAX_WIN_NEIGH_AVG]; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 97 | unsigned int rxlev_cnt; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 98 | uint8_t last_seen_nr; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 99 | }; |
| 100 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 101 | /* the per subscriber data for lchan */ |
| 102 | struct gsm_subscriber_connection { |
Holger Hans Peter Freyther | 79f763f | 2010-09-16 00:53:37 +0800 | [diff] [blame] | 103 | struct llist_head entry; |
| 104 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 105 | /* To whom we are allocated at the moment */ |
| 106 | struct gsm_subscriber *subscr; |
| 107 | |
Holger Hans Peter Freyther | e7bd863 | 2013-06-30 15:30:47 +0200 | [diff] [blame] | 108 | /* LU expiration handling */ |
| 109 | uint8_t expire_timer_stopped; |
Holger Hans Peter Freyther | ca11443 | 2014-02-08 15:20:48 +0100 | [diff] [blame] | 110 | /* SMS helpers for libmsc */ |
| 111 | uint8_t next_rp_ref; |
Holger Hans Peter Freyther | e7bd863 | 2013-06-30 15:30:47 +0200 | [diff] [blame] | 112 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 113 | /* |
| 114 | * Operations that have a state and might be pending |
| 115 | */ |
| 116 | struct gsm_loc_updating_operation *loc_operation; |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 117 | struct gsm_security_operation *sec_operation; |
Holger Hans Peter Freyther | 02d39b2 | 2010-07-05 15:34:16 +0800 | [diff] [blame] | 118 | struct gsm_anchor_operation *anch_operation; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 119 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 120 | /* Are we part of a special "silent" call */ |
| 121 | int silent_call; |
Holger Hans Peter Freyther | 182c81f | 2010-12-29 16:28:33 +0100 | [diff] [blame] | 122 | int put_channel; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 123 | |
Holger Hans Peter Freyther | 2f9d1ef | 2010-09-16 20:14:01 +0800 | [diff] [blame] | 124 | /* bsc structures */ |
| 125 | struct osmo_bsc_sccp_con *sccp_con; |
| 126 | |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 127 | /* back pointers */ |
Holger Hans Peter Freyther | 4049455 | 2010-06-28 17:09:29 +0800 | [diff] [blame] | 128 | int in_release; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 129 | struct gsm_lchan *lchan; |
Holger Hans Peter Freyther | e071ab7 | 2010-06-30 12:40:10 +0800 | [diff] [blame] | 130 | struct gsm_lchan *ho_lchan; |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 131 | struct gsm_bts *bts; |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 132 | |
| 133 | /* for assignment handling */ |
Pablo Neira Ayuso | bf540cb | 2011-05-06 12:11:06 +0200 | [diff] [blame] | 134 | struct osmo_timer_list T10; |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 135 | struct gsm_lchan *secondary_lchan; |
| 136 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 137 | }; |
| 138 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 139 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 140 | #define ROLE_BSC |
| 141 | #include "gsm_data_shared.h" |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 142 | |
Holger Hans Peter Freyther | 5ba6f48 | 2009-10-28 14:23:39 +0100 | [diff] [blame] | 143 | |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 144 | /* Some statistics of our network */ |
| 145 | struct gsmnet_stats { |
| 146 | struct { |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 147 | struct osmo_counter *total; |
| 148 | struct osmo_counter *no_channel; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 149 | } chreq; |
| 150 | struct { |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 151 | struct osmo_counter *attempted; |
| 152 | struct osmo_counter *no_channel; /* no channel available */ |
| 153 | struct osmo_counter *timeout; /* T3103 timeout */ |
| 154 | struct osmo_counter *completed; /* HO COMPL received */ |
| 155 | struct osmo_counter *failed; /* HO FAIL received */ |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 156 | } handover; |
| 157 | struct { |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 158 | struct osmo_counter *attach; |
| 159 | struct osmo_counter *normal; |
| 160 | struct osmo_counter *periodic; |
| 161 | struct osmo_counter *detach; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 162 | } loc_upd_type; |
| 163 | struct { |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 164 | struct osmo_counter *reject; |
| 165 | struct osmo_counter *accept; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 166 | } loc_upd_resp; |
| 167 | struct { |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 168 | struct osmo_counter *attempted; |
| 169 | struct osmo_counter *detached; |
| 170 | struct osmo_counter *completed; |
| 171 | struct osmo_counter *expired; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 172 | } paging; |
| 173 | struct { |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 174 | struct osmo_counter *submitted; /* MO SMS submissions */ |
| 175 | struct osmo_counter *no_receiver; |
| 176 | struct osmo_counter *delivered; /* MT SMS deliveries */ |
| 177 | struct osmo_counter *rp_err_mem; |
| 178 | struct osmo_counter *rp_err_other; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 179 | } sms; |
| 180 | struct { |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 181 | struct osmo_counter *mo_setup; |
| 182 | struct osmo_counter *mo_connect_ack; |
| 183 | struct osmo_counter *mt_setup; |
| 184 | struct osmo_counter *mt_connect; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 185 | } call; |
Holger Hans Peter Freyther | 3ba36d5 | 2010-04-17 06:48:29 +0200 | [diff] [blame] | 186 | struct { |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 187 | struct osmo_counter *rf_fail; |
| 188 | struct osmo_counter *rll_err; |
Holger Hans Peter Freyther | 3ba36d5 | 2010-04-17 06:48:29 +0200 | [diff] [blame] | 189 | } chan; |
Holger Hans Peter Freyther | bb110f9 | 2010-04-12 10:45:52 +0200 | [diff] [blame] | 190 | struct { |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 191 | struct osmo_counter *oml_fail; |
| 192 | struct osmo_counter *rsl_fail; |
Holger Hans Peter Freyther | bb110f9 | 2010-04-12 10:45:52 +0200 | [diff] [blame] | 193 | } bts; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 194 | }; |
| 195 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 196 | enum gsm_auth_policy { |
| 197 | GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */ |
| 198 | GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */ |
| 199 | GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */ |
| 200 | }; |
| 201 | |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 202 | #define GSM_T3101_DEFAULT 10 |
Harald Welte | 67161f2 | 2012-06-03 13:01:47 +0200 | [diff] [blame] | 203 | #define GSM_T3105_DEFAULT 40 |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 204 | #define GSM_T3113_DEFAULT 60 |
Andreas Eversberg | 75e13a4 | 2013-02-07 11:51:16 +0100 | [diff] [blame] | 205 | #define GSM_T3122_DEFAULT 10 |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 206 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 207 | struct gsm_network { |
| 208 | /* global parameters */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 209 | uint16_t country_code; |
| 210 | uint16_t network_code; |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 211 | char *name_long; |
| 212 | char *name_short; |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 213 | enum gsm_auth_policy auth_policy; |
Harald Welte | 1085c09 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 214 | enum gsm48_reject_value reject_cause; |
Harald Welte | 4381cfe | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 215 | int a5_encryption; |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 216 | int neci; |
Harald Welte | 648b6ce | 2009-12-14 09:00:24 +0100 | [diff] [blame] | 217 | int send_mm_info; |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 218 | struct { |
| 219 | int active; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 220 | /* Window RXLEV averaging */ |
| 221 | unsigned int win_rxlev_avg; /* number of SACCH frames */ |
| 222 | /* Window RXQUAL averaging */ |
| 223 | unsigned int win_rxqual_avg; /* number of SACCH frames */ |
| 224 | /* Window RXLEV neighbouring cells averaging */ |
| 225 | unsigned int win_rxlev_avg_neigh; /* number of SACCH frames */ |
| 226 | |
| 227 | /* how often should we check for power budget HO */ |
| 228 | unsigned int pwr_interval; /* SACCH frames */ |
| 229 | /* how much better does a neighbor cell have to be ? */ |
| 230 | unsigned int pwr_hysteresis; /* dBm */ |
| 231 | /* maximum distacne before we try a handover */ |
| 232 | unsigned int max_distance; /* TA values */ |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 233 | } handover; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 234 | |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 235 | struct gsmnet_stats stats; |
| 236 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 237 | /* layer 4 */ |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 238 | struct mncc_sock_state *mncc_state; |
Harald Welte | 29b64e9 | 2010-12-23 01:07:46 +0100 | [diff] [blame] | 239 | int (*mncc_recv) (struct gsm_network *net, struct msgb *msg); |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 240 | struct llist_head upqueue; |
| 241 | struct llist_head trans_list; |
Holger Hans Peter Freyther | abcddf1 | 2010-06-14 18:20:15 +0800 | [diff] [blame] | 242 | struct bsc_api *bsc_api; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 243 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 244 | unsigned int num_bts; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 245 | struct llist_head bts_list; |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 246 | |
| 247 | /* timer values */ |
| 248 | int T3101; |
Holger Hans Peter Freyther | 23975e7 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 249 | int T3103; |
| 250 | int T3105; |
| 251 | int T3107; |
| 252 | int T3109; |
| 253 | int T3111; |
| 254 | int T3113; |
| 255 | int T3115; |
| 256 | int T3117; |
| 257 | int T3119; |
Harald Welte | 2862dca | 2010-12-23 14:39:29 +0100 | [diff] [blame] | 258 | int T3122; |
Holger Hans Peter Freyther | 23975e7 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 259 | int T3141; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 260 | |
Jan Luebbe | bfbdeec | 2012-12-27 00:27:16 +0100 | [diff] [blame] | 261 | /* timer to expire old location updates */ |
| 262 | struct osmo_timer_list subscr_expire_timer; |
| 263 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 264 | /* Radio Resource Location Protocol (TS 04.31) */ |
| 265 | struct { |
| 266 | enum rrlp_mode mode; |
| 267 | } rrlp; |
Holger Hans Peter Freyther | 5a3a61d | 2010-09-06 09:25:48 +0800 | [diff] [blame] | 268 | |
| 269 | /* enable the DTXu and DTXd for this network */ |
| 270 | int dtx_enabled; |
| 271 | |
Holger Hans Peter Freyther | 7889107 | 2010-09-06 09:36:02 +0800 | [diff] [blame] | 272 | enum gsm_chan_t ctype_by_chreq[16]; |
| 273 | |
Holger Hans Peter Freyther | 76fc4a3 | 2010-09-06 09:41:50 +0800 | [diff] [blame] | 274 | /* Use a TCH for handling requests of type paging any */ |
| 275 | int pag_any_tch; |
| 276 | |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 277 | /* MSC data in case we are a true BSC */ |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 278 | struct osmo_bsc_data *bsc_data; |
Holger Hans Peter Freyther | daee5ca | 2010-12-22 12:34:39 +0100 | [diff] [blame] | 279 | |
| 280 | /* subscriber related features */ |
Jacob Erlbeck | 1e30a28 | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 281 | struct gsm_subscriber_group *subscr_group; |
Holger Hans Peter Freyther | 11b28f9 | 2010-12-24 13:48:27 +0100 | [diff] [blame] | 282 | struct gsm_sms_queue *sms_queue; |
Daniel Willmann | 6fc4a98 | 2011-07-22 17:55:42 +0200 | [diff] [blame] | 283 | |
| 284 | /* control interface */ |
| 285 | struct ctrl_handle *ctrl; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 286 | }; |
| 287 | |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 288 | struct osmo_esme; |
| 289 | |
| 290 | enum gsm_sms_source_id { |
| 291 | SMS_SOURCE_UNKNOWN = 0, |
| 292 | SMS_SOURCE_MS, /* received from MS */ |
| 293 | SMS_SOURCE_VTY, /* received from VTY */ |
| 294 | SMS_SOURCE_SMPP, /* received via SMPP */ |
| 295 | }; |
| 296 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 297 | #define SMS_HDR_SIZE 128 |
| 298 | #define SMS_TEXT_SIZE 256 |
Harald Welte | e07b6a7 | 2012-11-23 19:02:37 +0100 | [diff] [blame] | 299 | |
| 300 | struct gsm_sms_addr { |
| 301 | uint8_t ton; |
| 302 | uint8_t npi; |
| 303 | char addr[21+1]; |
| 304 | }; |
| 305 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 306 | struct gsm_sms { |
Harald Welte | d409be7 | 2009-11-07 00:06:19 +0900 | [diff] [blame] | 307 | unsigned long long id; |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 308 | struct gsm_subscriber *receiver; |
Harald Welte | c0de14d | 2012-11-23 23:35:01 +0100 | [diff] [blame] | 309 | struct gsm_sms_addr src, dst; |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 310 | enum gsm_sms_source_id source; |
| 311 | |
| 312 | struct { |
| 313 | struct osmo_esme *esme; |
| 314 | uint32_t sequence_nr; |
| 315 | int transaction_mode; |
| 316 | char msg_id[16]; |
| 317 | } smpp; |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 318 | |
Harald Welte | b9c758b | 2009-07-05 14:02:46 +0200 | [diff] [blame] | 319 | unsigned long validity_minutes; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 320 | uint8_t reply_path_req; |
| 321 | uint8_t status_rep_req; |
| 322 | uint8_t ud_hdr_ind; |
| 323 | uint8_t protocol_id; |
| 324 | uint8_t data_coding_scheme; |
| 325 | uint8_t msg_ref; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 326 | uint8_t user_data_len; |
| 327 | uint8_t user_data[SMS_TEXT_SIZE]; |
Harald Welte | f3efc59 | 2009-07-27 20:11:35 +0200 | [diff] [blame] | 328 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 329 | char text[SMS_TEXT_SIZE]; |
| 330 | }; |
| 331 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 332 | 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] | 333 | int (*mncc_recv)(struct gsm_network *, struct msgb *)); |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 334 | 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] | 335 | |
Harald Welte | 84874c9 | 2009-12-14 22:33:02 +0100 | [diff] [blame] | 336 | /* Get reference to a neighbor cell on a given BCCH ARFCN */ |
Harald Welte | 0b12103 | 2009-12-15 00:21:31 +0100 | [diff] [blame] | 337 | 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] | 338 | uint16_t arfcn, uint8_t bsic); |
Harald Welte | 84874c9 | 2009-12-14 22:33:02 +0100 | [diff] [blame] | 339 | |
Harald Welte | 1d014a5 | 2009-08-08 15:38:29 +0200 | [diff] [blame] | 340 | enum gsm_bts_type parse_btstype(const char *arg); |
Holger Hans Peter Freyther | 2dceae6 | 2009-06-12 17:39:38 +0200 | [diff] [blame] | 341 | const char *btstype2str(enum gsm_bts_type type); |
Harald Welte | be99149 | 2009-05-23 13:56:40 +0000 | [diff] [blame] | 342 | struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac, |
| 343 | struct gsm_bts *start_bts); |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 344 | |
Andreas Eversberg | 8226fa7 | 2009-06-29 15:19:38 +0200 | [diff] [blame] | 345 | extern void *tall_bsc_ctx; |
Harald Welte | f88c8a0 | 2009-12-20 13:48:15 +0100 | [diff] [blame] | 346 | extern int ipacc_rtp_direct; |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 347 | |
Harald Welte | f383aa1 | 2012-07-02 19:51:55 +0200 | [diff] [blame] | 348 | /* this actaully refers to the IPA transport, not the BTS model */ |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 349 | static inline int is_ipaccess_bts(struct gsm_bts *bts) |
| 350 | { |
| 351 | switch (bts->type) { |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 352 | case GSM_BTS_TYPE_NANOBTS: |
Harald Welte | f383aa1 | 2012-07-02 19:51:55 +0200 | [diff] [blame] | 353 | case GSM_BTS_TYPE_OSMO_SYSMO: |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 354 | return 1; |
| 355 | default: |
| 356 | break; |
| 357 | } |
| 358 | return 0; |
| 359 | } |
| 360 | |
Harald Welte | 5b57067 | 2009-08-10 10:08:01 +0200 | [diff] [blame] | 361 | static inline int is_siemens_bts(struct gsm_bts *bts) |
| 362 | { |
| 363 | switch (bts->type) { |
| 364 | case GSM_BTS_TYPE_BS11: |
| 365 | return 1; |
| 366 | default: |
| 367 | break; |
| 368 | } |
| 369 | |
| 370 | return 0; |
| 371 | } |
| 372 | |
Andreas Eversberg | 7d8fa34 | 2013-12-05 13:25:06 +0100 | [diff] [blame] | 373 | static inline int is_nokia_bts(struct gsm_bts *bts) |
| 374 | { |
| 375 | switch (bts->type) { |
| 376 | case GSM_BTS_TYPE_NOKIA_SITE: |
| 377 | return 1; |
| 378 | default: |
| 379 | break; |
| 380 | } |
| 381 | |
| 382 | return 0; |
| 383 | } |
| 384 | |
Andreas Eversberg | dcf38e1 | 2013-12-05 14:37:11 +0100 | [diff] [blame] | 385 | static inline int is_e1_bts(struct gsm_bts *bts) |
| 386 | { |
| 387 | switch (bts->type) { |
| 388 | case GSM_BTS_TYPE_BS11: |
| 389 | case GSM_BTS_TYPE_RBS2000: |
| 390 | case GSM_BTS_TYPE_NOKIA_SITE: |
| 391 | return 1; |
| 392 | default: |
| 393 | break; |
| 394 | } |
| 395 | |
| 396 | return 0; |
| 397 | } |
| 398 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 399 | enum gsm_auth_policy gsm_auth_policy_parse(const char *arg); |
| 400 | const char *gsm_auth_policy_name(enum gsm_auth_policy policy); |
| 401 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 402 | enum rrlp_mode rrlp_mode_parse(const char *arg); |
| 403 | const char *rrlp_mode_name(enum rrlp_mode mode); |
| 404 | |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 405 | enum bts_gprs_mode bts_gprs_mode_parse(const char *arg); |
| 406 | const char *bts_gprs_mode_name(enum bts_gprs_mode mode); |
| 407 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 408 | 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] | 409 | 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] | 410 | struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan); |
| 411 | |
Harald Welte | f3d8e92 | 2010-06-14 22:44:42 +0200 | [diff] [blame] | 412 | int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat); |
Harald Welte | fbda4e1 | 2010-03-04 11:04:52 +0100 | [diff] [blame] | 413 | int gsm_bts_model_register(struct gsm_bts_model *model); |
| 414 | |
Holger Hans Peter Freyther | 2412a07 | 2010-06-28 15:47:12 +0800 | [diff] [blame] | 415 | struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan); |
| 416 | void subscr_con_free(struct gsm_subscriber_connection *conn); |
| 417 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 418 | struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, |
| 419 | enum gsm_bts_type type, |
| 420 | uint8_t tsc, uint8_t bsic); |
Harald Welte | 142d12d | 2014-12-29 17:47:08 +0100 | [diff] [blame] | 421 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 422 | void set_ts_e1link(struct gsm_bts_trx_ts *ts, uint8_t e1_nr, |
| 423 | uint8_t e1_ts, uint8_t e1_ts_ss); |
| 424 | |
| 425 | void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked); |
| 426 | int gsm_bts_has_feature(struct gsm_bts *bts, enum gsm_bts_features feat); |
| 427 | struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr); |
Holger Hans Peter Freyther | a49b2c0 | 2014-11-21 11:18:45 +0100 | [diff] [blame] | 428 | int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx); |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 429 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 430 | /* generic E1 line operations for all ISDN-based BTS. */ |
| 431 | extern struct e1inp_line_ops bts_isdn_e1inp_line_ops; |
| 432 | |
Harald Welte | e555c2b | 2012-08-17 13:02:12 +0200 | [diff] [blame] | 433 | extern const struct value_string bts_type_names[_NUM_GSM_BTS_TYPE+1]; |
| 434 | extern const struct value_string bts_type_descs[_NUM_GSM_BTS_TYPE+1]; |
| 435 | |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 436 | /* control interface handling */ |
| 437 | int bsc_base_ctrl_cmds_install(void); |
Holger Hans Peter Freyther | 9dbc3f8 | 2014-03-23 12:06:36 +0100 | [diff] [blame] | 438 | int msc_ctrl_cmds_install(void); |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 439 | |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 440 | /* dependency handling */ |
| 441 | void bts_depend_mark(struct gsm_bts *bts, int dep); |
| 442 | void bts_depend_clear(struct gsm_bts *bts, int dep); |
| 443 | int bts_depend_check(struct gsm_bts *bts); |
Holger Hans Peter Freyther | f7e23c5 | 2014-12-17 15:44:32 +0100 | [diff] [blame] | 444 | int bts_depend_is_depedency(struct gsm_bts *base, struct gsm_bts *other); |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 445 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 446 | #endif /* _GSM_DATA_H */ |