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); }
UtlBoolean SipProtocolServerBase::send(SipMessage* message, const char* hostAddress, int hostPort) { UtlBoolean sendOk = FALSE; UtlString localIp(message->getLocalIp()); if (localIp.length() < 1) { localIp = mDefaultIp; } SipClient* client = createClient(hostAddress, hostPort, localIp); if(client) { int isBusy = client->isInUseForWrite(); UtlString clientNames; client->getClientNames(clientNames); OsSysLog::add(FAC_SIP, PRI_DEBUG, "Sip%sServerBase::send %p isInUseForWrite %d, client info\n %s", mProtocolString.data(), client, isBusy, clientNames.data()); sendOk = client->sendTo(*message, hostAddress, hostPort); if(!sendOk) { OsTask* pCallingTask = OsTask::getCurrentTask(); OsTaskId_t callingTaskId = -1; OsTaskId_t clientTaskId = -1; if ( pCallingTask ) { pCallingTask->id(callingTaskId); } client->id(clientTaskId); if (clientTaskId != callingTaskId) { // Do not need to clientLock.acquireWrite(); // as deleteClient uses the locking list lock // which is all that is needed as the client is // already marked as busy when we called // createClient above. deleteClient(client); client = NULL; } } } if(client) { releaseClient(client); } return(sendOk); }
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); }