res_pjsip_rfc3326: Order of 'Reason' headers break many endpoints
authorRoss Beer <ross.beer@voicehost.co.uk>
Tue, 6 Mar 2018 19:31:01 +0000 (19:31 +0000)
committerJoshua Colp <jcolp@digium.com>
Wed, 7 Mar 2018 16:08:09 +0000 (10:08 -0600)
ASTERISK-27554

Change-Id: If61c7faab7d2fa1031c056ed6268fe928e2391cf

res/res_pjsip_rfc3326.c

index 6c02a17..5ac16f0 100644 (file)
@@ -91,12 +91,12 @@ static void rfc3326_add_reason_header(struct ast_sip_session *session, struct pj
 {
        char buf[20];
 
-       snprintf(buf, sizeof(buf), "Q.850;cause=%i", ast_channel_hangupcause(session->channel) & 0x7f);
-       ast_sip_add_header(tdata, "Reason", buf);
-
        if (ast_channel_hangupcause(session->channel) == AST_CAUSE_ANSWERED_ELSEWHERE) {
                ast_sip_add_header(tdata, "Reason", "SIP;cause=200;text=\"Call completed elsewhere\"");
        }
+
+       snprintf(buf, sizeof(buf), "Q.850;cause=%i", ast_channel_hangupcause(session->channel) & 0x7f);
+       ast_sip_add_header(tdata, "Reason", buf);
 }
 
 static void rfc3326_outgoing_request(struct ast_sip_session *session, struct pjsip_tx_data *tdata)