aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/openbsc/gb_proxy.h
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-25 11:17:31 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-10-09 18:02:33 +0200
commit9a83d7af55772e4e2e6f187ab11d3f2a2665791c (patch)
treeb57ec27fd26bba90c88252251c5249bafd4d85d1 /openbsc/include/openbsc/gb_proxy.h
parent55ec2bf97f9b30ea44c05e1ec5310bf93cee7884 (diff)
gbproxy: Refactor IMSI matching
The current implementation makes it difficult to add further match expressions. This patch adds a new struct gbproxy_match that contains the fields needed for each match expression. The matches (config) and the results (link_info) are stored in arrays. All related functions are updated to use them. The old fields in the config structure are removed. Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/include/openbsc/gb_proxy.h')
-rw-r--r--openbsc/include/openbsc/gb_proxy.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/openbsc/include/openbsc/gb_proxy.h b/openbsc/include/openbsc/gb_proxy.h
index 1e8158b60..78d618b21 100644
--- a/openbsc/include/openbsc/gb_proxy.h
+++ b/openbsc/include/openbsc/gb_proxy.h
@@ -59,6 +59,17 @@ enum gbproxy_keep_mode {
GBPROX_KEEP_ALWAYS,
};
+enum gbproxy_match_id {
+ GBPROX_MATCH_PATCHING,
+ GBPROX_MATCH_LAST
+};
+
+struct gbproxy_match {
+ int enable;
+ char *re_str;
+ regex_t re_comp;
+};
+
struct gbproxy_config {
/* parsed from config file */
uint16_t nsip_sgsn_nsei;
@@ -77,7 +88,6 @@ struct gbproxy_config {
int core_mcc;
uint8_t* core_apn;
size_t core_apn_size;
- char * match_re;
int tlli_max_age;
int tlli_max_len;
@@ -89,8 +99,7 @@ struct gbproxy_config {
enum gbproxy_keep_mode keep_link_infos;
/* IMSI checking/matching */
- int check_imsi;
- regex_t imsi_re_comp;
+ struct gbproxy_match matches[GBPROX_MATCH_LAST];
/* Used to generate identifiers */
unsigned bss_ptmsi_state;
@@ -154,8 +163,7 @@ struct gbproxy_link_info {
int is_deregistered;
- int imsi_matches;
-
+ int is_matching[GBPROX_MATCH_LAST];
};
@@ -217,7 +225,8 @@ struct gbproxy_link_info *gbproxy_link_info_by_ptmsi(
uint32_t ptmsi);
int gbproxy_imsi_matches(
- struct gbproxy_peer *peer,
+ struct gbproxy_config *cfg,
+ enum gbproxy_match_id match_id,
struct gbproxy_link_info *link_info);
uint32_t gbproxy_map_tlli(
uint32_t other_tlli, struct gbproxy_link_info *link_info, int to_bss);
@@ -229,7 +238,7 @@ uint32_t gbproxy_make_sgsn_tlli(
uint32_t bss_tlli);
void gbproxy_reset_link(struct gbproxy_link_info *link_info);
int gbproxy_check_imsi(
- struct gbproxy_peer *peer, const uint8_t *imsi, size_t imsi_len);
+ struct gbproxy_match *match, const uint8_t *imsi, size_t imsi_len);
/* Message patching */
void gbproxy_patch_bssgp(
@@ -243,10 +252,8 @@ int gbproxy_patch_llc(
int *len_change, struct gprs_gb_parse_context *parse_ctx);
int gbproxy_set_patch_filter(
- struct gbproxy_config *cfg, const char *filter, const char **err_msg);
-void gbproxy_clear_patch_filter(struct gbproxy_config *cfg);
-int gbproxy_check_imsi(
- struct gbproxy_peer *peer, const uint8_t *imsi, size_t imsi_len);
+ struct gbproxy_match *match, const char *filter, const char **err_msg);
+void gbproxy_clear_patch_filter(struct gbproxy_match *match);
/* Peer handling */
struct gbproxy_peer *gbproxy_peer_by_bvci(