[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "configuration" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Mar 2 12:49:52 CST 2011
branch "configuration" has been created
at 49098782accde3746af4857574c15ceac1ea7916 (commit)
- Log -----------------------------------------------------------------
commit 49098782accde3746af4857574c15ceac1ea7916
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Mar 2 14:50:02 2011 -0400
Add configuration interface support with UDP transport functioning.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 642c2ee..a791fa9 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
+ ["visitor"] local class SipConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
{
};
@@ -47,6 +47,20 @@ module V1
};
/**
+ * Local visitor class for visiting SIP configuration items
+ */
+ ["visitor"] local class SipConfigurationItemVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationItemVisitor
+ {
+ };
+
+ /**
+ * Generic SIP configuration item
+ */
+ ["visitor:SipConfigurationItemVisitor"] class SipConfigurationItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ {
+ };
+
+ /**
* SIP Domain group, used to configure a specific domain
*/
class SipDomainGroup extends SipConfigurationGroup
@@ -60,7 +74,7 @@ module V1
/**
* Domain item for bindings
*/
- class SipBindingsItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ class SipBindingsItem extends SipConfigurationItem
{
/**
* Addresses the domain is reachable over
@@ -84,7 +98,7 @@ module V1
/**
* Host information configuration item
*/
- class SipHostItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ class SipHostItem extends SipConfigurationItem
{
/**
* String containing the IP address or string address
@@ -100,7 +114,7 @@ module V1
/**
* Crypto certificate configuration item
*/
- class SipCertificateItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ class SipCertificateItem extends SipConfigurationItem
{
/**
* Full certificate to use
@@ -111,7 +125,7 @@ module V1
/**
* Routing service configuration item
*/
- class SipRoutingItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ class SipRoutingItem extends SipConfigurationItem
{
/**
* Name of the routing service to use
@@ -122,7 +136,7 @@ module V1
/**
* RTP Media service configuration item
*/
- class SipRTPMediaServiceItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ class SipRTPMediaServiceItem extends SipConfigurationItem
{
/**
* Name of the RTP media service to use
@@ -133,7 +147,7 @@ module V1
/**
* Signaling NAT configuration item
*/
- class SipSignalingNATItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ class SipSignalingNATItem extends SipConfigurationItem
{
/**
* Boolean for whether STUN is enabled
@@ -144,7 +158,7 @@ module V1
/**
* Media NAT configuration item
*/
- class SipMediaNATItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ class SipMediaNATItem extends SipConfigurationItem
{
/**
* Boolean for whether symmetric RTP is enabled
@@ -170,7 +184,7 @@ module V1
/**
* Access control lists item
*/
- class SipACLItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ class SipACLItem extends SipConfigurationItem
{
/**
* Name of this ACL item. A user may want to have multiple.
@@ -201,7 +215,7 @@ module V1
/**
* User agent presentation configuration item
*/
- class SipUserAgentItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ class SipUserAgentItem extends SipConfigurationItem
{
/**
* String that our user agent should appear as
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d03df8c..18a4bfd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -27,11 +27,14 @@ asterisk_scf_component_add_file(SipSessionManager PJSipSessionModule.h)
asterisk_scf_component_add_file(SipSessionManager PJSipLoggingModule.cpp)
asterisk_scf_component_add_file(SipSessionManager PJSipLoggingModuleConstruction.cpp)
asterisk_scf_component_add_file(SipSessionManager PJSipLoggingModule.h)
+asterisk_scf_component_add_file(SipSessionManager SipConfiguration.cpp)
+asterisk_scf_component_add_file(SipSessionManager SipConfiguration.h)
asterisk_scf_component_add_file(SipSessionManager SipStateReplicatorListener.cpp)
asterisk_scf_component_add_file(SipSessionManager SipStateReplicator.h)
asterisk_scf_component_add_slice(SipSessionManager ../local-slice/SipIf.ice)
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)
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 22b5955..c694ce5 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -133,6 +133,33 @@ bool PJSipManager::setTransports(pjsip_endpoint *endpoint, Ice::PropertiesPtr pr
return true;
}
+pjsip_transport *PJSipManager::createUDPTransport(std::string address, int port)
+{
+ 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, 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())
+ {
+ status = pjsip_udp_transport_start6(mEndpoint, &udpAddr.ipv6, NULL, 2, &udpTransport);
+ }
+
+ if (status != PJ_SUCCESS)
+ {
+ lg(Error) << "Failed to create UDP transport.";
+ }
+
+ return udpTransport;
+}
+
}; //End namespace SipSessionManager
}; //End namespace AsteriskSCF
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index eaedf0d..fde60b6 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -80,6 +80,11 @@ public:
* for logging incoming and outgoing SIP messages
*/
void registerLoggingModule();
+
+ /**
+ * Create a UDP transport.
+ */
+ pjsip_transport *createUDPTransport(std::string, int);
private:
static PJSipManager *mInstance;
pjsip_endpoint *mEndpoint;
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
new file mode 100644
index 0000000..c645ffe
--- /dev/null
+++ b/src/SipConfiguration.cpp
@@ -0,0 +1,820 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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.
+ */
+
+#include <IceUtil/UUID.h>
+
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <pjlib.h>
+#include <pjsip.h>
+
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+
+#include "SipConfigurationIf.h"
+#include "PJSipManager.h"
+#include "SipConfiguration.h"
+
+namespace AsteriskSCF
+{
+namespace SipSessionManager
+{
+
+using namespace AsteriskSCF::SIP::V1;
+using namespace AsteriskSCF::System::Configuration::V1;
+
+class UDPTransportImplPriv
+{
+public:
+ /**
+ * Constructor implementation for this
+ */
+ UDPTransportImplPriv() : mTransport(0) { };
+
+ /**
+ * Destructor implementation that shuts down the transport gracefully if we go away
+ */
+ ~UDPTransportImplPriv()
+ {
+ if (mTransport)
+ {
+ pjsip_transport_shutdown(mTransport);
+ }
+ };
+
+ /**
+ * Address itself.
+ */
+ std::string mAddress;
+
+ /**
+ * Can't forget the port.
+ */
+ int mPort;
+
+ /**
+ * Configuration group itself.
+ */
+ SipUDPTransportGroupPtr mGroup;
+
+ /**
+ * Transport within pjsip.
+ */
+ pjsip_transport *mTransport;
+};
+
+class ConfigurationServiceImplPriv
+{
+public:
+ /**
+ * Constructor for this private class
+ */
+ ConfigurationServiceImplPriv(PJSipManager *manager) : mPJSipManager(manager) { };
+
+ /**
+ * Configured SIP domains
+ */
+ std::map<std::string, SipDomainGroupPtr> mConfiguredDomains;
+
+ /**
+ * Configured UDP SIP transports
+ */
+ std::map<std::string, boost::shared_ptr<UDPTransportImplPriv> > mConfiguredUDPTransports;
+
+ /**
+ * Configured TCP SIP transports
+ */
+ std::map<std::string, SipTCPTransportGroupPtr> mConfiguredTCPTransports;
+
+ /**
+ * Configured TLS SIP transports
+ */
+ std::map<std::string, SipTLSTransportGroupPtr> mConfiguredTLSTransports;
+
+ /**
+ * General SIP configuration
+ */
+ SipGeneralGroupPtr mGeneralGroup;
+
+ /**
+ * PJSipManager Pointer
+ */
+ PJSipManager *mPJSipManager;
+};
+
+ConfigurationServiceImpl::ConfigurationServiceImpl(PJSipManager *manager)
+{
+ boost::shared_ptr<ConfigurationServiceImplPriv> newPriv(new ConfigurationServiceImplPriv(manager));
+ mImplPriv = newPriv;
+}
+
+ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class visitor : public SipConfigurationGroupVisitor
+ {
+ public:
+ visitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& groups) : mImplPriv(implPriv), mGroups(groups) { };
+
+ /**
+ * Internal helper function which determines what configuration items should be returned
+ */
+ void insertRequestedConfigurationItems(ConfigurationItemDict& requestedItems,
+ ConfigurationItemDict& localItems,
+ ConfigurationItemDict& returnedItems)
+ {
+
+ for (ConfigurationItemDict::iterator requestedItem = requestedItems.begin();
+ requestedItem != requestedItems.end();
+ ++requestedItem)
+ {
+ ConfigurationItemDict::iterator localItem = localItems.find((*requestedItem).first);
+
+ if (localItem == localItems.end())
+ {
+ continue;
+ }
+
+ returnedItems.insert(make_pair((*requestedItem).first, (*requestedItem).second));
+ }
+ }
+
+ void visitSipGeneralGroup(const ::AsteriskSCF::SIP::V1::SipGeneralGroupPtr& group)
+ {
+ if (!mImplPriv->mGeneralGroup)
+ {
+ return;
+ }
+
+ SipGeneralGroupPtr returnedGroup = new SipGeneralGroup();
+
+ insertRequestedConfigurationItems(group->configurationItems, mImplPriv->mGeneralGroup->configurationItems, returnedGroup->configurationItems);
+
+ mGroups.push_back(returnedGroup);
+ };
+
+ void visitSipDomainGroup(const ::AsteriskSCF::SIP::V1::SipDomainGroupPtr& group)
+ {
+ std::map<std::string, SipDomainGroupPtr>::iterator localDomain = mImplPriv->mConfiguredDomains.find(group->domain);
+
+ if (localDomain == mImplPriv->mConfiguredDomains.end())
+ {
+ return;
+ }
+
+ SipDomainGroupPtr returnedGroup = new SipDomainGroup();
+ returnedGroup->domain = group->domain;
+
+ insertRequestedConfigurationItems(group->configurationItems, (*localDomain).second->configurationItems, returnedGroup->configurationItems);
+
+ mGroups.push_back(returnedGroup);
+
+ };
+
+ void visitSipUDPTransportGroup(const ::AsteriskSCF::SIP::V1::SipUDPTransportGroupPtr& group)
+ {
+ std::map<std::string, boost::shared_ptr<UDPTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredUDPTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredUDPTransports.end())
+ {
+ return;
+ }
+
+ SipUDPTransportGroupPtr returnedGroup = new SipUDPTransportGroup();
+ returnedGroup->name = group->name;
+
+ insertRequestedConfigurationItems(group->configurationItems, (*localTransport).second->mGroup->configurationItems, returnedGroup->configurationItems);
+
+ mGroups.push_back(returnedGroup);
+ };
+
+ void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredTCPTransports.end())
+ {
+ return;
+ }
+
+ SipTCPTransportGroupPtr returnedGroup = new SipTCPTransportGroup();
+ returnedGroup->name = group->name;
+
+ insertRequestedConfigurationItems(group->configurationItems, (*localTransport).second->configurationItems, returnedGroup->configurationItems);
+
+ mGroups.push_back(returnedGroup);
+ };
+
+ void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredTLSTransports.end())
+ {
+ return;
+ }
+
+ SipTLSTransportGroupPtr returnedGroup = new SipTLSTransportGroup();
+ returnedGroup->name = group->name;
+
+ insertRequestedConfigurationItems(group->configurationItems, (*localTransport).second->configurationItems, returnedGroup->configurationItems);
+
+ mGroups.push_back(returnedGroup);
+ };
+ private:
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ ConfigurationGroupSeq& mGroups;
+ };
+
+ ConfigurationGroupSeq newGroups;
+ SipConfigurationGroupVisitorPtr v = new visitor(mImplPriv, newGroups);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+
+ return newGroups;
+}
+
+ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class visitor : public SipConfigurationGroupVisitor
+ {
+ public:
+ visitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& groups) :
+ mImplPriv(implPriv), mGroups(groups) { };
+
+ void visitSipGeneralGroup(const ::AsteriskSCF::SIP::V1::SipGeneralGroupPtr& group)
+ {
+ if (!mImplPriv->mGeneralGroup)
+ {
+ return;
+ }
+
+ mGroups.push_back(mImplPriv->mGeneralGroup);
+ };
+
+ void visitSipDomainGroup(const ::AsteriskSCF::SIP::V1::SipDomainGroupPtr& group)
+ {
+ std::map<std::string, SipDomainGroupPtr>::iterator localDomain = mImplPriv->mConfiguredDomains.find(group->domain);
+
+ if (localDomain == mImplPriv->mConfiguredDomains.end())
+ {
+ return;
+ }
+
+ mGroups.push_back((*localDomain).second);
+ };
+
+ void visitSipUDPTransportGroup(const ::AsteriskSCF::SIP::V1::SipUDPTransportGroupPtr& group)
+ {
+ std::map<std::string, boost::shared_ptr<UDPTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredUDPTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredUDPTransports.end())
+ {
+ return;
+ }
+
+ mGroups.push_back((*localTransport).second->mGroup);
+ };
+
+ void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredTCPTransports.end())
+ {
+ return;
+ }
+
+ mGroups.push_back((*localTransport).second);
+ };
+
+ void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredTLSTransports.end())
+ {
+ return;
+ }
+
+ mGroups.push_back((*localTransport).second);
+ };
+ private:
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ ConfigurationGroupSeq& mGroups;
+ };
+
+ ConfigurationGroupSeq newGroups;
+ SipConfigurationGroupVisitorPtr v = new visitor(mImplPriv, newGroups);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+
+ return newGroups;
+}
+
+ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice::Current&)
+{
+ ConfigurationGroupSeq groups;
+
+ if (mImplPriv->mGeneralGroup)
+ {
+ SipGeneralGroupPtr general = new SipGeneralGroup();
+ groups.push_back(general);
+ }
+
+ for (std::map<std::string, SipDomainGroupPtr>::iterator group = mImplPriv->mConfiguredDomains.begin();
+ group != mImplPriv->mConfiguredDomains.end();
+ ++group)
+ {
+ SipDomainGroupPtr domain = new SipDomainGroup();
+ domain->domain = (*group).second->domain;
+ groups.push_back(domain);
+ }
+
+ for (std::map<std::string, boost::shared_ptr<UDPTransportImplPriv> >::iterator group = mImplPriv->mConfiguredUDPTransports.begin();
+ group != mImplPriv->mConfiguredUDPTransports.end();
+ ++group)
+ {
+ SipUDPTransportGroupPtr transport = new SipUDPTransportGroup();
+ transport->name = (*group).second->mGroup->name;
+ groups.push_back(transport);
+ }
+
+ for (std::map<std::string, SipTCPTransportGroupPtr>::iterator group = mImplPriv->mConfiguredTCPTransports.begin();
+ group != mImplPriv->mConfiguredTCPTransports.end();
+ ++group)
+ {
+ SipTCPTransportGroupPtr transport = new SipTCPTransportGroup();
+ transport->name = (*group).second->name;
+ groups.push_back(transport);
+ }
+
+ for (std::map<std::string, SipTLSTransportGroupPtr>::iterator group = mImplPriv->mConfiguredTLSTransports.begin();
+ group != mImplPriv->mConfiguredTLSTransports.end();
+ ++group)
+ {
+ SipTLSTransportGroupPtr transport = new SipTLSTransportGroup();
+ transport->name = (*group).second->name;
+ groups.push_back(transport);
+ }
+
+ return groups;
+}
+
+void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class groupsVisitor : public SipConfigurationGroupVisitor
+ {
+ public:
+ groupsVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+
+ private:
+ /**
+ * Helper function which performs serial number checking of items
+ */
+ void performSerialCheck(ConfigurationItemDict& changedItems, ConfigurationItemDict& localItems)
+ {
+ for (ConfigurationItemDict::iterator item = changedItems.begin();
+ item != changedItems.end();
+ ++item)
+ {
+ // If serial checking is to be skipped for this item just skip over it
+ if ((*item).second->serialNumber == -1)
+ {
+ continue;
+ }
+
+ ConfigurationItemDict::iterator localItem = localItems.find((*item).first);
+
+ if (localItem == localItems.end())
+ {
+ // This is a new item so serial checking does not apply
+ continue;
+ }
+
+ if ((*item).second->serialNumber < (*localItem).second->serialNumber)
+ {
+ /* XXX Need to throw the exception */
+ }
+ }
+ }
+
+ void visitSipGeneralGroup(const ::AsteriskSCF::SIP::V1::SipGeneralGroupPtr& group)
+ {
+ if (!mImplPriv->mGeneralGroup)
+ {
+ mImplPriv->mGeneralGroup = new SipGeneralGroup();
+ }
+ else
+ {
+ performSerialCheck(group->configurationItems, mImplPriv->mGeneralGroup->configurationItems);
+ }
+
+ class generalItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ private:
+ };
+
+ SipConfigurationItemVisitorPtr generalVisitor = new generalItemsVisitor();
+
+ for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
+ item != group->configurationItems.end();
+ ++item)
+ {
+ mImplPriv->mGeneralGroup->configurationItems.insert(make_pair((*item).first, (*item).second));
+ (*item).second->visit(generalVisitor);
+ }
+ }
+
+ void visitSipDomainGroup(const ::AsteriskSCF::SIP::V1::SipDomainGroupPtr& group)
+ {
+ std::map<std::string, SipDomainGroupPtr>::iterator localDomainGroup = mImplPriv->mConfiguredDomains.find(group->domain);
+ SipDomainGroupPtr localDomain;
+
+ if (localDomainGroup == mImplPriv->mConfiguredDomains.end())
+ {
+ localDomain = new SipDomainGroup;
+ localDomain->domain = group->domain;
+ mImplPriv->mConfiguredDomains.insert(make_pair(group->domain, localDomain));
+ }
+ else
+ {
+ localDomain = (*localDomainGroup).second;
+ performSerialCheck(group->configurationItems, localDomain->configurationItems);
+ }
+
+ class domainItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ private:
+ };
+
+ SipConfigurationItemVisitorPtr domainVisitor = new domainItemsVisitor();
+
+ for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
+ item != group->configurationItems.end();
+ ++item)
+ {
+ localDomain->configurationItems.insert(make_pair((*item).first, (*item).second));
+ (*item).second->visit(domainVisitor);
+ }
+ };
+
+ void visitSipUDPTransportGroup(const ::AsteriskSCF::SIP::V1::SipUDPTransportGroupPtr& group)
+ {
+ std::map<std::string, boost::shared_ptr<UDPTransportImplPriv> >::iterator localTransportGroup = mImplPriv->mConfiguredUDPTransports.find(group->name);
+ boost::shared_ptr<UDPTransportImplPriv> localTransport;
+
+ if (localTransportGroup == mImplPriv->mConfiguredUDPTransports.end())
+ {
+ boost::shared_ptr<UDPTransportImplPriv> newTransport(new UDPTransportImplPriv());
+ localTransport = newTransport;
+ localTransport->mGroup = new SipUDPTransportGroup;
+ localTransport->mGroup->name = group->name;
+ mImplPriv->mConfiguredUDPTransports.insert(make_pair(group->name, localTransport));
+ }
+ else
+ {
+ localTransport = (*localTransportGroup).second;
+ performSerialCheck(group->configurationItems, localTransport->mGroup->configurationItems);
+ }
+
+ class udpTransportItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ udpTransportItemsVisitor(boost::shared_ptr<UDPTransportImplPriv> localTransport) : mLocalTransport(localTransport) { };
+
+ void visitSipHostItem(const ::AsteriskSCF::SIP::V1::SipHostItemPtr& hostItem)
+ {
+ mLocalTransport->mAddress = hostItem->host;
+ mLocalTransport->mPort = hostItem->port;
+ };
+ private:
+ boost::shared_ptr<UDPTransportImplPriv> mLocalTransport;
+ };
+
+ SipConfigurationItemVisitorPtr udpTransportVisitor = new udpTransportItemsVisitor(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(udpTransportVisitor);
+ }
+
+ // Reconcile all the changes received
+ if (localTransport->mTransport)
+ {
+ pjsip_transport_shutdown(localTransport->mTransport);
+ }
+
+ localTransport->mTransport = mImplPriv->mPJSipManager->createUDPTransport(localTransport->mAddress, localTransport->mPort);
+ };
+
+ void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransportGroup = mImplPriv->mConfiguredTCPTransports.find(group->name);
+ SipTCPTransportGroupPtr localTransport;
+
+ if (localTransportGroup == mImplPriv->mConfiguredTCPTransports.end())
+ {
+ localTransport = new SipTCPTransportGroup;
+ localTransport->name = group->name;
+ mImplPriv->mConfiguredTCPTransports.insert(make_pair(group->name, localTransport));
+ }
+ else
+ {
+ localTransport = (*localTransportGroup).second;
+ performSerialCheck(group->configurationItems, localTransport->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);
+ }
+ };
+
+ void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransportGroup = mImplPriv->mConfiguredTLSTransports.find(group->name);
+ SipTLSTransportGroupPtr localTransport;
+
+ if (localTransportGroup == mImplPriv->mConfiguredTLSTransports.end())
+ {
+ localTransport = new SipTLSTransportGroup;
+ localTransport->name = group->name;
+ mImplPriv->mConfiguredTLSTransports.insert(make_pair(group->name, localTransport));
+ }
+ else
+ {
+ localTransport = (*localTransportGroup).second;
+ performSerialCheck(group->configurationItems, localTransport->configurationItems);
+ }
+
+ class tlsTransportItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ private:
+ };
+
+ SipConfigurationItemVisitorPtr tlsTransportVisitor = new tlsTransportItemsVisitor();
+
+ 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(tlsTransportVisitor);
+ }
+ };
+
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ };
+
+ SipConfigurationGroupVisitorPtr v = new groupsVisitor(mImplPriv);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+}
+
+void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class groupsVisitor : public SipConfigurationGroupVisitor
+ {
+ public:
+ groupsVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+
+ void removeItems(SipConfigurationItemVisitor* visitor, ConfigurationItemDict& itemsToRemove,
+ ConfigurationItemDict& localItems)
+ {
+ for (ConfigurationItemDict::const_iterator item = itemsToRemove.begin();
+ item != itemsToRemove.end();
+ ++item)
+ {
+ ConfigurationItemDict::iterator localItem = localItems.find((*item).first);
+ if (localItem == localItems.end())
+ {
+ continue;
+ }
+ if (visitor != 0)
+ {
+ (*item).second->visit(visitor);
+ }
+ localItems.erase(localItem);
+ }
+ }
+
+ void visitSipGeneralGroup(const ::AsteriskSCF::SIP::V1::SipGeneralGroupPtr& group)
+ {
+ if (!mImplPriv->mGeneralGroup)
+ {
+ return;
+ }
+
+ class generalItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ private:
+ } generalVisitor;
+
+ removeItems(&generalVisitor, group->configurationItems, mImplPriv->mGeneralGroup->configurationItems);
+ };
+
+ void visitSipDomainGroup(const ::AsteriskSCF::SIP::V1::SipDomainGroupPtr& group)
+ {
+ std::map<std::string, SipDomainGroupPtr>::iterator localDomain = mImplPriv->mConfiguredDomains.find(group->domain);
+
+ if (localDomain == mImplPriv->mConfiguredDomains.end())
+ {
+ return;
+ }
+
+ class domainItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ private:
+ } domainVisitor;
+
+ removeItems(&domainVisitor, group->configurationItems, (*localDomain).second->configurationItems);
+ };
+
+ void visitSipUDPTransportGroup(const ::AsteriskSCF::SIP::V1::SipUDPTransportGroupPtr& group)
+ {
+ std::map<std::string, boost::shared_ptr<UDPTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredUDPTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredUDPTransports.end())
+ {
+ return;
+ }
+
+ class udpTransportItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ private:
+ } udpTransportVisitor;
+
+ removeItems(&udpTransportVisitor, group->configurationItems, (*localTransport).second->mGroup->configurationItems);
+ };
+
+ void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredTCPTransports.end())
+ {
+ return;
+ }
+
+ class tcpTransportItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ private:
+ } tcpTransportVisitor;
+
+ removeItems(&tcpTransportVisitor, group->configurationItems, (*localTransport).second->configurationItems);
+ };
+
+ void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredTLSTransports.end())
+ {
+ return;
+ }
+
+ class tlsTransportItemsVisitor : public SipConfigurationItemVisitor
+ {
+ public:
+ private:
+ } tlsTransportVisitor;
+
+ removeItems(&tlsTransportVisitor, group->configurationItems, (*localTransport).second->configurationItems);
+ };
+ private:
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ };
+
+ SipConfigurationGroupVisitorPtr v = new groupsVisitor(mImplPriv);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+}
+
+void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class visitor : public SipConfigurationGroupVisitor
+ {
+ public:
+ visitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+
+ void visitSipGeneralGroup(const ::AsteriskSCF::SIP::V1::SipGeneralGroupPtr& group)
+ {
+ if (!mImplPriv->mGeneralGroup)
+ {
+ return;
+ }
+
+ /* XXX What should we do as a result of this going away? */
+ mImplPriv->mGeneralGroup = 0;
+ };
+
+ void visitSipDomainGroup(const ::AsteriskSCF::SIP::V1::SipDomainGroupPtr& group)
+ {
+ std::map<std::string, SipDomainGroupPtr>::iterator localDomain = mImplPriv->mConfiguredDomains.find(group->domain);
+
+ if (localDomain == mImplPriv->mConfiguredDomains.end())
+ {
+ return;
+ }
+
+ /* XXX This needs to, like, notify pjsip probably */
+ mImplPriv->mConfiguredDomains.erase(localDomain);
+ };
+
+ void visitSipUDPTransportGroup(const ::AsteriskSCF::SIP::V1::SipUDPTransportGroupPtr& group)
+ {
+ std::map<std::string, boost::shared_ptr<UDPTransportImplPriv> >::iterator localTransport = mImplPriv->mConfiguredUDPTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredUDPTransports.end())
+ {
+ return;
+ }
+
+ // The act of removing the transport will destroy it and cause the transport to be shutdown
+ mImplPriv->mConfiguredUDPTransports.erase(localTransport);
+ };
+
+ void visitSipTCPTransportGroup(const ::AsteriskSCF::SIP::V1::SipTCPTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTCPTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTCPTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredTCPTransports.end())
+ {
+ return;
+ }
+
+ mImplPriv->mConfiguredTCPTransports.erase(localTransport);
+ };
+
+ void visitSipTLSTransportGroup(const ::AsteriskSCF::SIP::V1::SipTLSTransportGroupPtr& group)
+ {
+ std::map<std::string, SipTLSTransportGroupPtr>::iterator localTransport = mImplPriv->mConfiguredTLSTransports.find(group->name);
+
+ if (localTransport == mImplPriv->mConfiguredTLSTransports.end())
+ {
+ return;
+ }
+
+ mImplPriv->mConfiguredTLSTransports.erase(localTransport);
+ };
+ private:
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ };
+
+ SipConfigurationGroupVisitorPtr v = new visitor(mImplPriv);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+}
+
+};
+
+};
diff --git a/src/SipConfiguration.h b/src/SipConfiguration.h
new file mode 100644
index 0000000..ed03f52
--- /dev/null
+++ b/src/SipConfiguration.h
@@ -0,0 +1,62 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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.
+ */
+
+#pragma once
+
+#include <Ice/Ice.h>
+
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+
+#include "PJSipManager.h"
+#include "SipConfigurationIf.h"
+
+namespace AsteriskSCF
+{
+
+namespace SipSessionManager
+{
+
+ /*
+ * Private implementation class for ConfigurationServiceImpl.
+ */
+ class ConfigurationServiceImplPriv;
+
+ /**
+ * Implementation of the configuration service.
+ */
+ class ConfigurationServiceImpl : public AsteriskSCF::System::Configuration::V1::ConfigurationService
+ {
+ public:
+ ConfigurationServiceImpl(PJSipManager*);
+ 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&);
+ void setConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ void removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ void removeConfigurationGroups(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ private:
+ /**
+ * Private implementation details.
+ */
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ };
+
+}; //End namespace SipSessionManager
+
+}; //End namespace AsteriskSCF
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 2afe7ab..cf54c57 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -29,6 +29,7 @@
#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
#include <AsteriskSCF/System/Component/ReplicaIf.h>
#include <AsteriskSCF/SmartProxy.h>
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
#include <AsteriskSCF/Logger/IceLogger.h>
#include <AsteriskSCF/logger.h>
@@ -40,6 +41,7 @@
#include "PJSipManager.h"
#include "SipSession.h"
#include "SipStateReplicator.h"
+#include "SipConfiguration.h"
using namespace std;
using namespace AsteriskSCF::SipSessionManager;
@@ -50,6 +52,7 @@ using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::SessionCommunications::V1;
using namespace AsteriskSCF::SmartProxy;
+using namespace AsteriskSCF::System::Configuration::V1;
namespace
{
@@ -73,6 +76,7 @@ public:
// Smart pointers do your thing.
mReplicaService = 0;
mComponentService = 0;
+ mConfigurationService = 0;
mGlobalAdapter = 0;
mLocalAdapter = 0;
}
@@ -114,6 +118,7 @@ private:
Discovery::V1::ServiceManagementPrx mComponentServiceManagement;
ReplicaPtr mReplicaService;
ComponentServicePtr mComponentService;
+ ConfigurationServicePtr mConfigurationService;
PJSipManager *mPJSipManager;
SipStateReplicatorListenerPtr mReplicatorListener;
SipStateReplicatorListenerPrx mReplicatorListenerProxy;
@@ -129,6 +134,7 @@ private:
static const string ComponentServiceId("SipChannelComponent");
static const string EndpointLocatorObjectId("SipChannelEndpointLocator");
static const string ReplicaServiceId("SipChannelReplica");
+static const string ConfigurationServiceId("SipConfigurationService");
/**
* This class provides implementation for the ComponentService interface, which
@@ -519,6 +525,11 @@ void SipSessionManager::initialize(const std::string appName, const Ice::Communi
// it now.
mServiceLocator = ServiceLocatorPrx::checkedCast(mCommunicator->propertyToProxy("LocatorService.Proxy"));
+ // Create and publish our Configuration interface support.
+ mConfigurationService = new ConfigurationServiceImpl(mPJSipManager);
+ mGlobalAdapter->add(mConfigurationService, mCommunicator->stringToIdentity(ConfigurationServiceId));
+ lg(Debug) << "Created SIP Configuration Implementation";
+
// Create and publish our Replica interface support.
mReplicaService = new ReplicaImpl(mLocalAdapter);
mLocalAdapter->add(mReplicaService, mCommunicator->stringToIdentity(ReplicaServiceId));
commit 475da6c6e49647d883663e3b93e443c57f415169
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Feb 28 09:49:54 2011 -0400
Whoops, I removed SipConfigurationItem and didn't change where I used it.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 5752535..642c2ee 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -55,7 +55,13 @@ module V1
* Name of the domain being configured
*/
string domain;
+ };
+ /**
+ * Domain item for bindings
+ */
+ class SipBindingsItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ {
/**
* Addresses the domain is reachable over
*/
@@ -78,7 +84,7 @@ module V1
/**
* Host information configuration item
*/
- class SipHostItem extends SipConfigurationItem
+ class SipHostItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
{
/**
* String containing the IP address or string address
@@ -94,7 +100,7 @@ module V1
/**
* Crypto certificate configuration item
*/
- class SipCertificateItem extends SipConfigurationItem
+ class SipCertificateItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
{
/**
* Full certificate to use
@@ -105,7 +111,7 @@ module V1
/**
* Routing service configuration item
*/
- class SipRoutingItem extends SipConfigurationItem
+ class SipRoutingItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
{
/**
* Name of the routing service to use
@@ -116,7 +122,7 @@ module V1
/**
* RTP Media service configuration item
*/
- class SipRTPMediaServiceItem extends SipConfigurationItem
+ class SipRTPMediaServiceItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
{
/**
* Name of the RTP media service to use
@@ -127,7 +133,7 @@ module V1
/**
* Signaling NAT configuration item
*/
- class SipSignalingNATItem extends SipConfigurationItem
+ class SipSignalingNATItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
{
/**
* Boolean for whether STUN is enabled
@@ -138,7 +144,7 @@ module V1
/**
* Media NAT configuration item
*/
- class SipMediaNATItem extends SipConfigurationItem
+ class SipMediaNATItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
{
/**
* Boolean for whether symmetric RTP is enabled
@@ -164,7 +170,7 @@ module V1
/**
* Access control lists item
*/
- class SipACLItem extends SipConfigurationItem
+ class SipACLItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
{
/**
* Name of this ACL item. A user may want to have multiple.
@@ -195,7 +201,7 @@ module V1
/**
* User agent presentation configuration item
*/
- class SipUserAgentItem extends SipConfigurationItem
+ class SipUserAgentItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
{
/**
* String that our user agent should appear as
commit 0adc89a842ccb2893a472539fe89ffb2e032f41a
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Feb 28 09:41:51 2011 -0400
Items do not need a visitor.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 775a957..5752535 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -33,13 +33,6 @@ module V1
};
/**
- * Local visitor class for visiting SIP configuration items
- */
- ["visitor"] local class SipConfigurationItemVisitor
- {
- };
-
- /**
* Generic SIP configuration group
*/
["visitor:SipConfigurationGroupVisitor"] class SipConfigurationGroup extends AsteriskSCF::System::Configuration::V1::ConfigurationGroup
@@ -47,13 +40,6 @@ module V1
};
/**
- * Generic SIP configuration item
- */
- ["visitor:SipConfigurationItemVisitor"] class SipConfigurationItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
- {
- };
-
- /**
* General SIP configuration group that contains general items related to the SIP component as a whole
*/
class SipGeneralGroup extends SipConfigurationGroup
commit f9be80d1e56708c2673f952d14a0a42b35cb891e
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Feb 28 09:10:49 2011 -0400
This should not be here.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 90c6977..775a957 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -26,11 +26,6 @@ module SIP
module V1
{
/**
- * String representation of the version of this interface
- */
- const string Version = "V1";
-
- /**
* Local visitor class for visiting SIP configuration groups
*/
["visitor"] local class SipConfigurationGroupVisitor
commit c004843947a6e1724a08225c7791cb46eee01304
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Feb 28 08:48:10 2011 -0400
Update configuration slice to actual, well, configuration slice.
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 420c1c3..90c6977 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -1,4 +1,22 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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.
+ */
+
#pragma once
+#include <Ice/BuiltinSequences.ice>
+#include "AsteriskSCF/System/Component/ConfigurationIf.ice"
module AsteriskSCF
{
@@ -7,175 +25,226 @@ module SIP
["suppress"]
module V1
{
- const string Version = "V1";
-
- /**
- * Machine-specific SIP configuration
- * information. Currently only includes
- * bind addresses/ports. Other options
- * that may be here in future times are
- * access control options, and global
- * NAT settings.
- */
- class SipGeneralConfiguration
- {
- // Our UDP IPv4 bind address and port
- string UdpBindAddressv4;
- // Our UDP IPv6 bind address and port
- string UdpBindAddressv6;
- // Our TCP IPv4 bind address and port
- string TcpBindAddressv4;
- // Our TCP IPv6 bind address and port
- // Currently, PJSIP does not support
- // IPv6 for TCP transport.
- string TcpBindAddressv6;
- // Our TLS IPv4 bind address and port
- string TlsBindAddressv4;
- // Our TLS IPv6 bind address and port
- // Currently, PJSIP does not support
- // IPv6 for TLS transport.
- string TlsBindAddressv6;
- };
-
- /**
- * General purpose direction enumeration.
- * Useful for detemining policies regarding
- * which types of endpoints can send and
- * receive specific types of SIP messages.
- * The perspective used for directions is
- * from Asterisk SCF's point of view. So
- * INBOUND means indicates traffic to
- * Asterisk SCF, and OUTBOUND indicates
- * traffic to the endpoint.
- */
- enum Direction
- {
- NONE,
- INBOUND,
- OUTBOUND,
- BOTH
- };
-
- /**
- * Transport configuration options for
- * Endpoints. Currently only consists
- * of the endpoint's IP address and port,
- * plus an indication of whether the endpoint
- * requires a secure transport.
- */
- class SipEndpointTransportConfig
- {
- // The IP address and port of the endpoint.
- string IpAddress;
- // Security policy. In which call directions
- // do we require TLS?
- Direction secureTransport;
- };
-
- /**
- * Authentication configuration. Currently
- * only contains a secret. Other options may
- * include a list of SIP methods on which to
- * require authentication and a selection of
- * what algorithm to use when authenticating.
- */
- class SipEndpointAuthConfig
- {
- // Password
- string secret;
- };
-
- /**
- * Registration configuration. Consists
- * of the direction to register in, plus
- * expiration parameters
- */
- class SipEndpointRegistrationConfig
- {
- // In which direction should a REGISTER
- // be expected. This is a case where the
- // BOTH option is not permitted.
- Direction registerDirection;
- // If sending an outbound REGISTER,
- // our preferred expiration time.
- int outboundExpiry;
- // On inbound registrations, the largest
- // expiration we allow.
- int inboundMaxExpiry;
- // On inbound registrations, the smallest
- // expiration we allow.
- int inboundMinExpiry;
- };
-
- /**
- * Session options. Deals with INVITE sessions,
- * the most common type being a phone call.
- */
- sequence<string> OptionSeq;
- class SipEndpointSessionConfig
- {
- // The direction in which sessions can be
- // started with this endpoint.
- Direction callDirection;
- // Additional options supported by this
- // endpoint.
- OptionSeq supportedOptions;
- // The source IP address and port to use
- // when contacting this endpoint.
- string sourceAddress;
- };
-
- /**
- * Media options. Deals with types of media
- * supported by an endpoint. Currently only
- * contains a sequence of strings representing
- * supported codecs.
- */
- sequence<string> CodecSeq;
- class SipEndpointMediaConfig
- {
- CodecSeq allowedCodecs;
- };
-
- enum SubscriptionRole
- {
- SUBSCRIBER,
- NOTIFIER,
- EVENTPUBLICATIONAGENT,
- EVENTSTATECOMPOSITOR
- };
- /**
- * Subscription options. Deals with options
- * for subscriptions
- */
- class SipEndpointSubscriptionConfig
- {
- // The role Asterisk SCF plays in the
- // subscription.
- SubscriptionRole role;
- // For outbound SUBSCRIBE and PUBLISH
- // messages, our preferred expiration interval.
- int outboundExpiry;
- // For inbound SUBSCRIBE and PUBLISH
- // messages, our minimum allowed expiration interval.
- int inboundMinExpiry;
- // For inbound SUBSCRIBE and PUBLISH
- // messages, our maximum allowed expiration interval.
- int inboundMaxExpiry;
- // The name of the event package, as would
- // appear in the Event header of SIP messages.
- string eventPackage;
- };
-
- class SipEndpointConfig
- {
- SipEndpointTransportConfig transportConfig;
- SipEndpointAuthConfig authConfig;
- SipEndpointRegistrationConfig registrationConfig;
- SipEndpointSessionConfig sessionConfig;
- SipEndpointMediaConfig mediaConfig;
- SipEndpointSubscriptionConfig subscriptionConfig;
- };
+ /**
+ * String representation of the version of this interface
+ */
+ const string Version = "V1";
+
+ /**
+ * Local visitor class for visiting SIP configuration groups
+ */
+ ["visitor"] local class SipConfigurationGroupVisitor
+ {
+ };
+
+ /**
+ * Local visitor class for visiting SIP configuration items
+ */
+ ["visitor"] local class SipConfigurationItemVisitor
+ {
+ };
+
+ /**
+ * Generic SIP configuration group
+ */
+ ["visitor:SipConfigurationGroupVisitor"] class SipConfigurationGroup extends AsteriskSCF::System::Configuration::V1::ConfigurationGroup
+ {
+ };
+
+ /**
+ * Generic SIP configuration item
+ */
+ ["visitor:SipConfigurationItemVisitor"] class SipConfigurationItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ {
+ };
+
+ /**
+ * General SIP configuration group that contains general items related to the SIP component as a whole
+ */
+ class SipGeneralGroup extends SipConfigurationGroup
+ {
+ };
+
+ /**
+ * SIP Domain group, used to configure a specific domain
+ */
+ class SipDomainGroup extends SipConfigurationGroup
+ {
+ /**
+ * Name of the domain being configured
+ */
+ string domain;
+
+ /**
+ * 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
+ */
+ 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
+ */
+ class SipHostItem extends SipConfigurationItem
+ {
+ /**
+ * String containing the IP address or string address
+ */
+ string host;
+
+ /**
+ * Port number
+ */
+ int port;
+ };
+
+ /**
+ * Crypto certificate configuration item
+ */
+ class SipCertificateItem extends SipConfigurationItem
+ {
+ /**
+ * Full certificate to use
+ */
+ string certificate;
+ };
+
+ /**
+ * 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;
+ };
+
+ /**
+ * 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;
+ };
+
+ /**
+ * User agent presentation configuration item
+ */
+ class SipUserAgentItem extends SipConfigurationItem
+ {
+ /**
+ * String that our user agent should appear as
+ */
+ string userAgent;
+ };
+
+ /**
+ * Group of configuration items related to a UDP transport
+ */
+ class SipUDPTransportGroup extends SipTransportGroup
+ {
+ };
+
+ /**
+ * Group of configuration items related to a TCP transport
+ */
+ class SipTCPTransportGroup extends SipTransportGroup
+ {
+ };
+
+ /**
+ * Group of configuration items related to a TLS transport
+ */
+ class SipTLSTransportGroup extends SipTransportGroup
+ {
+ };
+
}; //module V1
+
}; //module SIP
-}; //module AsteriskSCF
+
+}; //module Asterisk SCF
commit 7217fe2813f620da720dfbdd65951ce0e8a6942c
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Feb 7 14:47:52 2011 -0600
Get rid of some bad code involving pjsip_endpoints.
Specifically, the PJSipManager was being fed one of its own private
members in order to pass along to the various PJSIP modules it would
register. This was overwhelmingly silly. Furthermore, I removed
the getEndpoint() method from PJSipManager because it's not needed.
Any interaction with the pjsip_endpoint should be done through
some public member function of PJSipManager instead.
Next change is going to involve the handling of PJSipModules within
the PJSipManager. This is going to have a direct effect on the
authentication extension point I'm currently working on.
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 366ce6f..22b5955 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -70,26 +70,20 @@ PJSipManager::PJSipManager(Ice::PropertiesPtr props)
}
}
-void PJSipManager::registerSessionModule(pjsip_endpoint *endpt,
- boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
+void PJSipManager::registerSessionModule(boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
AsteriskSCF::System::Component::V1::ReplicaPtr replica
)
{
- mSessionModule = new PJSipSessionModule(endpt, endpointFactoryPtr, sessionRouter,
+ mSessionModule = new PJSipSessionModule(mEndpoint, endpointFactoryPtr, sessionRouter,
serviceLocator, stateReplicator, replica);
}
-void PJSipManager::registerLoggingModule(pjsip_endpoint *endpt)
+void PJSipManager::registerLoggingModule()
{
- mLoggingModule = new PJSipLoggingModule(endpt);
-}
-
-pjsip_endpoint *PJSipManager::getEndpoint()
-{
- return mEndpoint;
+ mLoggingModule = new PJSipLoggingModule(mEndpoint);
}
PJSipSessionModule *PJSipManager::getSessionModule()
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 3db7875..eaedf0d 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -68,8 +68,7 @@ public:
* Register the PJSipSessionModule, responsible
* for basic call handling
*/
- void registerSessionModule(pjsip_endpoint *endpt,
- boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
+ void registerSessionModule(boost::shared_ptr<SipEndpointFactory> endpointFactoryPtr,
AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> sessionRouter,
AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx serviceLocator,
AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> stateReplicator,
@@ -80,7 +79,7 @@ public:
* Register the PJSipLoggingModule, responsible
* for logging incoming and outgoing SIP messages
*/
- void registerLoggingModule(pjsip_endpoint *endpt);
+ void registerLoggingModule();
private:
static PJSipManager *mInstance;
pjsip_endpoint *mEndpoint;
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 4c5a5ae..2afe7ab 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -94,7 +94,7 @@ private:
void registerWithRoutingService();
void deregisterFromRoutingService();
void configureEndpoints();
- void registerPJSipModules(pjsip_endpoint *endpt);
+ void registerPJSipModules();
void deregisterFromStateReplicator();
bool mDone;
@@ -445,7 +445,7 @@ void SipSessionManager::configureEndpoints()
}
}
-void SipSessionManager::registerPJSipModules(pjsip_endpoint *endpt)
+void SipSessionManager::registerPJSipModules()
{
Ice::PropertiesPtr props = mCommunicator->getProperties();
Ice::StringSeq moduleNames = props->getPropertyAsList("Sip.Modules");
@@ -459,12 +459,12 @@ void SipSessionManager::registerPJSipModules(pjsip_endpoint *endpt)
//we'll just do it here instead.
if (*i == "Session")
{
- mPJSipManager->registerSessionModule(endpt, mEndpointFactory,
+ mPJSipManager->registerSessionModule(mEndpointFactory,
mSessionRouter, mServiceLocator, mStateReplicator, mReplicaService);
}
else if (*i == "Logging" || *i == "Logger")
{
- mPJSipManager->registerLoggingModule(endpt);
+ mPJSipManager->registerLoggingModule();
}
}
lg(Debug) << "Registered PJSIP modules";
@@ -576,7 +576,7 @@ void SipSessionManager::start(const string& name, const Ice::CommunicatorPtr& ic
// Locate the State Replicator so we can fail over!
locateStateReplicator();
- registerPJSipModules(mPJSipManager->getEndpoint());
+ registerPJSipModules();
// Register with the state replicator if we are a listener
registerWithStateReplicator();
commit 94fbff7a05572c610bcf98bca77a9a8ec8afa4b8
Author: David M. Lee <dlee at digium.com>
Date: Thu Jan 20 12:33:27 2011 -0600
Refactored out several install functions for installation.
* asterisk_scf_component_install - Install a component
* asterisk_scf_slice_headers_install - Install generated .h files
* asterisk_scf_slice_install - Install .ice files
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 26732f6..d03df8c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -51,9 +51,7 @@ pjproject_link(SipSessionManager pjmedia)
pjproject_link(SipSessionManager pjlib-util)
pjproject_link(SipSessionManager pjlib)
-install(TARGETS SipSessionManager
- LIBRARY DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR}
- RUNTIME DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR})
+asterisk_scf_component_install(SipSessionManager)
asterisk_scf_component_init(SipStateReplicator CXX)
@@ -80,6 +78,4 @@ asterisk_scf_component_build_icebox(SipStateReplicator)
target_link_libraries(SipStateReplicator logging-client)
target_link_libraries(SipStateReplicator asterisk-scf-api)
-install(TARGETS SipStateReplicator
- LIBRARY DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR}
- RUNTIME DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR})
+asterisk_scf_component_install(SipStateReplicator)
commit 404f958889ea1cc8aaa8e08babd16e1aa798e3b9
Author: David M. Lee <dlee at digium.com>
Date: Thu Jan 13 20:25:54 2011 -0600
Properly install the SIP components.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 538af14..26732f6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -51,7 +51,9 @@ pjproject_link(SipSessionManager pjmedia)
pjproject_link(SipSessionManager pjlib-util)
pjproject_link(SipSessionManager pjlib)
-#asterisk_scf_component_install(SipSessionManager RUNTIME bin "SIP Session Manager" SipSessionManager)
+install(TARGETS SipSessionManager
+ LIBRARY DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR}
+ RUNTIME DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR})
asterisk_scf_component_init(SipStateReplicator CXX)
@@ -78,4 +80,6 @@ asterisk_scf_component_build_icebox(SipStateReplicator)
target_link_libraries(SipStateReplicator logging-client)
target_link_libraries(SipStateReplicator asterisk-scf-api)
-#asterisk_scf_component_install(SipStateReplicator RUNTIME bin "Sip State Replicator" SipStateReplicator)
+install(TARGETS SipStateReplicator
+ LIBRARY DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR}
+ RUNTIME DESTINATION ${ASTERISK_SCF_INSTALL_ICEBOX_DIR})
commit 5e9a29497d788051726638be0920c200d8e6c333
Author: David M. Lee <dlee at digium.com>
Date: Wed Jan 19 12:18:10 2011 -0600
We require cmake 2.8 or better.
Now make it a specific "You're cmake is old" failure, as opposed to some
random failure later on.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index abcb21a..7eb22fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,8 +10,8 @@
if(NOT integrated_build STREQUAL "true")
- # Minimum we require is 2.6
- cmake_minimum_required(VERSION 2.6)
+ # Minimum we require is 2.8
+ cmake_minimum_required(VERSION 2.8)
# Include common AsteriskSCF build infrastructure. Make sure your submodules
# are pulled.
commit dfd4ca15e66cde8fb9fd4bd088a67159e12dc1aa
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Jan 17 17:22:43 2011 -0600
Remove unneeded std::endls.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 3c1ece4..3080204 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -96,14 +96,14 @@ public:
}
catch (const std::exception &e)
{
- lg(Debug) << "ConnectBridgedSessionsCallback sending 400 due to exception: " << e.what() << std::endl;
+ lg(Debug) << "ConnectBridgedSessionsCallback sending 400 due to exception: " << e.what();
pjsip_dlg_respond(mInvSession->dlg, mRData, 400, NULL, NULL, NULL);
return;
}
pjsip_dlg_respond(mInvSession->dlg, mRData, 200, NULL, NULL, NULL);
Ice::Current current;
- lg(Debug) << "ConnectBridgedSessionsCallback calling session->stop(). " << std::endl;
+ lg(Debug) << "ConnectBridgedSessionsCallback calling session->stop(). ";
mSession->stop(new ResponseCode(16), current);
}
private:
@@ -129,21 +129,21 @@ public:
}
catch (const AsteriskSCF::Core::Routing::V1::DestinationNotFoundException &)
{
- lg(Debug) << "ConnectBridgedSessionsWithDestination sending 404 due to destination not found for target: "<< mTarget << std::endl;
+ lg(Debug) << "ConnectBridgedSessionsWithDestination sending 404 due to destination not found for target: "<< mTarget;
pjsip_dlg_respond(mInvSession->dlg, mRData, 404, NULL, NULL, NULL);
return;
}
catch (const std::exception &e)
{
- lg(Debug) << "ConnectBridgedSessionsWithDestination sending 400 due to exception: " << e.what() << std::endl;
+ lg(Debug) << "ConnectBridgedSessionsWithDestination sending 400 due to exception: " << e.what();
pjsip_dlg_respond(mInvSession->dlg, mRData, 400, NULL, NULL, NULL);
return;
... 1151 lines suppressed ...
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list