[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Sep 3 10:05:43 CDT 2010


branch "master" has been updated
       via  0cc4395275aa7e551e5e51cca150c63639979e16 (commit)
       via  f9b1d11bf0e6efe45cca6ae1615d7cccef941c36 (commit)
      from  ebf600990a908f4fb0f33b9aa0d24040bee9679c (commit)

Summary of changes:
 local-slice/CMakeLists.txt               |    2 +-
 src/PJSipSessionModule.cpp               |    2 +-
 src/SipChannelServiceEndpointLocator.cpp |    4 +-
 src/SipEndpoint.cpp                      |   59 ++++++++++-
 src/SipEndpoint.h                        |  167 +++++++++++++++++++++++++++++-
 src/SipEndpointFactory.cpp               |   15 +++-
 src/SipEndpointFactory.h                 |    2 +
 7 files changed, 242 insertions(+), 9 deletions(-)


- Log -----------------------------------------------------------------
commit 0cc4395275aa7e551e5e51cca150c63639979e16
Author: Mark Michelson <mmichelson at digium.com>
Date:   Fri Sep 3 10:06:31 2010 -0500

    Add a method to the SipEndpointFactory to retrieve an endpoint by name.
    
    The factory now has some "manager" capabilities to it, so it may be up
    for renaming at some point...

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index e54956d..52d9ab7 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -120,7 +120,7 @@ static void handle_new_invite(pjsip_rx_data *rdata)
 	//but for now have it there just so stuff'll compile!
 	//This should be looking up an endpoint instead of creating
 	//one.
-	SipEndpointPtr* caller = new SipEndpointPtr(factory->createEndpoint("Butt", NULL));
+	SipEndpointPtr* caller = new SipEndpointPtr(factory->findByName("Butt"));
 	(*caller)->setInviteSession(inv_session);
 	(*caller)->setDialog(dlg);
 
diff --git a/src/SipChannelServiceEndpointLocator.cpp b/src/SipChannelServiceEndpointLocator.cpp
index 30b24e5..80507d0 100644
--- a/src/SipChannelServiceEndpointLocator.cpp
+++ b/src/SipChannelServiceEndpointLocator.cpp
@@ -21,9 +21,7 @@ namespace SipChannelService
 Hydra::Core::Endpoint::V1::EndpointSeq SipChannelServiceEndpointLocator::lookup(const ::std::string& destination, const Ice::Current&)
 {
 	Hydra::Core::Endpoint::V1::EndpointSeq endpoints;
-	// XXX This should be looking up an endpoint instead of creating one.
-	// Just so it'll compile at the moment, I'll pass in a NULL properties pointer
-	SipEndpointPtr endpoint = mEndpointFactory->createEndpoint(destination, NULL);
+	SipEndpointPtr endpoint = mEndpointFactory->findByName(destination);
 	endpoints.push_back(endpoint->getSessionEndpoint());
 	return endpoints;
 }
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index c983616..3a678e8 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -195,6 +195,11 @@ public:
       return (this->mInviteSession == other.mInviteSession);
    }
 
+   bool operator==(const std::string &name) const
+   {
+      return (mName == name);
+   }
+
    void destroy();
 
    pjmedia_sdp_session *createSDPOffer();
diff --git a/src/SipEndpointFactory.cpp b/src/SipEndpointFactory.cpp
index f3f1d47..39e9852 100644
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@ -29,5 +29,18 @@ void SipEndpointFactory::remove(SipEndpointPtr endpoint)
    mEndpoints.erase(std::remove(mEndpoints.begin(), mEndpoints.end(), endpoint), mEndpoints.end());
 }
 
+SipEndpointPtr SipEndpointFactory::findByName(std::string endpointName)
+{
+   std::vector<SipEndpointPtr>::iterator iter;
+   for (iter = mEndpoints.begin(); iter != mEndpoints.end(); ++ iter)
+   {
+      if (*(*iter) == endpointName)
+	  {
+	  	return *iter;
+	  }
+   }
+   return 0;
+}
+
 }; // end SipChannelService
 }; // end Hydra
