mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
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
This commit is contained in:
@@ -195,13 +195,12 @@ static struct ast_sip_endpoint_formatter endpoint_auth_formatter = {
|
||||
.format_ami = format_ami_endpoint_auth
|
||||
};
|
||||
|
||||
static struct ao2_container *cli_get_container(void)
|
||||
static struct ao2_container *cli_get_container(const char *regex)
|
||||
{
|
||||
RAII_VAR(struct ao2_container *, container, NULL, ao2_cleanup);
|
||||
struct ao2_container *s_container;
|
||||
|
||||
container = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "auth",
|
||||
AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);
|
||||
container = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "auth", regex);
|
||||
if (!container) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -272,12 +271,14 @@ static int cli_print_body(void *obj, void *arg, int flags)
|
||||
static struct ast_cli_entry cli_commands[] = {
|
||||
AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "List PJSIP Auths",
|
||||
.command = "pjsip list auths",
|
||||
.usage = "Usage: pjsip list auths\n"
|
||||
" List the configured PJSIP Auths\n"),
|
||||
.usage = "Usage: pjsip list auths [ like <pattern> ]\n"
|
||||
" List the configured PJSIP Auths\n"
|
||||
" Optional regular expression pattern is used to filter the list.\n"),
|
||||
AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "Show PJSIP Auths",
|
||||
.command = "pjsip show auths",
|
||||
.usage = "Usage: pjsip show auths\n"
|
||||
" Show the configured PJSIP Auths\n"),
|
||||
.usage = "Usage: pjsip show auths [ like <pattern> ]\n"
|
||||
" Show the configured PJSIP Auths\n"
|
||||
" Optional regular expression pattern is used to filter the list.\n"),
|
||||
AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "Show PJSIP Auth",
|
||||
.command = "pjsip show auth",
|
||||
.usage = "Usage: pjsip show auth <id>\n"
|
||||
|
Reference in New Issue
Block a user