diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index a47d0f04..8b03b5a4 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -63,6 +63,7 @@ string AmConfig::Application = ""; AmConfig::ApplicationSelector AmConfig::AppSelect = AmConfig::App_SPECIFIED; AmConfig::AppMappingVector AmConfig::AppMapping; bool AmConfig::LogSessions = false; +int AmConfig::UnhandledReplyLoglevel = 0; unsigned int AmConfig::SessionLimit = 0; unsigned int AmConfig::SessionLimitErrCode = 503; @@ -226,6 +227,17 @@ int AmConfig::readConfiguration() LogSessions = cfg.getParameter("log_sessions")=="yes"; + if (cfg.hasParameter("unhandled_reply_loglevel")) { + string msglog = cfg.getParameter("unhandled_reply_loglevel"); + if (msglog == "no") UnhandledReplyLoglevel = -1; + else if (msglog == "error") UnhandledReplyLoglevel = 0; + else if (msglog == "warn") UnhandledReplyLoglevel = 1; + else if (msglog == "info") UnhandledReplyLoglevel = 2; + else if (msglog == "debug") UnhandledReplyLoglevel = 3; + else ERROR("Could not interpret unhandled_reply_loglevel \"%s\"\n", + msglog.c_str()); + } + Application = cfg.getParameter("application"); if (Application == "$(ruri.user)") { diff --git a/core/AmConfig.h b/core/AmConfig.h index af3c05bc..a7d50e51 100644 --- a/core/AmConfig.h +++ b/core/AmConfig.h @@ -125,6 +125,8 @@ struct AmConfig static bool LogSessions; + static int UnhandledReplyLoglevel; + /** Init function. Resolves SMTP server address. */ static int init(); diff --git a/core/AmSipDispatcher.cpp b/core/AmSipDispatcher.cpp index 35d31834..0a209b2b 100644 --- a/core/AmSipDispatcher.cpp +++ b/core/AmSipDispatcher.cpp @@ -42,12 +42,18 @@ AmSipDispatcher* AmSipDispatcher::instance() void AmSipDispatcher::handleSipMsg(AmSipReply &reply) { - AmSipReplyEvent* ev = new AmSipReplyEvent(reply); - if(!AmEventDispatcher::instance()->post(reply.local_tag,ev)){ - - ERROR("could not dispatch reply: %s\n", reply.print().c_str()); - delete ev; + AmSipReplyEvent* ev = new AmSipReplyEvent(reply); + if(!AmEventDispatcher::instance()->post(reply.local_tag,ev)){ + if ((reply.code >= 200) && (reply.code < 300)) { + if (AmConfig::UnhandledReplyLoglevel >= 0) { + _LOG(AmConfig::UnhandledReplyLoglevel, + "unhandled positive reply: %s\n", reply.print().c_str()); + } + } else { + ERROR("unhandled reply: %s\n", reply.print().c_str()); } + delete ev; + } } void AmSipDispatcher::handleSipMsg(AmSipRequest &req) diff --git a/core/etc/sems.conf.sample b/core/etc/sems.conf.sample index 94ffa8de..9ff757a4 100644 --- a/core/etc/sems.conf.sample +++ b/core/etc/sems.conf.sample @@ -250,7 +250,8 @@ loglevel=2 # # - use a Server/User-Agent header with the SEMS server # signature and version. -# Set server_signature=0 in ser_sems.cfg if you use it. +# Set server_signature=0 in ser_sems.cfg if you use SER +# as SIP stack. # # default=no # @@ -305,3 +306,16 @@ loglevel=2 # # dtmf_detector=spandsp +# optional parameter: unhandled_reply_loglevel={error|warn|info|debug|no} +# +# the default application logic implemented in the applications is to stop +# the session right after sending BYE, without waiting for a reply. this +# leads to many log entries of the form +# ERROR: [b6fa6bb0] handleSipMsg (AmSipDispatcher.cpp:48): unhandled +# reply: [code:200;phrase:[OK];... ] +# +# This parameter sets the log lovel of unhandled positive (200 class) replies. +# +# default: error +# +# unhandled_reply_loglevel=info