[sr-dev] git:master: xmlrpc: new parameter - mode

Daniel-Constantin Mierla miconda at gmail.com
Tue May 25 16:24:01 CEST 2010


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue May 25 10:29:03 2010 +0200

xmlrpc: new parameter - mode

- mode parameter controls the registration for non-SIP message callbacks
- if set to 1, module does not register the callback, the execution of
  XMLRPC functions being done from config. Useful if other module
  register callback for same type of messages, i.e., HTTP
- default is 0 (backward compatible default behavior)

---

 modules/xmlrpc/README         |   21 +++++++++++++++++----
 modules/xmlrpc/doc/params.xml |   19 +++++++++++++++++++
 modules/xmlrpc/xmlrpc.c       |   21 +++++++++++++--------
 3 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/modules/xmlrpc/README b/modules/xmlrpc/README
index fed4a70..7a7b6f7 100644
--- a/modules/xmlrpc/README
+++ b/modules/xmlrpc/README
@@ -2,7 +2,7 @@ Jan Janak
 
    iptelorg GmbH
 
-   Copyright © 2005 iptelorg GmbH
+   Copyright © 2005 iptelorg GmbH
    Revision History
    Revision $Revision$ $Date$
      __________________________________________________________________
@@ -24,6 +24,7 @@ Jan Janak
         1.5.2. autoconversion (string)
         1.5.3. escape_cr (integer)
         1.5.4. double_lf_to_crlf (integer)
+        1.5.5. mode (integer)
 
    1.6. Functions
 
@@ -407,7 +408,7 @@ Content-Length: 276
 1.3.3. Type Conversion
 
    The data types of the RPC API are converted to the data types of
-   XML-RPC and vice versa. Table 1, "Data Type Conversion" shows for each
+   XML-RPC and vice versa. Table 1, “Data Type Conversion” shows for each
    RPC API data type corresponding XML-RPC data type.
 
    Table 1. Data Type Conversion
@@ -565,6 +566,18 @@ modparam("xmlrpc", "escape_cr", 1)
    Example 5. Set the double_lf_to_crlf parameter
 modparam("xmlrpc", "double_lf_to_crlf", 1)
 
+1.5.5. mode (integer)
+
+   When set to 1, xmlrpc module does not register to core the callback
+   functions for non-SIP messages. Useful when other module register a
+   callback for HTTP request, being the decision of admin when to call the
+   XMLRPC route (or functions).
+
+   Default: 0.
+
+   Example 6. Set the mode parameter
+modparam("xmlrpc", "mode", 1)
+
 1.6. Functions
 
    Revision History
@@ -586,7 +599,7 @@ modparam("xmlrpc", "double_lf_to_crlf", 1)
    function with matching name. If such a function is found then
    dispatch_rpc() will pass control to the function to handle the request.
 
-   Example 6. dispatch_rpc usage
+   Example 7. dispatch_rpc usage
 #...
 modparam("xmlrpc", "route", "XMLRPC");
 #...
@@ -602,7 +615,7 @@ route[XMLRPC]{
    This function can be called from the config script to directly generate
    an XML-RPC reply.
 
-   Example 7. xmlrpc_reply usage
+   Example 8. xmlrpc_reply usage
 #...
 modparam("xmlrpc", "route", "XMLRPC");
 #...
diff --git a/modules/xmlrpc/doc/params.xml b/modules/xmlrpc/doc/params.xml
index f200b55..67e7a5f 100644
--- a/modules/xmlrpc/doc/params.xml
+++ b/modules/xmlrpc/doc/params.xml
@@ -116,6 +116,25 @@ modparam("xmlrpc", "double_lf_to_crlf", 1)
 	</example>
 	</section>
 
+	<section id="param_mode">
+	<title><varname>mode</varname> (integer)</title>
+	<para>
+		When set to 1, xmlrpc module does not register to core the callback
+		functions for non-SIP messages. Useful when other module register
+		a callback for HTTP request, being the decision of admin when to
+		call the XMLRPC route (or functions).
+	</para>
+	<para>
+		Default: 0.
+	</para>
+	<example>
+		<title>Set the <varname>mode</varname> parameter</title>
+		<programlisting>
+modparam("xmlrpc", "mode", 1)
+		</programlisting>
+	</example>
+	</section>
+
 	<!--
 	Obsolete (hardwired on in the rpc core functions, cannot  be turned off) 
 	-andrei
diff --git a/modules/xmlrpc/xmlrpc.c b/modules/xmlrpc/xmlrpc.c
index dc7af86..c502ad9 100644
--- a/modules/xmlrpc/xmlrpc.c
+++ b/modules/xmlrpc/xmlrpc.c
@@ -397,7 +397,8 @@ static int escape_cr=1; /* default on */
 /* convert double LF to CR LF (when on, LFLF becomes an escape for CRLF, needed
  with some xmlrpc clients that are not escaping CR to &#xD; )*/
 static int lflf2crlf=0; /* default off */
-
+/* do not register for non-sip requests */
+static int xmlrpc_mode = 0;
 
 /*
  * Exported functions
@@ -417,6 +418,7 @@ static param_export_t params[] = {
 	{"autoconversion", PARAM_INT, &autoconvert},
 	{"escape_cr", PARAM_INT, &escape_cr},
 	{"double_lf_to_crlf", PARAM_INT, &lflf2crlf},
+	{"mode", PARAM_INT, &xmlrpc_mode},
 	{0, 0, 0}
 };
 
@@ -2388,13 +2390,16 @@ static int mod_init(void)
 	register_select_table(xmlrpc_sel);
 	
 	/* register non-sip hooks */
-	memset(&nsh, 0, sizeof(nsh));
-	nsh.name="xmlrpc";
-	nsh.destroy=0;
-	nsh.on_nonsip_req=process_xmlrpc;
-	if (register_nonsip_msg_hook(&nsh)<0){
-		ERR("Failed to register non sip msg hooks\n");
-		return -1;
+	if(xmlrpc_mode==0)
+	{
+		memset(&nsh, 0, sizeof(nsh));
+		nsh.name="xmlrpc";
+		nsh.destroy=0;
+		nsh.on_nonsip_req=process_xmlrpc;
+		if (register_nonsip_msg_hook(&nsh)<0){
+			ERR("Failed to register non sip msg hooks\n");
+			return -1;
+		}
 	}
 	return 0;
 }




More information about the sr-dev mailing list