Commit e698e70c authored by Alexandre Savard's avatar Alexandre Savard

#8084: Fix get sip header segfault when stun transport selected

parent d6cc8a4f
......@@ -804,6 +804,16 @@ std::string SIPAccount::getContactHeader() const
std::string scheme;
std::string transport;
pjsip_transport_type_e transportType = transportType_;
if(transport_ == NULL) {
ERROR("Transport not created yet");
// The transport type must be specified, in our case START_OTHER refers to stun transport
if(transportType == PJSIP_TRANSPORT_START_OTHER) {
transportType = PJSIP_TRANSPORT_UDP;
// Use the CONTACT header provided by the registrar if any
......@@ -811,12 +821,12 @@ std::string SIPAccount::getContactHeader() const
// Else we determine this infor based on transport information
std::string address, port;
link_->findLocalAddressFromTransport(transport_, transportType_, address, port);
link_->findLocalAddressFromTransport(transport_, transportType, address, port);
// UDP does not require the transport specification
if (transportType_ == PJSIP_TRANSPORT_TLS) {
scheme = "sips:";
transport = ";transport=" + std::string(pjsip_transport_get_type_name(transportType_));
transport = ";transport=" + std::string(pjsip_transport_get_type_name(transportType));
} else
scheme = "sip:";
......@@ -88,7 +88,7 @@ static std::map<std::string, std::string> transferCallID;
* localport, localip, localexternalport
* @param call a SIPCall valid pointer
void setCallMediaLocal(SIPCall* call, const std::string &localIP);
static void setCallMediaLocal(SIPCall* call, const std::string &localIP);
* Helper function to parser header from incoming sip messages
......@@ -101,17 +101,17 @@ static pjsip_endpoint *endpt_;
static pjsip_module mod_ua_;
static pj_thread_t *thread;
void sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status UNUSED);
void sdp_request_offer_cb(pjsip_inv_session *inv, const pjmedia_sdp_session *offer);
void sdp_create_offer_cb(pjsip_inv_session *inv, pjmedia_sdp_session **p_offer);
void invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *e);
void outgoing_request_forked_cb(pjsip_inv_session *inv, pjsip_event *e);
void transaction_state_changed_cb(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e);
void registration_cb(pjsip_regc_cbparam *param);
pj_bool_t transaction_request_cb(pjsip_rx_data *rdata);
pj_bool_t transaction_response_cb(pjsip_rx_data *rdata UNUSED) ;
static void sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status UNUSED);
static void sdp_request_offer_cb(pjsip_inv_session *inv, const pjmedia_sdp_session *offer);
static void sdp_create_offer_cb(pjsip_inv_session *inv, pjmedia_sdp_session **p_offer);
static void invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *e);
static void outgoing_request_forked_cb(pjsip_inv_session *inv, pjsip_event *e);
static void transaction_state_changed_cb(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e);
static void registration_cb(pjsip_regc_cbparam *param);
static pj_bool_t transaction_request_cb(pjsip_rx_data *rdata);
static pj_bool_t transaction_response_cb(pjsip_rx_data *rdata UNUSED) ;
void transfer_client_cb(pjsip_evsub *sub, pjsip_event *event);
static void transfer_client_cb(pjsip_evsub *sub, pjsip_event *event);
* Send a reINVITE inside an active dialog to modify its state
......@@ -1470,7 +1470,9 @@ pjsip_tpselector *SIPVoIPLink::initTransportSelector(pjsip_transport *transport,
void SIPVoIPLink::createStunTransport(SIPAccount *account)
pj_str_t stunServer = account->getStunServerName();
pj_uint16_t stunPort = account->getStunPort();
pj_uint16_t stunPort = PJ_STUN_PORT; // account->getStunPort();
DEBUG("UserAgent: Create stun transport server name: %s, port: %d", account->getStunServerName(), stunPort);// account->getStunPort());
if (stunServerResolve(account) != PJ_SUCCESS) {
ERROR("Can't resolve STUN server");
......@@ -1561,6 +1563,7 @@ void SIPVoIPLink::findLocalAddressFromTransport(pjsip_transport *transport, pjsi
int i_port = 0;
// Find the local address and port for this transport
DEBUG("transportType: %d\n", transportType);
if (pjsip_tpmgr_find_local_addr(tpmgr, pool_, transportType, tp_sel, &localAddress, &i_port) != PJ_SUCCESS) {
WARN("SIPVoIPLink: Could not retreive local address and port from transport, using %s:%s", addr.c_str(), port.c_str());
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment