From 325762d2da2720dfb49703079316786daca7f974 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 19 Feb 2011 22:57:33 +0100 Subject: [PATCH] moves the OPTIONS handling from AmSipDispatcher to AmSessionFactory. patch by Robert Szokovacs. --- core/AmApi.cpp | 16 ++++++++++++++++ core/AmApi.h | 2 +- core/AmSipDispatcher.cpp | 16 +--------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/core/AmApi.cpp b/core/AmApi.cpp index 0cce1d7f..74489a9e 100644 --- a/core/AmApi.cpp +++ b/core/AmApi.cpp @@ -76,6 +76,22 @@ void AmSessionFactory::configureSession(AmSession* sess) { void AmSessionFactory::onOoDRequest(const AmSipRequest& req) { + if(req.method == "OPTIONS"){ + + // Basic OPTIONS support + if (!AmConfig::OptionsSessionLimit || + (AmSession::getSessionNum() < AmConfig::OptionsSessionLimit)) { + AmSipDialog::reply_error(req, 200, "OK"); + } else { + // return error code if near to overload + AmSipDialog::reply_error(req, + AmConfig::OptionsSessionLimitErrCode, + AmConfig::OptionsSessionLimitErrReason); + } + return; + + } + ERROR("sorry, we don't support beginning a new session with " "a '%s' message\n", req.method.c_str()); diff --git a/core/AmApi.h b/core/AmApi.h index df7b9977..c3358fb2 100644 --- a/core/AmApi.h +++ b/core/AmApi.h @@ -182,7 +182,7 @@ class AmSessionFactory: public AmPluginFactory /** * Method to receive any out-of-dialog request - * other than INVITE, REFER and OPTIONS + * other than INVITE and REFER * * Warning: * This method should not make any expensive diff --git a/core/AmSipDispatcher.cpp b/core/AmSipDispatcher.cpp index 0745c316..ac8dc857 100644 --- a/core/AmSipDispatcher.cpp +++ b/core/AmSipDispatcher.cpp @@ -95,21 +95,7 @@ void AmSipDispatcher::handleSipMsg(AmSipRequest &req) AmSessionContainer::instance()->startSessionUAS(req); } - else if(req.method == "OPTIONS"){ - - // Basic OPTIONS support - if (!AmConfig::OptionsSessionLimit || - (AmSession::getSessionNum() < AmConfig::OptionsSessionLimit)) { - AmSipDialog::reply_error(req, 200, "OK"); - } else { - // return error code if near to overload - AmSipDialog::reply_error(req, - AmConfig::OptionsSessionLimitErrCode, - AmConfig::OptionsSessionLimitErrReason); - } - return; - - } else if( (req.method == "CANCEL") || + else if( (req.method == "CANCEL") || (req.method == "BYE") ){ // CANCEL/BYE of a (here) non-existing dialog