[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "modular-transport-refactor" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Jun 23 07:56:46 CDT 2011
branch "modular-transport-refactor" has been updated
via 35293a3236ddc7df141b1854f643b63023667d01 (commit)
via 18af343adab9d9989a1393927dea65b9b9171a13 (commit)
via 4440b9c56a3eaa0e7ed189e8f4f403a80db2c4c5 (commit)
via e3cba07a3705a9ef7ef01a1a984e2076eb8b460f (commit)
via 76c154725df0c8e5570d4fe9330ee1d21caa2c1d (commit)
via 5f043c5c94c23df52f967d8f5a68b898cd8610bd (commit)
via e8b2cf2c740beb7227dd97e6123ba168dbd06fb9 (commit)
via a2e2aeeb76490683de851af22bd09063a387c7be (commit)
via 2e7eef7d9b5b1f8a1a829f6d626084f49021abe7 (commit)
via e8979048bb3679d1332b9abfd7e59a89f345efa4 (commit)
via 0f83f9f5fca5bc50b71b7fb529df74a279a21be6 (commit)
from 842ac2916a9dacfa0151dd121763d94aba3f23b5 (commit)
Summary of changes:
local-slice/SipConfigurationIf.ice | 758 ++++++++++++++++++------------------
src/CMakeLists.txt | 20 +-
src/DebugUtil.h | 33 ++
src/PJSipLoggingModule.cpp | 1 +
src/PJSipManager.cpp | 223 ++++++------
src/PJSipManager.h | 45 ++-
src/PJSipModule.h | 3 +-
src/PJUtil.h | 37 ++
src/STUNModule.cpp | 156 ++++++++
src/STUNModule.h | 101 +++++
src/STUNTransport.cpp | 356 +++++++++++++++++
src/STUNTransport.h | 44 ++
src/SipConfiguration.cpp | 158 ++++++--
src/SipConfiguration.h | 2 +-
src/SipEndpoint.cpp | 98 +----
src/SipEndpoint.h | 41 +-
src/SipEndpointFactory.cpp | 12 +-
src/SipEndpointFactory.h | 6 +-
src/SipModule.h | 68 ++++
src/SipSession.cpp | 8 +-
src/SipSession.h | 12 +-
src/SipSessionManagerApp.cpp | 21 +-
src/SipStateReplicator.h | 2 +-
src/SipStateReplicatorListener.cpp | 13 +-
src/TCPTransport.cpp | 95 +++++
src/TCPTransport.h | 41 ++
src/TLSTransport.cpp | 75 ++++
src/TLSTransport.h | 43 ++
src/Transports.cpp | 31 ++
src/Transports.h | 46 +++
src/UDPTransport.cpp | 100 +++++
src/UDPTransport.h | 41 ++
32 files changed, 1988 insertions(+), 702 deletions(-)
create mode 100644 src/DebugUtil.h
create mode 100644 src/PJUtil.h
create mode 100644 src/STUNModule.cpp
create mode 100644 src/STUNModule.h
create mode 100644 src/STUNTransport.cpp
create mode 100644 src/STUNTransport.h
create mode 100644 src/SipModule.h
create mode 100644 src/TCPTransport.cpp
create mode 100644 src/TCPTransport.h
create mode 100644 src/TLSTransport.cpp
create mode 100644 src/TLSTransport.h
create mode 100644 src/Transports.cpp
create mode 100644 src/Transports.h
create mode 100644 src/UDPTransport.cpp
create mode 100644 src/UDPTransport.h
- Log -----------------------------------------------------------------
commit 35293a3236ddc7df141b1854f643b63023667d01
Author: Brent Eagles <beagles at digium.com>
Date: Wed Jun 22 18:17:29 2011 -0230
Deal with problems introduced in merge and hook up configuration of the STUN transport.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index ddfe65d..f8ae0b7 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -27,380 +27,392 @@ module SIP
["suppress"]
module V1
{
- /**
- * Service locator category for finding the configuration service
- */
- const string ConfigurationDiscoveryCategory = "SipConfiguration";
-
- /**
- * Service locator parameters class for discovering the configuration service
- */
- unsliceable class SipConfigurationParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
- {
- /**
- * Unique name for the configuration service
- */
- string name;
- };
-
- /**
- * Local visitor class for visiting SIP configuration groups
- */
- local class SipConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
- {
- };
-
- /**
- * Generic SIP configuration group
- */
- ["visitor:SipConfigurationGroupVisitor"] class SipConfigurationGroup extends AsteriskSCF::System::Configuration::V1::ConfigurationGroup
- {
- };
-
- /**
- * General SIP configuration group that contains general items related to the SIP component as a whole
- */
- class SipGeneralGroup extends SipConfigurationGroup
- {
- };
-
- /**
- * Local visitor class for visiting SIP configuration items
- */
- local class SipConfigurationItemVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationItemVisitor
- {
- };
-
- /**
- * Generic SIP configuration item
- */
- ["visitor:SipConfigurationItemVisitor"] class SipConfigurationItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
- {
- };
-
- /**
- * SIP Endpoint group, used to configure an endpoint
- */
- class SipEndpointGroup extends SipConfigurationGroup
- {
- /**
- * Name of the endpoint being configured
- */
- string name;
- };
-
- /**
- * SIP Domain group, used to configure a specific domain
- */
- class SipDomainGroup extends SipConfigurationGroup
- {
- /**
- * Name of the domain being configured
- */
- string domain;
- };
-
- /**
- * Domain item for bindings
- */
- class SipBindingsItem extends SipConfigurationItem
- {
- /**
- * Addresses the domain is reachable over
- */
- Ice::StringSeq bindings;
- };
-
- /**
- * Generic SIP transport group that others derive from, primarily created since each one has
- * the requirement of a name
- */
- ["visitor:SipConfigurationGroupVisitor"] class SipTransportGroup extends SipConfigurationGroup
- {
- /**
- * Name of the specific transport. Since each one may have multiple transports this differentiates
- * them.
- */
- string name;
- };
-
- /**
- * Host information configuration item
- */
- ["visitor:SipConfigurationItemVisitor"] class SipHostItem extends SipConfigurationItem
- {
- /**
- * String containing the IP address or string address
- */
- string host;
-
- /**
- * Port number
- */
- int port;
- };
-
- /**
- * Source transport address configuration item
- */
- ["visitor:SipConfigurationItemVisitor"] class SipSourceTransportAddressItem extends SipHostItem
- {
- };
-
- /**
- * Target destination address configuration item
- */
- ["visitor:SipConfigurationItemVisitor"] class SipTargetDestinationAddressItem extends SipHostItem
- {
- };
-
- /**
- * Crypto certificate configuration item
- */
- class SipCryptoCertificateItem extends SipConfigurationItem
- {
- /**
- * Full location of certificate authority file
- */
- string certificateAuthority;
-
- /**
- * Full location of certificate file
- */
- string certificate;
-
- /**
- * Full location of private key file
- */
- string privateKey;
-
- /**
- * Password to open private key file
- */
- string privateKeyPassword;
- };
-
- /**
- * Crypto requirement configuration item
- */
- class SipCryptoRequirementsItem extends SipConfigurationItem
- {
- /**
- * Require verification of server certificate
- */
- bool requireVerifiedServer = false;
-
- /**
- * Require verification of client certificate
- */
- bool requireVerifiedClient = false;
-
- /**
- * Require client certificate be present
- */
- bool requireClientCertificate = false;
- };
-
- /**
- * TLS protocol methods
- */
- enum TLSProtocolMethod
- {
- PROTOCOLMETHODUNSPECIFIED,
- PROTOCOLMETHODTLSV1,
- PROTOCOLMETHODSSLV2,
- PROTOCOLMETHODSSLV3,
- PROTOCOLMETHODSSLV23,
- };
-
- /**
- * General crypto configuration item
- */
- class SipCryptoItem extends SipConfigurationItem
- {
- /**
- * TLS protocol method to use
- */
- TLSProtocolMethod protocolMethod = PROTOCOLMETHODUNSPECIFIED;
-
- /**
- * Supported ciphers (OpenSSL format)
- */
- string supportedCiphers;
-
- /**
- * Server name
- */
- string serverName;
-
- /**
- * TLS negotiation timeout in seconds
- */
- int timeout = 0;
- };
-
- /**
- * Routing service configuration item
- */
- class SipRoutingItem extends SipConfigurationItem
- {
- /**
- * Name of the routing service to use
- */
- string routingServiceName;
- };
-
- /**
- * RTP Media service configuration item
- */
- class SipRTPMediaServiceItem extends SipConfigurationItem
- {
- /**
- * Name of the RTP media service to use
- */
- string mediaServiceName;
-
- /**
- * Whether to choose an IPv6 RTP media service or not
- */
- bool requireIPv6 = false;
- };
-
- /**
- * Signaling NAT configuration item
- */
- class SipSignalingNATItem extends SipConfigurationItem
- {
- /**
- * Boolean for whether STUN is enabled
- */
- bool stun;
- };
-
- /**
- * Media NAT configuration item
- */
- class SipMediaNATItem extends SipConfigurationItem
- {
- /**
- * Boolean for whether symmetric RTP is enabled
- */
- bool symmetricRTP;
-
- /**
- * Boolean for whether STUN is enabled
- */
- bool stun;
-
- /**
- * Boolean for whether ICE is enabled
- */
- bool interactiveconnectivityestablishment;
-
- /**
- * Boolean for whether TURN is enabled
- */
- bool turn;
- };
-
- /**
- * Access control lists item
- */
- class SipACLItem extends SipConfigurationItem
- {
- /**
- * Name of this ACL item. A user may want to have multiple.
- */
- string name;
-
- /**
- * Ranges of allowed hosts
- */
- Ice::StringSeq allowRanges;
-
- /**
- * Specific allowed hosts
- */
- Ice::StringSeq allowHosts;
-
- /**
- * Ranges of denied hosts
- */
- Ice::StringSeq denyRanges;
-
- /**
- * Specific denied hosts
- */
- Ice::StringSeq denyHosts;
- };
-
- /**
- * Allowable call directions
- */
- enum SipAllowableCallDirection
- {
- Disabled,
- Inbound,
- Outbound,
- Both,
- };
-
- /**
- * Allowable call direction item
- */
- class SipAllowableCallDirectionItem extends SipConfigurationItem
- {
- /**
- * What direction is permitted for this endpoint
- */
- SipAllowableCallDirection callDirection = Both;
- };
-
- /**
- * User agent presentation configuration item
- */
- class SipUserAgentItem extends SipConfigurationItem
- {
- /**
- * String that our user agent should appear as
- */
- string userAgent;
- };
-
- /**
- * Transport information configuration item
- */
- class SipEndpointTransportItem extends SipConfigurationItem
- {
- /**
- * What directions to require secure transport in
- */
- SipAllowableCallDirection secureTransport = Disabled;
- };
-
- /**
- * Group of configuration items related to a UDP transport
- */
- ["visitor:SipConfigurationGroupVisitor"] class SipUDPTransportGroup extends SipTransportGroup
- {
- };
-
- /**
- * Group of configuration items related to a TCP transport
- */
- ["visitor:SipConfigurationGroupVisitor"] class SipTCPTransportGroup extends SipTransportGroup
- {
- };
-
- /**
- * Group of configuration items related to a TLS transport
- */
- ["visitor:SipConfigurationGroupVisitor"] class SipTLSTransportGroup extends SipTransportGroup
- {
- };
-}; /* module V1 */
+/**
+ * Service locator category for finding the configuration service
+ */
+const string ConfigurationDiscoveryCategory = "SipConfiguration";
-}; /* module SIP */
+/**
+ * Service locator parameters class for discovering the configuration service
+ */
+unsliceable class SipConfigurationParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
+{
+ /**
+ * Unique name for the configuration service
+ */
+ string name;
+};
+
+/**
+ * Local visitor class for visiting SIP configuration groups
+ */
+local class SipConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
+{
+};
+
+/**
+ * Generic SIP configuration group
+ */
+["visitor:SipConfigurationGroupVisitor"] class SipConfigurationGroup extends AsteriskSCF::System::Configuration::V1::ConfigurationGroup
+{
+};
+/**
+ * General SIP configuration group that contains general items related to the SIP component as a whole
+ */
+class SipGeneralGroup extends SipConfigurationGroup
+{
+};
+
+/**
+ * Local visitor class for visiting SIP configuration items
+ */
+local class SipConfigurationItemVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationItemVisitor
+{
+};
+
+/**
+ * Generic SIP configuration item
+ */
+["visitor:SipConfigurationItemVisitor"] class SipConfigurationItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+{
+};
+
+/**
+ * SIP Endpoint group, used to configure an endpoint
+ */
+class SipEndpointGroup extends SipConfigurationGroup
+{
+ /**
+ * Name of the endpoint being configured
+ */
+ string name;
+};
+
+/**
+ * SIP Domain group, used to configure a specific domain
+ */
+class SipDomainGroup extends SipConfigurationGroup
+{
+ /**
+ * Name of the domain being configured
+ */
+ string domain;
+};
+
+/**
+ * Domain item for bindings
+ */
+class SipBindingsItem extends SipConfigurationItem
+{
+ /**
+ * Addresses the domain is reachable over
+ */
+ Ice::StringSeq bindings;
+};
+
+/**
+ * Generic SIP transport group that others derive from, primarily created since each one has
+ * the requirement of a name
+ */
+["visitor:SipConfigurationGroupVisitor"] class SipTransportGroup extends SipConfigurationGroup
+{
+ /**
+ * Name of the specific transport. Since each one may have multiple transports this differentiates
+ * them.
+ */
+ string name;
+};
+
+/**
+ * Host information configuration item
+ */
+["visitor:SipConfigurationItemVisitor"] class SipHostItem extends SipConfigurationItem
+{
+ /**
+ * String containing the IP address or string address
+ */
+ string host;
+
+ /**
+ * Port number
+ */
+ int port;
+};
+
+/**
+ * Source transport address configuration item
+ */
+["visitor:SipConfigurationItemVisitor"] class SipSourceTransportAddressItem extends SipHostItem
+{
+};
+
+/**
+ * Target destination address configuration item
+ */
+["visitor:SipConfigurationItemVisitor"] class SipTargetDestinationAddressItem extends SipHostItem
+{
+};
+
+/**
+ * Crypto certificate configuration item
+ */
+class SipCryptoCertificateItem extends SipConfigurationItem
+{
+ /**
+ * Full location of certificate authority file
+ */
+ string certificateAuthority;
+
+ /**
+ * Full location of certificate file
+ */
+ string certificate;
+
+ /**
+ * Full location of private key file
+ */
+ string privateKey;
+
+ /**
+ * Password to open private key file
+ */
+ string privateKeyPassword;
+};
+
+/**
+ * Crypto requirement configuration item
+ */
+class SipCryptoRequirementsItem extends SipConfigurationItem
+{
+ /**
+ * Require verification of server certificate
+ */
+ bool requireVerifiedServer = false;
+
+ /**
+ * Require verification of client certificate
+ */
+ bool requireVerifiedClient = false;
+
+ /**
+ * Require client certificate be present
+ */
+ bool requireClientCertificate = false;
+};
+
+/**
+ * TLS protocol methods
+ */
+enum TLSProtocolMethod
+{
+ PROTOCOLMETHODUNSPECIFIED,
+ PROTOCOLMETHODTLSV1,
+ PROTOCOLMETHODSSLV2,
+ PROTOCOLMETHODSSLV3,
+ PROTOCOLMETHODSSLV23,
+};
+
+/**
+ * General crypto configuration item
+ */
+class SipCryptoItem extends SipConfigurationItem
+{
+ /**
+ * TLS protocol method to use
+ */
+ TLSProtocolMethod protocolMethod = PROTOCOLMETHODUNSPECIFIED;
+
+ /**
+ * Supported ciphers (OpenSSL format)
+ */
+ string supportedCiphers;
+
+ /**
+ * Server name
+ */
+ string serverName;
+
+ /**
+ * TLS negotiation timeout in seconds
+ */
+ int timeout = 0;
+};
+
+/**
+ * Routing service configuration item
+ */
+class SipRoutingItem extends SipConfigurationItem
+{
+ /**
+ * Name of the routing service to use
+ */
+ string routingServiceName;
+};
+
+/**
+ * RTP Media service configuration item
+ */
+class SipRTPMediaServiceItem extends SipConfigurationItem
+{
+ /**
+ * Name of the RTP media service to use
+ */
+ string mediaServiceName;
+
+ /**
+ * Whether to choose an IPv6 RTP media service or not
+ */
+ bool requireIPv6 = false;
+};
+
+/**
+ * Signaling NAT configuration item
+ */
+class SipSignalingNATItem extends SipConfigurationItem
+{
+ /**
+ * Boolean for whether STUN is enabled
+ */
+ bool stun;
+};
+
+/**
+ * STUN server to be used by Sip signalling.
+ */
+class SipSignalingSTUNHostItem extends SipConfigurationItem
+{
+ /**
+ * Address for the STUN server.
+ **/
+ string address;
+
+ /**
+ * Port for the STUN host.
+ */
+ int port;
+};
+
+/**
+ * Media NAT configuration item
+ */
+class SipMediaNATItem extends SipConfigurationItem
+{
+ /**
+ * Boolean for whether ICE is enabled
+ */
+ bool enableICE;
+
+ /**
+ * Boolean for whether TURN is enabled
+ */
+ bool enableTURN;
+};
+
+/**
+ * Access control lists item
+ */
+class SipACLItem extends SipConfigurationItem
+{
+ /**
+ * Name of this ACL item. A user may want to have multiple.
+ */
+ string name;
+
+ /**
+ * Ranges of allowed hosts
+ */
+ Ice::StringSeq allowRanges;
+
+ /**
+ * Specific allowed hosts
+ */
+ Ice::StringSeq allowHosts;
+
+ /**
+ * Ranges of denied hosts
+ */
+ Ice::StringSeq denyRanges;
+
+ /**
+ * Specific denied hosts
+ */
+ Ice::StringSeq denyHosts;
+};
+
+/**
+ * Allowable call directions
+ */
+enum SipAllowableCallDirection
+{
+ Disabled,
+ Inbound,
+ Outbound,
+ Both,
+};
+
+/**
+ * Allowable call direction item
+ */
+class SipAllowableCallDirectionItem extends SipConfigurationItem
+{
+ /**
+ * What direction is permitted for this endpoint
+ */
+ SipAllowableCallDirection callDirection = Both;
+};
+
+/**
+ * User agent presentation configuration item
+ */
+class SipUserAgentItem extends SipConfigurationItem
+{
+ /**
+ * String that our user agent should appear as
+ */
+ string userAgent;
+};
+
+/**
+ * Transport information configuration item
+ */
+class SipEndpointTransportItem extends SipConfigurationItem
+{
+ /**
+ * What directions to require secure transport in
+ */
+ SipAllowableCallDirection secureTransport = Disabled;
+};
+
+/**
+ * Group of configuration items related to a UDP transport
+ */
+["visitor:SipConfigurationGroupVisitor"] class SipUDPTransportGroup extends SipTransportGroup
+{
+};
+
+/**
+ * Group of configuration items related to a TCP transport
+ */
+["visitor:SipConfigurationGroupVisitor"] class SipTCPTransportGroup extends SipTransportGroup
+{
+};
+
+/**
+ * Group of configuration items related to a TLS transport
+ */
+["visitor:SipConfigurationGroupVisitor"] class SipTLSTransportGroup extends SipTransportGroup
+{
+};
+
+/**
+ * Group of configuration items related to a STUN enabled transport
+ */
+["visitor:SipConfigurationGroupVisitor"] class SipSTUNTransportGroup extends SipTransportGroup
+{
+};
+
+}; /* module V1 */
+}; /* module SIP */
}; /* module Asterisk SCF */
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d6c5e15..78f74ff 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -39,6 +39,8 @@ asterisk_scf_component_add_file(SipSessionManager STUNModule.cpp)
asterisk_scf_component_add_file(SipSessionManager STUNModule.h)
asterisk_scf_component_add_file(SipSessionManager STUNTransport.cpp)
asterisk_scf_component_add_file(SipSessionManager STUNTransport.h)
+asterisk_scf_component_add_file(SipSessionManager STUNTransportConfig.cpp)
+asterisk_scf_component_add_file(SipSessionManager STUNTransportConfig.h)
asterisk_scf_component_add_file(SipSessionManager PJSipModule.cpp)
asterisk_scf_component_add_file(SipSessionManager PJSipModule.h)
asterisk_scf_component_add_file(SipSessionManager PJSipSessionModule.cpp)
diff --git a/src/STUNModule.cpp b/src/STUNModule.cpp
index aefee48..687de6f 100644
--- a/src/STUNModule.cpp
+++ b/src/STUNModule.cpp
@@ -97,7 +97,7 @@ boost::shared_ptr<STUNModule> STUNModule::create(const PJSipManagerPtr& sipManag
// we can remove the poll method on this object.
//
pj_stun_config_init(config.get(), &sipManager->getCachingPool()->factory, 0, 0, 0);
-
+
status = pj_timer_heap_create(sipManager->getMemoryPool(),
properties->getPropertyAsIntWithDefault("Sip.PJSip.TimerHeap.Size", 1000),
&(config->timer_heap));
@@ -153,4 +153,4 @@ void STUNModule::destroyImpl()
mConfig.reset();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/STUNModule.h b/src/STUNModule.h
index d499687..492b213 100644
--- a/src/STUNModule.h
+++ b/src/STUNModule.h
@@ -48,6 +48,12 @@ namespace SipSessionManager
class PJSipManager;
typedef boost::shared_ptr<PJSipManager> PJSipManagerPtr;
+//
+// TODO: there currently isn't a precedent for low level pjlib-type
+// configuration. In the future, we may want to add configuration support
+// for this kidn of thing.
+//
+
class STUNModule : public SipModule
{
public:
diff --git a/src/STUNTransport.cpp b/src/STUNTransport.cpp
index 0774983..fba972b 100644
--- a/src/STUNTransport.cpp
+++ b/src/STUNTransport.cpp
@@ -112,7 +112,8 @@ private:
}
public:
- STUNTransport(pjsip_endpoint* endpoint, const Ice::PropertiesPtr& props, const STUNModulePtr& stun) :
+ STUNTransport(pjsip_endpoint* endpoint, const AsteriskSCF::Helpers::AddressPtr& stunServer,
+ const AsteriskSCF::Helpers::AddressPtr& address, const STUNModulePtr& stun) :
mDestroyed(false),
mEndpoint(endpoint),
mModule(stun),
@@ -139,14 +140,17 @@ public:
stunSockCB.on_rx_data = &onRxData;
stunSockCB.on_data_sent = &onDataSent;
- //
- // TODO: const table for property names, and allow for different bind addr for STUN enabled
- // transports.
- //
- string bindAddr = props->getPropertyWithDefault("Sip.Transport.UdpBindAddr", "0.0.0.0:5060");
pj_sockaddr udpAddr;
- pj_str_t pjAddrStr;
- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&pjAddrStr, bindAddr.c_str()), &udpAddr);
+ pj_str_t pjT;
+ if (address)
+ {
+ pj_sockaddr_init(pj_AF_UNSPEC(), &udpAddr, pj_cstr(&pjT, address->address().c_str()),
+ static_cast<pj_uint16_t>(address->port()));
+ }
+ else
+ {
+ pj_sockaddr_init(pj_AF_UNSPEC(), &udpAddr, pj_cstr(&pjT, "0.0.0.0"), 5060);
+ }
pj_status_t result = pj_stun_sock_create(mModule->getConfig(), 0, udpAddr.addr.sa_family, &stunSockCB,
&socketConfig, this, &mSocket);
@@ -155,28 +159,10 @@ public:
const char* message = "Failed to initalize STUN socket.";
logger(Error) << message;
throw InternalInitializationException(message);
- //
- // TODO: Throw!
- //
- }
-
- string stunServerProperty = props->getProperty("Sip.Transport.STUN.Server");
- auto_ptr<pj_str_t> stunServer;
- if (!stunServerProperty.empty())
- {
- stunServer = auto_ptr<pj_str_t>(new pj_str_t);
- pj_cstr(stunServer.get(), stunServerProperty.c_str());
- logger(Debug) << FUNLOG << " proceeding with STUN server " << stunServerProperty;
}
- pj_uint16_t port =
- static_cast<pj_uint16_t>(props->getPropertyAsIntWithDefault("Sip.Transport.STUN.Port", PJ_STUN_PORT));
- logger(Debug) << FUNLOG << " proceeding with STUN server " << stunServerProperty;
-
- //
- // TODO: More config! We may want to initialize and configure a resolver object.
- //
- result = pj_stun_sock_start(mSocket, stunServer.get(), port, 0);
+ result = pj_stun_sock_start(mSocket, pj_cstr(&pjT, stunServer->address().c_str()),
+ static_cast<pj_uint16_t>(stunServer->port()), 0);
if (fail(result))
{
const char* message = "Failed to start STUN socket.";
@@ -278,7 +264,7 @@ private:
{
assert(transport != 0);
memset(transport.get(), 0, sizeof *transport);
- strcpy(transport->obj_name, "ASCF"); // TODO: proper name initialization.
+ strcpy(transport->obj_name, "ASCFSTUN"); // TODO: proper name initialization.
transport->send_msg = &sendMsgImpl;
transport->do_shutdown = &shutdownImpl;
transport->destroy = &destroyImpl;
@@ -336,7 +322,7 @@ private:
pj_gettimeofday(&data->pkt_info.timestamp);
if (packetLength > sizeof data->pkt_info.packet)
{
- assert(false); // XXX houston, we have a problem.
+ assert("Packet length argument disagrees with packet length in data packet" == 0);
}
data->pkt_info.len = packetLength;
data->pkt_info.zero = 0;
@@ -359,10 +345,10 @@ private:
}
};
-TransportPtr createSTUNTransport(const PJSipManagerPtr& sipManager, const Ice::PropertiesPtr& properties,
- const std::string&, int)
+TransportPtr createSTUNTransport(const PJSipManagerPtr& sipManager, const AsteriskSCF::Helpers::AddressPtr& stunServer,
+ const AsteriskSCF::Helpers::AddressPtr& host)
{
- return TransportPtr(new STUNTransport(sipManager->getEndpoint(), properties,
+ return TransportPtr(new STUNTransport(sipManager->getEndpoint(), stunServer, host,
boost::dynamic_pointer_cast<STUNModule>(sipManager->getModule("STUN"))));
}
diff --git a/src/STUNTransport.h b/src/STUNTransport.h
index a895298..e7b0939 100644
--- a/src/STUNTransport.h
+++ b/src/STUNTransport.h
@@ -19,6 +19,7 @@
#include "Transports.h"
#include <string>
#include <Ice/PropertiesF.h>
+#include <AsteriskSCF/Helpers/Network.h>
//
// Forward declarations.
@@ -36,8 +37,8 @@ namespace SipSessionManager
class PJSipManager;
typedef boost::shared_ptr<PJSipManager> PJSipManagerPtr;
-TransportPtr createSTUNTransport(const PJSipManagerPtr& sipManager, const Ice::PropertiesPtr& properties,
- const std::string& hostname, int port);
+TransportPtr createSTUNTransport(const PJSipManagerPtr& sipManager, const AsteriskSCF::Helpers::AddressPtr& stunServer,
+ const AsteriskSCF::Helpers::AddressPtr& host);
} /* End of namespace SipSessionManager */
} /* End of namespace AsteriskSCF */
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index b1671e1..23b56f6 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -34,7 +34,9 @@
#include "UDPTransport.h"
#include "TCPTransport.h"
#include "TLSTransport.h"
+#include "STUNTransportConfig.h"
#include <vector>
+#include <AsteriskSCF/Helpers/Network.h>
using namespace AsteriskSCF::SIP::V1;
using namespace AsteriskSCF::System::Configuration::V1;
@@ -208,6 +210,16 @@ class EndpointConfigHelper : public boost::enable_shared_from_this<EndpointConfi
mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateTransport, mConfig, transport));
};
+ void visitSipMediaNATItem(const SipMediaNATItemPtr& item)
+ {
+ mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateMediaNATOptions, mConfig, item));
+ }
+
+ void visitSipSignalingNATItem(const SipSignalingNATItemPtr& item)
+ {
+ mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateSignalingNAT, mConfig, item));
+ }
+
private:
UpdateCommandList mUpdates;;
@@ -282,6 +294,16 @@ public:
mEndpoint->setSecureTransport(translateCallDirection(transport->secureTransport));
}
+ void updateMediaNATOptions(const SipMediaNATItemPtr& item)
+ {
+ mEndpoint->setMediaNATOptions(item->enableICE, item->enableTURN);
+ }
+
+ void updateSignalingNAT(const SipSignalingNATItemPtr& item)
+ {
+ mEndpoint->setSignalingNATOptions(item->stun);
+ }
+
void updated(const UpdateCommandList& updates)
{
//
@@ -351,7 +373,9 @@ class UDPTransportConfig : public ConfigBase, public boost::enable_shared_from_t
//
mConfig->update(hostItem);
}
+
private:
+ UpdateCommandList mUpdates;;
boost::shared_ptr<UDPTransportConfig> mConfig;
};
@@ -360,7 +384,7 @@ public:
/**
* Constructor implementation for this
*/
- UDPTransportConfig(const SipUDPTransportGroupPtr& group, PJSipManager* manager) :
+ UDPTransportConfig(const SipUDPTransportGroupPtr& group, const PJSipManagerPtr& manager) :
mGroup(group),
mManager(manager)
{
@@ -448,7 +472,7 @@ public:
/**
* Constructor implementation for this
*/
- TCPTransportConfig(const SipTCPTransportGroupPtr& group, PJSipManager* manager) :
+ TCPTransportConfig(const SipTCPTransportGroupPtr& group, PJSipManagerPtr& manager) :
mGroup(group),
mManager(manager)
{
@@ -562,7 +586,7 @@ public:
/**
* Constructor implementation for this
*/
- TLSTransportConfig(const SipTLSTransportGroupPtr& group, PJSipManager* manager) :
+ TLSTransportConfig(const SipTLSTransportGroupPtr& group, PJSipManagerPtr& manager) :
mGroup(group),
mManager(manager),
mNeedsUpdating(false)
@@ -714,6 +738,8 @@ bool getItem(const C& collection, I& iter, const K& key)
return iter != collection.end();
}
+typedef std::map<std::string, STUNTransportConfigPtr> STUNTransportMap;
+
/**
* ConfigurationData goes into a class by itself to aide in sharing and locking. Operations on the configuration data
* have been heavily generalized into templates and type specific helpers that map the protocols described by the
@@ -728,7 +754,7 @@ public:
typedef std::map<std::string, SipDomainGroupPtr> DomainMap;
typedef std::map<std::string, SipEndpointGroupPtr> EndpointMap;
- ConfigurationData(PJSipManager* manager, const boost::shared_ptr<SipEndpointFactory>& factory,
+ ConfigurationData(const PJSipManagerPtr& manager, const boost::shared_ptr<SipEndpointFactory>& factory,
const std::string& routingId, const LocatorRegistrySmartPrx& registry) :
mGroup(new SipGeneralGroup),
mPJSipManager(manager),
@@ -868,6 +894,20 @@ public:
}
}
+ void remove(const SipSTUNTransportGroupPtr& group)
+ {
+ STUNTransportConfigPtr config;
+ {
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ STUNTransportMap::iterator i = mSTUN.find(group->name);
+ if (i != mSTUN.end())
+ {
+ config = i->second;
+ mSTUN.erase(i);
+ }
+ }
+ }
+
SipGeneralGroupPtr getGroupFor(const SipGeneralGroupPtr&)
{
return mGroup;
@@ -939,6 +979,16 @@ public:
return 0;
}
+ const SipSTUNTransportGroupPtr getGroupFor(const SipSTUNTransportGroupPtr& group)
+ {
+ STUNTransportMap::const_iterator i;
+ if (getItem(mSTUN, i, group->name))
+ {
+ return i->second->getTypedGroup();
+ }
+ return 0;
+ }
+
private:
boost::shared_mutex mLock;
@@ -962,6 +1012,11 @@ private:
* Configured TLS SIP transports
*/
TLSTransportMap mTLS;
+
+ /**
+ * Configured STUN enabled transports.
+ */
+ STUNTransportMap mSTUN;
/**
* Configured SIP endpoints
@@ -976,7 +1031,7 @@ private:
/**
* PJSipManager Pointer
*/
- PJSipManager* mPJSipManager;
+ PJSipManagerPtr mPJSipManager;
/**
* Pointer to the endpoint factory used to create endpoints
@@ -1100,6 +1155,22 @@ private:
return transport->getVisitor();
}
+ SipConfigurationItemVisitorPtr updateGroup(const SipSTUNTransportGroupPtr& group)
+ {
+ STUNTransportMap::const_iterator i;
+ STUNTransportConfigPtr transport;
+ if (!getItem(mSTUN, i, group->name))
+ {
+ transport = STUNTransportConfig::create(mPJSipManager);
+ mSTUN.insert(make_pair(group->name, transport));
+ }
+ else
+ {
+ transport = i->second;
+ }
+ return transport->getVisitor();
+ }
+
template <class T>
void copyTemplates(ConfigurationGroupSeq& groups, const T& items)
{
@@ -1128,7 +1199,7 @@ typedef boost::shared_ptr<ConfigurationData> ConfigurationDataPtr;
class ConfigurationServiceImpl : public AsteriskSCF::System::Configuration::V1::ConfigurationService
{
public:
- ConfigurationServiceImpl(PJSipManager* manager, const boost::shared_ptr<SipEndpointFactory>& endpointFactory,
+ ConfigurationServiceImpl(const PJSipManagerPtr& manager, const boost::shared_ptr<SipEndpointFactory>& endpointFactory,
const std::string& routingId, const LocatorRegistrySmartPrx& locatorProxy);
ConfigurationGroupSeq getConfiguration(const ConfigurationGroupSeq&, const Ice::Current&);
ConfigurationGroupSeq getConfigurationAll(const ConfigurationGroupSeq&, const Ice::Current&);
@@ -1155,7 +1226,7 @@ private:
typedef IceUtil::Handle<ConfigurationServiceImpl> ConfigurationServiceImplPtr;
-ConfigurationServiceImpl::ConfigurationServiceImpl(PJSipManager* manager,
+ConfigurationServiceImpl::ConfigurationServiceImpl(const PJSipManagerPtr& manager,
const boost::shared_ptr<SipEndpointFactory>& factory, const std::string& routingId,
const LocatorRegistrySmartPrx& registry) :
mData(new ConfigurationData(manager, factory, routingId, registry))
@@ -1228,6 +1299,11 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(
getGeneric<SipTLSTransportGroupPtr>(mImpl->getData(), group, mGroups);
};
+ void visitSipSTUNTransportGroup(const ::AsteriskSCF::SIP::V1::SipSTUNTransportGroupPtr& group)
+ {
+ getGeneric<SipSTUNTransportGroupPtr>(mImpl->getData(), group, mGroups);
+ };
+
void visitSipEndpointGroup(const ::AsteriskSCF::SIP::V1::SipEndpointGroupPtr& group)
{
getGeneric<SipEndpointGroupPtr>(mImpl->getData(), group, mGroups);
@@ -1295,6 +1371,11 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(
{
genericGetAll<SipTLSTransportGroupPtr>(mImpl->getData(), group, mGroups);
};
+
+ void visitSipSTUNTransportGroup(const SipSTUNTransportGroupPtr& group)
+ {
+ genericGetAll<SipSTUNTransportGroupPtr>(mImpl->getData(), group, mGroups);
+ }
void visitSipEndpointGroup(const ::AsteriskSCF::SIP::V1::SipEndpointGroupPtr& group)
{
@@ -1377,6 +1458,11 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
genericSet<SipTLSTransportGroupPtr>(mImpl->getData(), group);
};
+ void visitSipSTUNTransportGroup(const SipSTUNTransportGroupPtr& group)
+ {
+ genericSet<SipSTUNTransportGroupPtr>(mImpl->getData(), group);
+ }
+
void visitSipEndpointGroup(const ::AsteriskSCF::SIP::V1::SipEndpointGroupPtr& group)
{
genericSet<SipEndpointGroupPtr>(mImpl->getData(), group);
@@ -1429,6 +1515,11 @@ void ConfigurationServiceImpl::removeConfigurationItems(
mImpl->getData()->removeFromGroup(group);
};
+ void visitSipSTUNTransportGroup(const SipSTUNTransportGroupPtr& group)
+ {
+ mImpl->getData()->removeFromGroup(group);
+ }
+
void visitSipEndpointGroup(const ::AsteriskSCF::SIP::V1::SipEndpointGroupPtr& group)
{
mImpl->getData()->removeFromGroup(group);
@@ -1479,6 +1570,11 @@ void ConfigurationServiceImpl::removeConfigurationGroups(
mImpl->getData()->remove(group);
};
+ void visitSipSTUNTransportGroup(const SipSTUNTransportGroupPtr& group)
+ {
+ mImpl->getData()->remove(group);
+ }
+
void visitSipEndpointGroup(const ::AsteriskSCF::SIP::V1::SipEndpointGroupPtr& group)
{
mImpl->getData()->remove(group);
@@ -1494,15 +1590,13 @@ void ConfigurationServiceImpl::removeConfigurationGroups(
(*group)->visit(v);
}
}
-
};
-
};
using namespace AsteriskSCF::SipSessionManager;
AsteriskSCF::System::Configuration::V1::ConfigurationServicePtr AsteriskSCF::SipSessionManager::createConfigurationServant(
- PJSipManager* manager,
+ const PJSipManagerPtr& manager,
const boost::shared_ptr<SipEndpointFactory>& endpointFactory,
const std::string& id,
const LocatorRegistrySmartPrx& locatorRegistry)
diff --git a/src/SipConfiguration.h b/src/SipConfiguration.h
index 89c0af1..c0608c3 100644
--- a/src/SipConfiguration.h
+++ b/src/SipConfiguration.h
@@ -38,7 +38,7 @@ namespace SipSessionManager
typedef ::AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::Core::Routing::V1::LocatorRegistryPrx> LocatorRegistrySmartPrx;
AsteriskSCF::System::Configuration::V1::ConfigurationServicePtr createConfigurationServant(
- SipSessionManager::PJSipManager* manager,
+ const PJSipManagerPtr& manager,
const boost::shared_ptr<SipEndpointFactory>& endpointFactory,
const std::string& routingId,
const LocatorRegistrySmartPrx& locatorRegistry);
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 3ff806f..9186605 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -44,7 +44,7 @@ public:
* Constructor for the SipEndpointImplPriv class.
*/
SipEndpointImplPriv(const Ice::ObjectAdapterPtr& adapter, const boost::shared_ptr<SipEndpointFactory>& factory,
- const std::string& name, PJSipManager *manager,
+ const std::string& name, const PJSipManagerPtr& manager,
const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica) :
mName(name), mAdapter(adapter), mEndpointFactory(factory), mManager(manager), mServiceLocator(serviceLocator),
@@ -85,7 +85,7 @@ public:
/**
* The PJSIP manager
*/
- PJSipManager *mManager;
+ PJSipManagerPtr mManager;
/**
*
@@ -98,26 +98,11 @@ public:
AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
};
-/**
- * Default constructor.
- */
-SipEndpoint::SipEndpoint(const Ice::ObjectAdapterPtr& adapter, const boost::shared_ptr<SipEndpointFactory>& factory,
- const std::string& name, const Ice::PropertyDict& props, PJSipManager *manager,
- const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
- const AsteriskSCF::System::Component::V1::ReplicaPtr& replica)
- : mImplPriv(new SipEndpointImplPriv(adapter, factory, name, manager, serviceLocator, replica))
-{
- lg(Debug) << "Constructing SIP endpoint " << name;
-
- mImplPriv->mEndpointProxy =
- AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx::uncheckedCast(
- mImplPriv->mAdapter->addWithUUID(this));
-
- setConfiguration(props);
-}
-
-SipEndpoint::SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpointFactory> factory, std::string name, PJSipManager *manager,
- const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator, const AsteriskSCF::System::Component::V1::ReplicaPtr replica)
+SipEndpoint::SipEndpoint(const Ice::ObjectAdapterPtr& adapter,
+ boost::shared_ptr<SipEndpointFactory> factory, std::string name,
+ const PJSipManagerPtr& manager,
+ const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+ const AsteriskSCF::System::Component::V1::ReplicaPtr replica)
: mImplPriv(new SipEndpointImplPriv(adapter, factory, name, manager, serviceLocator, replica))
{
lg(Debug) << "Constructing SIP endpoint " << name;
@@ -159,74 +144,15 @@ void SipEndpoint::setRTPOverIPv6(bool enabled)
mImplPriv->mConfig.sessionConfig.rtpOverIPv6 = enabled;
}
-void SipEndpoint::setConfiguration(const Ice::PropertyDict& props)
-{
- setTransportConfiguration(props);
- //setAuthConfiguration(props);
- //setRegistrationConfiguration(props);
- setSessionConfiguration(props);
- //setMediaConfiguration(props);
- //setSubscriptionConfiguration(props);
-}
-
-void SipEndpoint::setTransportConfiguration(const Ice::PropertyDict& props)
+void SipEndpoint::setMediaNATOptions(bool useICE, bool useTURN)
{
- std::string prefix("Sip.Endpoint.");
- prefix.append(mImplPriv->mName);
- prefix.append(".Transport.");
- // Got the basic prefix. Now get the known config options.
- Ice::PropertyDict::const_iterator IpAddress = props.find(prefix + "Address");
- if (IpAddress != props.end())
- {
- pj_str_t addr;
- pj_sockaddr sockaddr;
- pj_cstr(&addr, IpAddress->second.c_str());
- if (pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &addr, &sockaddr) != PJ_SUCCESS)
- {
- lg(Error) << "Bad address specifier in transport configuration for SIP endpoint " << mImplPriv->mName;
- }
- else
- {
- mImplPriv->mConfig.transportConfig.address = IpAddress->second;
- }
- }
- Ice::PropertyDict::const_iterator direction = props.find(prefix + "SecureTransport");
- if (direction != props.end())
- {
- mImplPriv->mConfig.transportConfig.secureTransport = SipEndpointConfig::stringToDirection(direction->second);
- }
- Ice::PropertyDict::const_iterator user = props.find(prefix + "User");
- if (user != props.end())
- {
- mImplPriv->mConfig.transportConfig.user = user->second;
- }
+ mImplPriv->mConfig.sessionConfig.rtpOverICE = useICE;
+ mImplPriv->mConfig.sessionConfig.rtpICEIncludeTURN = useTURN;
}
-void SipEndpoint::setSessionConfiguration(const Ice::PropertyDict& props)
+void SipEndpoint::setSignalingNATOptions(bool enable)
{
- std::string prefix("Sip.Endpoint.");
- prefix.append(mImplPriv->mName);
- prefix.append(".Session.");
- Ice::PropertyDict::const_iterator direction = props.find(prefix + "CallDirection");
- if (direction != props.end())
- {
- mImplPriv->mConfig.sessionConfig.callDirection = SipEndpointConfig::stringToDirection(direction->second);
- }
- Ice::PropertyDict::const_iterator address = props.find(prefix + "SourceAddress");
- if (address != props.end())
- {
- pj_str_t addr;
- pj_sockaddr sockaddr;
- pj_cstr(&addr, address->second.c_str());
- if (pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &addr, &sockaddr) != PJ_SUCCESS)
- {
- lg(Error) << "Bad address specifier in session configuration for SIP endpoint " << mImplPriv->mName;
- }
- else
- {
- mImplPriv->mConfig.sessionConfig.sourceAddress = address->second;
- }
- }
+ mImplPriv->mConfig.transportConfig.enableNAT = enable;
}
Direction SipEndpointConfig::stringToDirection(const std::string& directionString)
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 40a8e25..4401750 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -35,7 +35,6 @@
#include "SipSession.h"
-
namespace AsteriskSCF
{
@@ -46,6 +45,9 @@ class SipEndpointFactory;
class SipSession;
typedef IceUtil::Handle<SipSession> SipSessionPtr;
+class PJSipManager;
+typedef boost::shared_ptr<PJSipManager> PJSipManagerPtr;
+
/**
* General purpose direction enumeration.
* Useful for detemining policies regarding
@@ -83,6 +85,10 @@ public:
// Security policy. In which call directions
// do we require TLS?
Direction secureTransport;
+ //
+ // Enable NAT related features for the signalling transport.
+ //
+ bool enableNAT;
};
/**
@@ -141,6 +147,14 @@ public:
// Whether we are using IPv6 for media transport
// or not.
bool rtpOverIPv6;
+ //
+ // Enables ICE transport.
+ //
+ bool rtpOverICE;
+ //
+ // Enables TURN as a viable mechanism for traversing NATs.
+ //
+ bool rtpICEIncludeTURN;
};
/**
@@ -211,13 +225,10 @@ class SipEndpointImplPriv;
class SipEndpoint : public AsteriskSCF::SessionCommunications::V1::SessionEndpoint
{
public:
- SipEndpoint(const Ice::ObjectAdapterPtr& adapter, const boost::shared_ptr<SipEndpointFactory>& factory,
- const std::string& name, const Ice::PropertyDict& props, PJSipManager *manager,
- const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
- const AsteriskSCF::System::Component::V1::ReplicaPtr& replica);
- SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpointFactory> factory, std::string name, PJSipManager *manager,
- const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator, const AsteriskSCF::System::Component::V1::ReplicaPtr replica);
+ SipEndpoint(const Ice::ObjectAdapterPtr& adapter, boost::shared_ptr<SipEndpointFactory> factory, std::string name,
+ const PJSipManagerPtr& manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+ const AsteriskSCF::System::Component::V1::ReplicaPtr replica);
bool operator==(const std::string &name) const;
@@ -260,24 +271,14 @@ public:
void setSecureTransport(enum Direction);
void setRTPOverIPv6(bool);
+ void setMediaNATOptions(bool useICE, bool useTURN);
+ void setSignalingNATOptions(bool enable);
+
private:
/**
* Private implementation details.
*/
boost::shared_ptr<SipEndpointImplPriv> mImplPriv;
-
- /**
- * Set up configuration for the endpoint
- */
- void setConfiguration(const Ice::PropertyDict& props);
-
- void setTransportConfiguration(const Ice::PropertyDict& props);
-
- void setSessionConfiguration(const Ice::PropertyDict& props);
- void setRegistrationConfiguration(const Ice::PropertyDict& props);
- void setAuthConfiguration(const Ice::PropertyDict& props);
- void setMediaConfiguration(const Ice::PropertyDict& props);
- void setSubscriptionConfiguration(const Ice::PropertyDict& props);
};
/**
diff --git a/src/SipEndpointFactory.cpp b/src/SipEndpointFactory.cpp
index b816f9a..7080460 100644
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@ -23,17 +23,6 @@ namespace AsteriskSCF
namespace SipSessionManager
{
-SipEndpointPtr SipEndpointFactory::createEndpoint(const std::string& destination, const Ice::PropertiesPtr& props)
-{
- std::string prefix("Sip.Endpoint.");
- prefix.append(destination);
- Ice::PropertyDict endpointProps = props->getPropertiesForPrefix(prefix);
- SipEndpointPtr endpoint = new SipEndpoint(mAdapter, shared_from_this(), destination, endpointProps, mManager,
- mServiceLocator, mReplica);
- mEndpoints.push_back(endpoint);
- return endpoint;
-}
-
SipEndpointPtr SipEndpointFactory::createEndpoint(std::string endpointName)
{
SipEndpointPtr endpoint = new SipEndpoint(mAdapter, shared_from_this(), endpointName, mManager, mServiceLocator, mReplica);
diff --git a/src/SipEndpointFactory.h b/src/SipEndpointFactory.h
index 48cfd97..b865552 100644
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@ -35,13 +35,11 @@ namespace SipSessionManager
class SipEndpointFactory : public boost::enable_shared_from_this<SipEndpointFactory>
{
public:
- SipEndpointFactory(const Ice::ObjectAdapterPtr& adapter, PJSipManager *manager,
+ SipEndpointFactory(const Ice::ObjectAdapterPtr& adapter, const PJSipManagerPtr& manager,
const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica) :
mAdapter(adapter), mManager(manager), mServiceLocator(serviceLocator), mReplica(replica) { };
- SipEndpointPtr createEndpoint(const std::string& destination, const Ice::PropertiesPtr& props);
-
SipEndpointPtr createEndpoint(std::string);
void remove(std::string);
@@ -63,7 +61,7 @@ private:
/**
* The PJSIP Manager.
*/
- PJSipManager *mManager;
+ PJSipManagerPtr mManager;
/**
* A proxy to the service locator for proxy addition purposes.
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 63df653..3dd19e5 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -84,7 +84,7 @@ public:
* Constructor for the SipSessionPriv class.
*/
SipSessionPriv(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPtr& endpoint,
- const std::string& destination, PJSipManager *manager,
+ const std::string& destination, const PJSipManagerPtr& manager,
const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica)
: mAdapter(adapter), mDialog(0), mInviteSession(0), mEndpoint(endpoint), mDestination(destination),
@@ -241,7 +241,7 @@ public:
/**
* The PJSIP manager
*/
- PJSipManager *mManager;
+ PJSipManagerPtr mManager;
AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
@@ -312,7 +312,7 @@ void SipSession::initializePJSIPStructs()
*/
SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPtr& endpoint,
const std::string& destination, const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
- PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+ const PJSipManagerPtr& manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool ipv6, bool isUAC)
: mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
{
@@ -345,7 +345,7 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
const std::string& destination, const Ice::Identity& sessionid,
const Ice::Identity& mediaid, const AsteriskSCF::Media::V1::SessionPrx& mediasession,
const AsteriskSCF::Media::V1::StreamSourceSeq& sources, const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
- PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+ const PJSipManagerPtr& manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC)
: mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
{
diff --git a/src/SipSession.h b/src/SipSession.h
index 2a60c76..3e63cf9 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -43,16 +43,20 @@ namespace AsteriskSCF
namespace SipSessionManager
{
+//
+// Forward declarations.
+//
class SipEndpoint;
typedef IceUtil::Handle<SipEndpoint> SipEndpointPtr;
+class PJSipManager;
+typedef boost::shared_ptr<PJSipManager> PJSipManagerPtr;
+
/*
* Private implementation class for SipSession.
*/
class SipSessionPriv;
-//I can haz forward declaration.
-class PJSipManager;
/**
* This is where session related work items get enqueued.
@@ -94,7 +98,7 @@ class SipSession : public AsteriskSCF::SessionCommunications::V1::Session
{
public:
SipSession(const Ice::ObjectAdapterPtr&, const SipEndpointPtr&, const std::string&,
- const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, PJSipManager *manager,
+ const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const PJSipManagerPtr& manager,
const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
bool ipv6, bool isUAC);
@@ -102,7 +106,7 @@ public:
SipSession(const Ice::ObjectAdapterPtr&, const SipEndpointPtr&, const std::string&, const Ice::Identity&,
const Ice::Identity&, const AsteriskSCF::Media::V1::SessionPrx&,
const AsteriskSCF::Media::V1::StreamSourceSeq&, const AsteriskSCF::Media::V1::StreamSinkSeq&,
- PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+ const PJSipManagerPtr& manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
bool isUAC);
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 5fa316d..1a43ccf 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -97,7 +97,6 @@ private:
void registerWithStateReplicator();
void registerWithRoutingService();
void deregisterFromRoutingService();
- void configureEndpoints();
void registerPJSipModules();
void deregisterFromStateReplicator();
@@ -122,7 +121,7 @@ private:
ComponentServicePtr mComponentService;
ConfigurationServicePtr mConfigurationService;
ConfigurationServicePrx mConfigurationServiceProxy;
- PJSipManager *mPJSipManager;
+ PJSipManagerPtr mPJSipManager;
SipStateReplicatorListenerPtr mReplicatorListener;
SipStateReplicatorListenerPrx mReplicatorListenerProxy;
boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
@@ -454,17 +453,6 @@ void SipSessionManager::deregisterFromServiceLocator()
}
}
-void SipSessionManager::configureEndpoints()
-{
- Ice::PropertiesPtr props = mCommunicator->getProperties();
- Ice::StringSeq endpointNames = props->getPropertyAsList("Sip.Endpoints");
- for (Ice::StringSeq::iterator i = endpointNames.begin();
- i != endpointNames.end();
- ++i)
- {
- SipEndpointPtr endpoint = mEndpointFactory->createEndpoint(*i, props);
- }
-}
void SipSessionManager::registerPJSipModules()
{
@@ -522,7 +510,7 @@ void SipSessionManager::initialize(const string& appName, const Ice::Communicato
mAppName = appName;
// Initialize PJSIP
- mPJSipManager = new PJSipManager(ic->getProperties());
+ mPJSipManager.reset(new PJSipManager(ic->getProperties()));
lg(Debug) << "Created PJSIP manager";
//As nice as it is of IceBox to provide us with a communicator,
@@ -586,9 +574,6 @@ void SipSessionManager::initialize(const string& appName, const Ice::Communicato
mGlobalAdapter->activate();
mLocalAdapter->activate();
lg(Debug) << "Activated object adapters";
-
- configureEndpoints();
- lg(Debug) << "Endpoints configured";
}
catch(...)
{
@@ -646,7 +631,6 @@ void SipSessionManager::stop()
// TODO: This is probably a mistake. Many things access the PJSipManager instance and will continue
// to do so until all of the threads have completed. It really should be reference counted.
//
- delete mPJSipManager;
mCommunicator->destroy();
}
diff --git a/src/SipStateReplicator.h b/src/SipStateReplicator.h
index 02fde05..2dcd1b6 100644
--- a/src/SipStateReplicator.h
+++ b/src/SipStateReplicator.h
@@ -42,7 +42,7 @@ struct SipStateReplicatorListenerImpl;
class SipStateReplicatorListenerI : public AsteriskSCF::SIP::V1::SipStateReplicatorListener
{
public:
- SipStateReplicatorListenerI(const boost::shared_ptr<SipEndpointFactory>& factory, PJSipManager *manager);
+ SipStateReplicatorListenerI(const boost::shared_ptr<SipEndpointFactory>& factory, const PJSipManagerPtr& manager);
void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
void stateSet(const AsteriskSCF::SIP::V1::SipStateItemSeq&, const Ice::Current&);
bool operator==(const SipStateReplicatorListenerI &rhs);
diff --git a/src/SipStateReplicatorListener.cpp b/src/SipStateReplicatorListener.cpp
index 1027718..dd7153f 100644
--- a/src/SipStateReplicatorListener.cpp
+++ b/src/SipStateReplicatorListener.cpp
@@ -60,7 +60,7 @@ private:
struct SipStateReplicatorListenerImpl
{
public:
- SipStateReplicatorListenerImpl(const boost::shared_ptr<SipEndpointFactory>& factory, PJSipManager *manager)
+ SipStateReplicatorListenerImpl(const boost::shared_ptr<SipEndpointFactory>& factory, const PJSipManagerPtr& manager)
: mId(IceUtil::generateUUID()), mEndpointFactory(factory), mManager(manager) {}
void removeStateNoticeImpl(const Ice::StringSeq& itemKeys)
@@ -266,11 +266,11 @@ public:
std::string mId;
std::map<std::string, boost::shared_ptr<SipStateReplicatorItem> > mStateItems;
boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
- PJSipManager *mManager;
+ PJSipManagerPtr mManager;
};
SipStateReplicatorListenerI::SipStateReplicatorListenerI(const boost::shared_ptr<SipEndpointFactory>& factory,
- PJSipManager *manager)
+ const PJSipManagerPtr& manager)
: mImpl(new SipStateReplicatorListenerImpl(factory, manager))
{
}
commit 18af343adab9d9989a1393927dea65b9b9171a13
Author: Brent Eagles <beagles at digium.com>
Date: Tue Jun 21 21:13:17 2011 -0230
Resolve compile errors introduced in merge.
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 5bcb2ab..8532863 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -156,46 +156,6 @@ void PJSipManager::addTransport(const TransportPtr& transport)
mTransports.push_back(transport);
}
-PJSipLoggingModulePtr PJSipManager::getLoggingModule()
-{
- return mLoggingModule;
-}
-
-bool PJSipManager::setTransports(pjsip_endpoint *endpoint, const Ice::PropertiesPtr& props)
-{
- //XXX We'll also want to allow for TCP and TLS-specific
- //addresses to be specified.
- pj_sockaddr udpAddr;
- pj_status_t status;
- std::string udpBindAddr = props->getProperty("Sip.Transport.UdpBindAddr");
-
- if (udpBindAddr.empty())
- {
- return true;
- }
-
- pj_str_t udpString;
- pj_cstr(&udpString, udpBindAddr.c_str());
- //UNSPEC family means "you figure out the address family, pjlib!"
- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &udpString, &udpAddr);
- if (udpAddr.addr.sa_family == pj_AF_INET())
- {
- //XXX The fourth parameter should probably be controlled through
- //configuration. PJSIP reference says it should be the number of
- //processors on the machine.
- //
- status = pjsip_udp_transport_start(endpoint, &udpAddr.ipv4, NULL, 2, &mUdpTransport);
- if (status != PJ_SUCCESS)
- {
- lg(Error) << "Failed to create IPv4 UDP transport. DANG!";
- }
- }
- else if (udpAddr.addr.sa_family == pj_AF_INET6())
- {
- }
- return false; XXX
-}
-`
SipModulePtr PJSipManager::getModule(const string& moduleName)
{
boost::shared_lock<boost::shared_mutex> lock(mLock);
@@ -219,7 +179,7 @@ PJSipSessionModulePtr PJSipManager::getSessionModule()
return mSessionModule;
}
-PJSipLoggingModule *PJSipManager::getLoggingModule()
+PJSipLoggingModulePtr PJSipManager::getLoggingModule()
{
return mLoggingModule;
}
diff --git a/src/STUNTransport.cpp b/src/STUNTransport.cpp
index 8c14b84..0774983 100644
--- a/src/STUNTransport.cpp
+++ b/src/STUNTransport.cpp
@@ -363,7 +363,7 @@ TransportPtr createSTUNTransport(const PJSipManagerPtr& sipManager, const Ice::P
const std::string&, int)
{
return TransportPtr(new STUNTransport(sipManager->getEndpoint(), properties,
- dynamic_pointer_cast<STUNModule>(sipManager->getModule("STUN"))));
+ boost::dynamic_pointer_cast<STUNModule>(sipManager->getModule("STUN"))));
}
}
commit 4440b9c56a3eaa0e7ed189e8f4f403a80db2c4c5
Merge: 842ac29 e3cba07
Author: Brent Eagles <beagles at digium.com>
Date: Tue Jun 21 16:58:04 2011 -0230
Merging nat-traversal into modular-transport-refactor
diff --cc src/CMakeLists.txt
index 5aa8e59,8d7e7bf..d6c5e15
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@@ -40,11 -59,12 +55,12 @@@ asterisk_scf_component_add_slice(SipSes
asterisk_scf_component_add_slice(SipSessionManager ../local-slice/SipStateReplicationIf.ice)
asterisk_scf_component_add_slice(SipSessionManager ../local-slice/SipConfigurationIf.ice)
asterisk_scf_component_add_ice_libraries(SipSessionManager IceStorm)
- asterisk_scf_component_add_boost_libraries(SipSessionManager core)
+ asterisk_scf_component_add_boost_libraries(SipSessionManager core system)
asterisk_scf_component_build_icebox(SipSessionManager)
-target_link_libraries(SipSessionManager logging-client ${OPENSSL_LIBRARIES})
+target_link_libraries(SipSessionManager logging-client ice-util-cpp ${OPENSSL_LIBRARIES})
pjproject_link(SipSessionManager pjsip)
pjproject_link(SipSessionManager pjmedia)
+ pjproject_link(SipSessionManager pjnath)
pjproject_link(SipSessionManager pjlib-util)
pjproject_link(SipSessionManager pjlib)
asterisk_scf_component_install(SipSessionManager)
diff --cc src/PJSipManager.cpp
index ffd2854,94cad00..5bcb2ab
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@@ -93,122 -150,66 +150,106 @@@ void PJSipManager::registerLoggingModul
mLoggingModule = new PJSipLoggingModule(mEndpoint);
}
- PJSipSessionModulePtr PJSipManager::getSessionModule()
+ void PJSipManager::addTransport(const TransportPtr& transport)
{
- return mSessionModule;
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ mTransports.push_back(transport);
}
+PJSipLoggingModulePtr PJSipManager::getLoggingModule()
+{
+ return mLoggingModule;
+}
+
+bool PJSipManager::setTransports(pjsip_endpoint *endpoint, const Ice::PropertiesPtr& props)
+{
+ //XXX We'll also want to allow for TCP and TLS-specific
+ //addresses to be specified.
+ pj_sockaddr udpAddr;
+ pj_status_t status;
+ std::string udpBindAddr = props->getProperty("Sip.Transport.UdpBindAddr");
+
+ if (udpBindAddr.empty())
+ {
+ return true;
+ }
+
+ pj_str_t udpString;
+ pj_cstr(&udpString, udpBindAddr.c_str());
+ //UNSPEC family means "you figure out the address family, pjlib!"
+ pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &udpString, &udpAddr);
+ if (udpAddr.addr.sa_family == pj_AF_INET())
+ {
+ //XXX The fourth parameter should probably be controlled through
+ //configuration. PJSIP reference says it should be the number of
+ //processors on the machine.
+ //
+ status = pjsip_udp_transport_start(endpoint, &udpAddr.ipv4, NULL, 2, &mUdpTransport);
+ if (status != PJ_SUCCESS)
+ {
+ lg(Error) << "Failed to create IPv4 UDP transport. DANG!";
+ }
+ }
+ else if (udpAddr.addr.sa_family == pj_AF_INET6())
+ {
- status = pjsip_udp_transport_start6(endpoint, &udpAddr.ipv6, NULL, 2, &mUdpTransport);
- if (status != PJ_SUCCESS)
- {
- lg(Error) << "Failed to create IPv4 UDP transport. DANG!";
- }
+ }
- //XXX Note that TCP and TLS stuff should be done here. Also note that
- //currently PJSIP does not have functions for starting IPv6 TCP or
- //TLS transports, so we'll have to modify the code to allow for it.
- return true;
++ return false; XXX
+}
-
- pjsip_transport *PJSipManager::createUDPTransport(std::string address, int port)
++`
+ SipModulePtr PJSipManager::getModule(const string& moduleName)
{
- pj_sockaddr udpAddr;
- pj_status_t status;
- pj_str_t udpString;
- pj_cstr(&udpString, address.c_str());
- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &udpString, &udpAddr);
- pj_sockaddr_set_port(&udpAddr, boost::lexical_cast<pj_uint16_t>(port));
-
- pjsip_transport *udpTransport = NULL;
- if (udpAddr.addr.sa_family == pj_AF_INET())
- {
- status = pjsip_udp_transport_start(mEndpoint, &udpAddr.ipv4, NULL, 2, &udpTransport);
- }
- else if (udpAddr.addr.sa_family == pj_AF_INET6())
+ boost::shared_lock<boost::shared_mutex> lock(mLock);
+ SipModuleMap::const_iterator i = mModules.find(moduleName);
+ if (i != mModules.end())
{
- status = pjsip_udp_transport_start6(mEndpoint, &udpAddr.ipv6, NULL, 2, &udpTransport);
+ return i->second;
}
-
- if (status != PJ_SUCCESS)
- {
- lg(Error) << "Failed to create UDP transport.";
- }
-
- return udpTransport;
+ return SipModulePtr();
}
- pjsip_tpfactory *PJSipManager::createTCPTransport(std::string address, int port)
+ void PJSipManager::handleEvents()
{
- pj_sockaddr tcpAddr;
- pj_str_t tcpString;
- pj_cstr(&tcpString, address.c_str());
- pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &tcpString, &tcpAddr);
- pj_sockaddr_set_port(&tcpAddr, boost::lexical_cast<pj_uint16_t>(port));
-
- pjsip_tpfactory *tcpTransport = NULL;
+ onHandleEvents(mModules);
+ const pj_time_val delay = {0, 10};
+ pjsip_endpt_handle_events(mEndpoint, &delay);
+ }
- if (pjsip_tcp_transport_start(mEndpoint, &tcpAddr, 2, &tcpTransport) != PJ_SUCCESS)
- {
... 109 lines suppressed ...
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list