Skip to content
Snippets Groups Projects
Commit 2e9b206f authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#3674: Add contact option in configuration

parent abebe234
No related branches found
No related tags found
No related merge requests found
......@@ -119,6 +119,7 @@ void SIPAccount::serialize(Conf::YamlEmitter *emitter)
portstr << localPort_;
ScalarNode port(portstr.str());
ScalarNode serviceRoute(serviceRoute_);
ScalarNode contactUpdateEnabled(contactUpdateEnabled_);
ScalarNode mailbox(mailBox_);
ScalarNode publishAddr(publishedIpAddress_);
......@@ -179,6 +180,7 @@ void SIPAccount::serialize(Conf::YamlEmitter *emitter)
accountmap.setKeyValue(publishPortKey, &publishPort);
accountmap.setKeyValue(sameasLocalKey, &sameasLocal);
accountmap.setKeyValue(serviceRouteKey, &serviceRoute);
accountmap.setKeyValue(updateContactHeaderKey, &contactUpdateEnabled);
accountmap.setKeyValue(dtmfTypeKey, &dtmfType);
accountmap.setKeyValue(displayNameKey, &displayName);
accountmap.setKeyValue(codecsKey, &codecs);
......@@ -281,6 +283,8 @@ void SIPAccount::unserialize(Conf::MappingNode *map)
dtmfType_ = dtmfType;
map->getValue(serviceRouteKey, &serviceRoute_);
map->getValue(updateContactHeaderKey, &contactUpdateEnabled_);
// stun enabled
map->getValue(stunEnabledKey, &stunEnabled_);
map->getValue(stunServerKey, &stunServer_);
......
......@@ -55,6 +55,7 @@ namespace Conf {
const char *const sameasLocalKey = "sameasLocal";
const char *const dtmfTypeKey = "dtmfType";
const char *const serviceRouteKey = "serviceRoute";
const char *const updateContactHeaderKey = "updateContact";
// TODO: write an object to store credential which implement serializable
const char *const srtpKey = "srtp";
......
......@@ -1657,29 +1657,25 @@ static void update_contact_header(struct pjsip_regc_cbparam *param, SIPAccount *
ss << uri->port;
std::string recvContactPort = ss.str();
DEBUG("SIPVoIPLink: Current contact header %s:%s", recvContactHost.c_str(), recvContactPort.c_str());
std::string currentAddress, currentPort;
siplink->findLocalAddressFromTransport(account->transport_, PJSIP_TRANSPORT_UDP, currentAddress, currentPort);
DEBUG("SIPVoIPLink: Current contact header %s:%s\n", currentAddress.c_str(), currentPort.c_str());
// DEBUG("Received contact header %s",
bool updateContact = false;
std::string currentContactHeader = account->getContactHeader();
size_t foundHost = currentContactHeader.find(recvContactHost);
if(foundHost == std::string::npos) {
DEBUG("SIPVoIPLink: Host %s not in current contact header\n", recvContactHost.c_str());
updateContact = true;
}
size_t foundPort = currentContactHeader.find(recvContactPort);
if(foundPort == std::string::npos) {
DEBUG("SIPVoIPLink: Port %s not in current contact header\n", recvContactPort.c_str());
updateContact = true;
}
if(updateContact) {
DEBUG("SIPVoIPLink: Update contact header: %s:%s\n", recvContactHost.c_str(), recvContactPort.c_str());
account->setContactHeader(recvContactHost, recvContactPort);
siplink->sendRegister(account);
}
......@@ -1691,8 +1687,6 @@ void registration_cb(struct pjsip_regc_cbparam *param)
{
SIPAccount *account = static_cast<SIPAccount *>(param->token);
ERROR("SipVoipLink: REGISTRATION CALLBACK");
if (account == NULL) {
ERROR("SipVoipLink: account does'nt exist in registration callback");
return;
......@@ -1703,7 +1697,6 @@ void registration_cb(struct pjsip_regc_cbparam *param)
return;
}
DEBUG("SipVoipLink: Contact header from UAS, %d contact(s)", param->contact_cnt);
if(account->isContactUpdateEnabled()) {
update_contact_header(param, account);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment