diff options
author | George Joseph <george.joseph@fairview5.com> | 2014-09-18 15:13:29 +0000 |
---|---|---|
committer | George Joseph <george.joseph@fairview5.com> | 2014-09-18 15:13:29 +0000 |
commit | a2482acdce9cdcdbdf2b532a591992212c88cd09 (patch) | |
tree | 90149e07a5932348bbe032a3717ce2db9b4e2f63 /res/res_pjsip/config_transport.c | |
parent | 27df9b73e2272d63efe411c744917e1510bad32a (diff) |
res_pjsip: ami: Fix error in AMI output when an endpoint has no transport
When no transport is associated to an endpoint, the AMI output for
PJSIPShowEndpoint indicates an error instead of silently ignoring the
missing transport.
This patch causes the error to appear only if a transport was specified
on the endpoint and the transport doesn't exist. It also fixes an issue
with counting the objects that were actually found.
ASTERISK-24161 #close
ASTERISK-24331 #close
Tested by: George Joseph
Review: https://reviewboard.asterisk.org/r/3998/
........
Merged revisions 423282 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@423284 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip/config_transport.c')
-rw-r--r-- | res/res_pjsip/config_transport.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c index 785fcc5ac..0a56b9263 100644 --- a/res/res_pjsip/config_transport.c +++ b/res/res_pjsip/config_transport.c @@ -39,16 +39,20 @@ static int sip_transport_to_ami(const struct ast_sip_transport *transport, static int format_ami_endpoint_transport(const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami) { - RAII_VAR(struct ast_str *, buf, - ast_sip_create_ami_event("TransportDetail", ami), ast_free); - RAII_VAR(struct ast_sip_transport *, - transport, ast_sorcery_retrieve_by_id( - ast_sip_get_sorcery(), "transport", - endpoint->transport), ao2_cleanup); + RAII_VAR(struct ast_str *, buf, NULL, ast_free); + RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup); + + if (ast_strlen_zero(endpoint->transport)) { + return 0; + } + + buf = ast_sip_create_ami_event("TransportDetail", ami); if (!buf) { return -1; } + transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", + endpoint->transport); if (!transport) { astman_send_error_va(ami->s, ami->m, "Unable to retrieve " "transport %s\n", endpoint->transport); @@ -61,6 +65,8 @@ static int format_ami_endpoint_transport(const struct ast_sip_endpoint *endpoint ast_sorcery_object_get_id(endpoint)); astman_append(ami->s, "%s\r\n", ast_str_buffer(buf)); + ami->count++; + return 0; } |