]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_multihomed: Change Contact port to listening port. 01/3901/3
authorJoshua Colp <jcolp@digium.com>
Wed, 14 Sep 2016 13:42:46 +0000 (09:42 -0400)
committerJoshua Colp <jcolp@digium.com>
Thu, 15 Sep 2016 13:26:06 +0000 (08:26 -0500)
The res_pjsip_multihomed module determines what interface and transport
a request is going out on and updates the SIP message accordingly with
the address information. This currently incorrectly updates the Contact
header for connectionful protocols to the ephemeral connection port,
instead of the bound address for the listening socket which can actually
accept the connection back. If the remote side attempts to connect back on
the epehemeral port it will fail.

This change makes it so the port is updated to the bound port on
connectionful protocols and is maintained on UDP (as there can be
multiple of those).

ASTERISK-26374 #close

Change-Id: I50f8dab65b9f75117d73ba5f6bbcf6c9871854ab

res/res_pjsip_multihomed.c

index 745bc37ea8a3cbfd3521e70b17de034fc34394ec..d52f6e406d8e9c29f748a8b213e7b5f2bd54971f 100644 (file)
@@ -109,8 +109,11 @@ static pj_status_t multihomed_on_tx_message(pjsip_tx_data *tdata)
                return PJ_SUCCESS;
        }
 
-       /* The port in the message should always be that of the original transport */
-       prm.ret_port = tdata->tp_info.transport->local_name.port;
+       /* For UDP we can have multiple transports so the port needs to be maintained */
+       if (tdata->tp_info.transport->key.type == PJSIP_TRANSPORT_UDP ||
+               tdata->tp_info.transport->key.type == PJSIP_TRANSPORT_UDP6) {
+               prm.ret_port = tdata->tp_info.transport->local_name.port;
+       }
 
        /* If the IP source differs from the existing transport see if we need to update it */
        if (pj_strcmp(&prm.ret_addr, &tdata->tp_info.transport->local_name.host)) {