Exemplo n.º 1
0
// Constructor
SipTlsServer::SipTlsServer(int port,
                           SipUserAgent* userAgent,
                           UtlBoolean bUseNextAvailablePort,
                           const char* szBindAddr) :
   // Use PORT_NONE here to prevent SipTcpServer from opening a socket.
   SipTcpServer(PORT_NONE,
                userAgent,
                "SipTlsServer-%d",
                FALSE,
                NULL,
                SIP_TRANSPORT_TLS)
{
   Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                 "SipTlsServer[%s]::_  '%s' %s port %d szBindAddr = '%s'",
                 getName().data(), mName.data(),
                 bUseNextAvailablePort ? "use next available" : "specific",
                 port, szBindAddr);

   // mServerPort is set to PORT_NONE by SipTcpServer::SipTcpServer.
   mServerPort = port;
   mpServerBrokerListener = new SipServerBrokerListener(this);
   mIsSecureTransport = true;

   Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                 "SipTlsServer[%s]::_ port %d",
                 getName().data(), mServerPort);

   if (szBindAddr && 0 != strcmp(szBindAddr, "0.0.0.0"))
   {
      mDefaultIp = szBindAddr;
      createServerSocket(szBindAddr, mServerPort, bUseNextAvailablePort);
   }
   else
   {
      int numAddresses = 0;
      const HostAdapterAddress* adapterAddresses[MAX_IP_ADDRESSES];
      getAllLocalHostIps(adapterAddresses, numAddresses);

      for (int i = 0; i < numAddresses; i++)
      {
         createServerSocket(adapterAddresses[i]->mAddress.data(),
                            mServerPort,
                            bUseNextAvailablePort);
         if (0 == i)
         {
            // use the first IP address in the array
            // for the 'default ip'
            mDefaultIp = adapterAddresses[i]->mAddress.data();
         }
         delete adapterAddresses[i];
      }
   }

   // Correct mDefaultPort, which is set to SIP_PORT in SipProtocolServerBase.
   mDefaultPort = SIP_TLS_PORT;
}
Exemplo n.º 2
0
// Constructor
SipUdpServer::SipUdpServer(int port,
                           SipUserAgent* userAgent,
                           const char* natPingUrl,
                           int natPingFrequencySeconds,
                           const char* natPingMethod,
                           int udpReadBufferSize,
                           UtlBoolean bUseNextAvailablePort,
                           const char* szBoundIp) :
   SipProtocolServerBase(userAgent, "UDP", "SipUdpServer-%d"),
   mStunRefreshSecs(28), 
   mStunOptions(0)  
{
    OsSysLog::add(FAC_SIP, PRI_DEBUG,
                  "SipUdpServer::_ port = %d, bUseNextAvailablePort = %d, szBoundIp = '%s'",
                  port, bUseNextAvailablePort, szBoundIp);

    if (szBoundIp && 0 != strcmp(szBoundIp, "0.0.0.0"))
    {
        mDefaultIp = szBoundIp;
        int serverSocketPort = port;
        createServerSocket(szBoundIp, serverSocketPort, bUseNextAvailablePort, udpReadBufferSize);
    }
    else
    {
        int numAddresses = 0;
        const HostAdapterAddress* adapterAddresses[MAX_IP_ADDRESSES];
        getAllLocalHostIps(adapterAddresses, numAddresses);

        for (int i = 0; i < numAddresses; i++)
        {
            int serverSocketPort = port;
            
            createServerSocket(adapterAddresses[i]->mAddress.data(),
                               serverSocketPort,
                               bUseNextAvailablePort,
                               udpReadBufferSize);
            if (0 == i)
            {
                // use the first IP address in the array
                // for the 'default ip'
                mDefaultIp = adapterAddresses[i]->mAddress.data();
            }
            delete adapterAddresses[i];   
        }
    }

    if(natPingUrl && *natPingUrl)
        mNatPingUrl = natPingUrl;
    if(natPingMethod && *natPingMethod)
        mNatPingMethod = natPingMethod;
    else
        mNatPingMethod = "PING";

    mNatPingFrequencySeconds = natPingFrequencySeconds;
}
Exemplo n.º 3
0
// Constructor
SipTlsServer::SipTlsServer(int port,
                           SipUserAgent* userAgent, 
                           UtlBoolean bUseNextAvailablePort,
                           UtlString certNickname,
                           UtlString certPassword,
                           UtlString dbLocation,
                           const char*  szBindAddr) :
 SipProtocolServerBase(userAgent, "TLS", "SipTlsServer %d"),
 mCertNickname(certNickname),
 mCertPassword(certPassword),
 mDbLocation(dbLocation),
 mTlsInitCode(OS_SUCCESS)
{
    OsSysLog::add(FAC_SIP, PRI_DEBUG,
                  "SipTlsServer::_ port = %d, bUseNextAvailablePort = %d",
                  port, bUseNextAvailablePort);

    mServerPort = port ;
    mpServerBrokerListener = new SipServerBrokerListener(this);

#ifdef _DISABLE_MULTIPLE_INTERFACE_SUPPORT
   szBindAddr = "0.0.0.0" ;
#endif

    OsSysLog::add(FAC_SIP,PRI_DEBUG,"SipTlsServer::~ port %d", port);

    if (szBindAddr && 0 != strcmp(szBindAddr, "0.0.0.0"))
    {
        mDefaultIp = szBindAddr;
        createServerSocket(szBindAddr, mServerPort, bUseNextAvailablePort);
    }
    else      
    {
        int numAddresses = MAX_IP_ADDRESSES;
        const HostAdapterAddress* adapterAddresses[MAX_IP_ADDRESSES];
        getAllLocalHostIps(adapterAddresses, numAddresses);

        for (int i = 0; i < numAddresses; i++)
        {
            createServerSocket(adapterAddresses[i]->mAddress.data(),
                               mServerPort,
                               bUseNextAvailablePort);
            if (0 == i)
            {
                // use the first IP address in the array
                // for the 'default ip'
                mDefaultIp = adapterAddresses[i]->mAddress.data();
            }
            delete adapterAddresses[i];
        }
    }

   mDefaultPort = SIP_TLS_PORT;
}
Exemplo n.º 4
0
    void testCount()
    {
	const HostAdapterAddress *adapters[MAX_A];
	int numAddrs = MAX_A;
	bool ret = getAllLocalHostIps(adapters, numAddrs);
	CPPUNIT_ASSERT(ret == true);
	CPPUNIT_ASSERT(numAddrs > 0);
	
	printf ("Found %d interface(s)\n", numAddrs);
	int i;
	for (int i = 0; i < numAddrs; i++)
	{
	    printf("[%d] %s: %s\n", i, adapters[i]->mAdapter.data(), adapters[i]->mAddress.data()); 
	}
    }
