]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip/pjsip_message_filter: set preferred transport in pjsip_message_filter
authorBernd Zobl <b.zobl@commend.com>
Tue, 16 Mar 2021 16:45:23 +0000 (17:45 +0100)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Tue, 15 Jun 2021 14:06:36 +0000 (09:06 -0500)
Set preferred transport when querying the local address to use in
filter_on_tx_messages(). This prevents the module to erroneously select
the wrong transport if more than one transports of the same type (TCP or
TLS) are configured.

ASTERISK-29241

Change-Id: I598e60257a7f92b29efce1fb3e9a2fc06f1439b6

res/res_pjsip/pjsip_message_filter.c

index 7c91ba853d5ecccfec0c4e580edf6954ceb41df7..23369dc8e7aacc13da2177d8e779a9f41755f97b 100644 (file)
@@ -230,6 +230,7 @@ static pj_status_t filter_on_tx_message(pjsip_tx_data *tdata)
        pjsip_cseq_hdr *cseq;
        pjsip_via_hdr *via;
        pjsip_fromto_hdr *from;
+       pjsip_tpselector sel;
 
        sanitize_tdata(tdata);
 
@@ -239,6 +240,13 @@ static pj_status_t filter_on_tx_message(pjsip_tx_data *tdata)
        pj_strset2(&prm.dst_host, tdata->tp_info.dst_name);
        prm.local_if = PJ_TRUE;
 
+       if ((tdata->tp_info.transport->key.type != PJSIP_TRANSPORT_UDP) &&
+               (tdata->tp_info.transport->key.type != PJSIP_TRANSPORT_UDP6)) {
+               sel.type = PJSIP_TPSELECTOR_LISTENER;
+               sel.u.listener = tdata->tp_info.transport->factory;
+               prm.tp_sel = &sel;
+       }
+
        /* If we can't get the local address use best effort and let it pass */
        if (pjsip_tpmgr_find_local_addr2(pjsip_endpt_get_tpmgr(ast_sip_get_pjsip_endpoint()), tdata->pool, &prm) != PJ_SUCCESS) {
                return PJ_SUCCESS;