--- channels/chan_sip.c (Asterisk 13.38.0) +++ channels/chan_sip.c (working copy) @@ -11935,7 +11935,9 @@ static int copy_via_headers(struct sip_p if (rport && *(rport+6) == '=') rport = NULL; /* We already have a parameter to rport */ - if (((ast_test_flag(&p->flags[0], SIP_NAT_FORCE_RPORT)) || (rport && ast_test_flag(&p->flags[0], SIP_NAT_RPORT_PRESENT)))) { + if ((p->socket.type == AST_TRANSPORT_UDP && + ast_test_flag(&p->flags[0], SIP_NAT_FORCE_RPORT)) || + (rport && ast_test_flag(&p->flags[0], SIP_NAT_RPORT_PRESENT))) { /* We need to add received port - rport */ char *end; @@ -16988,8 +16990,9 @@ static enum parse_register_result parse_ ao2_t_unlink(peers_by_ip, peer, "ao2_unlink of peer from peers_by_ip table"); } - if ((transport_type != AST_TRANSPORT_WS) && (transport_type != AST_TRANSPORT_WSS) && - (!ast_test_flag(&peer->flags[0], SIP_NAT_FORCE_RPORT) && !ast_test_flag(&pvt->flags[0], SIP_NAT_RPORT_PRESENT))) { + if (transport_type == AST_TRANSPORT_UDP && + !ast_test_flag(&peer->flags[0], SIP_NAT_FORCE_RPORT) && + !ast_test_flag(&pvt->flags[0], SIP_NAT_RPORT_PRESENT)) { /* use the data provided in the Contact header for call routing */ ast_debug(1, "Store REGISTER's Contact header for call routing.\n"); /* XXX This could block for a long time XXX */ @@ -34374,18 +34377,7 @@ static int peer_ipcmp_cb_full(void *obj, } /* Conditions taken from parse_register_contact() */ - if (peer2->transports & (AST_TRANSPORT_WS | AST_TRANSPORT_WSS)) { - /* The contact address of websockets is always the transport source address and port */ - return 0; - } - - if (ast_test_flag(&peer->flags[0], SIP_NAT_FORCE_RPORT)) { - /* The contact address of NATed peers is always the transport source address and port */ - return 0; - } - - /* Have to assume that we used the registered contact header (non-NAT) */ - return CMP_MATCH | CMP_STOP; + return 0; } static int threadt_hash_cb(const void *obj, const int flags)