Commit 30a1b49d authored by Tristan Matthews's avatar Tristan Matthews

* #9910: SIP: use rport from VIA header if present

This fixes the issue where we weren't receiving BYE requests from the
ekiga.net callback account (520@ekiga.net).
parent acd1363f
......@@ -99,6 +99,7 @@ SIPAccount::SIPAccount(const std::string& accountID)
, keepAliveTimer_()
, link_(SIPVoIPLink::instance())
, receivedParameter_()
, rPort_(-1)
{}
void SIPAccount::serialize(Conf::YamlEmitter &emitter)
......
......@@ -505,6 +505,15 @@ class SIPAccount : public Account {
return receivedParameter_;
}
int getRPort() const {
if (rPort_ == -1)
return localPort_;
else
return rPort_;
}
void setRPort(int rPort) { rPort_ = rPort; }
/**
* Timer used to periodically send re-register request based
* on the "Expire" sip header (or the "expire" Contact parameter)
......@@ -734,9 +743,14 @@ class SIPAccount : public Account {
SIPVoIPLink* link_;
/**
* Received via parameters
* Optional: "received" parameter from VIA header
*/
std::string receivedParameter_;
/**
* Optional: "rport" parameter from VIA header
*/
int rPort_;
};
#endif
......@@ -519,11 +519,12 @@ void SIPVoIPLink::sendRegister(Account *a)
std::string contact = account->getContactHeader();
pj_str_t pjContact = pj_str((char*) contact.c_str());
if(!received.empty()) {
if (!received.empty()) {
// Set received parameter string to empty in order to avoid creating new transport for each register
account->setReceivedParameter("");
// Explicitely set the bound address port to 0 so that pjsip determine a random port by itself
account->transport_= sipTransport.createUdpTransport(account->getLocalInterface(), 0, received, account->getLocalPort());
account->transport_= sipTransport.createUdpTransport(account->getLocalInterface(), 0, received, account->getRPort());
account->setRPort(-1);
if(account->transport_ == NULL) {
ERROR("UserAgent: Could not create new udp transport with public address: %s:%d", received.c_str(), account->getLocalPort());
}
......@@ -1582,6 +1583,8 @@ void lookForReceivedParameter(pjsip_regc_cbparam *param, SIPAccount *account)
DEBUG("Cool received received parameter... uhhh?, the value is %s", publicIpFromReceived.c_str());
account->setReceivedParameter(publicIpFromReceived);
}
account->setRPort(param->rdata->msg_info.via->rport_param);
}
void registration_cb(pjsip_regc_cbparam *param)
......
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