gbproxy: Use a separate regexp for routing

Currently one regexp ('patching') is used for all matching.

This patch adds a second category 'routing' which is exclusively used
for SGSN selection. It also adds a corresponding VTY command:

  - match-imsi patching RE : MS related patching (currently APN)
  - match-imsi routing RE  : Select secondary SGSN on match only
  - no match-imsi          : Clear all filter expressions

Ticket: OW#1258
Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2014-09-25 13:21:48 +02:00 committed by Holger Hans Peter Freyther
parent 6c3fdc1091
commit b36032cb27
4 changed files with 10 additions and 7 deletions

View File

@ -61,6 +61,7 @@ enum gbproxy_keep_mode {
enum gbproxy_match_id {
GBPROX_MATCH_PATCHING,
GBPROX_MATCH_ROUTING,
GBPROX_MATCH_LAST
};

View File

@ -584,7 +584,7 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg,
if (link_info && cfg->route_to_sgsn2) {
if (cfg->acquire_imsi && link_info->imsi_len == 0)
sgsn_nsei = 0xffff;
else if (gbproxy_imsi_matches(cfg, GBPROX_MATCH_PATCHING,
else if (gbproxy_imsi_matches(cfg, GBPROX_MATCH_ROUTING,
link_info))
sgsn_nsei = cfg->nsip_sgsn2_nsei;
}

View File

@ -60,6 +60,7 @@ static const struct value_string keep_modes[] = {
static const struct value_string match_ids[] = {
{GBPROX_MATCH_PATCHING, "patching"},
{GBPROX_MATCH_ROUTING, "routing"},
{0, NULL}
};
@ -199,15 +200,16 @@ DEFUN(cfg_gbproxy_no_core_mcc,
DEFUN(cfg_gbproxy_match_imsi,
cfg_gbproxy_match_imsi_cmd,
"match-imsi patching .REGEXP",
"match-imsi (patching|routing) .REGEXP",
GBPROXY_MATCH_IMSI_STR
"Patch MS related information elements or route to secondary SGSN on match only\n"
"Patch MS related information elements on match only\n"
"Route to the secondary SGSN on match only\n"
"Regular expression for the IMSI match\n")
{
const char *filter = argv[0];
const char *filter = argv[1];
const char *err_msg = NULL;
struct gbproxy_match *match;
enum gbproxy_match_id match_id = get_string_value(match_ids, "patching");
enum gbproxy_match_id match_id = get_string_value(match_ids, argv[0]);
OSMO_ASSERT(match_id >= GBPROX_MATCH_PATCHING &&
match_id < GBPROX_MATCH_LAST);

View File

@ -2786,7 +2786,7 @@ static void test_gbproxy_secondary_sgsn()
gbcfg.route_to_sgsn2 = 1;
gbcfg.nsip_sgsn2_nsei = SGSN2_NSEI;
if (gbproxy_set_patch_filter(&gbcfg.matches[GBPROX_MATCH_PATCHING],
if (gbproxy_set_patch_filter(&gbcfg.matches[GBPROX_MATCH_ROUTING],
filter_re, &err_msg) != 0) {
fprintf(stderr, "gbprox_set_patch_filter: got error: %s\n",
err_msg);
@ -3219,7 +3219,7 @@ static void test_gbproxy_secondary_sgsn()
dump_global(stdout, 0);
gbproxy_clear_patch_filter(&gbcfg.matches[GBPROX_MATCH_PATCHING]);
gbproxy_clear_patch_filter(&gbcfg.matches[GBPROX_MATCH_ROUTING]);
gbprox_reset(&gbcfg);
gprs_ns_destroy(nsi);
nsi = NULL;