[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "tls" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue May 10 16:52:27 CDT 2011


branch "tls" has been created
        at  e67a41c2641c54ab24d231d2d7e12ad17825bda3 (commit)

- Log -----------------------------------------------------------------
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());

commit 1178a5061d81b691a58ffc2ac79be859a5feeade
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue May 10 17:03:06 2011 -0300

    Link against OpenSSL if present for TLS support within pjproject.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 254d404..c56d46f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,13 @@
 if(NOT logger_dir)
   message(FATAL_ERROR "The logger directory could not be found ${logger_dir}")
 endif()
+
+# TLS support within pjsip uses OpenSSL, so if found we need to link it in
+find_package(OpenSSL)
+if(OPENSSL_FOUND)
+  include_directories(${OPENSSL_INCLUDE_DIR})
+endif()
+
 include_directories(${logger_dir}/include)
 include_directories(${utils_dir}/StateReplicator/include)
 include_directories(${utils_dir}/SmartProxy/include)
@@ -40,7 +47,7 @@ asterisk_scf_component_add_slice(SipSessionManager ../local-slice/SipConfigurati
 asterisk_scf_component_add_ice_libraries(SipSessionManager IceStorm)
 asterisk_scf_component_add_boost_libraries(SipSessionManager core)
 asterisk_scf_component_build_icebox(SipSessionManager)
-target_link_libraries(SipSessionManager logging-client)
+target_link_libraries(SipSessionManager logging-client ${OPENSSL_LIBRARIES})
 pjproject_link(SipSessionManager pjsip)
 pjproject_link(SipSessionManager pjmedia)
 pjproject_link(SipSessionManager pjlib-util)

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list