int main(int argc, char* argv[]) { const char* configFileName = "siptest-config"; int proxyTcpPort; int proxyUdpPort; int proxyTlsPort; OsConfigDb configDb; // siptest uses osPrintf for output, so we have to un-suppress it. enableConsoleOutput(TRUE); if(configDb.loadFromFile(configFileName) == OS_SUCCESS) { osPrintf("Found config file: %s\n", configFileName); } else { configDb.set("SIP_TEST_UDP_PORT", "3000"); configDb.set("SIP_TEST_TCP_PORT", "3000"); configDb.set("SIP_TEST_TLS_PORT", "3001"); if(configDb.storeToFile(configFileName) == OS_SUCCESS) { osPrintf("Could not write config file: %s\n", configFileName); } } proxyUdpPort = configDb.getPort("SIP_TEST_UDP_PORT") ; proxyTcpPort = configDb.getPort("SIP_TEST_TCP_PORT") ; proxyTlsPort = configDb.getPort("SIP_TEST_TLS_PORT") ; UtlBoolean commandStatus = CommandProcessor::COMMAND_SUCCESS; char buffer[1024]; char* commandLine; CommandProcessor processor; SipLineMgr* lineMgr = new SipLineMgr(); SipRefreshMgr* refreshMgr = new SipRefreshMgr(); lineMgr->startLineMgr(); lineMgr->initializeRefreshMgr( refreshMgr ); SipUserAgent* sipUA = new SipUserAgent( proxyTcpPort ,proxyUdpPort ,proxyTlsPort ,NULL // default publicAddress ,NULL // default defaultUser ,NULL // default defaultSipAddress ,NULL // default sipProxyServers ,NULL // default sipDirectoryServers ,NULL // default sipRegistryServers ,NULL // default authenicateRealm ,NULL // default authenticateDb ,NULL // default authorizeUserIds ,NULL // default authorizePasswords ,lineMgr ); sipUA->allowMethod(SIP_REGISTER_METHOD); sipUA->allowMethod(SIP_SUBSCRIBE_METHOD); sipUA->allowMethod(SIP_NOTIFY_METHOD); sipUA->start(); sipUA->startMessageLog(); osPrintf( "SIP logging Started\n" ); refreshMgr->init( sipUA ); CommandMsgProcessor* msgProc = new CommandMsgProcessor(sipUA); msgProc->start(); processor.registerCommand("help", new HelpCommand(&processor)); processor.registerCommand("?", new HelpCommand(&processor)); processor.registerCommand("history", new HistoryCommand(&processor)); processor.registerCommand("send", new SipSendCommand(sipUA)); processor.registerCommand("lsend", new SipLSendCommand()); processor.registerCommand("get", new HttpGetCommand()); processor.registerCommand("respond", new RespondCommand(msgProc)); processor.registerCommand("rt", new RespondTemplate(msgProc)); processor.registerCommand("rrespond", new ResendResponse(msgProc)); processor.registerCommand("log", new SipLogCommand(*sipUA)); processor.registerCommand("auth", new AuthCommand(lineMgr)); processor.registerCommand("sleep", new SleepCommand()); processor.registerCommand("quit", new ExitCommand()); processor.registerCommand("exit", new ExitCommand()); //Initialization UtlBoolean doPrompt = isatty(STDIN_FILENO); if ( doPrompt ) { printf("Enter command or help/? for help\n"); printf("SIPdriver: "); } for ( commandStatus = CommandProcessor::COMMAND_SUCCESS; ( commandStatus < CommandProcessor::COMMAND_FAILED_EXIT && commandStatus != CommandProcessor::COMMAND_SUCCESS_EXIT && (commandLine = fgets(buffer,1024,stdin)) ); ) { //printf("GOT command line:\"%s\"\n", commandLine); commandStatus = processor.executeCommand(commandLine); //printf("command status: %d exit status: %d\n", commandStatus, //CommandProcessor::COMMAND_SUCCESS_EXIT); if ( doPrompt ) { printf("SIPdriver: "); } } delete msgProc; delete sipUA; return CommandProcessor::COMMAND_SUCCESS_EXIT != commandStatus; }
void testRefreshMgrUATeardown() { for (int i=0; i<NUM_OF_RUNS; ++i) { SipLineMgr* lineMgr = new SipLineMgr(); SipRefreshMgr* refreshMgr = new SipRefreshMgr(); lineMgr->startLineMgr(); lineMgr->initializeRefreshMgr( refreshMgr ); SipUserAgent* sipUA = new SipUserAgent( 5090 ,5090 ,5091 ,NULL // default publicAddress ,NULL // default defaultUser ,"127.0.0.1" // default defaultSipAddress ,NULL // default sipProxyServers ,NULL // default sipDirectoryServers ,NULL // default sipRegistryServers ,NULL // default authenicateRealm ,NULL // default authenticateDb ,NULL // default authorizeUserIds ,NULL // default authorizePasswords ,lineMgr ); sipUA->start(); refreshMgr->init(sipUA); CallManager *pCallManager = new CallManager(FALSE, NULL, //LineMgr TRUE, // early media in 180 ringing NULL, // CodecFactory 9000, // rtp start 9002, // rtp end "sip:[email protected]", "sip:[email protected]", sipUA, //SipUserAgent 0, // sipSessionReinviteTimer NULL, // mgcpStackTask NULL, // defaultCallExtension Connection::RING, // availableBehavior NULL, // unconditionalForwardUrl -1, // forwardOnNoAnswerSeconds NULL, // forwardOnNoAnswerUrl Connection::BUSY, // busyBehavior NULL, // sipForwardOnBusyUrl NULL, // speedNums CallManager::SIP_CALL, // phonesetOutgoingCallProtocol 4, // numDialPlanDigits CallManager::NEAR_END_HOLD, // holdType 5000, // offeringDelay "", // pLocal CP_MAXIMUM_RINGING_EXPIRE_SECONDS, //inviteExpireSeconds QOS_LAYER3_LOW_DELAY_IP_TOS, // expeditedIpTos 10, //maxCalls sipXmediaFactoryFactory(NULL)); //pMediaFactory #if 0 printf("Starting CallManager\n"); #endif pCallManager->start(); lineMgr->requestShutdown(); refreshMgr->requestShutdown(); sipUA->shutdown(TRUE); pCallManager->requestShutdown(); #if 0 printf("Deleting CallManager\n"); #endif delete pCallManager; delete refreshMgr; delete lineMgr; } for (int i=0; i<NUM_OF_RUNS; ++i) { sipxDestroyMediaFactoryFactory() ; } }
// Get and add the credentials for sipXsaa SipLineMgr* addCredentials (UtlString domain, UtlString realm) { SipLineMgr* lineMgr = NULL; UtlString user; CredentialDB* credentialDb; if ((credentialDb = CredentialDB::getInstance())) { Url identity; identity.setUserId(SAASERVER_ID_TOKEN); identity.setHostAddress(domain); UtlString ha1_authenticator; UtlString authtype; bool bSuccess = false; if (credentialDb->getCredential(identity, realm, user, ha1_authenticator, authtype)) { if ((lineMgr = new SipLineMgr())) { SipLine line(identity // user entered url ,identity // identity url ,user // user ,TRUE // visible ,SipLine::LINE_STATE_PROVISIONED ,TRUE // auto enable ,FALSE // use call handling ); if (lineMgr->addLine(line)) { lineMgr->startLineMgr(); if (lineMgr->addCredentialForLine( identity, realm, user, ha1_authenticator ,HTTP_DIGEST_AUTHENTICATION ) ) { lineMgr->setDefaultOutboundLine(identity); bSuccess = true; OsSysLog::add(LOG_FACILITY, PRI_INFO, "Added identity '%s': user='******' realm='%s'" ,identity.toString().data(), user.data(), realm.data() ); } else { OsSysLog::add(LOG_FACILITY, PRI_CRIT, "Error adding identity '%s': user='******' realm='%s'\n", identity.toString().data(), user.data(), realm.data() ); } } else { OsSysLog::add(LOG_FACILITY, PRI_CRIT, "addLine failed" ); } } else { OsSysLog::add(LOG_FACILITY, PRI_CRIT, "Constructing SipLineMgr failed" ); } } else { OsSysLog::add(LOG_FACILITY, PRI_CRIT, "No credential found for '%s' in realm '%s'" ,identity.toString().data(), realm.data() ); } if( !bSuccess ) { delete lineMgr; lineMgr = NULL; } } credentialDb->releaseInstance(); return lineMgr; }