diff --git a/src/sip/sip_utils.h b/src/sip/sip_utils.h index 9645ad0b1848db9c1bdb6f49eb5abb67c1fa9022..2fb5a28182857eccafa21658e1edf30f0a2bc103 100644 --- a/src/sip/sip_utils.h +++ b/src/sip/sip_utils.h @@ -44,6 +44,7 @@ namespace jami { namespace sip_utils { static constexpr int DEFAULT_SIP_PORT {5060}; static constexpr int DEFAULT_SIP_TLS_PORT {5061}; +static constexpr int DEFAULT_AUTO_SELECT_PORT {0}; enum class KeyExchangeProtocol { NONE, SDES }; diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index 62debcd1df849831e67c310da45cf3c947fb1c27..4ab8a078a9daead9d7545b66d80b8ebc7b5e5afe 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -614,6 +614,10 @@ void SIPAccount::setAccountDetails(const std::map<std::string, std::string> &det v.push_back(map); setCredentials(v); } + if (isIP2IP()) { + localPort_ = (localPort_ == sip_utils::DEFAULT_AUTO_SELECT_PORT) ? sip_utils::DEFAULT_SIP_PORT : localPort_; + tlsListenerPort_ = (tlsListenerPort_ == sip_utils::DEFAULT_AUTO_SELECT_PORT) ? sip_utils::DEFAULT_SIP_TLS_PORT : tlsListenerPort_; + } } std::map<std::string, std::string> diff --git a/src/sip/sipaccount.h b/src/sip/sipaccount.h index 4375f59eec88a69e4a176dd1e11c691f999be6b9..fae3b6b45978e3cd46a012b0d4a01fcf2e50d535 100644 --- a/src/sip/sipaccount.h +++ b/src/sip/sipaccount.h @@ -702,7 +702,7 @@ class SIPAccount : public SIPAccountBase { /** * Local port to whih this account is bound */ - pj_uint16_t localPort_ {sip_utils::DEFAULT_SIP_PORT}; + pj_uint16_t localPort_ {sip_utils::DEFAULT_AUTO_SELECT_PORT}; /** * Potential ip addresss on which this account is bound @@ -712,7 +712,7 @@ class SIPAccount : public SIPAccountBase { /** * The TLS listener port */ - pj_uint16_t tlsListenerPort_ {sip_utils::DEFAULT_SIP_TLS_PORT}; + pj_uint16_t tlsListenerPort_ {sip_utils::DEFAULT_AUTO_SELECT_PORT}; /** * Send Request Callback diff --git a/src/sip/siptransport.cpp b/src/sip/siptransport.cpp index 23707ec4dd69d0342cb9a4fa91abc0b6447f584d..dd457639fb5709bf09a4d817ccccf4d1fafad96c 100644 --- a/src/sip/siptransport.cpp +++ b/src/sip/siptransport.cpp @@ -329,7 +329,6 @@ SipTransportBroker::getUdpTransport(const IpAddr& ipAddress) std::shared_ptr<SipTransport> SipTransportBroker::createUdpTransport(const IpAddr& ipAddress) { - RETURN_IF_FAIL(ipAddress.getPort() != 0, nullptr, "Could not determine port for this transport"); RETURN_IF_FAIL(ipAddress, nullptr, "Could not determine IP address for this transport"); pjsip_udp_transport_cfg pj_cfg;