diff --git a/src/SipEndpointFactory.h b/src/SipEndpointFactory.h
index ccdaf0a..c6c6247 100644
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@ -34,6 +34,8 @@ SipEndpointFactory(Ice::ObjectAdapterPtr adapter) : mAdapter(adapter) { };
    SipEndpointPtr createEndpoint(std::string destination, Ice::PropertiesPtr props);
 
    void remove(SipEndpointPtr);
+
+   SipEndpointPtr findByName(std::string endpointName);
 private:
    /**
     * A pointer to the object adapter that endpoints will be added to.

commit f9b1d11bf0e6efe45cca6ae1615d7cccef941c36
Author: Mark Michelson <mmichelson at digium.com>
Date:   Fri Sep 3 09:19:27 2010 -0500

    Switch from using slice to C++ classes for configuration.
    
    With this, I now can parse endpoint transport options. The
    next thing I'll do is to add a method to the SipEndpointFactory
    to retrieve an endpoint by name.

diff --git a/local-slice/CMakeLists.txt b/local-slice/CMakeLists.txt
index 8c9d223..3c4aecb 100644
--- a/local-slice/CMakeLists.txt
+++ b/local-slice/CMakeLists.txt
@@ -1,3 +1,3 @@
 # Compile SIP Channel Service Component's own slice
 hydra_compile_slice(SipIf.ice lib "SIP Service Slice Types" SipChannelService)
-hydra_compile_slice(SipConfigurationIf.ice lib "SIP Configuration Slice Types" SipChannelService)
+#hydra_compile_slice(SipConfigurationIf.ice lib "SIP Configuration Slice Types" SipChannelService)
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index ddba338..4779c9f 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -9,7 +9,6 @@
 #include <Ice/Ice.h>
 #include <IceUtil/UUID.h>
 
-#include "SipEndpoint.h"
 #include "SipChannelServiceDataModel.h"
 #include "PJSipManager.h"
 #include "SipEndpointFactory.h"
@@ -238,8 +237,10 @@ private:
 /**
  * Default constructor.
  */
-SipEndpoint::SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpointFactory> factory, Ice::PropertyDict props) : mAdapter(adapter), mEndpointFactory(factory)
+SipEndpoint::SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpointFactory> factory, std::string name, Ice::PropertyDict props)
+: mName(name), mAdapter(adapter), mEndpointFactory(factory)
 {
+   std::cout << "Constructing SIP endpoint " << name << std::endl;
    mSessionEndpoint = new Hydra::Session::V1::SessionEndpoint();
    mSessionEndpoint->id = new Hydra::Core::Endpoint::V1::EndpointId();
    mSessionEndpoint->id->endpointManagerId = "pjsip";
@@ -390,6 +391,60 @@ void SipEndpoint::setRemoteDetails(std::string destination, int port)
 
 void SipEndpoint::setConfiguration(Ice::PropertyDict props)
 {
+	setTransportConfiguration(props);
+	//setAuthConfiguration(props);
+	//setRegistrationConfiguration(props);
+	//setSessionConfiguration(props);
+	//setMediaConfiguration(props);
+	//setSubscriptionConfiguration(props);
+}
+
+void SipEndpoint::setTransportConfiguration(Ice::PropertyDict props)
+{
+	std::string prefix("Sip.Endpoint.");
+	prefix.append(mName);
+	prefix.append(".Transport.");
+	// Got the basic prefix. Now get the known config options.
+	Ice::PropertyDict::iterator IpAddress = props.find(prefix + "Address");
+	if (IpAddress != props.end())
+	{
+		pj_str_t addr;
+		pj_cstr(&addr, IpAddress->second.c_str());
+		if (pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &addr, &mConfig.transportConfig.address) != PJ_SUCCESS)
+		{
+			std::cerr << "[ERROR] Bad address specifier in transport configuration for SIP endpoint " << mName << std::endl;
+		}
+	}
+	Ice::PropertyDict::iterator direction = props.find(prefix + "SecureTransport");
+	if (direction != props.end())
+	{
+		mConfig.transportConfig.secureTransport = mConfig.stringToDirection(direction->second);
+	}
+}
+
+Direction SipEndpointConfig::stringToDirection(std::string directionString)
+{
+	if (directionString == "Both")
+	{
+		return BOTH;
+	}
+	else if (directionString == "Inbound")
+	{
+		return INBOUND;
+	}
+	else if (directionString == "Outbound")
+	{
+		return OUTBOUND;
+	}
+	else if (directionString == "None")
+	{
+		return NONE;
+	}
+	else
+	{
+		std::cerr << "[WARNING] Invalid direction " << directionString << " provided. Assuming 'None'" << std::endl;
+		return NONE;
+	}
 }
 
 }; // end SipChannelService
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index c18f962..c983616 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -35,10 +35,161 @@ class SipSignalCommands;
 class SipSignalCallback;
 class SipEndpointFactory;
 
