瀏覽代碼

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)
Daniel-Constantin Mierla 15 年之前
父節點
當前提交
42d7638f14
共有 3 個文件被更改,包括 49 次插入12 次删除
  1. 17 4
      modules/xmlrpc/README
  2. 19 0
      modules/xmlrpc/doc/params.xml
  3. 13 8
      modules/xmlrpc/xmlrpc.c

+ 17 - 4
modules/xmlrpc/README

@@ -2,7 +2,7 @@ Jan Janak
 
 
    iptelorg GmbH
    iptelorg GmbH
 
 
-   Copyright © 2005 iptelorg GmbH
+   Copyright © 2005 iptelorg GmbH
    Revision History
    Revision History
    Revision $Revision$ $Date$
    Revision $Revision$ $Date$
      __________________________________________________________________
      __________________________________________________________________
@@ -24,6 +24,7 @@ Jan Janak
         1.5.2. autoconversion (string)
         1.5.2. autoconversion (string)
         1.5.3. escape_cr (integer)
         1.5.3. escape_cr (integer)
         1.5.4. double_lf_to_crlf (integer)
         1.5.4. double_lf_to_crlf (integer)
+        1.5.5. mode (integer)
 
 
    1.6. Functions
    1.6. Functions
 
 
@@ -407,7 +408,7 @@ Content-Length: 276
 1.3.3. Type Conversion
 1.3.3. Type Conversion
 
 
    The data types of the RPC API are converted to the data types of
    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.
    RPC API data type corresponding XML-RPC data type.
 
 
    Table 1. Data Type Conversion
    Table 1. Data Type Conversion
@@ -565,6 +566,18 @@ modparam("xmlrpc", "escape_cr", 1)
    Example 5. Set the double_lf_to_crlf parameter
    Example 5. Set the double_lf_to_crlf parameter
 modparam("xmlrpc", "double_lf_to_crlf", 1)
 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
 1.6. Functions
 
 
    Revision History
    Revision History
@@ -586,7 +599,7 @@ modparam("xmlrpc", "double_lf_to_crlf", 1)
    function with matching name. If such a function is found then
    function with matching name. If such a function is found then
    dispatch_rpc() will pass control to the function to handle the request.
    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");
 modparam("xmlrpc", "route", "XMLRPC");
 #...
 #...
@@ -602,7 +615,7 @@ route[XMLRPC]{
    This function can be called from the config script to directly generate
    This function can be called from the config script to directly generate
    an XML-RPC reply.
    an XML-RPC reply.
 
 
-   Example 7. xmlrpc_reply usage
+   Example 8. xmlrpc_reply usage
 #...
 #...
 modparam("xmlrpc", "route", "XMLRPC");
 modparam("xmlrpc", "route", "XMLRPC");
 #...
 #...

+ 19 - 0
modules/xmlrpc/doc/params.xml

@@ -116,6 +116,25 @@ modparam("xmlrpc", "double_lf_to_crlf", 1)
 	</example>
 	</example>
 	</section>
 	</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) 
 	Obsolete (hardwired on in the rpc core functions, cannot  be turned off) 
 	-andrei
 	-andrei

+ 13 - 8
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
 /* 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; )*/
  with some xmlrpc clients that are not escaping CR to &#xD; )*/
 static int lflf2crlf=0; /* default off */
 static int lflf2crlf=0; /* default off */
-
+/* do not register for non-sip requests */
+static int xmlrpc_mode = 0;
 
 
 /*
 /*
  * Exported functions
  * Exported functions
@@ -417,6 +418,7 @@ static param_export_t params[] = {
 	{"autoconversion", PARAM_INT, &autoconvert},
 	{"autoconversion", PARAM_INT, &autoconvert},
 	{"escape_cr", PARAM_INT, &escape_cr},
 	{"escape_cr", PARAM_INT, &escape_cr},
 	{"double_lf_to_crlf", PARAM_INT, &lflf2crlf},
 	{"double_lf_to_crlf", PARAM_INT, &lflf2crlf},
+	{"mode", PARAM_INT, &xmlrpc_mode},
 	{0, 0, 0}
 	{0, 0, 0}
 };
 };
 
 
@@ -2388,13 +2390,16 @@ static int mod_init(void)
 	register_select_table(xmlrpc_sel);
 	register_select_table(xmlrpc_sel);
 	
 	
 	/* register non-sip hooks */
 	/* 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;
 	return 0;
 }
 }