Module: sip-router
Branch: master
Commit: 07599b8befbc37f37372c64b83e84bbc1164e1cd
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=07599b8…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Sep 23 16:19:11 2009 +0200
xmlrpc(s): doc updated
- escape_cr and double_lf_to_crlf documented
---
modules_s/xmlrpc/README | 45 ++++++++++++++++++++++++++++++++++-
modules_s/xmlrpc/doc/params.xml | 49 +++++++++++++++++++++++++++++++++++++++
modules_s/xmlrpc/doc/xmlrpc.xml | 10 ++++++++
3 files changed, 102 insertions(+), 2 deletions(-)
diff --git a/modules_s/xmlrpc/README b/modules_s/xmlrpc/README
index d1abb54..fed4a70 100644
--- a/modules_s/xmlrpc/README
+++ b/modules_s/xmlrpc/README
@@ -22,6 +22,8 @@ Jan Janak
1.5.1. route (string)
1.5.2. autoconversion (string)
+ 1.5.3. escape_cr (integer)
+ 1.5.4. double_lf_to_crlf (integer)
1.6. Functions
@@ -473,6 +475,14 @@ route[XMLRPC]{
dispatch_rpc();
}
+ Another common problem is CRLF handling. According to the xml spec CR
+ ('\r') must be escaped (to 
) or they will be "normalized" when
+ parsing the xml document. However some xmlrpc clients do not follow
+ this rule (e.g. clients based on the python or php xmlrpclib) and send
+ CRLF unescaped. A possible workaround is to enable automatic LFLF to
+ CRLF conversion (using the double_lf_to_crlf modules parameter) and
+ replace CRLF with LFLF in the client queries.
+
1.4. Client Examples
* examples/xmlrpc_test.pl (basic perl application that builds and
@@ -524,6 +534,37 @@ modparam("xmlrpc", "route", "route_for_xmlrpcs")
Example 3. Set the autoconversion parameter
modparam("xmlrpc", "autoconversion", 1)
+1.5.3. escape_cr (integer)
+
+ Enable CR ('\r') escaping in replies. If enabled each '\r' in the
+ xmlrpc reply will be replaced with "
", according to the xml spec.
+
+ It should be turned off only if you suspect interoperability problems
+ with older clients.
+
+ Default: on.
+
+ Example 4. Set the escape_cr parameter
+modparam("xmlrpc", "escape_cr", 1)
+
+1.5.4. double_lf_to_crlf (integer)
+
+ When enabled double LFs ('\n\n') in the input xmlrpc strings will be
+ replaced with CR LF ('\r\n'). This makes LF LF behave like an escape
+ character for CR LF and is needed for compatibility with kamailio tools
+ and to work around buggy xmlrpc clients that don't escape the CR in CR
+ LF ('\r' should be escaped to "
" otherwise according to the xml
+ spec "\r\n" will be transformed to '\n'), but need to send CR LF in the
+ strings (e.g. they use tm.t_uac_wait).
+
+ Note: when this option is turned on, there is no way to send a double
+ LF ('\n\n'), it will always be transformed in CR LF ('\r\n').
+
+ Default: off.
+
+ Example 5. Set the double_lf_to_crlf parameter
+modparam("xmlrpc", "double_lf_to_crlf", 1)
+
1.6. Functions
Revision History
@@ -545,7 +586,7 @@ modparam("xmlrpc", "autoconversion", 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 4. dispatch_rpc usage
+ Example 6. dispatch_rpc usage
#...
modparam("xmlrpc", "route", "XMLRPC");
#...
@@ -561,7 +602,7 @@ route[XMLRPC]{
This function can be called from the config script to directly generate
an XML-RPC reply.
- Example 5. xmlrpc_reply usage
+ Example 7. xmlrpc_reply usage
#...
modparam("xmlrpc", "route", "XMLRPC");
#...
diff --git a/modules_s/xmlrpc/doc/params.xml b/modules_s/xmlrpc/doc/params.xml
index be7fd63..f200b55 100644
--- a/modules_s/xmlrpc/doc/params.xml
+++ b/modules_s/xmlrpc/doc/params.xml
@@ -67,6 +67,55 @@ modparam("xmlrpc", "autoconversion", 1)
</example>
</section>
+ <section id="escape_cr">
+ <title><varname>escape_cr</varname> (integer)</title>
+ <para>
+ Enable CR ('\r') escaping in replies. If enabled each '\r' in the
+ xmlrpc reply will be replaced with "&#xD;", according to the
+ xml spec.
+ </para>
+ <para>
+ It should be turned off only if you suspect interoperability problems
+ with older clients.
+ </para>
+ <para>
+ Default: on.
+ </para>
+ <example>
+ <title>Set the <varname>escape_cr</varname> parameter</title>
+ <programlisting>
+modparam("xmlrpc", "escape_cr", 1)
+ </programlisting>
+ </example>
+ </section>
+
+ <section id="double_lf_to_crlf">
+ <title><varname>double_lf_to_crlf</varname> (integer)</title>
+ <para>
+ When enabled double LFs ('\n\n') in the input xmlrpc strings
+ will be replaced with CR LF ('\r\n'). This makes LF LF behave like
+ an escape character for CR LF and is needed for compatibility with
+ kamailio tools and to work around buggy xmlrpc clients that don't
+ escape the CR in CR LF ('\r' should be escaped to "&#xD;"
+ otherwise according to the xml spec "\r\n" will be transformed to
+ '\n'), but need to send CR LF in the strings (e.g. they use
+ <function>tm.t_uac_wait</function>).
+ </para>
+ <para>
+ Note: when this option is turned on, there is no way to send a double
+ LF ('\n\n'), it will always be transformed in CR LF ('\r\n').
+ </para>
+ <para>
+ Default: off.
+ </para>
+ <example>
+ <title>Set the <varname>double_lf_to_crlf</varname> parameter</title>
+ <programlisting>
+modparam("xmlrpc", "double_lf_to_crlf", 1)
+ </programlisting>
+ </example>
+ </section>
+
<!--
Obsolete (hardwired on in the rpc core functions, cannot be turned off)
-andrei
diff --git a/modules_s/xmlrpc/doc/xmlrpc.xml b/modules_s/xmlrpc/doc/xmlrpc.xml
index 2cdf422..81cf02a 100644
--- a/modules_s/xmlrpc/doc/xmlrpc.xml
+++ b/modules_s/xmlrpc/doc/xmlrpc.xml
@@ -699,6 +699,16 @@ route[XMLRPC]{
</programlisting>
</example>
</para>
+ <para>
+ Another common problem is CRLF handling. According to the xml spec
+ CR ('\r') must be escaped (to &#xD;) or they will be "normalized"
+ when parsing the xml document. However some xmlrpc clients do not
+ follow this rule (e.g. clients based on the python or php xmlrpclib)
+ and send CRLF unescaped. A possible workaround is to enable
+ automatic LFLF to CRLF conversion (using the
+ <varname>double_lf_to_crlf</varname> modules parameter) and replace
+ CRLF with LFLF in the client queries.
+ </para>
</section>
</section>
Module: sip-router
Branch: master
Commit: da2a085760f30c8b0afb72555871465e551f0060
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=da2a085…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Sep 23 14:12:50 2009 +0200
xmlrpc(s): option for replacing double lf with crlf
Added "double_lf_to_crlf" config parameter. When set double LFs in
the input xmlrpc strings are replaced with CR LF. This is needed
to work around some xmlrpc buggy clients that don't escape CR
('\r' should be escaped to 
 ). When using one of those buggy
clients, use double LF as an escape for CR LF and turn this
option on.Turning this option on makes it also more compatible with
kamailio tools (kamailio mi xmlrpc always converts double LF to CR
LF).
Note that when double_lf_to_crlf is on it's not possible to send
a double lf.
Here is what the xmlrpc modules sees for various combinations of
CR and LF in the input, when CR is _not_ escaped:
0 1 (double_lf_to_crlf)
\n -> \r \r
\r -> \r \r
\r\r -> \n\n \r\n
\n\n -> \n\n \r\n
\r\n -> \n !!! \n !!!
\n\r -> \n\n \r\n
Note that when double_lf_to_crlf is 0, the xmlrpc module behaves
correctly according to the xml specs.
---
modules_s/xmlrpc/xmlrpc.c | 37 ++++++++++++++++++++++++++++++-------
1 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/modules_s/xmlrpc/xmlrpc.c b/modules_s/xmlrpc/xmlrpc.c
index 34106bc..0823a20 100644
--- a/modules_s/xmlrpc/xmlrpc.c
+++ b/modules_s/xmlrpc/xmlrpc.c
@@ -394,6 +394,9 @@ static int xmlrpc_route_no=DEFAULT_RT;
static int autoconvert=0;
/* in replies, escape CR to 
 (according to the xml specs) */
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 
 )*/
+static int lflf2crlf=0; /* default off */
/*
@@ -413,6 +416,7 @@ static param_export_t params[] = {
{"route", PARAM_STRING, &xmlrpc_route},
{"autoconversion", PARAM_INT, &autoconvert},
{"escape_cr", PARAM_INT, &escape_cr},
+ {"double_lf_to_crlf", PARAM_INT, &lflf2crlf},
{0, 0, 0}
};
@@ -1080,6 +1084,7 @@ static time_t xmlrpc2time(const char* str)
/* get_* flags: */
#define GET_X_AUTOCONV 1
#define GET_X_NOREPLY 2
+#define GET_X_LFLF2CRLF 4 /* replace "\n\n" with "\r\n" */
/* xml value types */
enum xmlrpc_val_type{
@@ -1294,14 +1299,16 @@ static int get_double(double* val, struct xmlrpc_reply* reply,
/** Convert a parameter encoded in XML-RPC to a zero terminated string.
*
- * @param val A pointer to an integer variable where the result will be
- stored.
+ * @param val A pointer to a char* variable where the result will be
+ * stored (the result is dynamically allocated, but it's garbage
+ * collected, so it doesn't have to be freed)
* @param reply A pointer to XML-RPC reply being constructed (used to indicate
* conversion errors).
* @param doc A pointer to the XML-RPC request document.
* @param value A pointer to the element containing the parameter to be
* converted within the document.
* @param flags : GET_X_AUTOCONV - try autoconverting
+ * GET_X_LFLF2CRLF - replace double '\n' with `\r\n'
* GET_X_NOREPLY - do not reply
* @return <0 on error, 0 on success
*/
@@ -1360,6 +1367,18 @@ static int get_string(char** val, struct xmlrpc_reply* reply,
ret=0;
switch(type){
case XML_T_STR:
+ if (flags & GET_X_LFLF2CRLF){
+ p=val_str;
+ while(*p){
+ if (*p=='\n' && *(p+1)=='\n'){
+ *p='\r';
+ p+=2;
+ continue;
+ }
+ p++;
+ }
+ }
+ /* no break */
case XML_T_DATE: /* no special conversion */
case XML_T_DOUBLE: /* no special conversion */
if (add_garbage(JUNK_XMLCHAR, val_str, reply) < 0){
@@ -1428,7 +1447,8 @@ static int rpc_scan(rpc_ctx_t* ctx, char* fmt, ...)
va_start(ap, fmt);
modifiers=0;
read = 0;
- f=autoconvert?GET_X_AUTOCONV:0;
+ f=(autoconvert?GET_X_AUTOCONV:0) |
+ (lflf2crlf?GET_X_LFLF2CRLF:0);
while(*fmt) {
if (!ctx->act_param) goto error;
value = ctx->act_param->xmlChildrenNode;
@@ -1737,8 +1757,11 @@ static int rpc_struct_scan(struct rpc_struct* s, char* fmt, ...)
char* member_name;
struct xmlrpc_reply* reply;
int ret;
+ int f;
read = 0;
+ f=(autoconvert?GET_X_AUTOCONV:0) |
+ (lflf2crlf?GET_X_LFLF2CRLF:0);
va_start(ap, fmt);
while(*fmt) {
member_name = va_arg(ap, char*);
@@ -1751,23 +1774,23 @@ static int rpc_struct_scan(struct rpc_struct* s, char* fmt, ...)
case 't': /* Date and time */
case 'd': /* Integer */
int_ptr = va_arg(ap, int*);
- if (get_int(int_ptr, reply, s->doc, value, 0) < 0) goto error;
+ if (get_int(int_ptr, reply, s->doc, value, f) < 0) goto error;
break;
case 'f': /* double */
double_ptr = va_arg(ap, double*);
- if (get_double(double_ptr, reply, s->doc, value, 0) < 0)
+ if (get_double(double_ptr, reply, s->doc, value, f) < 0)
goto error;
break;
case 's': /* zero terminated string */
char_ptr = va_arg(ap, char**);
- if (get_string(char_ptr, reply, s->doc, value, 0) < 0) goto error;
+ if (get_string(char_ptr, reply, s->doc, value, f) < 0) goto error;
break;
case 'S': /* str structure */
str_ptr = va_arg(ap, str*);
- if (get_string(&str_ptr->s, reply, s->doc, value, 0) < 0)
+ if (get_string(&str_ptr->s, reply, s->doc, value, f) < 0)
goto error;
str_ptr->len = strlen(str_ptr->s);
break;
Hello professors, i have some questions about kamailio. After i install rtpproxy 0.3version, the kamailio server can't work any more. The following is the error message. Dose any one know the reason? dose the rtpproxy 0.3 change something that kamailio need?
Sep 23 11:07:53 [4911] INFO:core:init_mod: initializing module registrar
Sep 23 11:07:53 [4911] INFO:core:init_mod: initializing module textops
Sep 23 11:07:53 [4911] INFO:core:init_mod: initializing module uri_db
Sep 23 11:07:53 [4911] INFO:core:init_mod: initializing module siputils
Sep 23 11:07:53 [4911] INFO:core:init_mod: initializing module xlog
Sep 23 11:07:53 [4911] INFO:core:init_mod: initializing module acc
Sep 23 11:07:53 [4911] INFO:core:probe_max_receive_buffer: using a UDP receive buffer of 255 kb
Sep 23 11:07:53 [4911] INFO:core:probe_max_receive_buffer: using a UDP receive buffer of 255 kb
Sep 23 11:07:53 [4911] INFO:core:probe_max_receive_buffer: using a UDP receive buffer of 255 kb
Sep 23 11:07:57 [4925] ERROR:core:build_req_buf_from_sip_req: out of pkg memory
Sep 23 11:07:57 [4925] ERROR:tm:print_uac_request: no more shm_mem
Sep 23 11:07:57 [4925] ERROR:tm:t_forward_nonack: failure to add branches
Sep 23 11:07:57 [4925] ERROR:tm:_reply_light: failed to allocate shmem buffer
Sep 23 11:07:57 [4925] ERROR:tm:relay_reply: no more share memory
Sep 23 11:07:57 [4925] ERROR:tm:_reply_light: failed to allocate shmem buffer
网易邮箱用户购物独享现金返还
Hi *,
What would be the suggestions regarding having a process / thread that can
be used to ping (keepalive) a connection to a particular db backend. I am
specifically looking at coding something for mysql (our firewall is closing
connections to mysql if they are idle for longer than 30mins). I would like
to have a process that would go through all connections and "ping" them
every so often. I would imagine each DB impl can either ignore the ping
function or actually do something with it. I would imagine this will be
useful for a few backend db implementations. Any input before I go ahead?
Cheers
Jason