Exemplo n.º 5
0
// Constructor
SipUdpServer::SipUdpServer(int port,
                           SipUserAgent* userAgent,
                           int udpReadBufferSize,
                           UtlBoolean bUseNextAvailablePort,
                           const char* szBoundIp) :
   SipProtocolServerBase(userAgent,
                         SIP_TRANSPORT_UDP,
                         "SipUdpServer-%d"),
   mStunRefreshSecs(28), 
   mStunOptions(0)
{
    OsSysLog::add(FAC_SIP, PRI_DEBUG,
                  "SipUdpServer[%s]::_ port = %d, bUseNextAvailablePort = %d, szBoundIp = '%s'",
                  getName().data(), port, bUseNextAvailablePort, szBoundIp);

    if (szBoundIp && 0 != strcmp(szBoundIp, "0.0.0.0"))
    {
       // If an address was supplied, only open a socket on that address.
       mDefaultIp = szBoundIp;
       int serverSocketPort = port;
       createServerSocket(szBoundIp, serverSocketPort, bUseNextAvailablePort,
                          udpReadBufferSize);
    }
    else
    {
       // If no address was supplied, get all local addresses and open
       // sockets on all of them.
       int numAddresses = 0;
       const HostAdapterAddress* adapterAddresses[MAX_IP_ADDRESSES];
       getAllLocalHostIps(adapterAddresses, numAddresses);

       if (numAddresses >= 1)
       {
          // Use the first IP address in the array for the 'default IP address'.
          mDefaultIp = adapterAddresses[0]->mAddress.data();
       }
       for (int i = 0; i < numAddresses; i++)
       {
          int serverSocketPort = port;
            
          createServerSocket(adapterAddresses[i]->mAddress.data(),
                             serverSocketPort,
                             bUseNextAvailablePort,
                             udpReadBufferSize);
          delete adapterAddresses[i];   
       }
    }
}