[nat] Make the string -> regexp parsing public
This way it can be used from within a test case to test
the regexps..
diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c
index c24f7e5..9688de3 100644
--- a/openbsc/src/nat/bsc_nat_vty.c
+++ b/openbsc/src/nat/bsc_nat_vty.c
@@ -224,27 +224,13 @@
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 @@
"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 @@
{
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 @@
{
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;
}