[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
Mon Aug 23 17:53:22 CDT 2010


branch "master" has been updated
       via  0817d6977185da73da1d1a90564b64099cfb2860 (commit)
      from  2f3c8ab9fecd676ea8ba955022dde0b4ec4adcc9 (commit)

Summary of changes:
 src/PJSipManager.cpp |   39 +++++++++++++++++++++++++++++++++++++++
 src/PJSipManager.h   |    3 +++
 2 files changed, 42 insertions(+), 0 deletions(-)


- Log -----------------------------------------------------------------
commit 0817d6977185da73da1d1a90564b64099cfb2860
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Aug 23 17:54:28 2010 -0500

    Add transport initialization to PJSipManager.

diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 8b2d7de..fdd1fe6 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -48,6 +48,7 @@ PJSipManager::PJSipManager()
 	// if necessary.
 	pj_caching_pool_init(&mCachingPool, NULL, 1024 * 1024);
 	pjsip_endpt_create(&mCachingPool.factory, "SIP", &mEndpoint);
+	setTransports(mEndpoint);
 	mMemoryPool = pj_pool_create(&mCachingPool.factory, "SIP", 1024, 1024, NULL);
 	if (!mMemoryPool)
 	{
@@ -97,6 +98,44 @@ bool PJSipManager::unregisterModule(pjsip_module *module)
 	return true;
 }
 
+bool PJSipManager::setTransports(pjsip_endpoint *endpoint)
+{
+	//XXX We'll also want to allow for TCP and TLS-specific
+	//addresses to be specified.
+	pj_sockaddr udpAddr;
+	pj_status_t status;
+	//UNSPEC family means "you figure out the address family, pjlib!"
+	//XXX Hard-coded local addr for the time being. This will be a variable
+	//to read from a config at some point
+	char ip[] = "127.0.0.1";
+	pj_str_t udpString = pj_str(ip);
+	pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &udpString, &udpAddr);
+	if (udpAddr.addr.sa_family == pj_AF_INET())
+	{
+		//XXX The fourth parameter should probably be controlled through
+		//configuration. PJSIP reference says it should be the number of
+		//processors on the machine.
+		//
+		status = pjsip_udp_transport_start(endpoint, &udpAddr.ipv4, NULL, 2, &mUdpTransport);
+		if (status != PJ_SUCCESS)
+		{
+			std::cerr << "[ERROR] Failed to create IPv4 UDP transport. DANG!" << std::endl;
+		}
+	}
+	else if (udpAddr.addr.sa_family == pj_AF_INET6())
+	{
+		status = pjsip_udp_transport_start6(endpoint, &udpAddr.ipv6, NULL, 2, &mUdpTransport);
+		if (status != PJ_SUCCESS)
+		{
+			std::cerr << "[ERROR] Failed to create IPv4 UDP transport. DANG!" << std::endl;
+		}
+	}
+	//XXX Note that TCP and TLS stuff should be done here. Also note that
+	//currently PJSIP does not have functions for starting IPv6 TCP or
+	//TLS transports, so we'll have to modify the code to allow for it.
+	return true;
+}
+
 }; //End namespace SIP
 
 }; //End namespace Hydra
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 3427c3a..33e09a5 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -56,6 +56,9 @@ private:
 	pj_thread_t *mPjThread;
 	pj_caching_pool mCachingPool;
 	pj_pool_t *mMemoryPool;
+	pjsip_transport *mUdpTransport;
+
+	bool setTransports(pjsip_endpoint *endpoint);
 };
 
 }; //End namespace SIP

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list