<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7847">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_endpoint_identifier_ip.c: Allow multiple IdentifyDetail AMI events.<br><br>The AMI PJSIPShowEndpoint action could only list one IdentifyDetail AMI<br>event per endpoint. However, there is no reason that multiple<br>type=identify sections cannot identify the same endpoint.<br><br>* Reworked format_ami_endpoint_identify() to generate as many<br>IdentifyDetail AMI events as there are matching identifiers.<br><br>Change-Id: Ie146792aef72d78e05416ab5b27bc552a30399db<br>---<br>M res/res_pjsip_endpoint_identifier_ip.c<br>1 file changed, 32 insertions(+), 25 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_endpoint_identifier_ip.c b/res/res_pjsip_endpoint_identifier_ip.c<br>index 5324af7..14f4cfd 100644<br>--- a/res/res_pjsip_endpoint_identifier_ip.c<br>+++ b/res/res_pjsip_endpoint_identifier_ip.c<br>@@ -484,47 +484,54 @@<br> return ast_sip_sorcery_object_to_ami(identify, buf);<br> }<br> <br>-static int find_identify_by_endpoint(void *obj, void *arg, int flags)<br>+static int send_identify_ami_event(void *obj, void *arg, void *data, int flags)<br> {<br> struct ip_identify_match *identify = obj;<br> const char *endpoint_name = arg;<br>+ struct ast_sip_ami *ami = data;<br>+ struct ast_str *buf;<br> <br>- return strcmp(identify->endpoint_name, endpoint_name) ? 0 : CMP_MATCH;<br>+ /* Build AMI event */<br>+ buf = ast_sip_create_ami_event("IdentifyDetail", ami);<br>+ if (!buf) {<br>+ return CMP_STOP;<br>+ }<br>+ if (sip_identify_to_ami(identify, &buf)) {<br>+ ast_free(buf);<br>+ return CMP_STOP;<br>+ }<br>+ ast_str_append(&buf, 0, "EndpointName: %s\r\n", endpoint_name);<br>+<br>+ /* Send AMI event */<br>+ astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));<br>+ ++ami->count;<br>+<br>+ ast_free(buf);<br>+ return 0;<br> }<br> <br> static int format_ami_endpoint_identify(const struct ast_sip_endpoint *endpoint,<br> struct ast_sip_ami *ami)<br> {<br>- RAII_VAR(struct ao2_container *, identifies, NULL, ao2_cleanup);<br>- RAII_VAR(struct ip_identify_match *, identify, NULL, ao2_cleanup);<br>- RAII_VAR(struct ast_str *, buf, NULL, ast_free);<br>+ struct ao2_container *identifies;<br>+ struct ast_variable fields = {<br>+ .name = "endpoint",<br>+ .value = ast_sorcery_object_get_id(endpoint),<br>+ };<br> <br> identifies = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "identify",<br>- AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);<br>+ AST_RETRIEVE_FLAG_MULTIPLE, &fields);<br> if (!identifies) {<br> return -1;<br> }<br> <br>- identify = ao2_callback(identifies, 0, find_identify_by_endpoint,<br>- (void *) ast_sorcery_object_get_id(endpoint));<br>- if (!identify) {<br>- return 1;<br>- }<br>+ /* Build and send any found identify object's AMI IdentifyDetail event. */<br>+ ao2_callback_data(identifies, OBJ_MULTIPLE | OBJ_NODATA,<br>+ send_identify_ami_event,<br>+ (void *) ast_sorcery_object_get_id(endpoint),<br>+ ami);<br> <br>- if (!(buf = ast_sip_create_ami_event("IdentifyDetail", ami))) {<br>- return -1;<br>- }<br>-<br>- if (sip_identify_to_ami(identify, &buf)) {<br>- return -1;<br>- }<br>-<br>- ast_str_append(&buf, 0, "EndpointName: %s\r\n",<br>- ast_sorcery_object_get_id(endpoint));<br>-<br>- astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));<br>- ami->count++;<br>-<br>+ ao2_ref(identifies, -1);<br> return 0;<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7847">change 7847</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/7847"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ie146792aef72d78e05416ab5b27bc552a30399db </div>
<div style="display:none"> Gerrit-Change-Number: 7847 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>