[nat] Add a regexp test command to the VTY.

This allows to test the regexp to be used for allo/deny of
the imsi filter.
This commit is contained in:
Holger Hans Peter Freyther 2010-05-14 23:43:12 +08:00
parent a0aeaa799e
commit 52c4ba0309
1 changed files with 19 additions and 0 deletions

View File

@ -410,6 +410,24 @@ DEFUN(cfg_bsc_desc,
return CMD_SUCCESS;
}
DEFUN(test_regex, test_regex_cmd,
"test regex PATTERN STRING",
"Check if the string is matching the current pattern.")
{
regex_t reg;
char *str = NULL;
memset(&reg, 0, sizeof(reg));
bsc_parse_reg(_nat, &reg, &str, 1, argv);
vty_out(vty, "String matches allow pattern: %d%s",
regexec(&reg, argv[1], 0, NULL, 0) == 0, VTY_NEWLINE);
talloc_free(str);
regfree(&reg);
return CMD_SUCCESS;
}
int bsc_nat_vty_init(struct bsc_nat *nat)
{
_nat = nat;
@ -424,6 +442,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
install_element(VIEW_NODE, &show_stats_cmd);
install_element(VIEW_NODE, &close_bsc_cmd);
install_element(VIEW_NODE, &show_msc_cmd);
install_element(VIEW_NODE, &test_regex_cmd);
openbsc_vty_add_cmds();