Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 1 | #ifndef _GB_PROXY_H |
| 2 | #define _GB_PROXY_H |
| 3 | |
| 4 | |
| 5 | #include <osmocom/core/msgb.h> |
Neels Hofmeyr | 6179f0c | 2018-02-21 00:39:36 +0100 | [diff] [blame] | 6 | #include <osmocom/gsm/gsm23003.h> |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 7 | |
| 8 | #include <osmocom/gprs/gprs_ns.h> |
| 9 | #include <osmocom/vty/command.h> |
| 10 | |
| 11 | #include <sys/types.h> |
| 12 | #include <regex.h> |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 13 | #include <stdbool.h> |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 14 | |
| 15 | #define GBPROXY_INIT_VU_GEN_TX 256 |
| 16 | |
| 17 | struct rate_ctr_group; |
| 18 | struct gprs_gb_parse_context; |
| 19 | struct tlv_parsed; |
| 20 | |
| 21 | enum gbproxy_global_ctr { |
| 22 | GBPROX_GLOB_CTR_INV_BVCI, |
| 23 | GBPROX_GLOB_CTR_INV_LAI, |
| 24 | GBPROX_GLOB_CTR_INV_RAI, |
| 25 | GBPROX_GLOB_CTR_INV_NSEI, |
| 26 | GBPROX_GLOB_CTR_PROTO_ERR_BSS, |
| 27 | GBPROX_GLOB_CTR_PROTO_ERR_SGSN, |
| 28 | GBPROX_GLOB_CTR_NOT_SUPPORTED_BSS, |
| 29 | GBPROX_GLOB_CTR_NOT_SUPPORTED_SGSN, |
| 30 | GBPROX_GLOB_CTR_RESTART_RESET_SGSN, |
| 31 | GBPROX_GLOB_CTR_TX_ERR_SGSN, |
| 32 | GBPROX_GLOB_CTR_OTHER_ERR, |
| 33 | GBPROX_GLOB_CTR_PATCH_PEER_ERR, |
| 34 | }; |
| 35 | |
| 36 | enum gbproxy_peer_ctr { |
| 37 | GBPROX_PEER_CTR_BLOCKED, |
| 38 | GBPROX_PEER_CTR_UNBLOCKED, |
| 39 | GBPROX_PEER_CTR_DROPPED, |
| 40 | GBPROX_PEER_CTR_INV_NSEI, |
| 41 | GBPROX_PEER_CTR_TX_ERR, |
| 42 | GBPROX_PEER_CTR_RAID_PATCHED_BSS, |
| 43 | GBPROX_PEER_CTR_RAID_PATCHED_SGSN, |
| 44 | GBPROX_PEER_CTR_APN_PATCHED, |
| 45 | GBPROX_PEER_CTR_TLLI_PATCHED_BSS, |
| 46 | GBPROX_PEER_CTR_TLLI_PATCHED_SGSN, |
| 47 | GBPROX_PEER_CTR_PTMSI_PATCHED_BSS, |
| 48 | GBPROX_PEER_CTR_PTMSI_PATCHED_SGSN, |
| 49 | GBPROX_PEER_CTR_PATCH_CRYPT_ERR, |
| 50 | GBPROX_PEER_CTR_PATCH_ERR, |
| 51 | GBPROX_PEER_CTR_ATTACH_REQS, |
| 52 | GBPROX_PEER_CTR_ATTACH_REJS, |
| 53 | GBPROX_PEER_CTR_ATTACH_ACKS, |
| 54 | GBPROX_PEER_CTR_ATTACH_COMPLS, |
| 55 | GBPROX_PEER_CTR_RA_UPD_REQS, |
| 56 | GBPROX_PEER_CTR_RA_UPD_REJS, |
| 57 | GBPROX_PEER_CTR_RA_UPD_ACKS, |
| 58 | GBPROX_PEER_CTR_RA_UPD_COMPLS, |
| 59 | GBPROX_PEER_CTR_GMM_STATUS_BSS, |
| 60 | GBPROX_PEER_CTR_GMM_STATUS_SGSN, |
| 61 | GBPROX_PEER_CTR_DETACH_REQS, |
| 62 | GBPROX_PEER_CTR_DETACH_ACKS, |
| 63 | GBPROX_PEER_CTR_PDP_ACT_REQS, |
| 64 | GBPROX_PEER_CTR_PDP_ACT_REJS, |
| 65 | GBPROX_PEER_CTR_PDP_ACT_ACKS, |
| 66 | GBPROX_PEER_CTR_PDP_DEACT_REQS, |
| 67 | GBPROX_PEER_CTR_PDP_DEACT_ACKS, |
| 68 | GBPROX_PEER_CTR_TLLI_UNKNOWN, |
| 69 | GBPROX_PEER_CTR_TLLI_CACHE_SIZE, |
| 70 | GBPROX_PEER_CTR_LAST, |
| 71 | }; |
| 72 | |
| 73 | enum gbproxy_keep_mode { |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 74 | GBPROX_KEEP_NEVER, /* don't ever keep TLLI/IMSI state of de-registered subscribers */ |
| 75 | GBPROX_KEEP_REATTACH, /* keep if re-attach has been requested by SGSN */ |
| 76 | GBPROX_KEEP_IDENTIFIED, /* keep if we had resolved an IMSI */ |
| 77 | GBPROX_KEEP_ALWAYS, /* always keep */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | enum gbproxy_match_id { |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 81 | GBPROX_MATCH_PATCHING, /* match rule on whether or not we should patch */ |
| 82 | GBPROX_MATCH_ROUTING, /* match rule on whether or not we should route (2-SGSN) */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 83 | GBPROX_MATCH_LAST |
| 84 | }; |
| 85 | |
| 86 | struct gbproxy_match { |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 87 | bool enable; /* is this match enabled? */ |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 88 | char *re_str; /* regular expression (for IMSI) in string format */ |
| 89 | regex_t re_comp; /* compiled regular expression (for IMSI) */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 90 | }; |
| 91 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 92 | /* global gb-proxy configuration */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 93 | struct gbproxy_config { |
| 94 | /* parsed from config file */ |
| 95 | uint16_t nsip_sgsn_nsei; |
| 96 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 97 | /* NS instance of libosmogb */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 98 | struct gprs_ns_inst *nsi; |
| 99 | |
| 100 | /* Linked list of all Gb peers (except SGSN) */ |
| 101 | struct llist_head bts_peers; |
| 102 | |
| 103 | /* Counter */ |
| 104 | struct rate_ctr_group *ctrg; |
| 105 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 106 | /* MCC/MNC to be patched into RA-ID on the way from BSS to SGSN? */ |
Neels Hofmeyr | 6179f0c | 2018-02-21 00:39:36 +0100 | [diff] [blame] | 107 | struct osmo_plmn_id core_plmn; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 108 | |
| 109 | /* APN to be patched into PDP CTX ACT REQ on the way from BSS to SGSN */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 110 | uint8_t* core_apn; |
| 111 | size_t core_apn_size; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 112 | |
Pau Espin Pedrol | e0d647f | 2018-08-17 13:13:27 +0200 | [diff] [blame] | 113 | /* Frequency (sec) at which timer to clean stale links is fired (0 disabled) */ |
| 114 | unsigned int clean_stale_timer_freq; |
Pau Espin Pedrol | 0248524 | 2018-08-16 12:11:46 +0200 | [diff] [blame] | 115 | /* If !0, Max age to consider a struct gbproxy_link_info as stale */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 116 | int tlli_max_age; |
Pau Espin Pedrol | 0248524 | 2018-08-16 12:11:46 +0200 | [diff] [blame] | 117 | /* If !0, Max len of gbproxy_peer->list (list of struct gbproxy_link_info) */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 118 | int tlli_max_len; |
Pau Espin Pedrol | 0248524 | 2018-08-16 12:11:46 +0200 | [diff] [blame] | 119 | /* If !0, Max len of gbproxy_link_info->stored_msgs (list of msgb) */ |
| 120 | uint32_t stored_msgs_max_len; |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 121 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 122 | /* Should the P-TMSI be patched on the fly (required for 2-SGSN config) */ |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 123 | bool patch_ptmsi; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 124 | /* Should the IMSI be acquired by the proxy (required for 2-SGSN config) */ |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 125 | bool acquire_imsi; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 126 | /* Should we route subscribers to two different SGSNs? */ |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 127 | bool route_to_sgsn2; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 128 | /* NSEI of the second SGSN */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 129 | uint16_t nsip_sgsn2_nsei; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 130 | /* should we keep a cache of per-subscriber state even after de-registration? */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 131 | enum gbproxy_keep_mode keep_link_infos; |
| 132 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 133 | /* IMSI checking/matching for 2-SGSN routing and patching */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 134 | struct gbproxy_match matches[GBPROX_MATCH_LAST]; |
| 135 | }; |
| 136 | |
| 137 | struct gbproxy_patch_state { |
Neels Hofmeyr | 6179f0c | 2018-02-21 00:39:36 +0100 | [diff] [blame] | 138 | struct osmo_plmn_id local_plmn; |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 139 | |
| 140 | /* List of TLLIs for which patching is enabled */ |
| 141 | struct llist_head logical_links; |
| 142 | int logical_link_count; |
| 143 | }; |
| 144 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 145 | /* one peer at NS level that we interact with (BSS/PCU) */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 146 | struct gbproxy_peer { |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 147 | /* linked to gbproxy_config.bts_peers */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 148 | struct llist_head list; |
| 149 | |
| 150 | /* point back to the config */ |
| 151 | struct gbproxy_config *cfg; |
| 152 | |
| 153 | /* NSEI of the peer entity */ |
| 154 | uint16_t nsei; |
| 155 | |
| 156 | /* BVCI used for Point-to-Point to this peer */ |
| 157 | uint16_t bvci; |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 158 | bool blocked; |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 159 | |
| 160 | /* Routeing Area that this peer is part of (raw 04.08 encoding) */ |
| 161 | uint8_t ra[6]; |
| 162 | |
| 163 | /* Counter */ |
| 164 | struct rate_ctr_group *ctrg; |
| 165 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 166 | /* State related to on-the-fly patching of certain messages */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 167 | struct gbproxy_patch_state patch_state; |
Pau Espin Pedrol | e0d647f | 2018-08-17 13:13:27 +0200 | [diff] [blame] | 168 | |
| 169 | /* Fired periodically to clean up stale links from list */ |
| 170 | struct osmo_timer_list clean_stale_timer; |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | struct gbproxy_tlli_state { |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 174 | /* currently active TLLI */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 175 | uint32_t current; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 176 | /* newly-assigned TLLI (e.g. during P-TMSI allocation procedure) */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 177 | uint32_t assigned; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 178 | /* has the BSS side validated (confirmed) the new TLLI? */ |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 179 | bool bss_validated; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 180 | /* has the SGSN side validated (confirmed) the new TLLI? */ |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 181 | bool net_validated; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 182 | /* NOTE: once both are validated, we set current = assigned and assigned = 0 */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 183 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 184 | /* The P-TMSI for this subscriber */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 185 | uint32_t ptmsi; |
| 186 | }; |
| 187 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 188 | /* One TLLI (= UE, = Subscriber) served via this proxy */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 189 | struct gbproxy_link_info { |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 190 | /* link to gbproxy_peer.patch_state.logical_links */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 191 | struct llist_head list; |
| 192 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 193 | /* TLLI on the BSS/PCU side */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 194 | struct gbproxy_tlli_state tlli; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 195 | /* TLLI on the SGSN side (can be different in case of P-TMSI patching) */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 196 | struct gbproxy_tlli_state sgsn_tlli; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 197 | /* NSEI of the SGSN serving this link */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 198 | uint32_t sgsn_nsei; |
| 199 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 200 | /* timestamp when we last had any contact with this UE */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 201 | time_t timestamp; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 202 | |
| 203 | /* IMSI of the subscriber (if/once known) */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 204 | uint8_t *imsi; |
| 205 | size_t imsi_len; |
| 206 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 207 | /* is the IMSI acquisition still pending? */ |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 208 | bool imsi_acq_pending; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 209 | |
| 210 | /* queue of stored UL messages (until IMSI acquisition completes and we can |
| 211 | * determine which of the SGSNs we should route this to */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 212 | struct llist_head stored_msgs; |
Pau Espin Pedrol | 0248524 | 2018-08-16 12:11:46 +0200 | [diff] [blame] | 213 | uint32_t stored_msgs_len; |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 214 | |
| 215 | /* generated N(U) we use (required due to IMSI acquisition */ |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 216 | unsigned vu_gen_tx_bss; |
| 217 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 218 | /* is this subscriber deregistered (TLLI invalidated)? */ |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 219 | bool is_deregistered; |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 220 | |
Harald Welte | 4a8769a | 2019-03-22 08:26:45 +0100 | [diff] [blame] | 221 | /* does this link match either the (2-SGSN) routing or the patching rule? */ |
Harald Welte | bec7041 | 2019-03-22 09:44:42 +0100 | [diff] [blame^] | 222 | bool is_matching[GBPROX_MATCH_LAST]; |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 223 | }; |
| 224 | |
| 225 | |
| 226 | /* gb_proxy_vty .c */ |
| 227 | |
| 228 | int gbproxy_vty_init(void); |
| 229 | int gbproxy_parse_config(const char *config_file, struct gbproxy_config *cfg); |
| 230 | |
Daniel Willmann | 13404b7 | 2018-06-01 07:21:20 +0200 | [diff] [blame] | 231 | /* gb_proxy_ctrl.c */ |
| 232 | int gb_ctrl_cmds_install(void); |
| 233 | |
Neels Hofmeyr | 4b4c586 | 2017-09-04 15:13:25 +0200 | [diff] [blame] | 234 | |
| 235 | /* gb_proxy.c */ |
| 236 | int gbproxy_init_config(struct gbproxy_config *cfg); |
| 237 | |
| 238 | /* Main input function for Gb proxy */ |
| 239 | int gbprox_rcvmsg(struct gbproxy_config *cfg, struct msgb *msg, uint16_t nsei, uint16_t ns_bvci, uint16_t nsvci); |
| 240 | |
| 241 | int gbprox_signal(unsigned int subsys, unsigned int signal, |
| 242 | void *handler_data, void *signal_data); |
| 243 | |
| 244 | /* Reset all persistent NS-VC's */ |
| 245 | int gbprox_reset_persistent_nsvcs(struct gprs_ns_inst *nsi); |
| 246 | |
| 247 | void gbprox_reset(struct gbproxy_config *cfg); |
| 248 | |
| 249 | /* TLLI info handling */ |
| 250 | void gbproxy_delete_link_infos(struct gbproxy_peer *peer); |
| 251 | struct gbproxy_link_info *gbproxy_update_link_state_ul( |
| 252 | struct gbproxy_peer *peer, time_t now, |
| 253 | struct gprs_gb_parse_context *parse_ctx); |
| 254 | struct gbproxy_link_info *gbproxy_update_link_state_dl( |
| 255 | struct gbproxy_peer *peer, time_t now, |
| 256 | struct gprs_gb_parse_context *parse_ctx); |
| 257 | int gbproxy_update_link_state_after( |
| 258 | struct gbproxy_peer *peer, struct gbproxy_link_info *link_info, |
| 259 | time_t now, struct gprs_gb_parse_context *parse_ctx); |
| 260 | int gbproxy_remove_stale_link_infos(struct gbproxy_peer *peer, time_t now); |
| 261 | void gbproxy_delete_link_info(struct gbproxy_peer *peer, |
| 262 | struct gbproxy_link_info *link_info); |
| 263 | void gbproxy_link_info_discard_messages(struct gbproxy_link_info *link_info); |
| 264 | |
| 265 | void gbproxy_attach_link_info(struct gbproxy_peer *peer, time_t now, |
| 266 | struct gbproxy_link_info *link_info); |
| 267 | void gbproxy_update_link_info(struct gbproxy_link_info *link_info, |
| 268 | const uint8_t *imsi, size_t imsi_len); |
| 269 | void gbproxy_detach_link_info(struct gbproxy_peer *peer, |
| 270 | struct gbproxy_link_info *link_info); |
| 271 | struct gbproxy_link_info *gbproxy_link_info_alloc( struct gbproxy_peer *peer); |
| 272 | |
| 273 | struct gbproxy_link_info *gbproxy_link_info_by_tlli( |
| 274 | struct gbproxy_peer *peer, uint32_t tlli); |
| 275 | struct gbproxy_link_info *gbproxy_link_info_by_imsi( |
| 276 | struct gbproxy_peer *peer, const uint8_t *imsi, size_t imsi_len); |
| 277 | struct gbproxy_link_info *gbproxy_link_info_by_any_sgsn_tlli( |
| 278 | struct gbproxy_peer *peer, uint32_t tlli); |
| 279 | struct gbproxy_link_info *gbproxy_link_info_by_sgsn_tlli( |
| 280 | struct gbproxy_peer *peer, |
| 281 | uint32_t tlli, uint32_t sgsn_nsei); |
| 282 | struct gbproxy_link_info *gbproxy_link_info_by_ptmsi( |
| 283 | struct gbproxy_peer *peer, |
| 284 | uint32_t ptmsi); |
| 285 | |
| 286 | int gbproxy_imsi_matches( |
| 287 | struct gbproxy_config *cfg, |
| 288 | enum gbproxy_match_id match_id, |
| 289 | struct gbproxy_link_info *link_info); |
| 290 | uint32_t gbproxy_map_tlli( |
| 291 | uint32_t other_tlli, struct gbproxy_link_info *link_info, int to_bss); |
| 292 | |
| 293 | /* needed by gb_proxy_tlli.h */ |
| 294 | uint32_t gbproxy_make_bss_ptmsi(struct gbproxy_peer *peer, uint32_t sgsn_ptmsi); |
| 295 | uint32_t gbproxy_make_sgsn_tlli( |
| 296 | struct gbproxy_peer *peer, struct gbproxy_link_info *link_info, |
| 297 | uint32_t bss_tlli); |
| 298 | void gbproxy_reset_link(struct gbproxy_link_info *link_info); |
| 299 | int gbproxy_check_imsi( |
| 300 | struct gbproxy_match *match, const uint8_t *imsi, size_t imsi_len); |
| 301 | |
| 302 | /* Message patching */ |
| 303 | void gbproxy_patch_bssgp( |
| 304 | struct msgb *msg, uint8_t *bssgp, size_t bssgp_len, |
| 305 | struct gbproxy_peer *peer, struct gbproxy_link_info *link_info, |
| 306 | int *len_change, struct gprs_gb_parse_context *parse_ctx); |
| 307 | |
| 308 | int gbproxy_patch_llc( |
| 309 | struct msgb *msg, uint8_t *llc, size_t llc_len, |
| 310 | struct gbproxy_peer *peer, struct gbproxy_link_info *link_info, |
| 311 | int *len_change, struct gprs_gb_parse_context *parse_ctx); |
| 312 | |
| 313 | int gbproxy_set_patch_filter( |
| 314 | struct gbproxy_match *match, const char *filter, const char **err_msg); |
| 315 | void gbproxy_clear_patch_filter(struct gbproxy_match *match); |
| 316 | |
| 317 | /* Peer handling */ |
| 318 | struct gbproxy_peer *gbproxy_peer_by_bvci( |
| 319 | struct gbproxy_config *cfg, uint16_t bvci); |
| 320 | struct gbproxy_peer *gbproxy_peer_by_nsei( |
| 321 | struct gbproxy_config *cfg, uint16_t nsei); |
| 322 | struct gbproxy_peer *gbproxy_peer_by_rai( |
| 323 | struct gbproxy_config *cfg, const uint8_t *ra); |
| 324 | struct gbproxy_peer *gbproxy_peer_by_lai( |
| 325 | struct gbproxy_config *cfg, const uint8_t *la); |
| 326 | struct gbproxy_peer *gbproxy_peer_by_lac( |
| 327 | struct gbproxy_config *cfg, const uint8_t *la); |
| 328 | struct gbproxy_peer *gbproxy_peer_by_bssgp_tlv( |
| 329 | struct gbproxy_config *cfg, struct tlv_parsed *tp); |
| 330 | struct gbproxy_peer *gbproxy_peer_alloc(struct gbproxy_config *cfg, uint16_t bvci); |
| 331 | void gbproxy_peer_free(struct gbproxy_peer *peer); |
| 332 | int gbproxy_cleanup_peers(struct gbproxy_config *cfg, uint16_t nsei, uint16_t bvci); |
| 333 | |
| 334 | #endif |