本文整理汇总了C++中OsConfigDb::get方法的典型用法代码示例。如果您正苦于以下问题:C++ OsConfigDb::get方法的具体用法?C++ OsConfigDb::get怎么用?C++ OsConfigDb::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsConfigDb
的用法示例。
在下文中一共展示了OsConfigDb::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readConfig
// Read config information.
void SipRedirectorISN::readConfig(OsConfigDb& configDb)
{
if (configDb.get("BASE_DOMAIN", mBaseDomain) != OS_SUCCESS ||
mBaseDomain.isNull())
{
OsSysLog::add(FAC_SIP, PRI_CRIT,
"%s::readConfig "
"BASE_DOMAIN parameter missing or empty",
mLogName.data());
}
else
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig "
"BASE_DOMAIN is '%s'", mLogName.data(), mBaseDomain.data());
}
if (configDb.get("PREFIX", mPrefix) != OS_SUCCESS ||
mPrefix.isNull())
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig "
"dialing prefix is empty", mLogName.data());
}
else
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig "
"dialing prefix is '%s'", mLogName.data(), mPrefix.data());
}
}
示例2: RegEx
/// Read (or re-read) the configuration.
void
MSFT_ExchangeTransferHack::readConfig( OsConfigDb& configDb /**< a subhash of the individual configuration
* parameters for this instance of this plugin. */
)
{
/*
* @note
* The parent service may call the readConfig method at any time to
* indicate that the configuration may have changed. The plugin
* should reinitialize itself based on the configuration that exists when
* this is called. The fact that it is a subhash means that whatever prefix
* is used to identify the plugin (see PluginHooks) has been removed (see the
* examples in PluginHooks::readConfig).
*/
Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "MSFT_ExchangeTransferHack[%s]::readConfig",
mInstanceName.data()
);
if (mUserAgentRegEx)
{
delete mUserAgentRegEx;
mUserAgentRegEx = NULL;
}
UtlString recognizer;
if (configDb.get(RecognizerConfigKey, recognizer) && !recognizer.isNull())
{
Os::Logger::instance().log( FAC_SIP, PRI_INFO
,"MSFT_ExchangeTransferHack[%s]::readConfig "
" recognizer %s : '%s'"
,mInstanceName.data(), RecognizerConfigKey
,recognizer.data()
);
try
{
mUserAgentRegEx = new RegEx(recognizer.data());
}
catch(const char* compileError)
{
Os::Logger::instance().log( FAC_SIP, PRI_ERR
,"MSFT_ExchangeTransferHack[%s]::readConfig "
" Invalid recognizer expression '%s' : %s"
,mInstanceName.data()
,recognizer.data()
,compileError
);
mUserAgentRegEx = NULL;
}
}
else
{
Os::Logger::instance().log( FAC_SIP, PRI_NOTICE
,"MSFT_ExchangeTransferHack[%s]::readConfig "
" no recognizer '%s'"
,mInstanceName.data(), RecognizerConfigKey
);
}
}
示例3:
/// Read (or re-read) the authorization rules.
void
TransferControl::readConfig( OsConfigDb& configDb /**< a subhash of the individual configuration
* parameters for this instance of this plugin. */
)
{
/*
* @note
* The parent service may call the readConfig method at any time to
* indicate that the configuration may have changed. The plugin
* should reinitialize itself based on the configuration that exists when
* this is called. The fact that it is a subhash means that whatever prefix
* is used to identify the plugin (see PluginHooks) has been removed (see the
* examples in PluginHooks::readConfig).
*/
Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "TransferControl[%s]::readConfig",
mInstanceName.data()
);
if (configDb.get(RecognizerConfigKey1, server1) && !server1.isNull())
{
Os::Logger::instance().log(FAC_SIP,PRI_INFO
,"TransferControl[%s]::readConfig "
" server %s : '%s'"
,mInstanceName.data(), RecognizerConfigKey1
,server1.data()
);
}
if (configDb.get(RecognizerConfigKey2, server2) && !server2.isNull())
{
Os::Logger::instance().log(FAC_SIP,PRI_INFO
,"TransferControl[%s]::readConfig "
" server %s : '%s'"
,mInstanceName.data(), RecognizerConfigKey2
,server2.data()
);
}
}
示例4: isNull
/// constructor
SharedSecret::SharedSecret(OsConfigDb& domainConfigDb)
{
UtlString base64secret;
if (OS_SUCCESS == domainConfigDb.get(SipXecsService::DomainDbKey::SHARED_SECRET, base64secret))
{
if ( !NetBase64Codec::decode(base64secret, *this)
|| isNull()
)
{
Os::Logger::instance().log(FAC_KERNEL, PRI_CRIT,
"SharedSecret::_ invalid value '%s' for '%s' found in '%s'; aborting",
base64secret.data(),
SipXecsService::DomainDbKey::SHARED_SECRET,
domainConfigDb.getIdentityLabel());
// We assume that if the component wants a signing secret for some security-critical
// purpose. Rather than continue without this security-critical data, stop.
assert(false);
}
else
{
Os::Logger::instance().log(FAC_KERNEL, PRI_DEBUG,
"SharedSecret::_ loaded from '%s' length %zu",
domainConfigDb.getIdentityLabel(), length());
}
}
else
{
Os::Logger::instance().log(FAC_KERNEL, PRI_CRIT,
"SharedSecret::_ no value for '%s' found in '%s'; using fixed value",
SipXecsService::DomainDbKey::SHARED_SECRET, domainConfigDb.getIdentityLabel());
// We assume that if the component wants a signing secret for some security-critical
// purpose. Rather than continue without this security-critical data, stop.
// @TODO assert(false);
}
};
示例5: readConfig
// Read config information.
void SipRedirectorRegDB::readConfig(OsConfigDb& configDb)
{
configDb.get("MAPPING_FILE", mMappingFileName);
}
示例6: addCredentials
// Initializer
OsStatus
SipRedirectorJoin::initialize(OsConfigDb& configDb,
int redirectorNo,
const UtlString& localDomainHost)
{
// If the join redirection is active, set up the machinery
// to execute it.
if (mRedirectorActive == OS_SUCCESS)
{
// Get and save our domain name.
mDomain = localDomainHost;
UtlString bindIp;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
{
bindIp = "0.0.0.0";
}
// Authentication Realm Name
UtlString realm;
configDb.get("SIP_REGISTRAR_AUTHENTICATE_REALM", realm);
// Get SipLineMgr containing the credentials for REGISTRAR_ID_TOKEN.
SipLineMgr* lineMgr = addCredentials(mDomain, realm);
// Create a SIP user agent to generate SUBSCRIBEs and receive NOTIFYs,
// and save a pointer to it.
// Having a separate user agent ensures that the NOTIFYs are not
// processed for redirection, but rather we can act as a UAS to
// process them.
mpSipUserAgent = new SipUserAgent(
// Let the system choose the port numbers.
PORT_DEFAULT, // sipTcpPort
PORT_DEFAULT, // sipUdpPort
PORT_DEFAULT, // sipTlsPort
NULL, // publicAddress
NULL, // defaultUser
bindIp, // defaultSipAddress
NULL, // sipProxyServers
NULL, // sipDirectoryServers
NULL, // sipRegistryServers
NULL, // authenicateRealm
NULL, // authenticateDb
NULL, // authorizeUserIds
NULL, // authorizePasswords
lineMgr, // lineMgr
SIP_DEFAULT_RTT, // sipFirstResendTimeout
TRUE, // defaultToUaTransactions
-1, // readBufferSize
OsServerTask::DEF_MAX_MSGS, // queueSize
FALSE // bUseNextAvailablePort
);
mpSipUserAgent->setUserAgentHeaderProperty("sipXecs/redirectorJoin");
mpSipUserAgent->start();
// Initialize the CSeq counter to an arbitrary acceptable value.
mCSeq = 14711;
// Create and start the task to receive NOTIFYs.
mTask = new SipRedirectorJoinTask(mpSipUserAgent, redirectorNo);
mTask->start();
}
return mRedirectorActive;
}
示例7: readConfig
// Read config information.
void SipRedirectorPresenceRouting::readConfig(OsConfigDb& configDb)
{
// extract the realm information from the config DB - we need this part
// to do the credentials db look-up.
if ((configDb.get(CONFIG_SETTING_REALM, mRealm) != OS_SUCCESS) ||
mRealm.isNull())
{
OsSysLog::add(FAC_SIP, PRI_ERR,
"%s::readConfig No Realm specified in the configuration",
mLogName.data());
}
else
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig mRealm = '%s'",
mLogName.data(), mRealm.data() );
}
mbForwardToVmOnBusy = configDb.getBoolean(CONFIG_SETTING_VOICEMAIL_ON_BUSY, FALSE);
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig mbForwardToVmOnBusy = %d",
mLogName.data(), mbForwardToVmOnBusy);
UtlString prefsFilename;
configDb.get(CONFIG_SETTING_USER_PREFS_FILE, prefsFilename);
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig prefsFilename = %s",
mLogName.data(), prefsFilename.data());
mUserPrefs.loadPrefs( prefsFilename );
UtlString openFirePresenceServerUrlAsString;
if ((configDb.get(CONFIG_OPENFIRE_PRESENCE_SERVER_URL, openFirePresenceServerUrlAsString) != OS_SUCCESS) ||
openFirePresenceServerUrlAsString.isNull())
{
OsSysLog::add(FAC_SIP, PRI_ERR,
"%s::readConfig No URL specified for openfire presence server in the configuration",
mLogName.data());
}
else
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig openFirePresenceServerUrlAsString = '%s'",
mLogName.data(), openFirePresenceServerUrlAsString.data() );
mOpenFirePresenceServerUrl.fromString( openFirePresenceServerUrlAsString );
}
UtlString presenceMonitorServerUrlAsString;
if ((configDb.get(CONFIG_PRESENCE_MONITOR_SERVER_URL, presenceMonitorServerUrlAsString) != OS_SUCCESS) ||
presenceMonitorServerUrlAsString.isNull())
{
OsSysLog::add(FAC_SIP, PRI_ERR,
"%s::readConfig No URL specified for local presence monitor server in the configuration",
mLogName.data());
}
else
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig presenceMonitorServerUrlAsString = '%s'",
mLogName.data(), presenceMonitorServerUrlAsString.data() );
mLocalPresenceMonitorServerUrl.fromString( presenceMonitorServerUrlAsString );
}
}
示例8: main
//
// The main entry point to sipXrls.
//
int main(int argc, char* argv[])
{
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
UtlString argString;
for (int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if (argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", VERSION, PACKAGE_REVISION);
return 1;
}
else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return 1;
}
}
// Load configuration file.
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
fprintf(stderr, "Failed to load config DB from file '%s'",
fileName.data());
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int udpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, udpPort) != OS_SUCCESS)
{
udpPort = RLS_DEFAULT_UDP_PORT;
}
int tcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, tcpPort) != OS_SUCCESS)
{
tcpPort = RLS_DEFAULT_TCP_PORT;
}
UtlString bindIp;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
bindIp = RLS_DEFAULT_BIND_IP;
UtlString resourceListFile;
if ((configDb.get(CONFIG_SETTING_RLS_FILE, resourceListFile) !=
OS_SUCCESS) ||
resourceListFile.isNull())
{
Os::Logger::instance().log(LOG_FACILITY, PRI_CRIT,
"Resource list file name is not configured");
return 1;
}
UtlString domainName;
if ((configDb.get(CONFIG_SETTING_DOMAIN_NAME, domainName) !=
OS_SUCCESS) ||
domainName.isNull())
{
Os::Logger::instance().log(LOG_FACILITY, PRI_CRIT,
"Resource domain name is not configured");
return 1;
}
UtlString realm;
if ((configDb.get(CONFIG_SETTING_AUTHENTICATE_REALM, realm) !=
OS_SUCCESS) ||
realm.isNull())
{
Os::Logger::instance().log(LOG_FACILITY, PRI_CRIT,
//.........这里部分代码省略.........
示例9: loadConfig
//
// Pull out important parameters from the config DB.
// These parameters are set at runtime and cannot be changed without a restart.
//
UtlBoolean ParkService::loadConfig(
int& UdpPort,
int& TcpPort,
int& RtpBase,
UtlString& bindIp,
int& MaxSessions,
UtlBoolean& OneButtonBLF,
UtlString& domain,
UtlString& realm,
UtlString& user,
SipLineMgr* lineMgr,
int& Lifetime,
int& BlindXferWait,
int& KeepAliveTime
)
{
UtlBoolean ret = true;
// SipXecsService owns the main configDb
OsConfigDb& configDb = getConfigDb();
// Read the user agent parameters from the config file.
if (configDb.get(CONFIG_SETTING_UDP_PORT, UdpPort) != OS_SUCCESS)
UdpPort = PARK_DEFAULT_UDP_PORT;
if (configDb.get(CONFIG_SETTING_TCP_PORT, TcpPort) != OS_SUCCESS)
TcpPort = PARK_DEFAULT_TCP_PORT;
if (configDb.get(CONFIG_SETTING_RTP_PORT, RtpBase) != OS_SUCCESS)
RtpBase = DEFAULT_RTP_PORT;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
bindIp = PARK_DEFAULT_BIND_IP;
if (configDb.get(CONFIG_SETTING_MAX_SESSIONS, MaxSessions) != OS_SUCCESS)
{
MaxSessions = DEFAULT_MAX_SESSIONS;
}
OneButtonBLF =
configDb.getBoolean(CONFIG_SETTING_ONE_BUTTON_BLF, DEFAULT_ONE_BUTTON_BLF);
OsConfigDb domainConfiguration;
OsPath domainConfigPath = SipXecsService::domainConfigPath();
if (OS_SUCCESS == domainConfiguration.loadFromFile(domainConfigPath.data()))
{
domainConfiguration.get(SipXecsService::DomainDbKey::SIP_DOMAIN_NAME, domain);
domainConfiguration.get(SipXecsService::DomainDbKey::SIP_REALM, realm);
if (!domain.isNull() && !realm.isNull())
{
CredentialDB* credentialDb;
if ((credentialDb = CredentialDB::getInstance()))
{
Url identity;
identity.setUserId(PARK_SERVER_ID_TOKEN);
identity.setHostAddress(domain);
UtlString ha1_authenticator;
UtlString authtype;
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
)
)
{
OsSysLog::add(LOG_FACILITY, PRI_INFO,
"Added identity '%s': user='%s' realm='%s'"
,identity.toString().data(), user.data(), realm.data()
);
}
else
{
OsSysLog::add(LOG_FACILITY, PRI_ERR,
"Error adding identity '%s': user='%s' realm='%s'\n"
" escape and timeout from park may not work.",
identity.toString().data(), user.data(), realm.data()
//.........这里部分代码省略.........
示例10: supervisorMain
int supervisorMain(bool bOriginalSupervisor)
{
// Create forked process which will do nothing unless parent dies. Parent continues with initialization.
forkSupervisorInWaiting();
// Drop privileges down to the specified user & group
const char * sipxpbxuser = SipXecsService::User();
const char * sipxpbxgroup = SipXecsService::Group();
if (NULL == sipxpbxuser || 0 == strlen(sipxpbxuser))
{
osPrintf("sipXsupervisor: Failed to setuid(%s), username not defined.\n",
sipxpbxuser);
return 2;
}
if (NULL == sipxpbxgroup || 0 == strlen(sipxpbxgroup))
{
osPrintf("sipXsupervisor: Failed to setgid(%s), groupname not defined.\n",
sipxpbxgroup);
return 2;
}
struct group * grp = getgrnam(sipxpbxgroup);
if (NULL == grp)
{
if (0 != errno)
{
osPrintf("getgrnam(%s) failed, errno = %d.",
sipxpbxgroup, errno);
}
else
{
osPrintf(
"sipXsupervisor: getgrnam(%s) failed, user does not exist.",
sipxpbxgroup);
}
return 3;
}
struct passwd * pwd = getpwnam(sipxpbxuser);
if (NULL == pwd)
{
if (0 != errno)
{
osPrintf("getpwnam(%s) failed, errno = %d.",
sipxpbxuser, errno);
}
else
{
osPrintf(
"sipXsupervisor: getpwnam(%s) failed, user does not exist.",
sipxpbxuser);
}
return 3;
}
// Change group first, cause once user is changed this cannot be done.
if (0 != setgid(grp->gr_gid))
{
osPrintf("sipXsupervisor: setgid(%d) failed, errno = %d.",
(int)grp->gr_gid, errno);
return 4;
}
if (0 != setuid(pwd->pw_uid))
{
osPrintf("sipXsupervisor: setuid(%d) failed, errno = %d.",
(int)pwd->pw_uid, errno);
return 4;
}
# if 0
// Only output problems. This keeps the startup output clean.
osPrintf("sipXsupervisor: Dropped privileges with setuid(%s)/setgid(%s).",
sipxpbxuser, sipxpbxgroup);
#endif
OsMsgQShared::setQueuePreference(OsMsgQShared::QUEUE_UNLIMITED);
// Block all signals in this the main thread
// Any threads created after this will have all signals masked.
OsTask::blockSignals();
// Create a new task to wait for signals. Only that task
// will ever see a signal from the outside.
SignalTask* signalTask = new SignalTask();
signalTask->start() ;
// All osPrintf output should go to the console until the log file is initialized.
enableConsoleOutput(true);
// Initialize the log file.
Os::LoggerHelper::instance().processName = "Supervisor";
UtlString logFile = SipXecsService::Path(SipXecsService::LogDirType, "sipxsupervisor.log");
Os::LoggerHelper::instance().initialize(PRI_DEBUG, logFile.data());
if (!bOriginalSupervisor)
{
Os::Logger::instance().log(FAC_SUPERVISOR, PRI_CRIT,
//.........这里部分代码省略.........
示例11: main
//
// The main entry point to the sipXpark
//
int main(int argc, char* argv[])
{
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
// Register Signal handlers so we can perform graceful shutdown
pt_signal(SIGINT, sigHandler); // Trap Ctrl-C on NT
pt_signal(SIGILL, sigHandler);
pt_signal(SIGABRT, sigHandler); // Abort signal 6
pt_signal(SIGFPE, sigHandler); // Floading Point Exception
pt_signal(SIGSEGV, sigHandler); // Address access violations signal 11
pt_signal(SIGTERM, sigHandler); // Trap kill -15 on UNIX
#if defined(__pingtel_on_posix__)
pt_signal(SIGHUP, sigHandler); // Hangup
pt_signal(SIGQUIT, sigHandler);
pt_signal(SIGPIPE, SIG_IGN); // Handle TCP Failure
pt_signal(SIGBUS, sigHandler);
pt_signal(SIGSYS, sigHandler);
pt_signal(SIGXCPU, sigHandler);
pt_signal(SIGXFSZ, sigHandler);
pt_signal(SIGUSR1, sigHandler);
pt_signal(SIGUSR2, sigHandler);
#endif
UtlString argString;
for(int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if(argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", SIPXCHANGE_VERSION, SIPXCHANGE_VERSION_COMMENT);
return(1);
}
else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return(1);
}
}
// Load configuration file file
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int UdpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, UdpPort) != OS_SUCCESS)
{
UdpPort = PRESENCE_DEFAULT_UDP_PORT;
}
int TcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, TcpPort) != OS_SUCCESS)
{
TcpPort = PRESENCE_DEFAULT_TCP_PORT;
}
UtlString bindIp;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
{
bindIp = PRESENCE_DEFAULT_BIND_IP;
}
// Bind the SIP user agent to a port and start it up
SipUserAgent* userAgent = new SipUserAgent(TcpPort, UdpPort, PORT_NONE,
NULL, NULL, bindIp );
userAgent->start();
if (!userAgent->isOk())
{
//.........这里部分代码省略.........
示例12: defaultDomainUrl
// Constructor
SipRegistrar::SipRegistrar(OsConfigDb* configDb) :
OsServerTask("SipRegistrar", NULL, SIPUA_DEFAULT_SERVER_OSMSG_QUEUE_SIZE),
mConfigDb(configDb),
mRegistrationDB(RegistrationDB::getInstance()), // implicitly loads database
mHttpServer(NULL),
mXmlRpcDispatch(NULL),
mReplicationConfigured(false),
mSipUserAgent(NULL),
mRedirectServer(NULL),
mRedirectMsgQ(NULL),
// Create the SipRegistrarServer object so it will be available immediately,
// but don't start the associated thread until the registrar is operational.
mRegistrarServer(new SipRegistrarServer(*this)),
mRegistrarMsgQ(NULL),
mRegistrarInitialSync(NULL),
mRegistrarSync(NULL),
mRegisterEventServer(NULL),
mRegistrarTest(NULL),
mRegistrarPersist(NULL)
{
OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipRegistrar::SipRegistrar constructed.");
mHttpPort = mConfigDb->getPort("SIP_REGISTRAR_XMLRPC_PORT");
if (PORT_NONE == mHttpPort)
{
OsSysLog::add(FAC_SIP, PRI_NOTICE,
"SipRegistrar::SipRegistrar"
" SIP_REGISTRAR_XMLRPC_PORT == PORT_NONE :"
" peer synchronization disabled"
);
}
else // HTTP/RPC port is configured
{
if (PORT_DEFAULT == mHttpPort)
{
mHttpPort = SIP_REGISTRAR_DEFAULT_XMLRPC_PORT;
}
configurePeers();
}
// Some phones insist (incorrectly) on putting the proxy port number on urls;
// we get it from the configuration so that we can ignore it.
mProxyNormalPort = mConfigDb->getPort("SIP_REGISTRAR_PROXY_PORT");
if (mProxyNormalPort == PORT_DEFAULT)
{
mProxyNormalPort = SIP_PORT;
}
// Domain Name
mConfigDb->get("SIP_REGISTRAR_DOMAIN_NAME", mDefaultDomain);
if ( mDefaultDomain.isNull() )
{
OsSocket::getHostIp(&mDefaultDomain);
OsSysLog::add(FAC_SIP, PRI_CRIT,
"SIP_REGISTRAR_DOMAIN_NAME not configured using IP '%s'",
mDefaultDomain.data()
);
}
// get the url parts for the domain
Url defaultDomainUrl(mDefaultDomain);
mDefaultDomainPort = defaultDomainUrl.getHostPort();
defaultDomainUrl.getHostAddress(mDefaultDomainHost);
// make sure that the unspecified domain name is also valid
addValidDomain(mDefaultDomainHost, mDefaultDomainPort);
// read the domain configuration
OsConfigDb domainConfig;
domainConfig.loadFromFile(SipXecsService::domainConfigPath());
// Domain Aliases
// (other domain names that this registrar accepts as valid in the request URI)
UtlString domainAliases;
domainConfig.get(SipXecsService::DomainDbKey::SIP_DOMAIN_ALIASES, domainAliases);
if (!domainAliases.isNull())
{
OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipRegistrar::SipRegistrar "
"SIP_DOMAIN_ALIASES : %s", domainAliases.data());
}
else
{
OsSysLog::add(FAC_SIP, PRI_ERR, "SipRegistrar::SipRegistrar "
"SIP_DOMAIN_ALIASES not found.");
}
UtlString aliasString;
int aliasIndex = 0;
while(NameValueTokenizer::getSubField(domainAliases.data(), aliasIndex,
", \t", &aliasString))
{
Url aliasUrl(aliasString);
UtlString hostAlias;
aliasUrl.getHostAddress(hostAlias);
int port = aliasUrl.getHostPort();
addValidDomain(hostAlias,port);
aliasIndex++;
//.........这里部分代码省略.........
示例13: while
/// Read (or re-read) the authorization rules.
void
SubscriptionAuth::readConfig( OsConfigDb& configDb /**< a subhash of the individual configuration
* parameters for this instance of this plugin. */
)
{
/*
* @note
* The parent service may call the readConfig method at any time to
* indicate that the configuration may have changed. The plugin
* should reinitialize itself based on the configuration that exists when
* this is called. The fact that it is a subhash means that whatever prefix
* is used to identify the plugin (see PluginHooks) has been removed (see the
* examples in PluginHooks::readConfig).
*/
OsSysLog::add(FAC_SIP, PRI_DEBUG, "SubscriptionAuth[%s]::readConfig",
mInstanceName.data()
);
mEventPackagesRequiringAuthentication.destroyAll();
mTargetsExemptedFromAuthentication.destroyAll();
UtlString eventPackagesRequiringAuthentication;
if (configDb.get(EventsRequiringAuthenticationKey,
eventPackagesRequiringAuthentication) &&
!eventPackagesRequiringAuthentication.isNull())
{
OsSysLog::add( FAC_SIP, PRI_INFO
,"SubscriptionAuth[%s]::readConfig "
" %s = '%s'"
,mInstanceName.data(), EventsRequiringAuthenticationKey
,eventPackagesRequiringAuthentication.data()
);
int eventPackageIndex = 0;
UtlString eventPackageName;
while(NameValueTokenizer::getSubField(eventPackagesRequiringAuthentication.data(),
eventPackageIndex,
", \t", &eventPackageName))
{
mEventPackagesRequiringAuthentication.insert( new UtlString( eventPackageName ) );
eventPackageIndex++;
}
}
else
{
OsSysLog::add( FAC_SIP, PRI_NOTICE
,"SubscriptionAuth[%s]::readConfig "
" %s not found - no subscription will be challenged by this plug-in"
,mInstanceName.data(), EventsRequiringAuthenticationKey
);
}
UtlString targetsExemptedFromAuthentication;
if (configDb.get(TargetsExemptedFromAuthenticationKey,
targetsExemptedFromAuthentication) &&
!targetsExemptedFromAuthentication.isNull())
{
OsSysLog::add( FAC_SIP, PRI_INFO
,"SubscriptionAuth[%s]::readConfig "
" %s = '%s'"
,mInstanceName.data(), TargetsExemptedFromAuthenticationKey
,targetsExemptedFromAuthentication.data()
);
int targetIndex = 0;
UtlString targetName;
while(NameValueTokenizer::getSubField(targetsExemptedFromAuthentication.data(),
targetIndex,
", \t", &targetName))
{
RegEx* targetRegEx;
targetIndex++;
try
{
targetRegEx = new RegEx(targetName.data());
mTargetsExemptedFromAuthentication.insert(targetRegEx);
}
catch(const char* compileError)
{
OsSysLog::add(FAC_SIP, PRI_ERR
,"SubscriptionAuth[%s]::readConfig Invalid recognizer expression '%s' for '%s': %s"
,mInstanceName.data()
,targetName.data()
,TargetsExemptedFromAuthenticationKey
,compileError
);
}
}
}
}
示例14: readConfig
// Read config information.
void SipRedirectorGateway::readConfig(OsConfigDb& configDb)
{
UtlString string;
char *endptr;
mReturn = OS_SUCCESS;
if (configDb.get("MAPPING_FILE", mMappingFileName) != OS_SUCCESS ||
mMappingFileName.isNull())
{
OsSysLog::add(FAC_SIP, PRI_CRIT,
"%s::readConfig "
"MAPPING_FILE parameter '%s' missing or empty",
mLogName.data(), mMappingFileName.data());
mReturn = OS_FAILED;
}
else
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig "
"MAPPING_FILE is '%s'",
mLogName.data(), mMappingFileName.data());
}
if (configDb.get("PREFIX", mPrefix) != OS_SUCCESS ||
mPrefix.isNull())
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig "
"dialing prefix is empty", mLogName.data());
}
else
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig "
"dialing prefix is '%s'", mLogName.data(), mPrefix.data());
}
if (configDb.get("DIGITS", string) == OS_SUCCESS &&
!string.isNull() &&
(mDigits = strtol(string.data(), &endptr, 10),
endptr - string.data() == string.length() &&
mDigits >= 1 && mDigits <= 10))
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig "
"variable digit count is %d", mLogName.data(), mDigits);
}
else
{
OsSysLog::add(FAC_SIP, PRI_CRIT,
"%s::readConfig "
"variable digit count is missing, empty, "
"or out of range (1 to 10)",
mLogName.data());
mReturn = OS_FAILED;
}
if (configDb.get("PORT", string) == OS_SUCCESS &&
!string.isNull() &&
(mPort = strtol(string.data(), &endptr, 10),
endptr - string.data() == string.length() &&
mPort >= 1 && mPort <= 65535))
{
OsSysLog::add(FAC_SIP, PRI_INFO,
"%s::readConfig "
"listening port is %d", mLogName.data(), mPort);
}
else
{
OsSysLog::add(FAC_SIP, PRI_CRIT,
"%s::readConfig "
"listening port '%s' is missing, empty, "
"or out of range (1 to 65535)",
mLogName.data(), string.data());
mReturn = OS_FAILED;
}
}
示例15: main
//
// The main entry point to sipXsaa.
//
int main(int argc, char* argv[])
{
// Block all signals in this the main thread.
// Any threads created from now on will have all signals masked.
OsTask::blockSignals();
// Create a new task to wait for signals. Only that task
// will ever see a signal from the outside.
SignalTask* signalTask = new SignalTask();
signalTask->start();
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
UtlString argString;
for (int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if (argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", SIPXCHANGE_VERSION,
SIPXCHANGE_VERSION_COMMENT);
return 1;
}
else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return 1;
}
}
// Load configuration file.
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int udpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, udpPort) != OS_SUCCESS)
{
udpPort = SAA_DEFAULT_UDP_PORT;
}
int tcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, tcpPort) != OS_SUCCESS)
{
tcpPort = SAA_DEFAULT_TCP_PORT;
}
UtlString bindIp;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
bindIp = SAA_DEFAULT_BIND_IP;
UtlString appearanceGroupFile;
if ((configDb.get(CONFIG_SETTING_SAA_FILE, appearanceGroupFile) !=
OS_SUCCESS) ||
appearanceGroupFile.isNull())
{
OsSysLog::add(LOG_FACILITY, PRI_CRIT,
"Appearance group file name is not configured");
return 1;
}
UtlString domainName;
if ((configDb.get(CONFIG_SETTING_DOMAIN_NAME, domainName) !=
OS_SUCCESS) ||
domainName.isNull())
{
OsSysLog::add(LOG_FACILITY, PRI_CRIT,
"Resource domain name is not configured");
//.........这里部分代码省略.........