summaryrefslogtreecommitdiff
path: root/res/res_pjsip_outbound_registration.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2015-10-20 15:02:30 -0600
committerGeorge Joseph <george.joseph@fairview5.com>2015-10-24 11:02:43 -0500
commita8aee0bbdb09f5cfb49802f0c3c09e741814045c (patch)
tree2111b5324001ee7bc49ad38b2751eae25dff091b /res/res_pjsip_outbound_registration.c
parent08fe5256a90c70955110c3a64ee252b319809d35 (diff)
res_pjsip: Add "like" processing to pjsip list and show commands
Add the ability to filter output from pjsip list and show commands using the "like" predicate like chan_sip. For endpoints, aors, auths, registrations, identifyies and transports, the modification was a simple change of an ast_sorcery_retrieve_by_fields call to ast_sorcery_retrieve_by_regex. For channels and contacts a little more work had to be done because neither of those objects are true sorcery objects. That was just removing the non-matching object from the final container. Of course, a little extra plumbing in the common pjsip_cli code was needed to parse the "like" and pass the regex to the get_container callbacks. Some of the get_container code in res_pjsip_endpoint_identifier was also refactored for simplicity. ASTERISK-25477 #close Reported by: Bryant Zimmerman Tested by: George Joseph Change-Id: I646d9326b778aac26bb3e2bcd7fa1346d24434f1
Diffstat (limited to 'res/res_pjsip_outbound_registration.c')
-rw-r--r--res/res_pjsip_outbound_registration.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 038cc0b20..7ff5f1619 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -1639,11 +1639,12 @@ static int ami_show_outbound_registrations(struct mansession *s,
return 0;
}
-static struct ao2_container *cli_get_container(void)
+static struct ao2_container *cli_get_container(const char *regex)
{
- RAII_VAR(struct ao2_container *, container, get_registrations(), ao2_cleanup);
+ RAII_VAR(struct ao2_container *, container, NULL, ao2_cleanup);
struct ao2_container *s_container;
+ container = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "registration", regex);
if (!container) {
return NULL;
}
@@ -1747,12 +1748,14 @@ static struct ast_cli_entry cli_outbound_registration[] = {
AST_CLI_DEFINE(cli_register, "Registers an outbound registration target"),
AST_CLI_DEFINE(my_cli_traverse_objects, "List PJSIP Registrations",
.command = "pjsip list registrations",
- .usage = "Usage: pjsip list registrations\n"
- " List the configured PJSIP Registrations\n"),
+ .usage = "Usage: pjsip list registrations [ like <pattern> ]\n"
+ " List the configured PJSIP Registrations\n"
+ " Optional regular expression pattern is used to filter the list.\n"),
AST_CLI_DEFINE(my_cli_traverse_objects, "Show PJSIP Registrations",
.command = "pjsip show registrations",
- .usage = "Usage: pjsip show registrations\n"
- " Show the configured PJSIP Registrations\n"),
+ .usage = "Usage: pjsip show registrations [ like <pattern> ]\n"
+ " Show the configured PJSIP Registrations\n"
+ " Optional regular expression pattern is used to filter the list.\n"),
AST_CLI_DEFINE(my_cli_traverse_objects, "Show PJSIP Registration",
.command = "pjsip show registration",
.usage = "Usage: pjsip show registration <id>\n"