Module: sems
Branch: 1.4
Commit: 44f9845ace2e24e9cd0fea86f5cee1ae81d17b20
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=44f9845ace2e24e9cd0fea86f5cee1ae81d17b20

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Thu Sep 12 20:42:33 2013 +0200

reply to OPTIONS also if no application configured

reported by Julian Santer

Conflicts:

        core/AmApi.cpp
        core/AmPlugIn.cpp
        core/AmSipDispatcher.cpp
        core/sip/defs.h

---

 core/AmApi.cpp           |   47 ++++++++++++++++++++++++---------------------
 core/AmApi.h             |    3 ++
 core/AmPlugIn.cpp        |    4 +-
 core/AmSipDispatcher.cpp |    9 +++++++-
 core/AmSipHeaders.h      |    1 +
 5 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/core/AmApi.cpp b/core/AmApi.cpp
index c67baef..895234b 100644
--- a/core/AmApi.cpp
+++ b/core/AmApi.cpp
@@ -76,37 +76,40 @@ 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)) {
-      // return error code if near to overload
-      AmSipDialog::reply_error(req,
-                              AmConfig::OptionsSessionLimitErrCode, 
-                              AmConfig::OptionsSessionLimitErrReason);
-      return;
-    }
-
-    if (AmConfig::ShutdownMode) {
-      // return error code if in shutdown mode
-      AmSipDialog::reply_error(req,
-                              AmConfig::ShutdownModeErrCode,
-                              AmConfig::ShutdownModeErrReason);
-      return;
-    }
-
-    AmSipDialog::reply_error(req, 200, "OK");
+  if (req.method == SIP_METH_OPTIONS) {
+    replyOptions(req);
     return;
   }
 
   INFO("sorry, we don't support beginning a new session with "
        "a '%s' message\n", req.method.c_str());
-    
+
   AmSipDialog::reply_error(req,501,"Not Implemented");
   return;
 }
 
+void AmSessionFactory::replyOptions(const AmSipRequest& req) {
+  // Basic OPTIONS support
+  if (AmConfig::OptionsSessionLimit &&
+      (AmSession::getSessionNum() >= AmConfig::OptionsSessionLimit)) {
+    // return error code if near to overload
+    AmSipDialog::reply_error(req,
+                            AmConfig::OptionsSessionLimitErrCode, 
+                            AmConfig::OptionsSessionLimitErrReason);
+    return;
+  }
+
+  if (AmConfig::ShutdownMode) {
+    // return error code if in shutdown mode
+    AmSipDialog::reply_error(req,
+                            AmConfig::ShutdownModeErrCode,
+                            AmConfig::ShutdownModeErrReason);
+    return;
+  }
+
+  AmSipDialog::reply_error(req, 200, "OK");
+}
+
 // void AmSessionFactory::postEvent(AmEvent* ev) {
 //   ERROR("unhandled Event in %s module\n", getName().c_str());
 //   delete ev;
diff --git a/core/AmApi.h b/core/AmApi.h
index 4a1a6ae..f6d37b9 100644
--- a/core/AmApi.h
+++ b/core/AmApi.h
@@ -134,6 +134,9 @@ class AmSessionFactory: public AmPluginFactory
   int configureModule(AmConfigReader& cfg);
 
  public:
+
+  static void replyOptions(const AmSipRequest& req);
+
   /**
    * This function applys the module configuration 
    */
diff --git a/core/AmPlugIn.cpp b/core/AmPlugIn.cpp
index 682212f..905eefc 100644
--- a/core/AmPlugIn.cpp
+++ b/core/AmPlugIn.cpp
@@ -794,14 +794,14 @@ AmSessionFactory* 
AmPlugIn::findSessionFactory(AmSipRequest& req)
     }
 
     if (req.cmd.empty()) {
-       ERROR("could not find any application matching configured criteria\n");
+       INFO("could not find any application matching configured criteria\n");
        return NULL;
     }
   }
 
   AmSessionFactory* session_factory = getFactory4App(req.cmd);
   if(!session_factory) {
-    ERROR("AmPlugIn::findSessionFactory: application '%s' not found !\n", 
req.cmd.c_str());
+    INFO("AmPlugIn::findSessionFactory: application '%s' not found !\n", 
req.cmd.c_str());
   }
 
   return session_factory;
diff --git a/core/AmSipDispatcher.cpp b/core/AmSipDispatcher.cpp
index 574ce54..d30259e 100644
--- a/core/AmSipDispatcher.cpp
+++ b/core/AmSipDispatcher.cpp
@@ -66,6 +66,7 @@ void AmSipDispatcher::handleSipMsg(AmSipRequest &req)
   AmEventDispatcher* ev_disp = AmEventDispatcher::instance();
 
   if(!local_tag.empty()) {
+    // in-dlg request
     AmSipRequestEvent* ev = new AmSipRequestEvent(req);
 
       if(!ev_disp->post(local_tag,ev)) {
@@ -111,8 +112,13 @@ void AmSipDispatcher::handleSipMsg(AmSipRequest &req)
       AmSessionFactory* sess_fact = 
AmPlugIn::instance()->findSessionFactory(req);
       if(!sess_fact){
 
-         AmSipDialog::reply_error(req,404,"Not found");
+       if (req.method == SIP_METH_OPTIONS) {
+         AmSessionFactory::replyOptions(req);
          return;
+       }
+
+       AmSipDialog::reply_error(req,404,"Not found");
+       return;
       }
 
       sess_fact->onOoDRequest(req);
@@ -126,4 +132,5 @@ void AmSipDispatcher::handleSipMsg(AmSipRequest &req)
       return;
     }
   }
+
 }
diff --git a/core/AmSipHeaders.h b/core/AmSipHeaders.h
index 1bdeef7..3535476 100644
--- a/core/AmSipHeaders.h
+++ b/core/AmSipHeaders.h
@@ -9,6 +9,7 @@
 #define SIP_METH_UPDATE         "UPDATE"
 #define SIP_METH_BYE            "BYE"
 #define SIP_METH_ACK            "ACK"
+#define SIP_METH_OPTIONS        "OPTIONS"
 
 #define SIP_HDR_FROM            "From"
 #define SIP_HDR_TO              "To"

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to