Skip to content
Snippets Groups Projects
Commit d88fe7a7 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #9911: SIP Transports must be cached by IP:port

This fixes the case where we could no longer register on a machine with
more than one network interface if it was disconnected, or if we changed
interfaces. If two interfaces were using the same port, the daemon
thought they were the same transport.
parent 3c2b4309
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,10 @@ void NetworkManager::StateChanged(const uint32_t &state)
void NetworkManager::PropertiesChanged(const std::map<std::string, ::DBus::Variant> &argin0)
{
WARN("Properties changed: %s", argin0.begin()->first.c_str());
WARN("Properties changed: ");
for (std::map<std::string, ::DBus::Variant>::const_iterator iter = argin0.begin();
iter != argin0.end(); ++iter)
WARN("%s", iter->first.c_str());
Manager::instance().registerAccounts();
}
......
......@@ -342,10 +342,14 @@ void SipTransport::createSipTransport(SIPAccount &account)
}
if (!account.transport_) {
DEBUG("SipTransport: Looking into previously created transport map for %s:%d",
account.getLocalInterface().c_str(), account.getLocalPort());
std::ostringstream key;
key << account.getLocalInterface();
key << ":";
key << account.getLocalPort();
DEBUG("SipTransport: Looking into previously created transport map for"
" %s", key.str().c_str());
// Could not create new transport, this transport may already exists
pjsip_transport *cachedTransport = transportMap_[account.getLocalPort()];
pjsip_transport *cachedTransport = transportMap_[key.str()];
if (cachedTransport) {
account.transport_ = cachedTransport;
......@@ -436,10 +440,10 @@ SipTransport::createUdpTransport(const std::string &interface, unsigned int port
}
}
DEBUG("SipTransport: Listening address %s, listening port %d", listeningAddress.c_str(), listeningPort);
DEBUG("SipTransport: Listening address %s", fullAddressStr.c_str());
// dump debug information to stdout
pjsip_tpmgr_dump_transports(pjsip_endpt_get_tpmgr(endpt_));
transportMap_[listeningPort] = transport;
transportMap_[fullAddressStr] = transport;
return transport;
}
......
......@@ -169,7 +169,7 @@ class SipTransport {
* UDP Transports are stored in this map in order to retreive them in case
* several accounts would share the same port number.
*/
std::map<pj_uint16_t, pjsip_transport*> transportMap_;
std::map<std::string, pjsip_transport*> transportMap_;
/**
* Stun resolver array
......
......@@ -534,7 +534,7 @@ static void use_sip_tls_cb(GtkWidget *widget, gpointer data)
static gchar *
get_interface_addr_from_name(const gchar * const iface_name)
{
#define UC(b) (((int)b)&0xff)
#define UC(b) (((int)b)&0xff)
int fd;
......
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