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

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Fri Mar  2 22:13:34 2012 +0100

sbc: load_cc_plugins config param - load call control modules from sbc module

---

 apps/sbc/SBC.cpp                                 |   33 ++++++++++++++++++++++
 apps/sbc/SBC.h                                   |    1 +
 apps/sbc/etc/sbc.conf                            |    7 ++++
 apps/sbc/tools/sems-sbc-load-callcontrol-modules |   12 ++++++++
 doc/Readme.sbc.txt                               |    4 ++
 5 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp
index 9d75ea4..c2c3519 100644
--- a/apps/sbc/SBC.cpp
+++ b/apps/sbc/SBC.cpp
@@ -77,6 +77,17 @@ int SBCFactory::onLoad()
     return -1;
   }
 
+  string load_cc_plugins = cfg.getParameter("load_cc_plugins");
+  if (!load_cc_plugins.empty()) {
+    INFO("loading call control plugins '%s' from '%s'\n",
+        load_cc_plugins.c_str(), AmConfig::PlugInPath.c_str());
+    if (AmPlugIn::instance()->load(AmConfig::PlugInPath, load_cc_plugins) < 0) 
{
+      ERROR("loading call control plugins '%s' from '%s'\n",
+           load_cc_plugins.c_str(), AmConfig::PlugInPath.c_str());
+      return -1;
+    }
+  }
+
   session_timer_fact = AmPlugIn::instance()->getFactory4Seh("session_timer");
   if(!session_timer_fact) {
     WARN("session_timer plug-in not loaded - "
@@ -350,6 +361,9 @@ void SBCFactory::invoke(const string& method, const AmArg& 
args,
   } else if (method == "setRegexMap"){
     args.assertArrayFmt("u");
     setRegexMap(args,ret);
+  } else if (method == "loadCallcontrolModules"){
+    args.assertArrayFmt("s");
+    loadCallcontrolModules(args,ret);
   } else if(method == "_list"){ 
     ret.push(AmArg("listProfiles"));
     ret.push(AmArg("reloadProfiles"));
@@ -359,6 +373,7 @@ void SBCFactory::invoke(const string& method, const AmArg& 
args,
     ret.push(AmArg("setActiveProfile"));
     ret.push(AmArg("getRegexMapNames"));
     ret.push(AmArg("setRegexMap"));
+    ret.push(AmArg("loadCallcontrolModules"));
   }  else
     throw AmDynInvoke::NotImplemented(method);
 }
@@ -542,6 +557,24 @@ void SBCFactory::setRegexMap(const AmArg& args, AmArg& 
ret) {
   ret.push("OK");
 }
 
+void SBCFactory::loadCallcontrolModules(const AmArg& args, AmArg& ret) {
+  string load_cc_plugins = args[0].asCStr();
+  if (!load_cc_plugins.empty()) {
+    INFO("loading call control plugins '%s' from '%s'\n",
+        load_cc_plugins.c_str(), AmConfig::PlugInPath.c_str());
+    if (AmPlugIn::instance()->load(AmConfig::PlugInPath, load_cc_plugins) < 0) 
{
+      ERROR("loading call control plugins '%s' from '%s'\n",
+           load_cc_plugins.c_str(), AmConfig::PlugInPath.c_str());
+      
+      ret.push(500);
+      ret.push("Failed - please see server logs\n");
+      return;
+    }
+  }
+  ret.push(200);
+  ret.push("OK");
+}
+
 SBCDialog::SBCDialog(const SBCCallProfile& call_profile)
   : m_state(BB_Init),
     auth(NULL),
diff --git a/apps/sbc/SBC.h b/apps/sbc/SBC.h
index e70400c..1150db8 100644
--- a/apps/sbc/SBC.h
+++ b/apps/sbc/SBC.h
@@ -59,6 +59,7 @@ class SBCFactory: public AmSessionFactory,
   void setActiveProfile(const AmArg& args, AmArg& ret);
   void getRegexMapNames(const AmArg& args, AmArg& ret);
   void setRegexMap(const AmArg& args, AmArg& ret);
+  void loadCallcontrolModules(const AmArg& args, AmArg& ret);
 
   string getActiveProfileMatch(string& profile_rule, const AmSipRequest& req,
                               const string& app_param, AmUriParser& 
ruri_parser,
diff --git a/apps/sbc/etc/sbc.conf b/apps/sbc/etc/sbc.conf
index f78f80d..e5dab80 100644
--- a/apps/sbc/etc/sbc.conf
+++ b/apps/sbc/etc/sbc.conf
@@ -24,6 +24,13 @@ active_profile=transparent
 #
 #regex_maps=src_ipmap,ruri_map,usermap
 
+# load_cc_plugins - semicolon-separated list of call-control plugins to load
+#                   here the module names (.so names) must be specified, 
without .so
+#                   analogous to load_plugins in sems.conf
+#
+# e.g. load_cc_plugins=cc_pcalls;cc_ctl
+#load_cc_plugins=cc_pcalls;cc_ctl
+
 ## RFC4028 Session Timer
 # default configuration - can be overridden by call profiles
 
diff --git a/apps/sbc/tools/sems-sbc-load-callcontrol-modules 
b/apps/sbc/tools/sems-sbc-load-callcontrol-modules
new file mode 100755
index 0000000..5000364
--- /dev/null
+++ b/apps/sbc/tools/sems-sbc-load-callcontrol-modules
@@ -0,0 +1,12 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+import sys
+from xmlrpclib import *
+
+if len(sys.argv) != 2:
+       print "usage: %s <semicolon separated list of plugins to load>" % 
sys.argv[0]
+       sys.exit(1)
+
+s = ServerProxy('http://localhost:8090')
+print "Active calls: %d" % s.calls()
+print s.di('sbc','loadCallcontrolModules',sys.argv[1])
diff --git a/doc/Readme.sbc.txt b/doc/Readme.sbc.txt
index 8288bf1..1d6646d 100644
--- a/doc/Readme.sbc.txt
+++ b/doc/Readme.sbc.txt
@@ -406,6 +406,10 @@ Call control (CC) modules for the sbc application 
implement business logic which
 how the SBC operates. For example, a CC module can implement concurrent call 
limits, call
 limits per user, enforce other policies, or implement routing logic.
 
+Call control (CC) modules should be loaded using the load_cc_plugins option in 
sbc.conf,
+or loaded later into the server by the sems-sbc-loadcallcontrol-modules script
+(loadCallcontrolModules DI function).
+
 Multiple CC modules may be applied for one call. The data that the CC modules 
get from the
 call may be freely configured. Call control modules may also be applied 
through message parts
 (replacement patterns).

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

Reply via email to