|
|
|
|
@ -221,6 +221,7 @@ int AmConfig::readConfiguration()
|
|
|
|
|
DBG("Reading configuration...\n");
|
|
|
|
|
|
|
|
|
|
AmConfigReader cfg;
|
|
|
|
|
int ret=0;
|
|
|
|
|
|
|
|
|
|
if(cfg.loadFile(AmConfig::ConfigurationFile.c_str())){
|
|
|
|
|
ERROR("while loading main configuration file\n");
|
|
|
|
|
@ -230,6 +231,15 @@ int AmConfig::readConfiguration()
|
|
|
|
|
// take values from global configuration file
|
|
|
|
|
// they will be overwritten by command line args
|
|
|
|
|
|
|
|
|
|
// stderr
|
|
|
|
|
if(cfg.hasParameter("stderr")){
|
|
|
|
|
if(!setLogStderr(cfg.getParameter("stderr"), true)){
|
|
|
|
|
ERROR("invalid stderr value specified,"
|
|
|
|
|
" valid are only yes or no\n");
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_SYSLOG_LOG
|
|
|
|
|
if (cfg.hasParameter("syslog_facility")) {
|
|
|
|
|
set_syslog_facility(cfg.getParameter("syslog_facility").c_str());
|
|
|
|
|
@ -251,7 +261,7 @@ int AmConfig::readConfiguration()
|
|
|
|
|
if(cfg.hasParameter("sip_port")){
|
|
|
|
|
if(!setSIPPort(cfg.getParameter("sip_port").c_str())){
|
|
|
|
|
ERROR("invalid sip port specified\n");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(cfg.hasParameter("media_ip")) {
|
|
|
|
|
@ -313,7 +323,7 @@ int AmConfig::readConfiguration()
|
|
|
|
|
if(cfg.hasParameter("loglevel")){
|
|
|
|
|
if(!setLogLevel(cfg.getParameter("loglevel"))){
|
|
|
|
|
ERROR("invalid log level specified\n");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -350,29 +360,30 @@ int AmConfig::readConfiguration()
|
|
|
|
|
if (!appcfg.good()) {
|
|
|
|
|
ERROR("could not load application mapping file at '%s'\n",
|
|
|
|
|
appcfg_fname.c_str());
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (!appcfg.eof()) {
|
|
|
|
|
string entry;
|
|
|
|
|
getline (appcfg,entry);
|
|
|
|
|
if (!entry.length() || entry[0] == '#')
|
|
|
|
|
continue;
|
|
|
|
|
vector<string> re_v = explode(entry, "=>");
|
|
|
|
|
if (re_v.size() != 2) {
|
|
|
|
|
ERROR("Incorrect line '%s' in %s: expected format 'regexp=>app_name'\n",
|
|
|
|
|
entry.c_str(), appcfg_fname.c_str());
|
|
|
|
|
return -1;
|
|
|
|
|
else {
|
|
|
|
|
while (!appcfg.eof()) {
|
|
|
|
|
string entry;
|
|
|
|
|
getline (appcfg,entry);
|
|
|
|
|
if (!entry.length() || entry[0] == '#')
|
|
|
|
|
continue;
|
|
|
|
|
vector<string> re_v = explode(entry, "=>");
|
|
|
|
|
if (re_v.size() != 2) {
|
|
|
|
|
ERROR("Incorrect line '%s' in %s: expected format 'regexp=>app_name'\n",
|
|
|
|
|
entry.c_str(), appcfg_fname.c_str());
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
regex_t app_re;
|
|
|
|
|
if (regcomp(&app_re, re_v[0].c_str(), REG_EXTENDED | REG_NOSUB)) {
|
|
|
|
|
ERROR("compiling regex '%s' in %s.\n",
|
|
|
|
|
re_v[0].c_str(), appcfg_fname.c_str());
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
DBG("adding application mapping '%s' => '%s'\n",
|
|
|
|
|
re_v[0].c_str(),re_v[1].c_str());
|
|
|
|
|
AppMapping.push_back(make_pair(app_re, re_v[1]));
|
|
|
|
|
}
|
|
|
|
|
regex_t app_re;
|
|
|
|
|
if (regcomp(&app_re, re_v[0].c_str(), REG_EXTENDED | REG_NOSUB)) {
|
|
|
|
|
ERROR("compiling regex '%s' in %s.\n",
|
|
|
|
|
re_v[0].c_str(), appcfg_fname.c_str());
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
DBG("adding application mapping '%s' => '%s'\n",
|
|
|
|
|
re_v[0].c_str(),re_v[1].c_str());
|
|
|
|
|
AppMapping.push_back(make_pair(app_re, re_v[1]));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
AppSelect = App_SPECIFIED;
|
|
|
|
|
@ -385,7 +396,7 @@ int AmConfig::readConfiguration()
|
|
|
|
|
if(!setDaemonMode(cfg.getParameter("fork"))){
|
|
|
|
|
ERROR("invalid fork value specified,"
|
|
|
|
|
" valid are only yes or no\n");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -394,7 +405,7 @@ int AmConfig::readConfiguration()
|
|
|
|
|
if(!setDaemonMode(cfg.getParameter("daemon"))){
|
|
|
|
|
ERROR("invalid daemon value specified,"
|
|
|
|
|
" valid are only yes or no\n");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -408,15 +419,6 @@ int AmConfig::readConfiguration()
|
|
|
|
|
|
|
|
|
|
#endif /* !DISABLE_DAEMON_MODE */
|
|
|
|
|
|
|
|
|
|
// stderr
|
|
|
|
|
if(cfg.hasParameter("stderr")){
|
|
|
|
|
if(!setLogStderr(cfg.getParameter("stderr"), false)){
|
|
|
|
|
ERROR("invalid stderr value specified,"
|
|
|
|
|
" valid are only yes or no\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaxShutdownTime = cfg.getParameterInt("max_shutdown_time",
|
|
|
|
|
DEFAULT_MAX_SHUTDOWN_TIME);
|
|
|
|
|
|
|
|
|
|
@ -424,7 +426,7 @@ int AmConfig::readConfiguration()
|
|
|
|
|
if(cfg.hasParameter("rtp_low_port")){
|
|
|
|
|
if(!setRtpLowPort(cfg.getParameter("rtp_low_port"))){
|
|
|
|
|
ERROR("invalid rtp low port specified\n");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -432,7 +434,7 @@ int AmConfig::readConfiguration()
|
|
|
|
|
if(cfg.hasParameter("rtp_high_port")){
|
|
|
|
|
if(!setRtpHighPort(cfg.getParameter("rtp_high_port"))){
|
|
|
|
|
ERROR("invalid rtp high port specified\n");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -440,12 +442,12 @@ int AmConfig::readConfiguration()
|
|
|
|
|
#ifdef SESSION_THREADPOOL
|
|
|
|
|
if(!setSessionProcessorThreads(cfg.getParameter("session_processor_threads"))){
|
|
|
|
|
ERROR("invalid session_processor_threads value specified\n");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
if (SessionProcessorThreads<1) {
|
|
|
|
|
ERROR("invalid session_processor_threads value specified."
|
|
|
|
|
" need at least one thread\n");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
WARN("session_processor_threads specified in sems.conf,\n");
|
|
|
|
|
@ -458,14 +460,14 @@ int AmConfig::readConfiguration()
|
|
|
|
|
if(cfg.hasParameter("media_processor_threads")){
|
|
|
|
|
if(!setMediaProcessorThreads(cfg.getParameter("media_processor_threads"))){
|
|
|
|
|
ERROR("invalid media_processor_threads value specified");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(cfg.hasParameter("sip_server_threads")){
|
|
|
|
|
if(!setSIPServerThreads(cfg.getParameter("sip_server_threads"))){
|
|
|
|
|
ERROR("invalid sip_server_threads value specified");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -486,7 +488,7 @@ int AmConfig::readConfiguration()
|
|
|
|
|
if(cfg.hasParameter("dead_rtp_time")){
|
|
|
|
|
if(!setDeadRtpTime(cfg.getParameter("dead_rtp_time"))){
|
|
|
|
|
ERROR("invalid dead_rtp_time value specified");
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -534,11 +536,11 @@ int AmConfig::readConfiguration()
|
|
|
|
|
} else {
|
|
|
|
|
ERROR("unknown setting for '100rel' config option: '%s'.\n",
|
|
|
|
|
rel100s.c_str());
|
|
|
|
|
return -1;
|
|
|
|
|
ret = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INFO("100rel: %d.\n", AmConfig::rel100);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|