diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-05-14 23:43:12 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-05-14 23:43:12 +0800 |
commit | be9201a2729fa0ed214c0a93905d766004014f3d (patch) | |
tree | 8e81a90769697a2c1473a2ed2faaa183f4f610ee | |
parent | a43c56637d0be3584a60892b2e4825634a2cb6fa (diff) |
[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.
-rw-r--r-- | openbsc/src/nat/bsc_nat_vty.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c index 2c804b35a..7209ae946 100644 --- a/openbsc/src/nat/bsc_nat_vty.c +++ b/openbsc/src/nat/bsc_nat_vty.c @@ -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(®, 0, sizeof(reg)); + bsc_parse_reg(_nat, ®, &str, 1, argv); + + vty_out(vty, "String matches allow pattern: %d%s", + regexec(®, argv[1], 0, NULL, 0) == 0, VTY_NEWLINE); + + talloc_free(str); + regfree(®); + 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(); |