[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
Mon May 23 10:36:03 CDT 2011


branch "master" has been updated
       via  ccfb81d546c08b540f175a65fc905123f430f4fc (commit)
       via  4709f65485b46d0c5299d7e8877c1c7b58326444 (commit)
       via  e67a41c2641c54ab24d231d2d7e12ad17825bda3 (commit)
      from  6e45f7d7d7ec3e8be48c53e0b581a946171b1c59 (commit)

Summary of changes:
 config/Sip.config                  |    5 ++++-
 config/SipConfigurator.py          |    5 +++++
 local-slice/SipConfigurationIf.ice |   11 +++++++++++
 src/SipConfiguration.cpp           |   32 +++++++++++++++++++++-----------
 src/SipEndpoint.cpp                |    5 +++++
 src/SipEndpoint.h                  |    1 +
 src/SipSession.cpp                 |   15 +++++++++++++--
 7 files changed, 60 insertions(+), 14 deletions(-)


- Log -----------------------------------------------------------------
commit ccfb81d546c08b540f175a65fc905123f430f4fc
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon May 23 12:35:10 2011 -0300

    Incorporate review feedback.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index cadb6b7..2731b02 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -429,7 +429,7 @@ void SipSession::start(const Ice::Current&)
     SipEndpointConfig &config = mImplPriv->mEndpoint->getConfig();
 
     std::string prefix;
-    if (config.transportConfig.secureTransport != NONE)
+    if (config.transportConfig.secureTransport == OUTBOUND || config.transportConfig.secureTransport == BOTH)
     {
 	prefix = "sips";
     }

commit 4709f65485b46d0c5299d7e8877c1c7b58326444
Merge: e67a41c 6e45f7d
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon May 23 12:34:12 2011 -0300

    Merge branch 'master' into tls
    
    Conflicts:
    	config/Sip.config
    	config/SipConfigurator.py
    	src/SipConfiguration.cpp
    	src/SipEndpoint.cpp
    	src/SipEndpoint.h

diff --cc config/Sip.config
index a4826b3,e1f3937..176d796
--- a/config/Sip.config
+++ b/config/Sip.config
@@@ -73,7 -73,7 +73,10 @@@ targetport=506
  #sourcehost=
  # Source port of the transport to use
  #sourceport=
 -# What directions calls are permitted in. Valid options are inbound, outbound, and both.
 +# What directions calls are permitted in. Valid options are none, inbound, outbound, and both.
  direction=both
 +# What directions secure transport is required in. Valid options are none, inbound, outbound, and both.
 +securetransport=none
+ # Whether to use IPv6 for media transport or not
+ rtpoveripv6=no
++
diff --cc config/SipConfigurator.py
index 7398e9d,4b820f2..1a63436
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@@ -107,15 -107,13 +107,18 @@@ class SipSectionVisitors(Configurator.S
                      return AsteriskSCF.SIP.V1.SipAllowableCallDirection.Outbound
                  elif self.config.get(section, item) == 'both':
                      return AsteriskSCF.SIP.V1.SipAllowableCallDirection.Both
 +                elif self.config.get(section, item) == 'none':
 +                    return AsterisksCF.SIP.V1.SipAllowableCallDirection.Disabled
  
          transformer = AllowableCallDirectionTransformer(config)
 +
          mapper.map('direction', AsteriskSCF.SIP.V1.SipAllowableCallDirectionItem(), 'callDirection', 'callDirection', transformer.get, None)
  
 +        mapper.map('securetransport', AsteriskSCF.SIP.V1.SipEndpointTransportItem(), 'secureTransport', 'transport', transformer.get, None)
 +
+         item = AsteriskSCF.SIP.V1.RTPMediaServiceItem()
+         mapper.map('rtpoveripv6', item, 'requireIPv6', 'mediaservice', config.getboolean, None)
+ 
          item = AsteriskSCF.SIP.V1.SipCryptoCertificateItem()
          mapper.map('certificateauthorityfile', item, 'certificateAuthority', 'cryptocert', config.get, None)
          mapper.map('certificatefile', item, 'certificate', 'cryptocert', config.get, None)
diff --cc src/SipConfiguration.cpp
index 633d70a,055f7b1..f65f05d
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@@ -34,13 -47,302 +47,312 @@@ namespace AsteriskSC
  namespace SipSessionManager
  {
  
- using namespace AsteriskSCF::SIP::V1;
- using namespace AsteriskSCF::System::Configuration::V1;
- using namespace AsteriskSCF::Core::Routing::V1;
+ /**
+  *
+  * The createGroupTemplate() pattern implements boilerplate for creating "empty" copies of a group. All of the basic
+  * group elements should be copied except for the group dictionary. This will be copied separately.
+  *
+  **/
+ 
+ /**
+  * A generic instance of the createGroupTemplate() that creates a new, empty instance of a named group.
+  *
+  * @param group an instance of the group to create a template for.
+  * @return a new instance of type T that may contain members copied from the group parameter.
+  **/
+ template <typename T>
+ T createGroupTemplate(const T& group)
+ {
+     T result = new typename T::element_type;
+     assert(result);
+     result->name = group->name;
+     return result;
+ }
+ 
+ /**
+  * A specialization for SipGeneralGroup, which contains no additional members.
+  **/
+ template<>
+ SipGeneralGroupPtr createGroupTemplate(const SipGeneralGroupPtr&)
+ {
+     return new SipGeneralGroup;
+ }
+ 
+ /**
+  * A specialization for SipDomainGroup which has a data member with a different name.
+  **/
+ template <>
+ SipDomainGroupPtr createGroupTemplate(const SipDomainGroupPtr& source)
+ {
+     SipDomainGroupPtr r(new SipDomainGroup);
+     r->domain = source->domain;
+     return r;
+ }
+ 
+ /**
+  *
+  * performSerialCheck checks to see if an update is out of order and currently ... does nothing. We need to add some
+  * logging or update filtering.
+  *
+  * @param changedItems the items in the update.
+  *
+  * @param localItems the current items in the configuration.
+  * 
+  **/
+ static void performSerialCheck(const ConfigurationItemDict& changedItems, const ConfigurationItemDict& localItems)
+ {
+     for (ConfigurationItemDict::const_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::const_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 < item->second->serialNumber)
+         {
+             //
+             // XXX Either throw an exception or log & remove the update!
+             //
+         }
+     }
+ }
+ 
+ typedef boost::function<void()> UpdateCommand;
+ typedef vector<UpdateCommand> UpdateCommandList;
+ 
+ /**
+  * A helper class and visitor for propogating configuration changes to the SIPEndPoint implementation.
+  **/
+ class EndpointConfigHelper : public boost::enable_shared_from_this<EndpointConfigHelper>
+ {
+     //
+     // Helper visitor that will be used to interpret the contents of the relevant configuration group.
+     // Reference counting and destruction plays an important part of the processing. The destructor for
+     // the visitor calls back into the helper to do any finalization or cleanup. This pattern will be
+     // revisited in the other helpers in this source file.
+     //
+     class Visitor : public SipConfigurationItemVisitor
+     {
+     public:
+         Visitor(const boost::shared_ptr<EndpointConfigHelper>& config) :
+           mConfig(config)
+         {
+         }
+ 
+         ~Visitor()
+         {
+             try
+             {
+                 //
+                 // Don't forget to tell the helper that all of the updates have been performed
+                 // and it can perform final processing.
+                 //
+                 mConfig->updated(mUpdates);
+             }
+             catch(...)
+             {
+                 //
+                 // NOTE TODO XXX?
+                 // Now here's the tricky part and where we need to look hard. If we gone this far
+                 // in configuration and we fail at this final stage, we really should undo all of
+                 // our configuration changes. This is easier said that done, so perhaps its
+                 // best if, for the time being at least, simply strive to keep *internally* consistent and
+                 // deal with reconciling with other components as a TBD.
+                 //
+             }
+         }
+ 
+         /**
+          * A different sort of approach to collecting the updates. By using boost's bind and function
+          * templates we can store the calls that we need to make and pass it to the configuration
+          * object's instance to call on itself. This allows the lock to only be held in once place,
+          * but the updates to appear to be spread over multiple calls.
+          **/
+         void visitSipAllowableCallDirectionItem(const SipAllowableCallDirectionItemPtr& direction)
+         {
+             mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateDirection, mConfig, direction));
+         }
+         
+         void visitSipSourceTransportAddressItem(const SipSourceTransportAddressItemPtr& source)
+         {
+             mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateSource, mConfig, source));
+         }
+ 
+         void visitSipTargetDestinationAddressItem(const SipTargetDestinationAddressItemPtr& target)
+         {
+             mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateTarget, mConfig, target));
+         };
+ 
+ 	void visitSipRTPMediaServiceItem(const SipRTPMediaServiceItemPtr& service)
+ 	{
+ 	    mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateMediaService, mConfig, service));
+ 	};
+ 
++	void visitSipEndpointTransportItem(const SipEndpointTransportItemPtr& transport)
++	{
++	    mUpdates.push_back(boost::bind(&EndpointConfigHelper::updateTransport, mConfig, transport));
++	};
++
+     private:
+ 
+         UpdateCommandList mUpdates;;
+         //
+         // We keep a reference to the parent as the helper itself isn't held by the configuration
+         // object or client.
+         //
+         boost::shared_ptr<EndpointConfigHelper> mConfig;
+     };
+ 
+ public:
+     EndpointConfigHelper(const SipEndpointPtr& endpoint, 
+         const boost::shared_ptr<SipEndpointFactory>& endpointFactory,
+         const LocatorRegistrySmartPrx& registry,
+         const string& routingId) :
+       mEndpoint(endpoint),
+       mFactory(endpointFactory),
+       mRegistry(registry),
+       mRoutingId(routingId)
+     {
+     }
+ 
+     virtual ~EndpointConfigHelper()
+     {
+         //
+         // Doesn't really need to do anything at the moment.
+         //
+     }
+ 
+     SipConfigurationItemVisitorPtr getVisitor()
+     {
+         return new Visitor(shared_from_this());
+     }
+ 
 -    void updateDirection(const SipAllowableCallDirectionItemPtr& direction)
