diff options
Diffstat (limited to 'openbsc/src/nat')
-rw-r--r-- | openbsc/src/nat/bsc_nat_utils.c | 14 | ||||
-rw-r--r-- | openbsc/src/nat/bsc_nat_vty.c | 22 |
2 files changed, 18 insertions, 18 deletions
diff --git a/openbsc/src/nat/bsc_nat_utils.c b/openbsc/src/nat/bsc_nat_utils.c index 050d25e28..dbff1ab3e 100644 --- a/openbsc/src/nat/bsc_nat_utils.c +++ b/openbsc/src/nat/bsc_nat_utils.c @@ -273,3 +273,17 @@ int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg, struct } } +void bsc_parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv) +{ + if (*imsi) { + talloc_free(*imsi); + *imsi = NULL; + } + regfree(reg); + + if (argc > 0) { + *imsi = talloc_strdup(ctx, argv[0]); + regcomp(reg, argv[0], 0); + } +} + diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c index c24f7e511..9688de3f8 100644 --- a/openbsc/src/nat/bsc_nat_vty.c +++ b/openbsc/src/nat/bsc_nat_vty.c @@ -224,27 +224,13 @@ DEFUN(cfg_nat, cfg_nat_cmd, "nat", "Configute the NAT") return CMD_SUCCESS; } -static void parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv) -{ - if (*imsi) { - talloc_free(*imsi); - *imsi = NULL; - } - regfree(reg); - - if (argc > 0) { - *imsi = talloc_strdup(ctx, argv[0]); - regcomp(reg, argv[0], 0); - } -} - DEFUN(cfg_nat_imsi_allow, cfg_nat_imsi_allow_cmd, "imsi allow [REGEXP]", "Allow matching IMSIs to talk to the MSC. " "The defualt is to allow everyone.") { - parse_reg(_nat, &_nat->imsi_allow_re, &_nat->imsi_allow, argc, argv); + bsc_parse_reg(_nat, &_nat->imsi_allow_re, &_nat->imsi_allow, argc, argv); return CMD_SUCCESS; } @@ -254,7 +240,7 @@ DEFUN(cfg_nat_imsi_deny, "Deny matching IMSIs to talk to the MSC. " "The defualt is to not deny.") { - parse_reg(_nat, &_nat->imsi_deny_re, &_nat->imsi_deny, argc, argv); + bsc_parse_reg(_nat, &_nat->imsi_deny_re, &_nat->imsi_deny, argc, argv); return CMD_SUCCESS; } @@ -373,7 +359,7 @@ DEFUN(cfg_bsc_imsi_allow, { struct bsc_config *conf = vty->index; - parse_reg(conf, &conf->imsi_allow_re, &conf->imsi_allow, argc, argv); + bsc_parse_reg(conf, &conf->imsi_allow_re, &conf->imsi_allow, argc, argv); return CMD_SUCCESS; } @@ -385,7 +371,7 @@ DEFUN(cfg_bsc_imsi_deny, { struct bsc_config *conf = vty->index; - parse_reg(conf, &conf->imsi_deny_re, &conf->imsi_deny, argc, argv); + bsc_parse_reg(conf, &conf->imsi_deny_re, &conf->imsi_deny, argc, argv); return CMD_SUCCESS; } |