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
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index 3257f74..41ff4a7 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -584,7 +584,8 @@
if (link_info && cfg->route_to_sgsn2) {
if (cfg->acquire_imsi && link_info->imsi_len == 0)
sgsn_nsei = 0xffff;
- else if (gbproxy_imsi_matches(peer, link_info))
+ else if (gbproxy_imsi_matches(cfg, GBPROX_MATCH_PATCHING,
+ link_info))
sgsn_nsei = cfg->nsip_sgsn2_nsei;
}
@@ -1346,10 +1347,12 @@
int gbproxy_init_config(struct gbproxy_config *cfg)
{
struct timespec tp;
+
INIT_LLIST_HEAD(&cfg->bts_peers);
cfg->ctrg = rate_ctr_group_alloc(tall_bsc_ctx, &global_ctrg_desc, 0);
clock_gettime(CLOCK_REALTIME, &tp);
cfg->bss_ptmsi_state = tp.tv_sec + tp.tv_nsec;
cfg->sgsn_tlli_state = tp.tv_sec - tp.tv_nsec;
+
return 0;
}