++    enum Direction translateCallDirection(enum SipAllowableCallDirection direction)
+     {
 -        enum Direction callDirection;
 -        switch (direction->callDirection)
++        switch (direction)
+         {
+         case Inbound:
 -            callDirection = INBOUND;
 -            break;
++	    return INBOUND;
+         case Outbound:
 -            callDirection = OUTBOUND;
 -            break;
++	    return OUTBOUND;
+         case Both:
 -            callDirection = BOTH;
 -            break;
++	    return BOTH;
+         default:
 -            callDirection = NONE;
++	    return NONE;
+         }
 -        mEndpoint->setCallDirection(callDirection);
++    }
++
++    void updateDirection(const SipAllowableCallDirectionItemPtr& direction)
++    {
++        mEndpoint->setCallDirection(translateCallDirection(direction->callDirection));
+     }
+ 
+     void updateSource(const SipSourceTransportAddressItemPtr& source)
+     {
+         mEndpoint->setSourceAddress(source->host, source->port);
+     }
+ 
+     void updateTarget(const SipTargetDestinationAddressItemPtr& target)
+     {
+         mEndpoint->setTargetAddress(target->host, target->port);
+     }
+ 
+     void updateMediaService(const SipRTPMediaServiceItemPtr& service)
+     {
+ 	mEndpoint->setRTPOverIPv6(service->requireIPv6);
+     }
  
