Beispiel #1
0
UtlBoolean SipUdpServer::sendTo(SipMessage& message,
                               const char* address,
                               int port,
                               const char* szLocalSipIp)
{
    UtlBoolean sendOk;
    SipClient* pServer = NULL;
    
    if (szLocalSipIp)
    {
        UtlString localKey(szLocalSipIp);
        pServer = dynamic_cast <SipClient*> (mServers.findValue(&localKey));
    }
    else
    {
        // no local sip IP specified, so, use the default one
        pServer = dynamic_cast <SipClient*> (mServers.findValue(&mDefaultIp));
    }
    
    if (pServer)
    {
        sendOk = pServer->sendTo(message, address, port);
    }
    else
    {
        sendOk = false;
    }
    return (sendOk);
}
Beispiel #2
0
UtlBoolean SipUdpServer::sendTo(const SipMessage& message,
                               const char* address,
                               int port,
                               const char* szLocalSipIp)
{
    UtlBoolean sendOk;
    UtlVoidPtr* pServerContainer = NULL;
    SipClient* pServer = NULL;
    
    if (szLocalSipIp)
    {
        UtlString localKey(szLocalSipIp);
        pServerContainer = (UtlVoidPtr*)this->mServers.findValue(&localKey);
        if (pServerContainer)
        {
            pServer = (SipClient*) pServerContainer->getValue();
        }
    }
    else
    {
        // no local sip IP specified, so, use the default one
        UtlString defaultKey(mDefaultIp);
       
        pServerContainer = (UtlVoidPtr*) mServers.findValue(&defaultKey);
        if (pServerContainer)
        {
            pServer = (SipClient*) pServerContainer->getValue();
        }
    }
    
    if (pServer)
    {
        sendOk = pServer->sendTo(message, address, port);
    }
    else
    {
        sendOk = false;
    }
    return(sendOk);
}
Beispiel #3
0
OsSocket* SipUdpServer::buildClientSocket(int hostPort, const char* hostAddress, const char* localIp)
{
    if (mSipUserAgent && mSipUserAgent->getUseRport())
    {
        UtlVoidPtr* pSocketContainer = NULL;
        OsStunDatagramSocket* pSocket = NULL;

        assert(localIp != NULL);
        UtlString localKey(localIp);
        
        pSocketContainer = (UtlVoidPtr*)mServerSocketMap.findValue(&localKey);
        assert(pSocketContainer);
        
        pSocket = (OsStunDatagramSocket*)pSocketContainer->getValue();
        assert(pSocket);
        
        return pSocket ;
    }
    else
    {
        return(new OsStunDatagramSocket(hostPort, hostAddress, 0, localIp, 
            (mStunServer.length() != 0), mStunServer.data(), mStunRefreshSecs, mStunOptions));
    }
}
Beispiel #4
0
OsSocket* SipUdpServer::buildClientSocket(int hostPort,
                                          const char* hostAddress,
                                          const char* localIp,
                                          bool& existingSocketReused)
{
   OsStunDatagramSocket* pSocket;

   if (mSipUserAgent &&
       (mSipUserAgent->getUseRport() ||
        mSipUserAgent->isSymmetricSignalingImposed()))
   {
      // If there is a SipUserAgent and if it is set to use rport (why?),
      // look up the server socket for this local IP.
      assert(localIp != NULL);
      UtlString localKey(localIp);

      pSocket =
         dynamic_cast <OsStunDatagramSocket*> (mServerSocketMap.findValue(&localKey));
      assert(pSocket);

      existingSocketReused = true;
   }
   else
   {
      // Otherwise, construct a new socket.
      pSocket = new OsStunDatagramSocket(hostPort, hostAddress,
                                         0, localIp, 
                                         !mStunServer.isNull(),
                                         mStunServer.data(),
                                         mStunRefreshSecs,
                                         mStunOptions);

      existingSocketReused = false;
   }
   return pSocket;
}