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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed May 18 12:04:07 CDT 2011


branch "nat-traversal" has been updated
       via  e3cba07a3705a9ef7ef01a1a984e2076eb8b460f (commit)
      from  76c154725df0c8e5570d4fe9330ee1d21caa2c1d (commit)

Summary of changes:
 src/STUNTransport.cpp |   29 ++++++++++++++---------------
 src/TLSTransport.cpp  |    5 +++++
 src/Transports.cpp    |   27 ++-------------------------
 src/Transports.h      |   37 ++++---------------------------------
 4 files changed, 25 insertions(+), 73 deletions(-)


- Log -----------------------------------------------------------------
commit e3cba07a3705a9ef7ef01a1a984e2076eb8b460f
Author: Brent Eagles <beagles at digium.com>
Date:   Wed May 18 14:33:38 2011 -0230

    Remove duplicate impl of AddressPtr (now in ice-util-cpp) and fix gcc build errors.

diff --git a/src/STUNTransport.cpp b/src/STUNTransport.cpp
index 82c50c2..8c14b84 100644
--- a/src/STUNTransport.cpp
+++ b/src/STUNTransport.cpp
@@ -54,7 +54,7 @@ private:
         return PJ_TRUE;
     }
 
-    static pj_bool_t onDataSent(pj_stun_sock* stunSock, pj_ioqueue_op_key_t* sendKey, pj_ssize_t sent)
+    static pj_bool_t onDataSent(pj_stun_sock*, pj_ioqueue_op_key_t*, pj_ssize_t)
     {
         //
         // TODO. We could rig this up to allow asynchronous replies to the 
@@ -63,7 +63,7 @@ private:
         return PJ_TRUE;
     }
 
-    static pj_bool_t onStatus(pj_stun_sock* stunSock, pj_stun_sock_op operation, pj_status_t status)
+    static pj_bool_t onStatus(pj_stun_sock* stunSock, pj_stun_sock_op operation, pj_status_t)
     {
         //
         // Respond to binding update.
@@ -96,7 +96,7 @@ private:
         return t->sendData(data, remoteAddress, remoteAddressLength, token, callback);
     }
 
-    static pj_status_t shutdownImpl(pjsip_transport* transport)
+    static pj_status_t shutdownImpl(pjsip_transport*)
     {
         //
         // The STUN transport doesn't have a distinct shutdown.
@@ -169,7 +169,8 @@ public:
             logger(Debug) << FUNLOG << " proceeding with STUN server " << stunServerProperty;
         }
 
-        pj_uint16_t port = props->getPropertyAsIntWithDefault("Sip.Transport.STUN.Port", PJ_STUN_PORT);
+        pj_uint16_t port =
+            static_cast<pj_uint16_t>(props->getPropertyAsIntWithDefault("Sip.Transport.STUN.Port", PJ_STUN_PORT));
         logger(Debug) << FUNLOG << " proceeding with STUN server " << stunServerProperty;
 
         //
@@ -300,9 +301,9 @@ private:
             return;
         }
 
-        transport->type_name = "ASCF_SIP_NAT";
-        transport->info = "Asterisk SCF PJNATH based SIP transport";
-        transport->remote_name.host = pj_str("0.0.0.0");
+        transport->type_name = (char*)"ASCF_SIP_NAT";
+        transport->info = (char*)"Asterisk SCF PJNATH based SIP transport";
+        transport->remote_name.host = pj_str((char*)"0.0.0.0");
         transport->remote_name.port = 0;
         
         pj_stun_sock_info socketInfo;
@@ -324,7 +325,7 @@ private:
     void dataReceived(void* packet, unsigned packetLength, const pj_sockaddr_t* sourceAddress, unsigned addressLength)
     {
         boost::shared_ptr<pjsip_transport> transport(getCurrentTransport());
-        pjsip_rx_data* data = reinterpret_cast<pjsip_rx_data*>(pj_pool_zalloc(mModule->getPool(), sizeof pjsip_rx_data));
+        pjsip_rx_data* data = reinterpret_cast<pjsip_rx_data*>(pj_pool_zalloc(mModule->getPool(), sizeof (pjsip_rx_data)));
         data->tp_info.pool = mModule->getPool();
         data->tp_info.transport = transport.get();
         data->tp_info.tp_data = 0;
@@ -346,22 +347,20 @@ private:
             sizeof data->pkt_info.src_name, 0);
         data->pkt_info.src_port = pj_sockaddr_get_port(&data->pkt_info.src_addr);
         pj_size_t bytesReceived = pjsip_tpmgr_receive_packet(transport->tpmgr, data);