- class UDPTransportImplPriv
++    void updateTransport(const SipEndpointTransportItemPtr& transport)
++    {
++	mEndpoint->setSecureTransport(translateCallDirection(transport->secureTransport));
++    }
++
+     void updated(const UpdateCommandList& updates)
+     {
+         //
+         // NOTE: there is room for an inconsistent update, but holding the lock
+         // during RPCs seems like a bad plan. Even calling mFactory from
+         // here is a little suspect.
+         //
+         RegExSeq destinations;
+         bool updateSystem = !updates.empty();
+         {
+             boost::unique_lock<boost::shared_mutex> lock(mLock);
+             for (UpdateCommandList::const_iterator op = updates.begin();
+                  op != updates.end();
+                  ++op)
+             {
+                 UpdateCommand command = *op;
+                 command();
+             }
+             if (updateSystem)
+             {
+                 mFactory->generateRoutingDestinations(destinations);
+             }
+         }
+         if (updateSystem)
+         {
+             mRegistry->setEndpointLocatorDestinationIds(mRoutingId, destinations);
+         }
+     }
+ 
+ private:
+     boost::shared_mutex mLock;
+     SipEndpointPtr mEndpoint;
+     boost::shared_ptr<SipEndpointFactory> mFactory;
+     LocatorRegistrySmartPrx mRegistry;
+     string mRoutingId;
+ };
+ 
+ class ConfigBase
  {
  public:
+     virtual ~ConfigBase() {}
+ 
+     virtual SipConfigurationItemVisitorPtr getVisitor() { return 0; }
+ };
+ typedef boost::shared_ptr<ConfigBase> ConfigBasePtr;
+ 
+ /**
+  * The Transport specializations take care of any transport specific configuration and
+  * initialization. The UDP and TCP transports are so similar that they could probably
+  * share some functionality.
+  **/
+ class UDPTransportConfig : public ConfigBase, public boost::enable_shared_from_this<UDPTransportConfig>
+ {
+     class Visitor : public SipConfigurationItemVisitor
+     {
+     public:
+         Visitor(const boost::shared_ptr<UDPTransportConfig>& config) :
+             mConfig(config)
+         {
+         }
+ 
+         void visitSipHostItem(const SipHostItemPtr& hostItem)
+         {
+             //
+             // Where the UDPTransportConfig only has one variable that is configurable,
+             // we can initiate a complete update directly.
+             //
+             mConfig->update(hostItem);
+         }
+     private:
+         boost::shared_ptr<UDPTransportConfig> mConfig;
+         
+     };
+     
+ public:
      /**
       * Constructor implementation for this
       */
diff --cc src/SipEndpoint.cpp
index 3ec2f24,c130685..07f1a25
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@@ -151,11 -149,11 +149,16 @@@ void SipEndpoint::setCallDirection(enu
      mImplPriv->mConfig.sessionConfig.callDirection = direction;
  }
  
 +void SipEndpoint::setSecureTransport(enum Direction direction)
 +{
 +    mImplPriv->mConfig.transportConfig.secureTransport = direction;
 +}
 +
+ void SipEndpoint::setRTPOverIPv6(bool enabled)
+ {
+     mImplPriv->mConfig.sessionConfig.rtpOverIPv6 = enabled;
+ }
+ 
  void SipEndpoint::setConfiguration(const Ice::PropertyDict& props)
  {
      setTransportConfiguration(props);
diff --cc src/SipEndpoint.h
index cc73a76,2f5e011..40a8e25
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@@ -253,7 -257,7 +257,8 @@@ public
      void setSourceAddress(std::string, int);
      void setTargetAddress(std::string, int);
      void setCallDirection(enum Direction);
 +    void setSecureTransport(enum Direction);
+     void setRTPOverIPv6(bool);
  
  private:
      /**

commit e67a41c2641c54ab24d231d2d7e12ad17825bda3
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue May 10 18:53:06 2011 -0300

    Add the ability to specify that an endpoint should use secure transport.

diff --git a/config/Sip.config b/config/Sip.config
index 048a751..a4826b3 100644
--- a/config/Sip.config
+++ b/config/Sip.config
@@ -73,5 +73,7 @@ targetport=5060
 #sourcehost=
 # Source port of the transport to use
 #sourceport=
-# What directions calls are permitted in. Valid options are inbound, outbound, and both.
+# What directions calls are permitted in. Valid options are none, inbound, outbound, and both.
 direction=both
+# What directions secure transport is required in. Valid options are none, inbound, outbound, and both.
+securetransport=none
diff --git a/config/SipConfigurator.py b/config/SipConfigurator.py
index d04f2ac..7398e9d 100755
--- a/config/SipConfigurator.py
+++ b/config/SipConfigurator.py
@@ -107,10 +107,15 @@ class SipSectionVisitors(Configurator.SectionVisitors):
                     return AsteriskSCF.SIP.V1.SipAllowableCallDirection.Outbound
                 elif self.config.get(section, item) == 'both':
                     return AsteriskSCF.SIP.V1.SipAllowableCallDirection.Both
+                elif self.config.get(section, item) == 'none':
+                    return AsterisksCF.SIP.V1.SipAllowableCallDirection.Disabled
 
         transformer = AllowableCallDirectionTransformer(config)
+
         mapper.map('direction', AsteriskSCF.SIP.V1.SipAllowableCallDirectionItem(), 'callDirection', 'callDirection', transformer.get, None)
 
+        mapper.map('securetransport', AsteriskSCF.SIP.V1.SipEndpointTransportItem(), 'secureTransport', 'transport', 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)
diff --git a/local-slice/SipConfigurationIf.ice b/local-slice/SipConfigurationIf.ice
index 58cae24..8f0e391 100644
--- a/local-slice/SipConfigurationIf.ice
+++ b/local-slice/SipConfigurationIf.ice
@@ -345,6 +345,17 @@ module V1
    };
 
    /**
+    * Transport information configuration item
+    */
+   class SipEndpointTransportItem extends SipConfigurationItem
+   {
+       /**
+	* What directions to require secure transport in
+	*/
+       SipAllowableCallDirection secureTransport = Disabled;
+   };
+
+   /**
     * Group of configuration items related to a UDP transport
    */
    ["visitor:SipConfigurationGroupVisitor"] class SipUDPTransportGroup extends SipTransportGroup
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 76fa596..633d70a 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -875,27 +875,29 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
             public:
 		endpointItemsVisitor(SipEndpointPtr& visitedEndpoint) : mEndpoint(visitedEndpoint) { };
 
-		void visitSipAllowableCallDirectionItem(const ::AsteriskSCF::SIP::V1::SipAllowableCallDirectionItemPtr& direction)
+		enum Direction allowableCallDirection2Direction(enum SipAllowableCallDirection direction)
 		{
-		    enum Direction callDirection;
+                    if (direction == Inbound)
+                    {
+			return INBOUND;
+                    }
+                    else if (direction == Outbound)
+                    {
+			return OUTBOUND;
+                    }
+                    else if (direction == Both)
+                    {
+                        return BOTH;
+                    }
+                    else
+                    {
+                        return NONE;
+                    }
+		};
 
-		    if (direction->callDirection == Inbound)
-		    {
-			callDirection = INBOUND;
-		    }
-		    else if (direction->callDirection == Outbound)
-		    {
-			callDirection = OUTBOUND;
-		    }
-		    else if (direction->callDirection == Both)
-		    {
-			callDirection = BOTH;
-		    }
-		    else
-		    {
-			callDirection = NONE;
-		    }
-		    mEndpoint->setCallDirection(callDirection);
+		void visitSipAllowableCallDirectionItem(const ::AsteriskSCF::SIP::V1::SipAllowableCallDirectionItemPtr& direction)
+		{
+		    mEndpoint->setCallDirection(allowableCallDirection2Direction(direction->callDirection));
 		};
 
 		void visitSipSourceTransportAddressItem(const ::AsteriskSCF::SIP::V1::SipSourceTransportAddressItemPtr& source)
@@ -907,6 +909,12 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
 		{
 		    mEndpoint->setTargetAddress(target->host, target->port);
 		};
+
+		void visitSipEndpointTransportItem(const ::AsteriskSCF::SIP::V1::SipEndpointTransportItemPtr& transport)
+		{
+		    mEndpoint->setSecureTransport(allowableCallDirection2Direction(transport->secureTransport));
+		};
+
             private:
 		SipEndpointPtr& mEndpoint;
             };
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 50d740e..3ec2f24 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -151,6 +151,11 @@ void SipEndpoint::setCallDirection(enum Direction direction)
     mImplPriv->mConfig.sessionConfig.callDirection = direction;
 }
 