+/**
+ * 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
+{
+public:
+	// The IP address and port of the endpoint.
+	pj_sockaddr address;
+	// 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
+{
+public:
+	// Password
+	std::string secret;
+};
+
+/**
+ * Registration configuration. Consists
+ * of the direction to register in, plus
+ * expiration parameters
+ */
+class SipEndpointRegistrationConfig
+{
+public:
+	// 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.
+ */
+class SipEndpointSessionConfig
+{
+public:
+	// The direction in which sessions can be
+	// started with this endpoint.
+	Direction callDirection;
+	// Additional options supported by this
+	// endpoint.
+	std::vector<std::string> supportedOptions;
+	// The source IP address and port to use
+	// when contacting this endpoint.
+	std::string sourceAddress;
+};
+
+/**
+ * Media options. Deals with types of media
+ * supported by an endpoint. Currently only
+ * contains a sequence of strings representing
+ * supported codecs.
+ */
+class SipEndpointMediaConfig
+{
+public:
+	std::string allowedCodecs;
+};
+
+enum SubscriptionRole
+{
+	SUBSCRIBER,
+	NOTIFIER,
+	EVENTPUBLICATIONAGENT,
+	EVENTSTATECOMPOSITOR
+};
+/**
+ * Subscription options. Deals with options
+ * for subscriptions
+ */
+class SipEndpointSubscriptionConfig
+{
+public:
+	// 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.
+	std::string eventPackage;
+};
+
+class SipEndpointConfig
+{
+public:
+	SipEndpointTransportConfig transportConfig;
+	SipEndpointAuthConfig authConfig;
+	SipEndpointRegistrationConfig registrationConfig;
+	SipEndpointSessionConfig sessionConfig;
+	SipEndpointMediaConfig mediaConfig;
+	SipEndpointSubscriptionConfig subscriptionConfig;
+
+	/* Convert a specified direction string into its proper
+	 * enumerated value.
+	 */
+	Direction stringToDirection(std::string directionString);
+private:
+};
+
 class SipEndpoint : public IceUtil::Shared
 {
 public:
-   SipEndpoint(Ice::ObjectAdapterPtr, boost::shared_ptr<SipEndpointFactory>, Ice::PropertyDict props);
+   SipEndpoint(Ice::ObjectAdapterPtr, boost::shared_ptr<SipEndpointFactory>, std::string name, Ice::PropertyDict props);
 
    bool operator==(const SipEndpoint &other) const {
       return (this->mInviteSession == other.mInviteSession);
@@ -103,6 +254,13 @@ private:
 	*/
    void setConfiguration(Ice::PropertyDict props);
 
+   void setTransportConfiguration(Ice::PropertyDict props);
+
+   /**
+	* The name of the endpoint
+	*/
+   std::string mName;
+
    /**
     * An instance of signal commands.
     */
@@ -162,6 +320,8 @@ private:
     * An instance of SessionEndpoint containing session details.
     */
    Hydra::Session::V1::SessionEndpointPtr mSessionEndpoint;
+
+   SipEndpointConfig mConfig;
 };
 
 /**
diff --git a/src/SipEndpointFactory.cpp b/src/SipEndpointFactory.cpp
index a9252b8..f3f1d47 100644
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@ -19,7 +19,7 @@ SipEndpointPtr SipEndpointFactory::createEndpoint(std::string destination, Ice::
    std::string prefix("Sip.Endpoint.");
    prefix.append(destination);
    Ice::PropertyDict endpointProps = props->getPropertiesForPrefix(prefix);
-   SipEndpointPtr endpoint = new SipEndpoint(mAdapter, shared_from_this(), endpointProps);
+   SipEndpointPtr endpoint = new SipEndpoint(mAdapter, shared_from_this(), destination, endpointProps);
    mEndpoints.push_back(endpoint);
    return endpoint;
 }

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list