-        if (bytesReceived < 0)
-        {
-            assert(false);
-        }
+        assert(bytesReceived != 0);
     }
 
     pj_status_t sendData(pjsip_tx_data* data, const pj_sockaddr_t* remoteAddress, int remoteAddressLength, 
-        void* token, pjsip_transport_callback callback)
+        void*, pjsip_transport_callback)
     {
-        return pj_stun_sock_sendto(mSocket, &data->op_key.key, &data->buf.start, data->buf.cur - data->buf.start, 0,
+        return pj_stun_sock_sendto(mSocket, &data->op_key.key, &data->buf.start,
+                static_cast<pj_uint16_t>(data->buf.cur - data->buf.start), 0,
             remoteAddress, remoteAddressLength);
     }
 };
 
 TransportPtr createSTUNTransport(const PJSipManagerPtr& sipManager, const Ice::PropertiesPtr& properties,
-        const std::string& hostname, int port)
+        const std::string&, int)
 {
     return TransportPtr(new STUNTransport(sipManager->getEndpoint(), properties, 
         dynamic_pointer_cast<STUNModule>(sipManager->getModule("STUN"))));
diff --git a/src/TLSTransport.cpp b/src/TLSTransport.cpp
index 39ce8ce..0503662 100644
--- a/src/TLSTransport.cpp
+++ b/src/TLSTransport.cpp
@@ -45,8 +45,13 @@ private:
     pjsip_tpfactory* mFactory;
 };
 
+#if PJSIP_HAS_TLS_TRANSPORT
 TransportPtr createTLSTransport(const PJSipManagerPtr& manager, const string& hostname, int port,
         pjsip_tls_setting* settings)
+#else
+TransportPtr createTLSTransport(const PJSipManagerPtr&, const string& hostname, int port,
+        pjsip_tls_setting*)
+#endif
 {
     pj_sockaddr tlsAddr;
     pj_str_t tlsString;
diff --git a/src/Transports.cpp b/src/Transports.cpp
index f8c23f3..f52987d 100644
--- a/src/Transports.cpp
+++ b/src/Transports.cpp
@@ -20,35 +20,12 @@
 using namespace std;
 using namespace AsteriskSCF::SipSessionManager;
 
-Address::Address(const string& host, int port) :
-    mHostname(host),
-    mPort(port)
-{
-    boost::asio::ip::address a(boost::asio::ip::address::from_string(host));
-    mIsIPV6 = a.is_v6();
-}
-    
-int Address::port() const
-{
-    return mPort;
-}
-
-string Address::hostname() const
-{
-    return mHostname;
-}
-
-bool Address::isIPV6()
-{
-    return mIsIPV6;
-}
-
-void Transport::setAddress(const AddressPtr& newAddress)
+void Transport::setAddress(const AsteriskSCF::Helpers::AddressPtr& newAddress)
 {
     mAddress = newAddress;
 }
 
-AddressPtr Transport::getAddress() const
+AsteriskSCF::Helpers::AddressPtr Transport::getAddress() const
 {
     return mAddress;
 }
diff --git a/src/Transports.h b/src/Transports.h
index 96a6884..0e8a288 100644
--- a/src/Transports.h
+++ b/src/Transports.h
@@ -19,42 +19,13 @@
 #include <string>
 #include <vector>
 #include <boost/shared_ptr.hpp>
+#include <AsteriskSCF/Helpers/Network.h>
 
 namespace AsteriskSCF
 {
 namespace SipSessionManager
 {
 
-//
-// NOTE: Plan is to add this to ice-util-cpp or maybe even just util-cpp.
-//
-class Address
-{
-    //
-    // We don't want a proper assignment operator, this is to behave more like
-    // an atomic type and the only way to really do that is to hide the members
-    // and only allow modification through construction.
-    //
-    void operator=(const Address&);
-public:
-
-    Address(const std::string& hostname, int port);
-    Address(const Address&);
-
-    int port() const;
-    std::string hostname() const;
-
-    bool isIPV6();
-    
-private:
-    std::string mHostname;
-    int mPort;
-
-    bool mIsIPV6;
-};
-typedef boost::shared_ptr<Address> AddressPtr;
-typedef std::vector<AddressPtr> AddressSeq;
-
 class Transport
 {
 public:
@@ -62,11 +33,11 @@ public:
 
     virtual void destroy() = 0;
 
-    void setAddress(const AddressPtr& address);
-    AddressPtr getAddress() const;
+    void setAddress(const AsteriskSCF::Helpers::AddressPtr& address);
+    AsteriskSCF::Helpers::AddressPtr getAddress() const;
 
 private:
-    AddressPtr mAddress;
+    AsteriskSCF::Helpers::AddressPtr mAddress;
 };
 typedef boost::shared_ptr<Transport> TransportPtr;
 typedef std::vector<TransportPtr> TransportSeq;

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list