+void SipEndpoint::setSecureTransport(enum Direction direction)
+{
+    mImplPriv->mConfig.transportConfig.secureTransport = direction;
+}
+
 void SipEndpoint::setConfiguration(const Ice::PropertyDict& props)
 {
     setTransportConfiguration(props);
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index fc3aa21..cc73a76 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -253,6 +253,7 @@ public:
     void setSourceAddress(std::string, int);
     void setTargetAddress(std::string, int);
     void setCallDirection(enum Direction);
+    void setSecureTransport(enum Direction);
 
 private:
     /**
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 0eafdfc..f6956dd 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -428,13 +428,24 @@ void SipSession::start(const Ice::Current&)
     pjsip_dialog *dialog;
     SipEndpointConfig &config = mImplPriv->mEndpoint->getConfig();
 
+    std::string prefix;
+    if (config.transportConfig.secureTransport != NONE)
+    {
+	prefix = "sips";
+    }
+    else
+    {
+	prefix = "sip";
+    }
+
     char local[64];
-    pj_ansi_sprintf(local, "sip:%s", config.sessionConfig.sourceAddress.c_str());
+    pj_ansi_sprintf(local, "%s:%s", prefix.c_str(), config.sessionConfig.sourceAddress.c_str());
     local_uri = pj_str(local);
 
     char remote[64];
     bool userDefined = mImplPriv->mDestination.size() != 0;
-    pj_ansi_sprintf(remote, "sip:%s%s%s",
+    pj_ansi_sprintf(remote, "%s:%s%s%s",
+	prefix.c_str(),
         userDefined ? mImplPriv->mDestination.c_str() : "",
         userDefined ? "@" : "",
         config.transportConfig.address.c_str());

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


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list