]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_pjsip: Register for "BEFORE_MEDIA" responses
authorGeorge Joseph <gjoseph@digium.com>
Thu, 7 Jun 2018 13:46:03 +0000 (07:46 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Thu, 7 Jun 2018 14:31:45 +0000 (08:31 -0600)
chan_pjsip wasn't registering for "BEFORE_MEDIA" responses which meant
it was not updating HANGUPCAUSE for 4XX responses.  If the remote end
sent a "180 Ringing", then a "486 Busy", the hangup cause was left at
"180 Normal Clearing".

* Removed chan_pjsip_incoming_response from the original session
  supplement (which was handling only "AFTER MEDIA") and added it to a
  new session supplement which accepts both "BEFORE_MEDIA" and
  "AFTER_MEDIA".

* Also cleaned up some cleanup code in load module.

ASTERISK-27902

Change-Id: If9b860541887aca8ac2c9f2ed51ceb0550fb007a

channels/chan_pjsip.c

index b4eb711f796339a698ed21ce4311ac010436c269..21941ebfd6366715b6e5ceb6bd25dc69ac1b9b30 100644 (file)
@@ -144,11 +144,18 @@ static struct ast_sip_session_supplement chan_pjsip_supplement = {
        .session_begin = chan_pjsip_session_begin,
        .session_end = chan_pjsip_session_end,
        .incoming_request = chan_pjsip_incoming_request,
-       .incoming_response = chan_pjsip_incoming_response,
        /* It is important that this supplement runs after media has been negotiated */
        .response_priority = AST_SIP_SESSION_AFTER_MEDIA,
 };
 
+/*! \brief SIP session supplement structure just for responses */
+static struct ast_sip_session_supplement chan_pjsip_supplement_response = {
+       .method = "INVITE",
+       .priority = AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL,
+       .incoming_response = chan_pjsip_incoming_response,
+       .response_priority = AST_SIP_SESSION_BEFORE_MEDIA | AST_SIP_SESSION_AFTER_MEDIA,
+};
+
 static int chan_pjsip_incoming_ack(struct ast_sip_session *session, struct pjsip_rx_data *rdata);
 
 static struct ast_sip_session_supplement chan_pjsip_ack_supplement = {
@@ -3109,6 +3116,7 @@ static int load_module(void)
        }
 
        ast_sip_session_register_supplement(&chan_pjsip_supplement);
+       ast_sip_session_register_supplement(&chan_pjsip_supplement_response);
 
        if (!(pjsip_uids_onhold = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK,
                        AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, 37, uid_hold_hash_fn,
@@ -3123,10 +3131,6 @@ static int load_module(void)
 
        if (pjsip_channel_cli_register()) {
                ast_log(LOG_ERROR, "Unable to register PJSIP Channel CLI\n");
-               ast_sip_session_unregister_supplement(&chan_pjsip_ack_supplement);
-               ast_sip_session_unregister_supplement(&pbx_start_supplement);
-               ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
-               ast_sip_session_unregister_supplement(&call_pickup_supplement);
                goto end;
        }
 
@@ -3142,6 +3146,11 @@ static int load_module(void)
 end:
        ao2_cleanup(pjsip_uids_onhold);
        pjsip_uids_onhold = NULL;
+       ast_sip_session_unregister_supplement(&chan_pjsip_ack_supplement);
+       ast_sip_session_unregister_supplement(&pbx_start_supplement);
+       ast_sip_session_unregister_supplement(&chan_pjsip_supplement_response);
+       ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
+       ast_sip_session_unregister_supplement(&call_pickup_supplement);
        ast_custom_function_unregister(&dtmf_mode_function);
        ast_custom_function_unregister(&media_offer_function);
        ast_custom_function_unregister(&chan_pjsip_dial_contacts_function);
@@ -3160,6 +3169,7 @@ static int unload_module(void)
 
        pjsip_channel_cli_unregister();
 
+       ast_sip_session_unregister_supplement(&chan_pjsip_supplement_response);
        ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
        ast_sip_session_unregister_supplement(&pbx_start_supplement);
        ast_sip_session_unregister_supplement(&chan_pjsip_ack_supplement);