[asterisk-scf-commits] asterisk-scf/release/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Apr 20 17:42:15 CDT 2011
branch "master" has been updated
via 2d535b3c8813521ba060c544c80baabc2b452f76 (commit)
via 04e2c162bc7f6cd6b9bceb74089d1a9a29148b59 (commit)
via 0c1ba29dc6631ac5ce38a3d2629fe17afcd39627 (commit)
via df6502431fb6d495c88eb9a223820f063432bd7e (commit)
via 6fa0d1a69f5290d1154951965017380dc4e61825 (commit)
via 06ba07d7d56ed8447eeb188eb4bb5770a9c41adc (commit)
via a2ce7d678f3574f6f63691dacead5e2574ded080 (commit)
via 148efc74ad128c054300d461fb29ae8e31392bed (commit)
via dc0dbb97620670914e030aab47cf1e0f90915ef1 (commit)
via c5ed0db396867362132166c17aac2a74274bb48d (commit)
via 891cedd06767489bf8e00b9c1b98318d9c09d3ef (commit)
via 0f17de699ae1b4e8f7abdb69053405a30b4b7952 (commit)
via 4c5178bacdf897e9717c93187b2bcb657f2e1871 (commit)
via d17c5711691e51a7a46e787da409c568e8dc6cfd (commit)
via e37d9494e7db63a6f9e0798020dc3de62533da91 (commit)
via 72138cabee93955fb3d648ac78c1faea422e2733 (commit)
via 01940e42606ff1b41b53778a2b5148021be8d80b (commit)
via 053aefa444ff4d34070d67d6f45809005c9c7c57 (commit)
via 8b96c2315423a29b508d1d32622b5fd28b386653 (commit)
via 116744bd3cb957d26797c50bcc63e4c673ec49ad (commit)
via 7560c60db1c62ab3b846eba93098d9e81f1be09d (commit)
via db9137c28c816f89efc2f9d69accd5e60cc7ec95 (commit)
via 1cc1ec91224cb05370e8e996433ecb7b5f8201fe (commit)
via 49098782accde3746af4857574c15ceac1ea7916 (commit)
via 475da6c6e49647d883663e3b93e443c57f415169 (commit)
via 0adc89a842ccb2893a472539fe89ffb2e032f41a (commit)
via f9be80d1e56708c2673f952d14a0a42b35cb891e (commit)
via c004843947a6e1724a08225c7791cb46eee01304 (commit)
from 4c8c74c547955dd93c9e15d2f5c188918517aeeb (commit)
Summary of changes:
config/Configurator.py | 179 ++++++
config/Sip.config | 77 +++
config/SipConfigurator.py | 166 +++++
local-slice/SipConfigurationIf.ice | 535 +++++++++++------
src/CMakeLists.txt | 3 +
src/PJSipManager.cpp | 68 ++-
src/PJSipManager.h | 15 +
src/SipConfiguration.cpp | 1180 ++++++++++++++++++++++++++++++++++++
src/SipConfiguration.h | 66 ++
src/SipEndpoint.cpp | 33 +
src/SipEndpoint.h | 12 +
src/SipEndpointFactory.cpp | 17 +-
src/SipEndpointFactory.h | 10 +-
src/SipSessionManagerApp.cpp | 22 +-
14 files changed, 2198 insertions(+), 185 deletions(-)
create mode 100755 config/Configurator.py
create mode 100644 config/Sip.config
create mode 100755 config/SipConfigurator.py
create mode 100644 src/SipConfiguration.cpp
create mode 100644 src/SipConfiguration.h
- Log -----------------------------------------------------------------
commit 2d535b3c8813521ba060c544c80baabc2b452f76
Merge: 4c8c74c 04e2c16
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Apr 20 19:44:02 2011 -0300
Merge branch 'configuration'
Conflicts:
src/SipEndpoint.cpp
src/SipEndpointFactory.cpp
src/SipEndpointFactory.h
src/SipSessionManagerApp.cpp
diff --cc src/SipEndpoint.cpp
index 58e4ff6,f883949..50d740e
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@@ -118,7 -108,40 +118,40 @@@ SipEndpoint::SipEndpoint(const Ice::Obj
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)
+ : 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));
+ }
+
+ void SipEndpoint::removeFromAdapter()
+ {
+ mImplPriv->mAdapter->remove(mImplPriv->mEndpointProxy->ice_getIdentity());
+ }
+
+ void SipEndpoint::setSourceAddress(std::string address, int port)
+ {
+ char source[64];
+ pj_ansi_snprintf(source, sizeof(source), "%s:%d", address.c_str(), port);
+ mImplPriv->mConfig.sessionConfig.sourceAddress = source;
+ }
+
+ void SipEndpoint::setTargetAddress(std::string address, int port)
+ {
+ char target[64];
+ pj_ansi_snprintf(target, sizeof(target), "%s:%d", address.c_str(), port);
+ mImplPriv->mConfig.transportConfig.address = target;
+ }
+
+ void SipEndpoint::setCallDirection(enum Direction direction)
+ {
+ mImplPriv->mConfig.sessionConfig.callDirection = direction;
+ }
+
-void SipEndpoint::setConfiguration(Ice::PropertyDict props)
+void SipEndpoint::setConfiguration(const Ice::PropertyDict& props)
{
setTransportConfiguration(props);
//setAuthConfiguration(props);
diff --cc src/SipEndpoint.h
index 994554d,3704e28..fc3aa21
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@@ -207,11 -207,12 +207,14 @@@ class SipEndpointImplPriv
class SipEndpoint : public AsteriskSCF::SessionCommunications::V1::SessionEndpoint
{
public:
- SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpointFactory> factory, std::string name, Ice::PropertyDict props, PJSipManager *manager,
- const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator, const AsteriskSCF::System::Component::V1::ReplicaPtr replica);
+ 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);
+
bool operator==(const std::string &name) const;
/**
@@@ -231,17 -231,23 +234,26 @@@
AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx getEndpointProxy();
- // TODO: Find a way to use SipSessionPtr here, right now trying to do so results in the world exploding due to dependency insanity
+ //
+ // TODO: Find a way to use SipSessionPtr here, right now trying to do so results in the world exploding due to
+ // dependency insanity
+ //
AsteriskSCF::SipSessionManager::SipSessionPtr createSession(const std::string&);
- AsteriskSCF::SipSessionManager::SipSessionPtr createSession(const std::string&, const Ice::Identity&, const Ice::Identity&,
- const AsteriskSCF::Media::V1::SessionPrx&, const AsteriskSCF::Media::V1::StreamSourceSeq&,
- const AsteriskSCF::Media::V1::StreamSinkSeq&);
+ AsteriskSCF::SipSessionManager::SipSessionPtr createSession(const std::string&, const Ice::Identity&,
+ const Ice::Identity&, const AsteriskSCF::Media::V1::SessionPrx&,
+ const AsteriskSCF::Media::V1::StreamSourceSeq&, const AsteriskSCF::Media::V1::StreamSinkSeq&);
- void removeSession(AsteriskSCF::SessionCommunications::V1::SessionPtr);
+ void removeSession(const AsteriskSCF::SessionCommunications::V1::SessionPtr&);
+ void removeFromAdapter();
+
+ /**
+ * Configuration related operations
+ */
+ void setSourceAddress(std::string, int);
+ void setTargetAddress(std::string, int);
+ void setCallDirection(enum Direction);
+
private:
/**
* Private implementation details.
diff --cc src/SipEndpointFactory.cpp
index 9016be3,c6ffc46..09c4704
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@@ -33,13 -32,24 +33,24 @@@ SipEndpointPtr SipEndpointFactory::crea
return endpoint;
}
- void SipEndpointFactory::remove(const SipEndpointPtr&)
+ SipEndpointPtr SipEndpointFactory::createEndpoint(std::string endpointName)
{
- // TODO: Do we even need to remove sip endpoints yet?
- // mEndpoints.erase(std::remove(mEndpoints.begin(), mEndpoints.end(), endpoint), mEndpoints.end());
+ SipEndpointPtr endpoint = new SipEndpoint(mAdapter, shared_from_this(), endpointName, mManager, mServiceLocator, mReplica);
+ mEndpoints.push_back(endpoint);
+ return endpoint;
+ }
+
+ void SipEndpointFactory::remove(std::string endpointName)
+ {
+ SipEndpointPtr endpoint = findByName(endpointName);
+ if (endpoint != 0)
+ {
+ endpoint->removeFromAdapter();
+ mEndpoints.erase(std::remove(mEndpoints.begin(), mEndpoints.end(), endpoint), mEndpoints.end());
+ }
}
-SipEndpointPtr SipEndpointFactory::findByName(std::string endpointName)
+SipEndpointPtr SipEndpointFactory::findByName(const std::string& endpointName)
{
std::vector<SipEndpointPtr>::iterator iter;
for (iter = mEndpoints.begin(); iter != mEndpoints.end(); ++ iter)
diff --cc src/SipEndpointFactory.h
index 73c4d3a,2730186..6431604
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@@ -36,16 -36,18 +36,18 @@@ namespace SipSessionManage
class SipEndpointFactory : public boost::enable_shared_from_this<SipEndpointFactory>
{
public:
- SipEndpointFactory(Ice::ObjectAdapterPtr adapter, PJSipManager *manager,
- const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
- const AsteriskSCF::System::Component::V1::ReplicaPtr replica) :
+ SipEndpointFactory(const Ice::ObjectAdapterPtr& adapter, PJSipManager *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(std::string destination, Ice::PropertiesPtr props);
+ SipEndpointPtr createEndpoint(const std::string& destination, const Ice::PropertiesPtr& props);
- void remove(const SipEndpointPtr&);
+ SipEndpointPtr createEndpoint(std::string);
+
+ void remove(std::string);
- SipEndpointPtr findByName(std::string endpointName);
+ SipEndpointPtr findByName(const std::string& endpointName);
void generateRoutingDestinations(AsteriskSCF::Core::Routing::V1::RegExSeq&);
private:
diff --cc src/SipSessionManagerApp.cpp
index ecd5338,134dca2..18b12d5
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@@ -338,10 -336,7 +344,8 @@@ void SipSessionManager::registerWithRou
mEndpointFactory->generateRoutingDestinations(destinations);
- mRoutingId = mCommunicator->getProperties()->getPropertyWithDefault("Sip.RoutingId", "pjsip");
-
- EndpointLocatorPrx locator = EndpointLocatorPrx::uncheckedCast(mGlobalAdapter->createDirectProxy(mCommunicator->stringToIdentity(EndpointLocatorObjectId)));
+ EndpointLocatorPrx locator = EndpointLocatorPrx::uncheckedCast(
+ mGlobalAdapter->createDirectProxy(mCommunicator->stringToIdentity(EndpointLocatorObjectId)));
mRoutingServiceLocatorRegistry->addEndpointLocator(mRoutingId, destinations, locator);
}
commit 04e2c162bc7f6cd6b9bceb74089d1a9a29148b59
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Apr 11 18:20:38 2011 -0300
Fix visitor generation issue with some specific endpoint configuration items.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 5e6dc0b..58cae24 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -109,7 +109,7 @@ module V1
/**
* Host information configuration item
*/
- class SipHostItem extends SipConfigurationItem
+ ["visitor:SipConfigurationItemVisitor"] class SipHostItem extends SipConfigurationItem
{
/**
* String containing the IP address or string address
@@ -125,14 +125,14 @@ module V1
/**
* Source transport address configuration item
*/
- class SipSourceTransportAddressItem extends SipHostItem
+ ["visitor:SipConfigurationItemVisitor"] class SipSourceTransportAddressItem extends SipHostItem
{
};
/**
* Target destination address configuration item
*/
- class SipTargetDestinationAddressItem extends SipHostItem
+ ["visitor:SipConfigurationItemVisitor"] class SipTargetDestinationAddressItem extends SipHostItem
{
};
commit 0c1ba29dc6631ac5ce38a3d2629fe17afcd39627
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Apr 11 16:13:51 2011 -0300
Fix a bug where the routing id was not present before being used.
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index c896e1c..134dca2 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -336,8 +336,6 @@ void SipSessionManager::registerWithRoutingService()
mEndpointFactory->generateRoutingDestinations(destinations);
- mRoutingId = mCommunicator->getProperties()->getPropertyWithDefault("Sip.RoutingId", "pjsip");
-
EndpointLocatorPrx locator = EndpointLocatorPrx::uncheckedCast(mGlobalAdapter->createDirectProxy(mCommunicator->stringToIdentity(EndpointLocatorObjectId)));
mRoutingServiceLocatorRegistry->addEndpointLocator(mRoutingId, destinations, locator);
}
@@ -366,6 +364,9 @@ void SipSessionManager::locateRoutingService()
AsteriskSCF::SmartProxy::SmartProxy<LocatorRegistryPrx> pw(mServiceLocator, genericparams, lg);
mRoutingServiceLocatorRegistry = pw;
+
+ // This exists here since it may need to be known before actually contacting the routing service
+ mRoutingId = mCommunicator->getProperties()->getPropertyWithDefault("Sip.RoutingId", "pjsip");
}
void SipSessionManager::locateStateReplicator()
commit df6502431fb6d495c88eb9a223820f063432bd7e
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Apr 11 15:58:27 2011 -0300
Move initialization of the routing service proxy so it can be passed to the configuration service.
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 82738d5..c896e1c 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -533,6 +533,9 @@ void SipSessionManager::initialize(const std::string appName, const Ice::Communi
mEndpointFactory.reset(new SipEndpointFactory(mGlobalAdapter, mPJSipManager, mServiceLocator, mReplicaService));
lg(Debug) << "Created SIP endpoint factory";
+ // Locate the Routing Service so that we can do routing. This is done here so it can be passed to the configuration service.
+ locateRoutingService();
+
// Create and publish our Configuration interface support.
mConfigurationService = new ConfigurationServiceImpl(mPJSipManager, mEndpointFactory, mRoutingId, mRoutingServiceLocatorRegistry);
mGlobalAdapter->add(mConfigurationService, mCommunicator->stringToIdentity(ConfigurationServiceId));
@@ -578,9 +581,6 @@ void SipSessionManager::start(const string& name, const Ice::CommunicatorPtr& ic
// can be located.
registerWithServiceLocator();
- // Locate the Routing Service so that we can do routing.
- locateRoutingService();
-
// Locate the Session Router so we can REALLY do routing.
locateSessionRouter();
commit 6fa0d1a69f5290d1154951965017380dc4e61825
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Apr 11 15:30:30 2011 -0300
Do not attempt to start a TLS transport if pjsip has not been built with support for it.
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 7571b80..2fb8f6f 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -189,7 +189,9 @@ pjsip_tpfactory *PJSipManager::createTLSTransport(std::string address, int port,
pjsip_tpfactory *tlsTransport = NULL;
+#if PJSIP_HAS_TLS_TRANSPORT
if (pjsip_tls_transport_start(mEndpoint, tlsSettings, &tlsAddr, NULL, 2, &tlsTransport) != PJ_SUCCESS)
+#endif
{
lg(Error) << "Failed to create TLS transport.";
}
commit 06ba07d7d56ed8447eeb188eb4bb5770a9c41adc
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Apr 11 15:19:45 2011 -0300
Fix incompatibility with latest visitor generation code. Yay these are now in the visitor!
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index c89ed18..5e6dc0b 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -97,7 +97,7 @@ module V1
* Generic SIP transport group that others derive from, primarily created since each one has
* the requirement of a name
*/
- class SipTransportGroup extends SipConfigurationGroup
+ ["visitor:SipConfigurationGroupVisitor"] class SipTransportGroup extends SipConfigurationGroup
{
/**
* Name of the specific transport. Since each one may have multiple transports this differentiates
@@ -347,21 +347,21 @@ module V1
/**
* Group of configuration items related to a UDP transport
*/
- class SipUDPTransportGroup extends SipTransportGroup
+ ["visitor:SipConfigurationGroupVisitor"] class SipUDPTransportGroup extends SipTransportGroup
{
};
/**
* Group of configuration items related to a TCP transport
*/
- class SipTCPTransportGroup extends SipTransportGroup
+ ["visitor:SipConfigurationGroupVisitor"] class SipTCPTransportGroup extends SipTransportGroup
{
};
/**
* Group of configuration items related to a TLS transport
*/
- class SipTLSTransportGroup extends SipTransportGroup
+ ["visitor:SipConfigurationGroupVisitor"] class SipTLSTransportGroup extends SipTransportGroup
{
};
commit a2ce7d678f3574f6f63691dacead5e2574ded080
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Apr 11 14:30:08 2011 -0300
Update the routing service when endpoint configurations are pushed into the SIP component.
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 89e6d63..e374891 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -36,6 +36,7 @@ namespace SipSessionManager
using namespace AsteriskSCF::SIP::V1;
using namespace AsteriskSCF::System::Configuration::V1;
+using namespace AsteriskSCF::Core::Routing::V1;
class UDPTransportImplPriv
{
@@ -168,7 +169,9 @@ public:
/**
* Constructor for this private class
*/
- ConfigurationServiceImplPriv(PJSipManager *manager, boost::shared_ptr<SipEndpointFactory> factory) : mPJSipManager(manager), mEndpointFactory(factory) { };
+ ConfigurationServiceImplPriv(PJSipManager *manager, boost::shared_ptr<SipEndpointFactory> factory, std::string& id,
+ AsteriskSCF::SmartProxy::SmartProxy<LocatorRegistryPrx> registry) :
+ mPJSipManager(manager), mEndpointFactory(factory), mRoutingId(id), mRoutingServiceLocatorRegistry(registry) { };
/**
* Configured SIP domains
@@ -209,10 +212,21 @@ public:
* Pointer to the endpoint factory used to create endpoints
*/
boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
+
+ /**
+ * Identifier for our endpoint locator.
+ */
+ std::string mRoutingId;
+
+ /**
+ * Proxy to endpoint locator registry
+ */
+ AsteriskSCF::SmartProxy::SmartProxy<LocatorRegistryPrx> mRoutingServiceLocatorRegistry;
};
-ConfigurationServiceImpl::ConfigurationServiceImpl(PJSipManager *manager, boost::shared_ptr<SipEndpointFactory> factory) :
- mImplPriv(new ConfigurationServiceImplPriv(manager, factory))
+ConfigurationServiceImpl::ConfigurationServiceImpl(PJSipManager *manager, boost::shared_ptr<SipEndpointFactory> factory,
+ std::string& id, AsteriskSCF::SmartProxy::SmartProxy<LocatorRegistryPrx> registry) :
+ mImplPriv(new ConfigurationServiceImplPriv(manager, factory, id, registry))
{
}
@@ -917,6 +931,11 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
{
(*group)->visit(v);
}
+
+ // Update endpoint locator with any new destinations that may have been pushed
+ RegExSeq destinations;
+ mImplPriv->mEndpointFactory->generateRoutingDestinations(destinations);
+ mImplPriv->mRoutingServiceLocatorRegistry->setEndpointLocatorDestinationIds(mImplPriv->mRoutingId, destinations);
}
void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
diff --git a/src/SipConfiguration.h b/src/SipConfiguration.h
index 5444ddd..d658614 100644
--- a/src/SipConfiguration.h
+++ b/src/SipConfiguration.h
@@ -21,6 +21,9 @@
#include <boost/shared_ptr.hpp>
#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+#include <AsteriskSCF/Core/Routing/RoutingIf.h>
+
+#include <AsteriskSCF/SmartProxy.h>
#include "PJSipManager.h"
#include "SipEndpointFactory.h"
@@ -43,7 +46,8 @@ class ConfigurationServiceImplPriv;
class ConfigurationServiceImpl : public AsteriskSCF::System::Configuration::V1::ConfigurationService
{
public:
- ConfigurationServiceImpl(PJSipManager*, boost::shared_ptr<SipEndpointFactory>);
+ ConfigurationServiceImpl(PJSipManager*, boost::shared_ptr<SipEndpointFactory>, std::string&,
+ AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::Core::Routing::V1::LocatorRegistryPrx>);
AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationAll(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationGroups(const Ice::Current&);
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 9df89d0..82738d5 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -534,7 +534,7 @@ void SipSessionManager::initialize(const std::string appName, const Ice::Communi
lg(Debug) << "Created SIP endpoint factory";
// Create and publish our Configuration interface support.
- mConfigurationService = new ConfigurationServiceImpl(mPJSipManager, mEndpointFactory);
+ mConfigurationService = new ConfigurationServiceImpl(mPJSipManager, mEndpointFactory, mRoutingId, mRoutingServiceLocatorRegistry);
mGlobalAdapter->add(mConfigurationService, mCommunicator->stringToIdentity(ConfigurationServiceId));
lg(Debug) << "Created SIP Configuration Implementation";
commit 148efc74ad128c054300d461fb29ae8e31392bed
Author: Joshua Colp <jcolp at digium.com>
Date: Tue Mar 22 09:14:59 2011 -0300
Now that pjsip has IPv6 TLS transport support uncomment support for it in our component.
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index e13e846..7571b80 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -189,12 +189,11 @@ pjsip_tpfactory *PJSipManager::createTLSTransport(std::string address, int port,
pjsip_tpfactory *tlsTransport = NULL;
-/*
if (pjsip_tls_transport_start(mEndpoint, tlsSettings, &tlsAddr, NULL, 2, &tlsTransport) != PJ_SUCCESS)
{
lg(Error) << "Failed to create TLS transport.";
}
-*/
+
return tlsTransport;
}
commit dc0dbb97620670914e030aab47cf1e0f90915ef1
Author: Joshua Colp <jcolp at digium.com>
Date: Sun Mar 20 11:30:25 2011 -0300
Incorporate code review feedback.
diff --git a/config/SipConfigurator.py b/config/SipConfigurator.py
index 018bdc0..d04f2ac 100755
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@ -1,5 +1,21 @@
#!/usr/bin/env python
+#
+# Asterisk SCF -- An open-source communications framework.
+#
+# Copyright (C) 2011, Digium, Inc.
+#
+# See http://www.asterisk.org for more information about
+# the Asterisk SCF project. Please do not directly contact
+# any of the maintainers of this project for assistance;
+# the project provides a web site, mailing lists and IRC
+# channels for your use.
+#
+# This program is free software, distributed under the terms of
+# the GNU General Public License Version 2. See the LICENSE.txt file
+# at the top of the source tree.
+#
+
# Sip configurator
# Bring in the common configuration infrastructure
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 713aa9c..89e6d63 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -1,7 +1,7 @@
/*
* Asterisk SCF -- An open-source communications framework.
*
- * Copyright (C) 2010, Digium, Inc.
+ * Copyright (C) 2011, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk SCF project. Please do not directly contact
@@ -223,6 +223,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskS
public:
visitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& groups) : mImplPriv(implPriv), mGroups(groups) { };
+ private:
/**
* Internal helper function which determines what configuration items should be returned
*/
@@ -344,7 +345,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskS
mGroups.push_back(returnedGroup);
};
- private:
+
boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
ConfigurationGroupSeq& mGroups;
};
@@ -368,6 +369,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const Asteri
visitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& groups) :
mImplPriv(implPriv), mGroups(groups) { };
+ private:
void visitSipGeneralGroup(const ::AsteriskSCF::SIP::V1::SipGeneralGroupPtr& group)
{
if (!mImplPriv->mGeneralGroup)
@@ -437,7 +439,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const Asteri
mGroups.push_back((*localEndpoint).second);
};
- private:
+
boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
ConfigurationGroupSeq& mGroups;
};
@@ -468,7 +470,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice
++group)
{
SipDomainGroupPtr domain = new SipDomainGroup();
- domain->domain = (*group).second->domain;
+ domain->domain = group->second->domain;
groups.push_back(domain);
}
@@ -477,7 +479,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice
++group)
{
SipUDPTransportGroupPtr transport = new SipUDPTransportGroup();
- transport->name = (*group).second->mGroup->name;
+ transport->name = group->second->mGroup->name;
groups.push_back(transport);
}
@@ -486,7 +488,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice
++group)
{
SipTCPTransportGroupPtr transport = new SipTCPTransportGroup();
- transport->name = (*group).second->mGroup->name;
+ transport->name = group->second->mGroup->name;
groups.push_back(transport);
}
@@ -495,7 +497,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice
++group)
{
SipTLSTransportGroupPtr transport = new SipTLSTransportGroup();
- transport->name = (*group).second->mGroup->name;
+ transport->name = group->second->mGroup->name;
groups.push_back(transport);
}
@@ -504,7 +506,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice
++group)
{
SipEndpointGroupPtr endpoint = new SipEndpointGroup();
- endpoint->name = (*group).second->name;
+ endpoint->name = group->second->name;
groups.push_back(endpoint);
}
@@ -1068,6 +1070,7 @@ void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::Syst
public:
visitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+ private:
void visitSipGeneralGroup(const ::AsteriskSCF::SIP::V1::SipGeneralGroupPtr& group)
{
if (!mImplPriv->mGeneralGroup)
@@ -1141,7 +1144,7 @@ void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::Syst
mImplPriv->mEndpointFactory->remove(group->name);
mImplPriv->mConfiguredEndpoints.erase(localEndpoint);
};
- private:
+
boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
};
diff --git a/src/SipConfiguration.h b/src/SipConfiguration.h
index d2dc2c4..5444ddd 100644
--- a/src/SipConfiguration.h
+++ b/src/SipConfiguration.h
@@ -1,7 +1,7 @@
/*
* Asterisk SCF -- An open-source communications framework.
*
- * Copyright (C) 2010, Digium, Inc.
+ * Copyright (C) 2011, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk SCF project. Please do not directly contact
@@ -18,7 +18,6 @@
#include <Ice/Ice.h>
-#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <AsteriskSCF/System/Component/ConfigurationIf.h>
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 9410622..f883949 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -125,14 +125,14 @@ void SipEndpoint::removeFromAdapter()
void SipEndpoint::setSourceAddress(std::string address, int port)
{
char source[64];
- pj_ansi_sprintf(source, "%s:%d", address.c_str(), port);
+ pj_ansi_snprintf(source, sizeof(source), "%s:%d", address.c_str(), port);
mImplPriv->mConfig.sessionConfig.sourceAddress = source;
}
void SipEndpoint::setTargetAddress(std::string address, int port)
{
char target[64];
- pj_ansi_sprintf(target, "%s:%d", address.c_str(), port);
+ pj_ansi_snprintf(target, sizeof(target), "%s:%d", address.c_str(), port);
mImplPriv->mConfig.transportConfig.address = target;
}
commit c5ed0db396867362132166c17aac2a74274bb48d
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Fri Mar 11 17:53:38 2011 -0600
Remove unnecessary 'visitor' metadata.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 73e31cd..c89ed18 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -28,7 +28,7 @@ module V1
/**
* Local visitor class for visiting SIP configuration groups
*/
- ["visitor"] local class SipConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
+ local class SipConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
{
};
@@ -49,7 +49,7 @@ module V1
/**
* Local visitor class for visiting SIP configuration items
*/
- ["visitor"] local class SipConfigurationItemVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationItemVisitor
+ local class SipConfigurationItemVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationItemVisitor
{
};
commit 891cedd06767489bf8e00b9c1b98318d9c09d3ef
Author: Joshua Colp <jcolp at digium.com>
Date: Tue Mar 8 08:54:39 2011 -0400
Add python script that configures the SIP component.
Pitfalls:
1. Right now this includes a copy of the Configurator. Once reviewed and +1ed this will no longer be the case.
2. This uses dynamic slice loading meaning it must be run from within this directory. Once the proper way to
install translated slice is explored and implement this will no longer be true.
3. It hard codes an include directory to the Ice slice. Once the above is done this should also no longer be needed.
diff --git a/config/Configurator.py b/config/Configurator.py
new file mode 100755
index 0000000..6e20173
--- /dev/null
+++ b/config/Configurator.py
@@ -0,0 +1,179 @@
+#!/usr/bin/env python
+
+# Asterisk SCF Configurator Module
+
+import ConfigParser, os, Ice, getopt
+
+# Load and make the configuration interface available, we require it
+Ice.loadSlice('-I. --all ../../slice/AsteriskSCF/System/Component/ConfigurationIf.ice')
+import AsteriskSCF.System.Configuration.V1
+
+# Exception class used within the configurator application
+class ConfiguratorError(Exception):
+ def __init__(self, value):
+ self.value = value
+
+ def __str__(self):
+ return repr(self.value)
+
+# Common section visitor pattern implementation
+class SectionVisitors():
+ def __init__(self):
+ """Generic class meant to be inherited from for section visitors"""
+ self.groups = []
+
+ def visit(self, config, section):
+ """Execute the visit_ function corresponding to the section name"""
+ try:
+ method = getattr(self, 'visit_' + section)
+ except AttributeError:
+ self.visit_unsupported(config, section)
+ else:
+ method(config, section);
+
+ def visit_unsupported(self, config, section):
+ """Handle an unsupported configuration section"""
+ print "Unsupported configuration section " + section
+
+# Common option to item mapper implementation
+class OptionMapper():
+ options = { }
+
+ def __init(self):
+ """Generic class meant to perform option to item mapping"""
+ self.options = { }
+
+ def map(self, option, object, item, item_name, method, default = None):
+ setattr(object, item, default)
+ self.options[option] = [ object, item, item_name, method, default ]
+
+ def execute(self, group, section, option):
+ """Map options to configuration items based on options set"""
+ try:
+ object = self.options[option][0]
+ except:
+ return
+ item = self.options[option][1]
+ item_name = self.options[option][2]
+ method = self.options[option][3]
+ default = self.options[option][4]
+
+ try:
+ setattr(object, item, method(section, option))
+
+ except ValueError:
+ # This is not a fatal error since we just use the default value.
+ if default == None:
+ print "The specified value for option '" + option + "' is not valid and no default value exists."
+ else:
+ print "The specified value for option '" + option + "' is not valid. Using default value."
+ setattr(object, item, default)
+
+ # This has the potential to overwrite an existing item but this is done on purpose so that
+ # configuration options that all map to a single item can happily exist
+ if item != None:
+ group.configurationItems[item_name] = object
+
+ def finish(self, group):
+ """Finish mapping options by finding ones that should have a value but do not"""
+ for option in self.options:
+ item = self.options[option][1]
+ default = self.options[option][4]
+ if default == None:
+ if item == None:
+ print "Option '" + option + "' requires a value to be set and no default value exists."
+
+# Common configurator application logic
+class ConfiguratorApp(Ice.Application):
+ def __init__(self, defaultConfigFile, visitor, configurationService = None):
+ """Common configuration utility class"""
+
+ if defaultConfigFile == '':
+ raise ConfiguratorError('Configuration utility implementation issue - No default configuration filename specified.')
+
+ self.defaultConfigFile = defaultConfigFile
+ self.visitor = visitor
+ self.configurationService = configurationService
+
+ def usage(self):
+ """Print usage information for the configuration utility"""
+
+ print "Usage: " + self.appName() + " [--config=filename] [--proxy=stringified configuration service proxy] [--wipe]"
+ print "Push a configuration to a component."
+ print ""
+ print "Mandatory arguments to long options are mandatory for short options too."
+ print "-h, --help display help information"
+ print "-c, --config=FILENAME use specified configuration file instead of " + self.defaultConfigFile
+ print "-p, --proxy=PROXY use specified proxy instead of locating component"
+ print "-w, --wipe remove existing configuration before applying new one"
+
+ def run(self, args):
+ """Parse options, read configuration file, produce configuration data, and submit it"""
+
+ try:
+ opts, arguments = getopt.getopt(args[1:], "hc:p:w", ["help", "config=", "proxy=", "wipe"])
+ except getopt.GetoptError, err:
+ print str(err)
+ self.usage()
+ return 1
+
+ configFile = self.defaultConfigFile
+ configurationService = self.configurationService
+ configurationWipe = False
+
+ for o, a in opts:
+ if o in ("-h", "--help"):
+ self.usage()
+ return 1
+
+ elif o in ("-c", "--config"):
+ configFile = a
+
+ elif o in ("-p", "--proxy"):
+ configurationService = AsteriskSCF.System.Configuration.V1.ConfigurationServicePrx.checkedCast(self.communicator().stringToProxy(a))
+
+ elif o in ("-w", "--wipe"):
+ configurationWipe = True
+
+ if configurationService == None:
+ print "No configuration service to configure."
+ return 0
+
+ print "Reading configuration from file " + configFile
+ config = ConfigParser.ConfigParser()
+
+ # This purposely uses open and readfp so that the file is required to be present
+ try:
+ config.readfp(open(configFile))
+ except IOError:
+ print "Specified configuration file " + configFile + " could not be loaded."
+ return 0
+
+ print "Building configuration changes to send to component"
+ for section in config.sections():
+ self.visitor.visit(config, section)
+
+ if self.visitor.groups:
+ if configurationWipe == True:
+ print "Wiping existing configuration before applying changes"
+ # There is a race condition here where another component could modify the groups present, but if two
+ # components are altering the configuration we are best effort to begin with
+ try:
+ groups = configurationService.getConfigurationGroups()
+ configurationService.removeConfigurationGroups(groups)
+ except:
+ print "Configuration could not be wiped - Failed to contact component"
+ return 0
+
+ print "Applying configuration"
+
+ try:
+ configurationService.setConfiguration(self.visitor.groups)
+ print "Configuration applied"
+ except:
+ print "Configuration could not be applied - Failed to contact component"
+
+ else:
+ print "No configuration to apply"
+
+ return 0
diff --git a/config/Sip.config b/config/Sip.config
new file mode 100644
index 0000000..048a751
--- /dev/null
+++ b/config/Sip.config
@@ -0,0 +1,77 @@
+# General Configuation Options
+# Currently contains nothing, stay tuned!
+[general]
+
+# Example of a UDP transport binding to IPv4 localhost
+# The section name is considered the name of this transport
+[localhost-udp]
+# Type specifies what type of section this is, transport-udp is for UDP obviously
+type=transport-udp
+# Host is the address that we should bind to
+host=127.0.0.1
+# Port is the port that we should bind to, by default this is 5060
+port=5061
+
+# Example of a UDP transport binding to IPv6 localhost
+[localhost-udp6]
+type=transport-udp
+# Note that is IPv6
+host=::1
+port=5061
+
+# Example of a TCP transport binding to IPv4 localhost
+[localhost-tcp]
+# A type of transport-tcp specifies transport using TCP
+type=transport-tcp
+host=127.0.0.1
+port=5061
+
+# Example of a TCP transport binding to IPv6 localhost
+[localhost-tcp6]
+type=transport-tcp
+host=::1
+port=5061
+
+# Example of a TLS transport binding to IPv4 localhost
+[localhost-tls]
+# A type of translort-tls specifies transport using TLS
+type=transport-tls
+host=127.0.0.1
+port=5061
+# Filename (with path) to the certificate authority file
+#certificateauthorityfile=/tmp/bob.ca
+# Filename (with path) to the certificate file
+#certificatefile=/tmp/bob.cert
+# Filename (with path) to the private key file
+#privatekeyfile=/tmp/bob.key
+# Password to open the above private key file
+#privatekeypassword=zombies
+# Whether to require the server certificate to be verified or not
+#requireverifiedserver=yes
+# Whether to require the client certificate to be verified or not
+#requireverifiedclient=yes
+# Whether to require a client certificate
+#requireclientcertificate=yes
+# Supported cryptography ciphers (in OpenSSL format)
+#supportedciphers=
+# TLS server name
+#tlsservername=
+# Timeout value for TLS negotiation (0 means no timeout)
+tlstimeout=0
+# TLS protocol method to use (valid options are unspecified, tlsv1, sslv2, sslv3, sslv23)
+#tlsprotocolmethod=tlsv1
+
+# Example of a SIP endpoint configuration
+[bob]
+# A type of endpoint specifies this section is for a SIP endpoint
+type=endpoint
+# IP address or host of the SIP device we are targetting
+targethost=192.168.2.99
+# Port number of the SIP device we are targetting
+targetport=5060
+# Source IP address or host of the transport to use
+#sourcehost=
+# Source port of the transport to use
+#sourceport=
+# What directions calls are permitted in. Valid options are inbound, outbound, and both.
+direction=both
diff --git a/config/SipConfigurator.py b/config/SipConfigurator.py
new file mode 100755
index 0000000..018bdc0
--- /dev/null
+++ b/config/SipConfigurator.py
@@ -0,0 +1,150 @@
+#!/usr/bin/env python
+
+# Sip configurator
+
+# Bring in the common configuration infrastructure
+import Ice, Configurator, sys
+
+# Load our component specific configuration definitions
+Ice.loadSlice('-I. -I/opt/Ice-3.4.1/slice -I../../slice --all ../local-slice/SipConfigurationIf.ice')
+import AsteriskSCF.SIP.V1
+
+# Add our own visitor implementations for the sections we support
+class SipSectionVisitors(Configurator.SectionVisitors):
+ def visit_general(self, config, section):
+ group = AsteriskSCF.SIP.V1.SipGeneralGroup()
+ group.configurationItems = { }
+ self.groups.append(group)
+
+ def visit_transport_udp(self, config, section):
+ group = AsteriskSCF.SIP.V1.SipUDPTransportGroup()
+ group.name = section
+ group.configurationItems = { }
+
+ mapper = Configurator.OptionMapper()
+ item = AsteriskSCF.SIP.V1.SipHostItem()
+ mapper.map('host', item, 'host', 'address', config.get, None)
+ mapper.map('port', item, 'port', 'address', config.getint, 5060)
+ for option in config.options(section):
+ mapper.execute(group, section, option)
+
+ mapper.finish(group)
+
+ self.groups.append(group)
+
+ def visit_transport_tcp(self, config, section):
+ group = AsteriskSCF.SIP.V1.SipTCPTransportGroup()
+ group.name = section
+ group.configurationItems = { }
+
+ mapper = Configurator.OptionMapper()
+ item = AsteriskSCF.SIP.V1.SipHostItem()
+ mapper.map('host', item, 'host', 'address', config.get, None)
+ mapper.map('port', item, 'port', 'address', config.getint, 5060)
+ for option in config.options(section):
+ mapper.execute(group, section, option)
+
+ mapper.finish(group)
+
+ self.groups.append(group)
+
+ def visit_transport_tls(self, config, section):
+ group = AsteriskSCF.SIP.V1.SipTLSTransportGroup()
+ group.name = section
+ group.configurationItems = { }
+
+ mapper = Configurator.OptionMapper()
+ item = AsteriskSCF.SIP.V1.SipHostItem()
+ mapper.map('host', item, 'host', 'address', config.get, None)
+ mapper.map('port', item, 'port', 'address', config.getint, 5060)
+ for option in config.options(section):
+ mapper.execute(group, section, option)
+
+ mapper.finish(group)
+
+ self.groups.append(group)
+
+ def visit_endpoint(self, config, section):
+ group = AsteriskSCF.SIP.V1.SipEndpointGroup()
+ group.name = section
+ group.configurationItems = { }
+
+ mapper = Configurator.OptionMapper()
+
+ mapper.map('routing', AsteriskSCF.SIP.V1.SipRoutingItem(), 'routingServiceName', 'routingService', config.get, None)
+
+ item = AsteriskSCF.SIP.V1.SipSourceTransportAddressItem()
+ mapper.map('sourcehost', item, 'host', 'sourceaddress', config.get, None)
+ mapper.map('sourceport', item, 'port', 'sourceaddress', config.getint, 5060)
+
+ item = AsteriskSCF.SIP.V1.SipTargetDestinationAddressItem()
+ mapper.map('targethost', item, 'host', 'targetaddress', config.get, None)
+ mapper.map('targetport', item, 'port', 'targetaddress', config.getint, 5060)
+
+ class AllowableCallDirectionTransformer():
+ def __init__(self, config):
+ self.config = config
+ def get(self, section, item):
+ if self.config.get(section, item) == 'inbound':
+ return AsteriskSCF.SIP.V1.SipAllowableCallDirection.Inbound
+ elif self.config.get(section, item) == 'outbound':
+ return AsteriskSCF.SIP.V1.SipAllowableCallDirection.Outbound
+ elif self.config.get(section, item) == 'both':
+ return AsteriskSCF.SIP.V1.SipAllowableCallDirection.Both
+
+ transformer = AllowableCallDirectionTransformer(config)
+ mapper.map('direction', AsteriskSCF.SIP.V1.SipAllowableCallDirectionItem(), 'callDirection', 'callDirection', transformer.get, None)
+
+ item = AsteriskSCF.SIP.V1.SipCryptoCertificateItem()
+ mapper.map('certificateauthorityfile', item, 'certificateAuthority', 'cryptocert', config.get, None)
+ mapper.map('certificatefile', item, 'certificate', 'cryptocert', config.get, None)
+ mapper.map('privatekeyfile', item, 'privateKey', 'cryptocert', config.get, None)
+ mapper.map('privatekeypassword', item, 'privateKeyPassword', 'cryptocert', config.get, None)
+
+ item = AsteriskSCF.SIP.V1.SipCryptoRequirementsItem()
+ mapper.map('requireverifiedserver', item, 'requireVerifiedServer', 'cryptorequirements', config.getboolean, None)
+ mapper.map('requireverifiedclient', item, 'requireVerifiedClient', 'cryptorequirements', config.getboolean, None)
+ mapper.map('requireclientcertificate', item, 'requireClientCertificate', 'cryptorequirements', config.getboolean, None)
+
+ item = AsteriskSCF.SIP.V1.SipCryptoItem()
+ mapper.map('supportedciphers', item, 'supportedCiphers', 'crypto', config.get, None)
+ mapper.map('tlsservername', item, 'serverName', 'crypto', config.get, None)
+ mapper.map('tlstimeout', item, 'timeout', 'crypto', config.getint, None)
+
+ class TLSProtocolMethodTransformer():
+ def __init__(self, config):
+ self.config = config
+ def get(self, section, item):
+ if self.config.get(section, item) == 'unspecified':
+ return AsteriskSCF.SIP.V1.TLSProtocolMethod.PROTOCOLMETHODUNSPECIFIED
+ elif self.config.get(section, item) == 'tlsv1':
+ return AsteriskSCF.SIP.V1.TLSProtocolMethod.PROTOCOLMETHODTLSV1
+ elif self.config.get(section, item) == 'sslv2':
+ return AsteriskSCF.SIP.V1.TLSProtocolMethod.PROTOCOLMETHODTSSLV2
+ elif self.config.get(section, item) == 'sslv3':
+ return AsteriskSCF.SIP.V1.TLSProtocolMethod.PROTOCOLMETHODSSLV3
+ elif self.config.get(section, item) == 'sslv23':
+ return AsteriskSCF.SIP.V1.TLSProtocolMethod.PROTOCOLMETHODSSLV23
+
+ transformer = TLSProtocolMethodTransformer(config)
+ mapper.map('tlsprotocolmethod', item, 'protocolMethod', 'crypto', transformer.get, None)
+
+ for option in config.options(section):
+ mapper.execute(group, section, option)
+ mapper.finish(group)
+
+ self.groups.append(group)
+
+ def visit_unsupported(self, config, section):
+ if config.get(section, 'type') == 'transport-udp':
+ self.visit_transport_udp(config, section)
+ elif config.get(section, 'type') == 'transport-tcp':
+ self.visit_transport_tcp(config, section)
+ elif config.get(section, 'type') == 'transport-tls':
+ self.visit_transport_tls(config, section)
+ elif config.get(section, 'type') == 'endpoint':
+ self.visit_endpoint(config, section)
+
+# Make a configurator application and let it run
+app = Configurator.ConfiguratorApp('Sip.config', SipSectionVisitors())
+sys.exit(app.main(sys.argv))
commit 0f17de699ae1b4e8f7abdb69053405a30b4b7952
Author: Joshua Colp <jcolp at digium.com>
Date: Tue Mar 8 08:54:33 2011 -0400
Tweak include.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 9fa7d55..73e31cd 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -16,7 +16,7 @@
#pragma once
#include <Ice/BuiltinSequences.ice>
-#include "AsteriskSCF/System/Component/ConfigurationIf.ice"
+#include <AsteriskSCF/System/Component/ConfigurationIf.ice>
module AsteriskSCF
{
commit 4c5178bacdf897e9717c93187b2bcb657f2e1871
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Mar 7 10:52:29 2011 -0400
Remove underscores and don't use None since python uses it.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 0df317c..9fa7d55 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -188,11 +188,11 @@ module V1
*/
enum TLSProtocolMethod
{
- PROTOCOL_METHOD_UNSPECIFIED,
- PROTOCOL_METHOD_TLSV1,
- PROTOCOL_METHOD_SSLV2,
- PROTOCOL_METHOD_SSLV3,
- PROTOCOL_METHOD_SSLV23,
+ PROTOCOLMETHODUNSPECIFIED,
+ PROTOCOLMETHODTLSV1,
+ PROTOCOLMETHODSSLV2,
+ PROTOCOLMETHODSSLV3,
+ PROTOCOLMETHODSSLV23,
};
/**
@@ -203,7 +203,7 @@ module V1
/**
* TLS protocol method to use
*/
- TLSProtocolMethod protocolMethod = PROTOCOL_METHOD_UNSPECIFIED;
+ TLSProtocolMethod protocolMethod = PROTOCOLMETHODUNSPECIFIED;
/**
* Supported ciphers (OpenSSL format)
@@ -316,7 +316,7 @@ module V1
*/
enum SipAllowableCallDirection
{
- None,
+ Disabled,
Inbound,
Outbound,
Both,
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 599d87b..713aa9c 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -774,23 +774,23 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
void visitSipCryptoItem(const ::AsteriskSCF::SIP::V1::SipCryptoItemPtr& cryptoItem)
{
- if (cryptoItem->protocolMethod == PROTOCOL_METHOD_UNSPECIFIED)
+ if (cryptoItem->protocolMethod == PROTOCOLMETHODUNSPECIFIED)
{
mLocalTransport->mTLSSettings.method = PJSIP_SSL_UNSPECIFIED_METHOD;
}
- else if (cryptoItem->protocolMethod == PROTOCOL_METHOD_TLSV1)
+ else if (cryptoItem->protocolMethod == PROTOCOLMETHODTLSV1)
{
mLocalTransport->mTLSSettings.method = PJSIP_TLSV1_METHOD;
}
- else if (cryptoItem->protocolMethod == PROTOCOL_METHOD_SSLV2)
+ else if (cryptoItem->protocolMethod == PROTOCOLMETHODSSLV2)
{
mLocalTransport->mTLSSettings.method = PJSIP_SSLV2_METHOD;
}
- else if (cryptoItem->protocolMethod == PROTOCOL_METHOD_SSLV3)
+ else if (cryptoItem->protocolMethod == PROTOCOLMETHODSSLV3)
{
mLocalTransport->mTLSSettings.method = PJSIP_SSLV3_METHOD;
}
- else if (cryptoItem->protocolMethod == PROTOCOL_METHOD_SSLV23)
+ else if (cryptoItem->protocolMethod == PROTOCOLMETHODSSLV23)
{
mLocalTransport->mTLSSettings.method = PJSIP_SSLV23_METHOD;
}
commit d17c5711691e51a7a46e787da409c568e8dc6cfd
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Mar 7 10:06:29 2011 -0400
Add configuration items for TLS.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 709e820..0df317c 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -139,12 +139,86 @@ module V1
/**
* Crypto certificate configuration item
*/
- class SipCertificateItem extends SipConfigurationItem
+ class SipCryptoCertificateItem extends SipConfigurationItem
{
/**
- * Full certificate to use
+ * 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
+ {
+ PROTOCOL_METHOD_UNSPECIFIED,
+ PROTOCOL_METHOD_TLSV1,
+ PROTOCOL_METHOD_SSLV2,
+ PROTOCOL_METHOD_SSLV3,
+ PROTOCOL_METHOD_SSLV23,
+ };
+
+ /**
+ * General crypto configuration item
+ */
+ class SipCryptoItem extends SipConfigurationItem
+ {
+ /**
+ * TLS protocol method to use
+ */
+ TLSProtocolMethod protocolMethod = PROTOCOL_METHOD_UNSPECIFIED;
+
+ /**
+ * Supported ciphers (OpenSSL format)
+ */
+ string supportedCiphers;
+
+ /**
+ * Server name
+ */
+ string serverName;
+
+ /**
+ * TLS negotiation timeout in seconds
+ */
+ int timeout = 0;
};
/**
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 1243bba..599d87b 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -756,6 +756,48 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
mLocalTransport->mAddress = hostItem->host;
mLocalTransport->mPort = hostItem->port;
};
+
+ void visitSipCryptoCertificateItem(const ::AsteriskSCF::SIP::V1::SipCryptoCertificateItemPtr& certificateItem)
+ {
+ mLocalTransport->mTLSSettings.ca_list_file = pj_str((char*)certificateItem->certificateAuthority.c_str());
+ mLocalTransport->mTLSSettings.cert_file = pj_str((char*)certificateItem->certificate.c_str());
+ mLocalTransport->mTLSSettings.privkey_file = pj_str((char*)certificateItem->privateKey.c_str());
+ mLocalTransport->mTLSSettings.password = pj_str((char*)certificateItem->privateKeyPassword.c_str());
+ };
+
+ void visitSipCryptoRequirementsItem(const ::AsteriskSCF::SIP::V1::SipCryptoRequirementsItemPtr& requirementsItem)
+ {
+ mLocalTransport->mTLSSettings.verify_server = (requirementsItem->requireVerifiedServer == false) ? PJ_FALSE : PJ_TRUE;
+ mLocalTransport->mTLSSettings.verify_client = (requirementsItem->requireVerifiedClient == false) ? PJ_FALSE : PJ_TRUE;
+ mLocalTransport->mTLSSettings.require_client_cert = (requirementsItem->requireClientCertificate == false) ? PJ_FALSE : PJ_TRUE;
+ };
+
+ void visitSipCryptoItem(const ::AsteriskSCF::SIP::V1::SipCryptoItemPtr& cryptoItem)
+ {
+ if (cryptoItem->protocolMethod == PROTOCOL_METHOD_UNSPECIFIED)
+ {
+ mLocalTransport->mTLSSettings.method = PJSIP_SSL_UNSPECIFIED_METHOD;
+ }
+ else if (cryptoItem->protocolMethod == PROTOCOL_METHOD_TLSV1)
+ {
+ mLocalTransport->mTLSSettings.method = PJSIP_TLSV1_METHOD;
+ }
+ else if (cryptoItem->protocolMethod == PROTOCOL_METHOD_SSLV2)
+ {
+ mLocalTransport->mTLSSettings.method = PJSIP_SSLV2_METHOD;
+ }
+ else if (cryptoItem->protocolMethod == PROTOCOL_METHOD_SSLV3)
+ {
+ mLocalTransport->mTLSSettings.method = PJSIP_SSLV3_METHOD;
+ }
+ else if (cryptoItem->protocolMethod == PROTOCOL_METHOD_SSLV23)
+ {
+ mLocalTransport->mTLSSettings.method = PJSIP_SSLV23_METHOD;
+ }
+ mLocalTransport->mTLSSettings.ciphers = pj_str((char*)cryptoItem->supportedCiphers.c_str());
+ mLocalTransport->mTLSSettings.server_name = pj_str((char*)cryptoItem->serverName.c_str());
+ mLocalTransport->mTLSSettings.timeout.sec = cryptoItem->timeout;
+ };
private:
boost::shared_ptr<TLSTransportImplPriv> mLocalTransport;
};
commit e37d9494e7db63a6f9e0798020dc3de62533da91
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Mar 7 08:20:43 2011 -0400
Add TLS transport configuration support. Since pjsip does not yet support IPv6 on TLS the actual code that starts the transport is currently commented out.
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 5140eac..e13e846 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -179,6 +179,25 @@ pjsip_tpfactory *PJSipManager::createTCPTransport(std::string address, int port)
return tcpTransport;
}
+pjsip_tpfactory *PJSipManager::createTLSTransport(std::string address, int port, pjsip_tls_setting *tlsSettings)
+{
+ pj_sockaddr tlsAddr;
+ pj_str_t tlsString;
+ pj_cstr(&tlsString, address.c_str());
+ pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &tlsString, &tlsAddr);
+ pj_sockaddr_set_port(&tlsAddr, port);
+
+ pjsip_tpfactory *tlsTransport = NULL;
+
+/*
+ if (pjsip_tls_transport_start(mEndpoint, tlsSettings, &tlsAddr, NULL, 2, &tlsTransport) != PJ_SUCCESS)
+ {
+ lg(Error) << "Failed to create TLS transport.";
+ }
+*/
+ return tlsTransport;
+}
+
}; //End namespace SipSessionManager
}; //End namespace AsteriskSCF
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 106da1e..8c78987 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -90,6 +90,11 @@ public:
* Create a TCP transport.
*/
pjsip_tpfactory *createTCPTransport(std::string, int);
+
+ /**
+ * Create a TLS transport.
+ */
+ pjsip_tpfactory *createTLSTransport(std::string, int, pjsip_tls_setting*);
private:
static PJSipManager *mInstance;
pjsip_endpoint *mEndpoint;
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 52de50e..1243bba 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -109,7 +109,52 @@ public:
/**
* Configuration group itself.
*/
- SipTransportGroupPtr mGroup;
+ SipTCPTransportGroupPtr mGroup;
+
+ /**
+ * Transport factory within pjsip.
+ */
+ pjsip_tpfactory *mTransportFactory;
+};
+
+class TLSTransportImplPriv
+{
+public:
+ /**
+ * Constructor implementation for this
+ */
+ TLSTransportImplPriv() : mTransportFactory(0) { pjsip_tls_setting_default(&mTLSSettings); };
+
+ /**
+ * Destructor implementation that shuts down the transport gracefully if we go away
+ */
+ ~TLSTransportImplPriv()
+ {
+ if (mTransportFactory)
+ {
+ // Too bad this isn't possible right now
+ }
+ };
+
+ /**
+ * Address itself.
+ */
+ std::string mAddress;
+
+ /**
+ * Can't forget the port.
+ */
+ int mPort;
+
+ /**
+ * pjsip TLS settings.
+ */
+ pjsip_tls_setting mTLSSettings;
+
+ /**
+ * Configuration group itself.
+ */
+ SipTLSTransportGroupPtr mGroup;
/**
* Transport factory within pjsip.
@@ -143,7 +188,7 @@ public:
/**
* Configured TLS SIP transports
*/
- std::map<std::string, SipTLSTransportGroupPtr> mConfiguredTLSTransports;
+ std::map<std::string, boost::shared_ptr<TLSTransportImplPriv> > mConfiguredTLSTransports;
/**
* Configured SIP endpoints
@@ -268,7 +313,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskS
void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
{
- std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
+ std::map<std::string, boost::shared_ptr<TLSTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
if (localTransport == mImplPriv->mConfiguredTLSTransports.end())
{
@@ -278,7 +323,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskS
SipTLSTransportGroupPtr returnedGroup = new SipTLSTransportGroup();
returnedGroup->name = group->name;
- insertRequestedConfigurationItems(group->configurationItems, (*localTransport).second->configurationItems, returnedGroup->configurationItems);
+ insertRequestedConfigurationItems(group->configurationItems, (*localTransport).second->mGroup->configurationItems, returnedGroup->configurationItems);
mGroups.push_back(returnedGroup);
};
@@ -371,14 +416,14 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const Asteri
void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
{
- std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
+ std::map<std::string, boost::shared_ptr<TLSTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
if (localTransport == mImplPriv->mConfiguredTLSTransports.end())
{
return;
}
- mGroups.push_back((*localTransport).second);
+ mGroups.push_back((*localTransport).second->mGroup);
};
void visitSipEndpointGroup(const ::AsteriskSCF::SIP::V1::SipEndpointGroupPtr& group)
@@ -445,12 +490,12 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice
groups.push_back(transport);
}
- for (std::map<std::string, SipTLSTransportGroupPtr>::iterator group = mImplPriv->mConfiguredTLSTransports.begin();
+ for (std::map<std::string, boost::shared_ptr<TLSTransportImplPriv> >::iterator group = mImplPriv->mConfiguredTLSTransports.begin();
group != mImplPriv->mConfiguredTLSTransports.end();
++group)
{
SipTLSTransportGroupPtr transport = new SipTLSTransportGroup();
- transport->name = (*group).second->name;
+ transport->name = (*group).second->mGroup->name;
groups.push_back(transport);
}
@@ -684,36 +729,61 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
{
- std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransportGroup = mImplPriv->mConfiguredTLSTransports.find(group->name);
- SipTLSTransportGroupPtr localTransport;
-
+ std::map<std::string, boost::shared_ptr<TLSTransportImplPriv> >::iterator localTransportGroup = mImplPriv->mConfiguredTLSTransports.find(group->name);
+ boost::shared_ptr<TLSTransportImplPriv> localTransport;
+
if (localTransportGroup == mImplPriv->mConfiguredTLSTransports.end())
{
- localTransport = new SipTLSTransportGroup;
- localTransport->name = group->name;
+ boost::shared_ptr<TLSTransportImplPriv> newTransport(new TLSTransportImplPriv());
+ localTransport = newTransport;
+ localTransport->mGroup = new SipTLSTransportGroup;
+ localTransport->mGroup->name = group->name;
mImplPriv->mConfiguredTLSTransports.insert(make_pair(group->name, localTransport));
}
else
{
localTransport = (*localTransportGroup).second;
- performSerialCheck(group->configurationItems, localTransport->configurationItems);
+ performSerialCheck(group->configurationItems, localTransport->mGroup->configurationItems);
}
-
+
class tlsTransportItemsVisitor : public SipConfigurationItemVisitor
{
public:
+ tlsTransportItemsVisitor(boost::shared_ptr<TLSTransportImplPriv> localTransport) : mLocalTransport(localTransport) { };
+
+ void visitSipHostItem(const ::AsteriskSCF::SIP::V1::SipHostItemPtr& hostItem)
+ {
+ mLocalTransport->mAddress = hostItem->host;
+ mLocalTransport->mPort = hostItem->port;
+ };
private:
+ boost::shared_ptr<TLSTransportImplPriv> mLocalTransport;
};
-
- SipConfigurationItemVisitorPtr tlsTransportVisitor = new tlsTransportItemsVisitor();
-
+
+ std::string oldAddress = localTransport->mAddress;
+ int oldPort = localTransport->mPort;
+
+ SipConfigurationItemVisitorPtr tlsTransportVisitor = new tlsTransportItemsVisitor(localTransport);
+
for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
item != group->configurationItems.end();
++item)
{
- localTransport->configurationItems.insert(make_pair((*item).first, (*item).second));
+ localTransport->mGroup->configurationItems.insert(make_pair((*item).first, (*item).second));
(*item).second->visit(tlsTransportVisitor);
}
+
+ // Reconcile all the changes received
+ if (oldAddress != localTransport->mAddress || oldPort != localTransport->mPort)
+ {
+ if (localTransport->mTransportFactory)
+ {
+ // I hope eventually it becomes possible to do this... but for now it is not
+ }
+
+ std::cout << "Address: " << localTransport->mAddress << std::endl;
+ localTransport->mTransportFactory = mImplPriv->mPJSipManager->createTLSTransport(localTransport->mAddress, localTransport->mPort, &localTransport->mTLSSettings);
+ }
};
void visitSipEndpointGroup(const ::AsteriskSCF::SIP::V1::SipEndpointGroupPtr& group)
@@ -904,7 +974,7 @@ void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::Syste
void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
{
- std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
+ std::map<std::string, boost::shared_ptr<TLSTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
if (localTransport == mImplPriv->mConfiguredTLSTransports.end())
{
@@ -917,7 +987,7 @@ void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::Syste
private:
} tlsTransportVisitor;
- removeItems(&tlsTransportVisitor, group->configurationItems, (*localTransport).second->configurationItems);
+ removeItems(&tlsTransportVisitor, group->configurationItems, (*localTransport).second->mGroup->configurationItems);
};
void visitSipEndpointGroup(const ::AsteriskSCF::SIP::V1::SipEndpointGroupPtr& group)
@@ -1007,7 +1077,7 @@ void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::Syst
void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
{
- std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
+ std::map<std::string, boost::shared_ptr<TLSTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
if (localTransport == mImplPriv->mConfiguredTLSTransports.end())
{
commit 72138cabee93955fb3d648ac78c1faea422e2733
Author: Joshua Colp <jcolp at digium.com>
Date: Sun Mar 6 20:10:21 2011 -0400
Add support for configuring TCP transports.
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 8fbaca9..5140eac 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -161,6 +161,24 @@ pjsip_transport *PJSipManager::createUDPTransport(std::string address, int port)
return udpTransport;
}
+pjsip_tpfactory *PJSipManager::createTCPTransport(std::string address, int port)
+{
+ 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, port);
+
+ pjsip_tpfactory *tcpTransport = NULL;
+
+ if (pjsip_tcp_transport_start(mEndpoint, &tcpAddr, 2, &tcpTransport) != PJ_SUCCESS)
+ {
+ lg(Error) << "Failed to create TCP transport.";
+ }
+
+ return tcpTransport;
+}
+
}; //End namespace SipSessionManager
}; //End namespace AsteriskSCF
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index fde60b6..106da1e 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -85,6 +85,11 @@ public:
* Create a UDP transport.
*/
pjsip_transport *createUDPTransport(std::string, int);
+
+ /**
+ * Create a TCP transport.
+ */
+ pjsip_tpfactory *createTCPTransport(std::string, int);
private:
static PJSipManager *mInstance;
pjsip_endpoint *mEndpoint;
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 9732c6e..52de50e 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -77,6 +77,46 @@ public:
pjsip_transport *mTransport;
};
+class TCPTransportImplPriv
+{
+public:
+ /**
+ * Constructor implementation for this
+ */
+ TCPTransportImplPriv() : mTransportFactory(0) { };
+
+ /**
+ * Destructor implementation that shuts down the transport gracefully if we go away
+ */
+ ~TCPTransportImplPriv()
+ {
+ if (mTransportFactory)
+ {
+ // I hope in the future it will be possible to shut down TCP based transports but for now... it is not
+ }
+ };
+
+ /**
+ * Address itself.
+ */
+ std::string mAddress;
+
+ /**
+ * Can't forget the port.
+ */
+ int mPort;
+
+ /**
+ * Configuration group itself.
+ */
+ SipTransportGroupPtr mGroup;
+
+ /**
+ * Transport factory within pjsip.
+ */
+ pjsip_tpfactory *mTransportFactory;
+};
+
class ConfigurationServiceImplPriv
{
public:
@@ -98,7 +138,7 @@ public:
/**
* Configured TCP SIP transports
*/
- std::map<std::string, SipTCPTransportGroupPtr> mConfiguredTCPTransports;
+ std::map<std::string, boost::shared_ptr<TCPTransportImplPriv> > mConfiguredTCPTransports;
/**
* Configured TLS SIP transports
@@ -211,7 +251,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskS
void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
{
- std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
+ std::map<std::string, boost::shared_ptr<TCPTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
if (localTransport == mImplPriv->mConfiguredTCPTransports.end())
{
@@ -221,7 +261,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskS
SipTCPTransportGroupPtr returnedGroup = new SipTCPTransportGroup();
returnedGroup->name = group->name;
- insertRequestedConfigurationItems(group->configurationItems, (*localTransport).second->configurationItems, returnedGroup->configurationItems);
+ insertRequestedConfigurationItems(group->configurationItems, (*localTransport).second->mGroup->configurationItems, returnedGroup->configurationItems);
mGroups.push_back(returnedGroup);
};
@@ -319,14 +359,14 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const Asteri
void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
{
- std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
+ std::map<std::string, boost::shared_ptr<TCPTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
if (localTransport == mImplPriv->mConfiguredTCPTransports.end())
{
return;
}
- mGroups.push_back((*localTransport).second);
+ mGroups.push_back((*localTransport).second->mGroup);
};
void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
@@ -396,12 +436,12 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice
groups.push_back(transport);
}
- for (std::map<std::string, SipTCPTransportGroupPtr>::iterator group = mImplPriv->mConfiguredTCPTransports.begin();
+ for (std::map<std::string, boost::shared_ptr<TCPTransportImplPriv> >::iterator group = mImplPriv->mConfiguredTCPTransports.begin();
group != mImplPriv->mConfiguredTCPTransports.end();
++group)
{
SipTCPTransportGroupPtr transport = new SipTCPTransportGroup();
- transport->name = (*group).second->name;
+ transport->name = (*group).second->mGroup->name;
groups.push_back(transport);
}
@@ -586,36 +626,60 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
{
- std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransportGroup = mImplPriv->mConfiguredTCPTransports.find(group->name);
- SipTCPTransportGroupPtr localTransport;
+ std::map<std::string, boost::shared_ptr<TCPTransportImplPriv> >::iterator localTransportGroup = mImplPriv->mConfiguredTCPTransports.find(group->name);
+ boost::shared_ptr<TCPTransportImplPriv> localTransport;
if (localTransportGroup == mImplPriv->mConfiguredTCPTransports.end())
{
- localTransport = new SipTCPTransportGroup;
- localTransport->name = group->name;
+ boost::shared_ptr<TCPTransportImplPriv> newTransport(new TCPTransportImplPriv());
+ localTransport = newTransport;
+ localTransport->mGroup = new SipTCPTransportGroup;
+ localTransport->mGroup->name = group->name;
mImplPriv->mConfiguredTCPTransports.insert(make_pair(group->name, localTransport));
}
else
{
localTransport = (*localTransportGroup).second;
- performSerialCheck(group->configurationItems, localTransport->configurationItems);
+ performSerialCheck(group->configurationItems, localTransport->mGroup->configurationItems);
}
- class tcpTransportItemsVisitor : public SipConfigurationItemVisitor
- {
- public:
- private:
- };
-
- SipConfigurationItemVisitorPtr tcpTransportVisitor = new tcpTransportItemsVisitor();
-
- for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
- item != group->configurationItems.end();
- ++item)
- {
- localTransport->configurationItems.insert(make_pair((*item).first, (*item).second));
- (*item).second->visit(tcpTransportVisitor);
- }
+ class tcpTransportItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ tcpTransportItemsVisitor(boost::shared_ptr<TCPTransportImplPriv> localTransport) : mLocalTransport(localTransport) { };
+
+ void visitSipHostItem(const ::AsteriskSCF::SIP::V1::SipHostItemPtr& hostItem)
+ {
+ mLocalTransport->mAddress = hostItem->host;
+ mLocalTransport->mPort = hostItem->port;
+ };
+ private:
+ boost::shared_ptr<TCPTransportImplPriv> mLocalTransport;
+ };
+
+ std::string oldAddress = localTransport->mAddress;
+ int oldPort = localTransport->mPort;
+
+ SipConfigurationItemVisitorPtr tcpTransportVisitor = new tcpTransportItemsVisitor(localTransport);
+
+ for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
+ item != group->configurationItems.end();
+ ++item)
+ {
+ localTransport->mGroup->configurationItems.insert(make_pair((*item).first, (*item).second));
+ (*item).second->visit(tcpTransportVisitor);
+ }
+
+ // Reconcile all the changes received
+ if (oldAddress != localTransport->mAddress || oldPort != localTransport->mPort)
+ {
+ if (localTransport->mTransportFactory)
+ {
+ // I hope eventually it becomes possible to do this... but for now it is not
+ }
+
+ localTransport->mTransportFactory = mImplPriv->mPJSipManager->createTCPTransport(localTransport->mAddress, localTransport->mPort);
+ }
};
void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
@@ -822,7 +886,7 @@ void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::Syste
void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
{
- std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
+ std::map<std::string, boost::shared_ptr<TCPTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
if (localTransport == mImplPriv->mConfiguredTCPTransports.end())
{
@@ -835,7 +899,7 @@ void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::Syste
private:
} tcpTransportVisitor;
- removeItems(&tcpTransportVisitor, group->configurationItems, (*localTransport).second->configurationItems);
+ removeItems(&tcpTransportVisitor, group->configurationItems, (*localTransport).second->mGroup->configurationItems);
};
void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
@@ -931,7 +995,7 @@ void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::Syst
void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
{
- std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
+ std::map<std::string, boost::shared_ptr<TCPTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
if (localTransport == mImplPriv->mConfiguredTCPTransports.end())
{
commit 01940e42606ff1b41b53778a2b5148021be8d80b
Author: Joshua Colp <jcolp at digium.com>
Date: Sun Mar 6 18:50:07 2011 -0400
Destroy the SIP endpoint completely when told to.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index b06cf62..9410622 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -117,12 +117,9 @@ SipEndpoint::SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEnd
mImplPriv->mEndpointProxy = AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
}
-/**
- * Default destructor.
- */
-SipEndpoint::~SipEndpoint()
+void SipEndpoint::removeFromAdapter()
{
- lg(Debug) << "Deconstructing SIP endpoint " << mImplPriv->mName;
... 3990 lines suppressed ...
--
asterisk-scf/release/sip.git
More information about the asterisk-scf-commits
mailing list