<p>sungtae kim has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7808">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Add AMI action 'PJSIPShowAuths'<br><br>Add an AMI action which provides information on all<br>configured Auths.<br><br>ASTERISK-27547<br><br>Change-Id: I1a88a75b38a2b1dd9d1de6c0307b20a3f584c817<br>---<br>M res/res_pjsip.c<br>M res/res_pjsip/config_auth.c<br>2 files changed, 126 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/08/7808/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip.c b/res/res_pjsip.c<br>index c3deb98..8a66176 100644<br>--- a/res/res_pjsip.c<br>+++ b/res/res_pjsip.c<br>@@ -2267,7 +2267,7 @@<br> </syntax><br> </managerEventInstance><br> </managerEvent><br>- <managerEvent language="en_US" name="AorList"><br>+ <managerEvent language="en_US" name="AorList"><br> <managerEventInstance class="EVENT_FLAG_COMMAND"><br> <synopsis>Provide details about an Address of Record (AoR) section.</synopsis><br> <syntax><br>@@ -2306,6 +2306,37 @@<br> </parameter><br> <parameter name="SupportPath"><br> <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='support_path']/synopsis/node())"/></para><br>+ </parameter><br>+ </syntax><br>+ </managerEventInstance><br>+ </managerEvent><br>+ <managerEvent language="en_US" name="AuthList"><br>+ <managerEventInstance class="EVENT_FLAG_COMMAND"><br>+ <synopsis>Provide details about an Address of Record (Auth) section.</synopsis><br>+ <syntax><br>+ <parameter name="ObjectType"><br>+ <para>The object's type. This will always be 'auth'.</para><br>+ </parameter><br>+ <parameter name="ObjectName"><br>+ <para>The name of this object.</para><br>+ </parameter><br>+ <parameter name="Username"><br>+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='username']/synopsis/node())"/></para><br>+ </parameter><br>+ <parameter name="Md5Cred"><br>+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='md5_cred']/synopsis/node())"/></para><br>+ </parameter><br>+ <parameter name="Realm"><br>+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='realm']/synopsis/node())"/></para><br>+ </parameter><br>+ <parameter name="AuthType"><br>+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='auth_type']/synopsis/node())"/></para><br>+ </parameter><br>+ <parameter name="Password"><br>+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='password']/synopsis/node())"/></para><br>+ </parameter><br>+ <parameter name="NonceLifetime"><br>+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='nonce_lifetime']/synopsis/node())"/></para><br> </parameter><br> </syntax><br> </managerEventInstance><br>@@ -2496,6 +2527,33 @@<br> </managerEvent><br> </responses><br> </manager><br>+ <manager name="PJSIPShowAuths" language="en_US"><br>+ <synopsis><br>+ Lists PJSIP Auths.<br>+ </synopsis><br>+ <syntax /><br>+ <description><br>+ <para><br>+ Provides a listing of all Auths. For each Auth an <literal>AuthList</literal> event<br>+ is raised that contains relevant attributes and status information. Once all<br>+ auths have been listed an <literal>AuthListComplete</literal> event is issued.<br>+ </para><br>+ </description><br>+ <responses><br>+ <list-elements><br>+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='AuthList'])" /><br>+ </list-elements><br>+ <managerEvent language="en_US" name="AuthListComplete"><br>+ <managerEventInstance class="EVENT_FLAG_COMMAND"><br>+ <synopsis>Provide final information about an auth list.</synopsis><br>+ <syntax><br>+ <parameter name="EventList"/><br>+ <parameter name="ListItems"/><br>+ </syntax><br>+ </managerEventInstance><br>+ </managerEvent><br>+ </responses><br>+ </manager><br> <br> ***/<br> <br>diff --git a/res/res_pjsip/config_auth.c b/res/res_pjsip/config_auth.c<br>index 9160e67..d1598e9 100644<br>--- a/res/res_pjsip/config_auth.c<br>+++ b/res/res_pjsip/config_auth.c<br>@@ -195,6 +195,67 @@<br> .format_ami = format_ami_endpoint_auth<br> };<br> <br>+static struct ao2_container *cli_get_auths(void)<br>+{<br>+ struct ao2_container *auths;<br>+<br>+ auths = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "auth",<br>+ AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);<br>+<br>+ return auths;<br>+}<br>+<br>+static int format_ami_authlist_handler(void *obj, void *arg, int flags)<br>+{<br>+ struct ast_sip_auth *auth = obj;<br>+ struct ast_sip_ami *ami = arg;<br>+ struct ast_str *buf;<br>+<br>+ buf = ast_sip_create_ami_event("AuthList", ami);<br>+ if (!buf) {<br>+ return -1;<br>+ }<br>+<br>+ sip_auth_to_ami(auth, &buf);<br>+<br>+ astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));<br>+ ami->count++;<br>+<br>+ ast_free(buf);<br>+<br>+ return 0;<br>+}<br>+<br>+static int ami_show_auths(struct mansession *s, const struct message *m)<br>+{<br>+ struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };<br>+ struct ao2_container *auths;<br>+<br>+ auths = cli_get_auths();<br>+ if (!auths) {<br>+ astman_send_error(s, m, "Could not get Auths\n");<br>+ return 0;<br>+ }<br>+<br>+ if (!ao2_container_count(auths)) {<br>+ astman_send_error(s, m, "No Auths found\n");<br>+ ao2_ref(auths, -1);<br>+ return 0;<br>+ }<br>+<br>+ astman_send_listack(s, m, "A listing of Auths follows, presented as AuthList events",<br>+ "start");<br>+<br>+ ao2_callback(auths, OBJ_NODATA, format_ami_authlist_handler, &ami);<br>+<br>+ astman_send_list_complete_start(s, m, "AuthListComplete", ami.count);<br>+ astman_send_list_complete_end(s);<br>+<br>+ ao2_ref(auths, -1);<br>+<br>+ return 0;<br>+}<br>+<br> static struct ao2_container *cli_get_container(const char *regex)<br> {<br> RAII_VAR(struct ao2_container *, container, NULL, ao2_cleanup);<br>@@ -331,6 +392,10 @@<br> ast_sip_register_cli_formatter(cli_formatter);<br> ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands));<br> <br>+ if (ast_manager_register_xml("PJSIPShowAuths", EVENT_FLAG_SYSTEM, ami_show_auths)) {<br>+ return -1;<br>+ }<br>+<br> return 0;<br> }<br> <br>@@ -340,5 +405,7 @@<br> ast_sip_unregister_cli_formatter(cli_formatter);<br> internal_sip_unregister_endpoint_formatter(&endpoint_auth_formatter);<br> <br>+ ast_manager_unregister("PJSIPShowAuths");<br>+<br> return 0;<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7808">change 7808</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/7808"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I1a88a75b38a2b1dd9d1de6c0307b20a3f584c817 </div>
<div style="display:none"> Gerrit-Change-Number: 7808 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>