Commit 5a26bd3a authored by Tristan Matthews's avatar Tristan Matthews

* #9898: properly initialize ports

parent e658638d
......@@ -2565,7 +2565,10 @@ namespace {
bool isIP2IP(const Conf::YamlNode *node)
{
std::string id;
dynamic_cast<const Conf::MappingNode *>(node)->getValue("id", &id);
const Conf::MappingNode *m = dynamic_cast<const Conf::MappingNode *>(node);
if (!m)
return false;
m->getValue("id", &id);
return id == "IP2IP";
}
......@@ -2627,7 +2630,8 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
Sequence::const_iterator ip2ip = std::find_if(seq->begin(), seq->end(), isIP2IP);
if (ip2ip != seq->end()) {
MappingNode *node = dynamic_cast<MappingNode*>(*ip2ip);
accountMap_[SIPAccount::IP2IP_PROFILE]->unserialize(node);
if (node)
accountMap_[SIPAccount::IP2IP_PROFILE]->unserialize(node);
}
// Initialize default UDP transport according to
......
......@@ -241,22 +241,17 @@ void SIPAccount::serialize(Conf::YamlEmitter &emitter)
Sequence::iterator seqit;
for (seqit = seq->begin(); seqit != seq->end(); ++seqit) {
MappingNode *node = (MappingNode*)*seqit;
MappingNode *node = static_cast<MappingNode*>(*seqit);
delete node->getValue(CONFIG_ACCOUNT_USERNAME);
delete node->getValue(CONFIG_ACCOUNT_PASSWORD);
delete node->getValue(CONFIG_ACCOUNT_REALM);
delete node;
}
}
void SIPAccount::unserialize(const Conf::MappingNode &map)
{
using namespace Conf;
MappingNode *srtpMap;
MappingNode *tlsMap;
MappingNode *zrtpMap;
map.getValue(ALIAS_KEY, &alias_);
map.getValue(TYPE_KEY, &type_);
......@@ -272,7 +267,7 @@ void SIPAccount::unserialize(const Conf::MappingNode &map)
map.getValue(RINGTONE_ENABLED_KEY, &ringtoneEnabled_);
map.getValue(Preferences::REGISTRATION_EXPIRE_KEY, &registrationExpire_);
map.getValue(INTERFACE_KEY, &interface_);
int port;
int port = DEFAULT_SIP_PORT;
map.getValue(PORT_KEY, &port);
localPort_ = port;
map.getValue(PUBLISH_ADDR_KEY, &publishedIpAddress_);
......@@ -305,12 +300,12 @@ void SIPAccount::unserialize(const Conf::MappingNode &map)
* the configuration file.
*/
if (credNode && credNode->getType() == SEQUENCE) {
SequenceNode *credSeq = (SequenceNode *) credNode;
SequenceNode *credSeq = static_cast<SequenceNode *>(credNode);
Sequence::iterator it;
Sequence *seq = credSeq->getSequence();
for (it = seq->begin(); it != seq->end(); ++it) {
MappingNode *cred = (MappingNode *)(*it);
MappingNode *cred = static_cast<MappingNode *>(*it);
std::string user;
std::string pass;
std::string realm;
......@@ -340,7 +335,7 @@ void SIPAccount::unserialize(const Conf::MappingNode &map)
setCredentials(creds);
// get srtp submap
srtpMap = (MappingNode *)(map.getValue(SRTP_KEY));
MappingNode *srtpMap = static_cast<MappingNode *>(map.getValue(SRTP_KEY));
if (srtpMap) {
srtpMap->getValue(SRTP_ENABLE_KEY, &srtpEnabled_);
......@@ -349,7 +344,7 @@ void SIPAccount::unserialize(const Conf::MappingNode &map)
}
// get zrtp submap
zrtpMap = (MappingNode *)(map.getValue(ZRTP_KEY));
MappingNode *zrtpMap = static_cast<MappingNode *>(map.getValue(ZRTP_KEY));
if (zrtpMap) {
zrtpMap->getValue(DISPLAY_SAS_KEY, &zrtpDisplaySas_);
......@@ -359,7 +354,7 @@ void SIPAccount::unserialize(const Conf::MappingNode &map)
}
// get tls submap
tlsMap = (MappingNode *)(map.getValue(TLS_KEY));
MappingNode *tlsMap = static_cast<MappingNode *>(map.getValue(TLS_KEY));
if (tlsMap) {
tlsMap->getValue(TLS_ENABLE_KEY, &tlsEnable_);
......
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