Commit 6f3bffff authored by Alexandre Savard's avatar Alexandre Savard

#9547: Extract all the transport layer from SIPVoIPLink to new SipTransport Class

parent 7a58f609
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "config.h" #include "config.h"
#include "../manager.h" #include "../manager.h"
#include "sip/sipvoiplink.h" #include "sip/sipvoiplink.h"
#include "sip/siptransport.h"
#include "account.h" #include "account.h"
#include "sip/sipaccount.h" #include "sip/sipaccount.h"
...@@ -411,17 +412,17 @@ std::vector<std::map<std::string, std::string> > ConfigurationManager::getHistor ...@@ -411,17 +412,17 @@ std::vector<std::map<std::string, std::string> > ConfigurationManager::getHistor
std::string std::string
ConfigurationManager::getAddrFromInterfaceName(const std::string& interface) ConfigurationManager::getAddrFromInterfaceName(const std::string& interface)
{ {
return SIPVoIPLink::getInterfaceAddrFromName(interface); return SipTransport::getInterfaceAddrFromName(interface);
} }
std::vector<std::string> ConfigurationManager::getAllIpInterface() std::vector<std::string> ConfigurationManager::getAllIpInterface()
{ {
return SIPVoIPLink::getAllIpInterface(); return SipTransport::getAllIpInterface();
} }
std::vector<std::string> ConfigurationManager::getAllIpInterfaceByName() std::vector<std::string> ConfigurationManager::getAllIpInterfaceByName()
{ {
return SIPVoIPLink::getAllIpInterfaceByName(); return SipTransport::getAllIpInterfaceByName();
} }
std::map<std::string, std::string> ConfigurationManager::getShortcuts() std::map<std::string, std::string> ConfigurationManager::getShortcuts()
......
...@@ -2563,7 +2563,7 @@ void ManagerImpl::loadDefaultAccountMap() ...@@ -2563,7 +2563,7 @@ void ManagerImpl::loadDefaultAccountMap()
{ {
// build a default IP2IP account with default parameters // build a default IP2IP account with default parameters
accountMap_[SIPAccount::IP2IP_PROFILE] = new SIPAccount(SIPAccount::IP2IP_PROFILE); accountMap_[SIPAccount::IP2IP_PROFILE] = new SIPAccount(SIPAccount::IP2IP_PROFILE);
SIPVoIPLink::instance()->createDefaultSipUdpTransport(); SIPVoIPLink::instance()->sipTransport.createDefaultSipUdpTransport();
accountMap_[SIPAccount::IP2IP_PROFILE]->registerVoIPLink(); accountMap_[SIPAccount::IP2IP_PROFILE]->registerVoIPLink();
} }
...@@ -2627,7 +2627,7 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser &parser) ...@@ -2627,7 +2627,7 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
// Initialize default UDP transport according to // Initialize default UDP transport according to
// IP to IP settings (most likely using port 5060) // IP to IP settings (most likely using port 5060)
SIPVoIPLink::instance()->createDefaultSipUdpTransport(); SIPVoIPLink::instance()->sipTransport.createDefaultSipUdpTransport();
// Force IP2IP settings to be loaded to be loaded // Force IP2IP settings to be loaded to be loaded
// No registration in the sense of the REGISTER method is performed. // No registration in the sense of the REGISTER method is performed.
......
...@@ -9,12 +9,14 @@ libsiplink_la_SOURCES = \ ...@@ -9,12 +9,14 @@ libsiplink_la_SOURCES = \
sipaccount.cpp \ sipaccount.cpp \
sipcall.cpp \ sipcall.cpp \
sipvoiplink.cpp \ sipvoiplink.cpp \
siptransport.cpp \
pattern.h \ pattern.h \
sdes_negotiator.h \ sdes_negotiator.h \
sdp.h \ sdp.h \
sipaccount.h \ sipaccount.h \
sipcall.h \ sipcall.h \
sipvoiplink.h \ sipvoiplink.h \
siptransport.h \
sip_utils.cpp \ sip_utils.cpp \
sip_utils.h sip_utils.h
......
...@@ -407,7 +407,7 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details) ...@@ -407,7 +407,7 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details)
publishedPort_ = atoi(details[CONFIG_PUBLISHED_PORT].c_str()); publishedPort_ = atoi(details[CONFIG_PUBLISHED_PORT].c_str());
if(stunServer_ != details[CONFIG_STUN_SERVER]) { if(stunServer_ != details[CONFIG_STUN_SERVER]) {
DEBUG("Stun server changed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); DEBUG("Stun server changed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
link_->destroyStunResolver(stunServer_); link_->sipTransport.destroyStunResolver(stunServer_);
// pj_stun_sock_destroy(pj_stun_sock *stun_sock); // pj_stun_sock_destroy(pj_stun_sock *stun_sock);
} }
stunServer_ = details[CONFIG_STUN_SERVER]; stunServer_ = details[CONFIG_STUN_SERVER];
...@@ -816,7 +816,7 @@ std::string SIPAccount::getContactHeader() const ...@@ -816,7 +816,7 @@ std::string SIPAccount::getContactHeader() const
// Else we determine this infor based on transport information // Else we determine this infor based on transport information
std::string address, port; std::string address, port;
link_->findLocalAddressFromTransport(transport_, transportType, address, port); link_->sipTransport.findLocalAddressFromTransport(transport_, transportType, address, port);
// UDP does not require the transport specification // UDP does not require the transport specification
std::string scheme; std::string scheme;
......
This diff is collapsed.
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "sipaccount.h" #include "sipaccount.h"
#include "voiplink.h" #include "voiplink.h"
#include "siptransport.h"
class EventThread; class EventThread;
class SIPCall; class SIPCall;
...@@ -211,49 +212,6 @@ class SIPVoIPLink : public VoIPLink { ...@@ -211,49 +212,6 @@ class SIPVoIPLink : public VoIPLink {
*/ */
std::string getUseragentName(SIPAccount *) const; std::string getUseragentName(SIPAccount *) const;
/**
* List all the interfaces on the system and return
* a vector list containing their IPV4 address.
* @param void
* @return std::vector<std::string> A std::string vector
* of IPV4 address available on all of the interfaces on
* the system.
*/
static std::vector<std::string> getAllIpInterface();
/**
* List all the interfaces on the system and return
* a vector list containing their name (eth0, eth0:1 ...).
* @param void
* @return std::vector<std::string> A std::string vector
* of interface name available on all of the interfaces on
* the system.
*/
static std::vector<std::string> getAllIpInterfaceByName();
/**
* List all the interfaces on the system and return
* a vector list containing their name (eth0, eth0:1 ...).
* @param void
* @return std::vector<std::string> A std::string vector
* of interface name available on all of the interfaces on
* the system.
*/
static std::string getInterfaceAddrFromName(const std::string &ifaceName);
/**
* Initialize the transport selector
* @param transport A transport associated with an account
*
* @return A pointer to the transport selector structure
*/
pjsip_tpselector *initTransportSelector(pjsip_transport *, pj_pool_t *) const;
/**
* This function unset the transport for a given account.
*/
void shutdownSipTransport(SIPAccount *account);
/** /**
* Send a SIP message to a call identified by its callid * Send a SIP message to a call identified by its callid
* *
...@@ -270,26 +228,7 @@ class SIPVoIPLink : public VoIPLink { ...@@ -270,26 +228,7 @@ class SIPVoIPLink : public VoIPLink {
*/ */
void createDefaultSipUdpTransport(); void createDefaultSipUdpTransport();
/** SipTransport sipTransport;
* Get the correct address to use (ie advertised) from
* a uri. The corresponding transport that should be used
* with that uri will be discovered.
*
* @param uri The uri from which we want to discover the address to use
* @param transport The transport to use to discover the address
*/
void findLocalAddressFromTransport(pjsip_transport *transport, pjsip_transport_type_e transportType, std::string &address, std::string &port) const;
/**
* Create a new stun resolver. Store it inside the array. Resolve public address for this
* server name.
* @param serverName The name of the stun server
* @param port number
*/
pj_status_t createStunResolver(pj_str_t serverName, pj_uint16_t port);
pj_status_t destroyStunResolver(const std::string serverName);
private: private:
/** /**
* Start a SIP Call * Start a SIP Call
...@@ -304,65 +243,6 @@ class SIPVoIPLink : public VoIPLink { ...@@ -304,65 +243,6 @@ class SIPVoIPLink : public VoIPLink {
SIPVoIPLink(); SIPVoIPLink();
/**
* General Sip transport creation method according to the
* transport type specified in account settings
* @param account The account for which a transport must be created.
*/
void createSipTransport(SIPAccount *account);
/**
* Create SIP UDP transport from account's setting
* @param account The account for which a transport must be created.
*/
pjsip_transport *createUdpTransport(std::string interface, unsigned int port);
/**
* Create The default TLS listener which is global to the application. This means that
* only one TLS connection can be established for the momment.
* @param the port number to create the TCP socket
* @param pjsip's tls settings for the transport to be created which contains:
* - path to ca certificate list file
* - path to certertificate file
* - path to private key file
* - the password for the file
* - the TLS method
* @param a pointer to store the listener created, in our case this is a static pointer
*/
void createTlsListener(pj_uint16_t, pjsip_tls_setting *, pjsip_tpfactory **);
/**
* Create a connection oriented TLS transport and register to the specified remote address.
* First, initialize the TLS listener sole instance. This means that, for the momment, only one TLS transport
* is allowed to be created in the application. Any subsequent account attempting to
* register a new using this transport even if new settings are specified.
* @param the remote address for this transport to be connected
* @param the local port to initialize the TCP socket
* @param pjsip's tls transport parameters
*/
pjsip_transport *
createTlsTransport(const std::string &remoteAddr,
pj_uint16_t tlsListenerPort,
pjsip_tls_setting *tlsSetting);
/**
* Create a UDP transport using stun server to resove public address
* @param account The account for which a transport must be created.
*/
pjsip_transport *createStunTransport(pj_str_t serverName, pj_uint16_t port);
/**
* 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_;
/**
* Stun resolver array
*/
std::map<std::string, pj_stun_sock *> stunSocketMap_;
/** /**
* Threading object * Threading object
*/ */
......
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