<p>Alexei Gradinari has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9047">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip_options: show/reload AOR qualify options using CLI<br><br>Currentrly pjsip_options code does not handle the situation when the<br>AOR qualify options were changed.<br><br>Also there is no way to find out what qualify options are using.<br><br>This patch add CLI commands to show and synchronize Aor qualify options:<br>pjsip show qualify endpoint <id><br> Show the current qualify options for all Aors on the PJSIP endpoint.<br>pjsip show qualify aor <id><br> Show the PJSIP Aor current qualify options.<br>pjsip reload qualify endpoint <id><br> Synchronize the qualify options for all Aors on the PJSIP endpoint.<br>pjsip reload qualify aor <id><br> Synchronize the PJSIP Aor qualify options.<br><br>ASTERISK-27872<br><br>Change-Id: I1746d10ef2b7954f2293f2e606cdd7428068c38c<br>---<br>M res/res_pjsip/pjsip_options.c<br>1 file changed, 188 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/47/9047/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c<br>index d05d7bd..0ece477 100644<br>--- a/res/res_pjsip/pjsip_options.c<br>+++ b/res/res_pjsip/pjsip_options.c<br>@@ -2360,6 +2360,189 @@<br> return CLI_SUCCESS;<br> }<br> <br>+static char *cli_show_qualify_endpoint(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br>+{<br>+ RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);<br>+ const char *endpoint_name;<br>+ char *aors;<br>+ char *aor_name;<br>+<br>+ switch (cmd) {<br>+ case CLI_INIT:<br>+ e->command = "pjsip show qualify endpoint";<br>+ e->usage =<br>+ "Usage: pjsip show qualify endpoint <id>\n"<br>+ " Show the current qualify options for all Aors on the PJSIP endpoint.\n";<br>+ return NULL;<br>+ case CLI_GENERATE:<br>+ return NULL;<br>+ }<br>+<br>+ if (a->argc != 5) {<br>+ return CLI_SHOWUSAGE;<br>+ }<br>+<br>+ endpoint_name = a->argv[4];<br>+<br>+ endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint",<br>+ endpoint_name);<br>+ if (!endpoint) {<br>+ ast_cli(a->fd, "Unable to retrieve endpoint %s\n", endpoint_name);<br>+ return CLI_FAILURE;<br>+ }<br>+<br>+ if (ast_strlen_zero(endpoint->aors)) {<br>+ ast_cli(a->fd, "No AORs configured for endpoint '%s'\n", endpoint_name);<br>+ return CLI_FAILURE;<br>+ }<br>+<br>+ aors = ast_strdupa(endpoint->aors);<br>+ while ((aor_name = ast_strip(strsep(&aors, ",")))) {<br>+ struct sip_options_aor *aor_options;<br>+<br>+ aor_options = ao2_find(sip_options_aors, aor_name, OBJ_SEARCH_KEY);<br>+ if (!aor_options) {<br>+ continue;<br>+ }<br>+<br>+ ast_cli(a->fd, " * AOR '%s' on endpoint '%s'\n", aor_name, endpoint_name);<br>+ ast_cli(a->fd, " Qualify frequency : %d sec\n", aor_options->qualify_frequency);<br>+ ast_cli(a->fd, " Qualify timeout : %d ms\n", (int)(aor_options->qualify_timeout / 1000));<br>+ ast_cli(a->fd, " Authenticate qualify : %s\n", aor_options->authenticate_qualify?"yes":"no");<br>+ ast_cli(a->fd, "\n");<br>+ ao2_ref(aor_options, -1);<br>+ }<br>+<br>+ return CLI_SUCCESS;<br>+}<br>+<br>+static char *cli_show_qualify_aor(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br>+{<br>+ struct sip_options_aor *aor_options;<br>+ const char *aor_name;<br>+<br>+ switch (cmd) {<br>+ case CLI_INIT:<br>+ e->command = "pjsip show qualify aor";<br>+ e->usage =<br>+ "Usage: pjsip show qualify aor <id>\n"<br>+ " Show the PJSIP Aor current qualify options.\n";<br>+ return NULL;<br>+ case CLI_GENERATE:<br>+ return NULL;<br>+ }<br>+<br>+ if (a->argc != 5) {<br>+ return CLI_SHOWUSAGE;<br>+ }<br>+<br>+ aor_name = a->argv[4];<br>+<br>+ aor_options = ao2_find(sip_options_aors, aor_name, OBJ_SEARCH_KEY);<br>+ if (!aor_options) {<br>+ ast_cli(a->fd, "Unable to retrieve aor '%s' qualify options\n", aor_name);<br>+ return CLI_FAILURE;<br>+ }<br>+<br>+ ast_cli(a->fd, " * AOR '%s'\n", aor_name);<br>+ ast_cli(a->fd, " Qualify frequency : %d sec\n", aor_options->qualify_frequency);<br>+ ast_cli(a->fd, " Qualify timeout : %d ms\n", (int)(aor_options->qualify_timeout / 1000));<br>+ ast_cli(a->fd, " Authenticate qualify : %s\n", aor_options->authenticate_qualify?"yes":"no");<br>+ ao2_ref(aor_options, -1);<br>+<br>+ return CLI_SUCCESS;<br>+}<br>+<br>+static char *cli_reload_qualify_endpoint(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br>+{<br>+ RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);<br>+ const char *endpoint_name;<br>+ char *aors;<br>+ char *aor_name;<br>+<br>+ switch (cmd) {<br>+ case CLI_INIT:<br>+ e->command = "pjsip reload qualify endpoint";<br>+ e->usage =<br>+ "Usage: pjsip reload qualify endpoint <id>\n"<br>+ " Synchronize the qualify options for all Aors on the PJSIP endpoint.\n";<br>+ return NULL;<br>+ case CLI_GENERATE:<br>+ return NULL;<br>+ }<br>+<br>+ if (a->argc != 5) {<br>+ return CLI_SHOWUSAGE;<br>+ }<br>+<br>+ endpoint_name = a->argv[4];<br>+<br>+ endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint",<br>+ endpoint_name);<br>+ if (!endpoint) {<br>+ ast_cli(a->fd, "Unable to retrieve endpoint %s\n", endpoint_name);<br>+ return CLI_FAILURE;<br>+ }<br>+<br>+ if (ast_strlen_zero(endpoint->aors)) {<br>+ ast_cli(a->fd, "No AORs configured for endpoint '%s'\n", endpoint_name);<br>+ return CLI_FAILURE;<br>+ }<br>+<br>+ aors = ast_strdupa(endpoint->aors);<br>+ while ((aor_name = ast_strip(strsep(&aors, ",")))) {<br>+ struct ast_sip_aor *aor;<br>+<br>+ aor = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "aor", aor_name);<br>+ if (!aor) {<br>+ continue;<br>+ }<br>+<br>+ ast_cli(a->fd, "Synchronizing AOR '%s' on endpoint '%s'\n", aor_name, endpoint_name);<br>+ ast_sip_push_task_wait_serializer(management_serializer,<br>+ sip_options_aor_observer_modified_task, aor);<br>+ ao2_ref(aor, -1);<br>+ }<br>+<br>+ return CLI_SUCCESS;<br>+}<br>+<br>+static char *cli_reload_qualify_aor(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br>+{<br>+ struct ast_sip_aor *aor;<br>+ const char *aor_name;<br>+<br>+ switch (cmd) {<br>+ case CLI_INIT:<br>+ e->command = "pjsip reload qualify aor";<br>+ e->usage =<br>+ "Usage: pjsip reload qualify aor <id>\n"<br>+ " Synchronize the PJSIP Aor qualify options.\n";<br>+ return NULL;<br>+ case CLI_GENERATE:<br>+ return NULL;<br>+ }<br>+<br>+ if (a->argc != 5) {<br>+ return CLI_SHOWUSAGE;<br>+ }<br>+<br>+ aor_name = a->argv[4];<br>+<br>+ aor = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "aor", aor_name);<br>+ if (!aor) {<br>+ ast_cli(a->fd, "Unable to retrieve aor '%s'\n", aor_name);<br>+ return CLI_FAILURE;<br>+ }<br>+<br>+ ast_cli(a->fd, "Synchronizing AOR '%s'\n", aor_name);<br>+ ast_sip_push_task_wait_serializer(management_serializer,<br>+ sip_options_aor_observer_modified_task, aor);<br>+ ao2_ref(aor, -1);<br>+<br>+ return CLI_SUCCESS;<br>+}<br>+<br> static int ami_sip_qualify(struct mansession *s, const struct message *m)<br> {<br> const char *endpoint_name = astman_get_header(m, "Endpoint");<br>@@ -2404,7 +2587,11 @@<br> }<br> <br> static struct ast_cli_entry cli_options[] = {<br>- AST_CLI_DEFINE(cli_qualify, "Send an OPTIONS request to a PJSIP endpoint")<br>+ AST_CLI_DEFINE(cli_qualify, "Send an OPTIONS request to a PJSIP endpoint"),<br>+ AST_CLI_DEFINE(cli_show_qualify_endpoint, "Show the current qualify options for all Aors on the PJSIP endpoint"),<br>+ AST_CLI_DEFINE(cli_show_qualify_aor, "Show the PJSIP Aor current qualify options"),<br>+ AST_CLI_DEFINE(cli_reload_qualify_endpoint, "Synchronize the qualify options for all Aors on the PJSIP endpoint"),<br>+ AST_CLI_DEFINE(cli_reload_qualify_aor, "Synchronize the PJSIP Aor qualify options"),<br> };<br> <br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9047">change 9047</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/9047"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I1746d10ef2b7954f2293f2e606cdd7428068c38c </div>
<div style="display:none"> Gerrit-Change-Number: 9047 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>