Module: sip-router
Branch: master
Commit: dd5490500f006f86e520958c5ca2646a1e3a96b7
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dd54905…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Fri Jul 17 00:15:39 2009 +0200
domain: API framework to be used by other modules
Add a new data structure and function bind_domain that can be used by
other modules to gain access to internal functions of domain module.
Implement inline function load_domain_api that does everything that
is necessary to make the API of the domain module available to the
caller.
---
modules_s/domain/domain_api.c | 35 ++++++++++++++++++++++++++
modules_s/domain/domain_api.h | 54 +++++++++++++++++++++++++++++++++++++++++
modules_s/domain/domain_mod.c | 2 +
3 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/modules_s/domain/domain_api.c b/modules_s/domain/domain_api.c
new file mode 100644
index 0000000..c88e5c8
--- /dev/null
+++ b/modules_s/domain/domain_api.c
@@ -0,0 +1,35 @@
+/*
+ * Domain module internal API
+ *
+ * Copyright (C) 2002-2003 Juha Heinanen
+ *
+ * This file is part of sip-router, a free SIP server.
+ *
+ * sip-router is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version
+ *
+ * sip-router is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "domain_api.h"
+#include "../../dprint.h"
+#include "domain.h"
+
+
+int bind_domain(domain_api_t* api)
+{
+ if (api == NULL) {
+ ERR("Invalid parameter value\n");
+ return -1;
+ }
+ return 0;
+}
diff --git a/modules_s/domain/domain_api.h b/modules_s/domain/domain_api.h
new file mode 100644
index 0000000..16ddd1f
--- /dev/null
+++ b/modules_s/domain/domain_api.h
@@ -0,0 +1,54 @@
+/*
+ * Domain module internal API
+ *
+ * Copyright (C) 2002-2003 Juha Heinanen
+ *
+ * This file is part of sip-router, a free SIP server.
+ *
+ * sip-router is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version
+ *
+ * sip-router is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _DOMAIN_API_H
+#define _DOMAIN_API_H
+
+#include "../../sr_module.h"
+#include "../../dprint.h"
+
+typedef struct domain_api {
+
+} domain_api_t;
+
+typedef int (*bind_domain_f)(domain_api_t* api);
+int bind_domain(domain_api_t* api);
+
+static inline int load_domain_api(domain_api_t* api)
+{
+ bind_domain_f bind_domain;
+
+ bind_domain = (bind_domain_f)find_export("bind_domain", 0, 0);
+
+ if (bind_domain == NULL) {
+ ERR("Cannot import bind_domain function from domain module\n");
+ return -1;
+ }
+
+ if (bind_domain(api) == -1) {
+ return -1;
+ }
+ return 0;
+}
+
+
+#endif /* _DOMAIN_API_H */
diff --git a/modules_s/domain/domain_mod.c b/modules_s/domain/domain_mod.c
index 957973f..c7e0515 100644
--- a/modules_s/domain/domain_mod.c
+++ b/modules_s/domain/domain_mod.c
@@ -38,6 +38,7 @@
#include "../../parser/parse_from.h"
#include "../../parser/parse_uri.h"
#include "../../usr_avp.h"
+#include "domain_api.h"
#include "domain_rpc.h"
#include "hash.h"
#include "domain.h"
@@ -124,6 +125,7 @@ static cmd_export_t cmds[] = {
{"lookup_domain", lookup_domain, 2, lookup_domain_fixup,
REQUEST_ROUTE|FAILURE_ROUTE },
{"get_did", (cmd_function)get_did, 0, 0, 0},
+ {"bind_domain", (cmd_function)bind_domain, 0, 0, 0},
{0, 0, 0, 0, 0}
};
Module: sip-router
Branch: master
Commit: d8fdebf9c589516185d5c6a4ff9453148f1b76f2
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d8fdebf…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Fri Jul 17 11:10:51 2009 +0200
domain: Add internal function is_domain_local
Add internal function is_domain_local that can be used to determine if
the domain name given in parameter is on the list of local domains. The
comparison of the domain name is always case insensitive.
There already is is_local function that does something similar, so we
can reuse the code from that function. is_domain_local takes a pointer
to str as parameter and this function is then called by is_local which
takes all the usual parameters that function which can be called from
the script take.
Finally, is_domain_local is exported through the internal API of the
domain module.
Function is_domain_local is now located in file domain.c and because of
db_get_did was also moved to file domain.c
---
modules_s/domain/domain.c | 104 +++++++++++++++++++++++++++++++++++++++++
modules_s/domain/domain.h | 17 +++++++
modules_s/domain/domain_api.c | 1 +
modules_s/domain/domain_api.h | 3 +-
modules_s/domain/domain_mod.c | 91 +-----------------------------------
5 files changed, 126 insertions(+), 90 deletions(-)
diff --git a/modules_s/domain/domain.c b/modules_s/domain/domain.c
index cd347bf..cb5cb32 100644
--- a/modules_s/domain/domain.c
+++ b/modules_s/domain/domain.c
@@ -22,6 +22,7 @@
#include <string.h>
#include "domain_mod.h"
+#include "hash.h"
#include "../../dprint.h"
#include "../../mem/shm_mem.h"
#include "../../lib/srdb2/db.h"
@@ -308,3 +309,106 @@ int load_domains(domain_t** dest)
free_domain_list(list);
return 1;
}
+
+
+/* Retrieve did directly from database, without using memory cache. Use 0 as
+ * the value of first parameter if you only want to know whether the entry is
+ * in the database. The function returns 1 if there is such entry, 0 if not,
+ * and -1 on error. The result is allocated using pkg_malloc and must be
+ * freed.
+ */
+int db_get_did(str* did, str* domain)
+{
+ db_res_t* res = NULL;
+ db_rec_t* rec;
+
+ if (!domain) {
+ ERR("BUG:Invalid parameter value\n");
+ goto err;
+ }
+
+ get_did_cmd->match[0].v.lstr = *domain;
+
+ if (db_exec(&res, get_did_cmd) < 0) {
+ ERR("Error in database query\n");
+ goto err;
+ }
+
+ rec = db_first(res);
+ if (rec) {
+ /* Test flags first, we are only interested in rows
+ * that are not disabled
+ */
+ if (rec->fld[1].flags & DB_NULL || (rec->fld[1].v.bitmap &
+ SRDB_DISABLED)) {
+ db_res_free(res);
+ return 0;
+ }
+
+ if (did) {
+ if (rec->fld[0].flags & DB_NULL) {
+ did->len = 0;
+ did->s = 0;
+ WARN("Domain '%.*s' has NULL did\n",
+ domain->len, ZSW(domain->s));
+ } else {
+ did->s = pkg_malloc(rec->fld[0].v.lstr.len);
+ if (!did->s) {
+ ERR("No memory left\n");
+ goto err;
+ }
+ memcpy(did->s, rec->fld[0].v.lstr.s, rec->fld[0].v.lstr.len);
+ did->len = rec->fld[0].v.lstr.len;
+ }
+ }
+
+ db_res_free(res);
+ return 1;
+ } else {
+ db_res_free(res);
+ return 0;
+ }
+
+ err:
+ if (res) db_res_free(res);
+ return -1;
+}
+
+
+/* Check if the domain name given in the parameter is one
+ * of the locally configured domain names.
+ * Returns 1 if yes and -1 otherwise
+ */
+int is_domain_local(str* domain)
+{
+ str tmp;
+
+ /* Make a temporary copy, domain name comparisons are always
+ * case insensitive
+ */
+ tmp.s = pkg_malloc(domain->len);
+ if (!tmp.s) {
+ ERR("No memory left\n");
+ return -1;
+ }
+ memcpy(tmp.s, domain->s, domain->len);
+ tmp.len = domain->len;
+ strlower(&tmp);
+
+ if (!db_mode) {
+ switch(db_get_did(0, &tmp)) {
+ case 1: goto found;
+ default: goto not_found;
+ }
+ } else {
+ if (hash_lookup(0, *active_hash, &tmp) == 1) goto found;
+ else goto not_found;
+ }
+
+ found:
+ pkg_free(tmp.s);
+ return 1;
+ not_found:
+ pkg_free(tmp.s);
+ return -1;
+}
diff --git a/modules_s/domain/domain.h b/modules_s/domain/domain.h
index d79a593..e0d0d37 100644
--- a/modules_s/domain/domain.h
+++ b/modules_s/domain/domain.h
@@ -72,4 +72,21 @@ void free_domain_list(domain_t* list);
typedef int (*domain_get_did_t)(str* did, str* domain);
+
+/* Retrieve did directly from database, without using memory cache. Use 0 as
+ * the value of first parameter if you only want to know whether the entry is
+ * in the database. The function returns 1 if there is such entry, 0 if not,
+ * and -1 on error. The result is allocated using pkg_malloc and must be
+ * freed.
+ */
+int db_get_did(str* did, str* domain);
+
+/* Check if the domain name given in the parameter is one
+ * of the locally configured domain names.
+ * Returns 1 if yes and -1 otherwise
+ */
+typedef int (*is_domain_local_f)(str* domain);
+int is_domain_local(str* domain);
+
+
#endif /* _DOMAIN_H */
diff --git a/modules_s/domain/domain_api.c b/modules_s/domain/domain_api.c
index c88e5c8..0996c67 100644
--- a/modules_s/domain/domain_api.c
+++ b/modules_s/domain/domain_api.c
@@ -31,5 +31,6 @@ int bind_domain(domain_api_t* api)
ERR("Invalid parameter value\n");
return -1;
}
+ api->is_domain_local = is_domain_local;
return 0;
}
diff --git a/modules_s/domain/domain_api.h b/modules_s/domain/domain_api.h
index 16ddd1f..2882332 100644
--- a/modules_s/domain/domain_api.h
+++ b/modules_s/domain/domain_api.h
@@ -25,9 +25,10 @@
#include "../../sr_module.h"
#include "../../dprint.h"
+#include "domain.h"
typedef struct domain_api {
-
+ is_domain_local_f is_domain_local;
} domain_api_t;
typedef int (*bind_domain_f)(domain_api_t* api);
diff --git a/modules_s/domain/domain_mod.c b/modules_s/domain/domain_mod.c
index c7e0515..e5d5cb0 100644
--- a/modules_s/domain/domain_mod.c
+++ b/modules_s/domain/domain_mod.c
@@ -381,107 +381,20 @@ static void destroy(void)
}
-/* Retrieve did directly from database, without using memory cache. Use 0 as
- * the value of first parameter if you only want to know whether the entry is
- * in the database. The function returns 1 if there is such entry, 0 if not,
- * and -1 on error. The result is allocated using pkg_malloc and must be
- * freed.
- */
-static int db_get_did(str* did, str* domain)
-{
- db_res_t* res = NULL;
- db_rec_t* rec;
-
- if (!domain) {
- ERR("BUG:Invalid parameter value\n");
- goto err;
- }
-
- get_did_cmd->match[0].v.lstr = *domain;
-
- if (db_exec(&res, get_did_cmd) < 0) {
- ERR("Error in database query\n");
- goto err;
- }
-
- rec = db_first(res);
- if (rec) {
- /* Test flags first, we are only interested in rows
- * that are not disabled
- */
- if (rec->fld[1].flags & DB_NULL || (rec->fld[1].v.bitmap &
- SRDB_DISABLED)) {
- db_res_free(res);
- return 0;
- }
-
- if (did) {
- if (rec->fld[0].flags & DB_NULL) {
- did->len = 0;
- did->s = 0;
- WARN("Domain '%.*s' has NULL did\n",
- domain->len, ZSW(domain->s));
- } else {
- did->s = pkg_malloc(rec->fld[0].v.lstr.len);
- if (!did->s) {
- ERR("No memory left\n");
- goto err;
- }
- memcpy(did->s, rec->fld[0].v.lstr.s, rec->fld[0].v.lstr.len);
- did->len = rec->fld[0].v.lstr.len;
- }
- }
-
- db_res_free(res);
- return 1;
- } else {
- db_res_free(res);
- return 0;
- }
-
- err:
- if (res) db_res_free(res);
- return -1;
-}
-
/*
* Check if domain is local
*/
static int is_local(struct sip_msg* msg, char* fp, char* s2)
{
- str domain, tmp;
+ str domain;
if (get_str_fparam(&domain, msg, (fparam_t*)fp) != 0) {
ERR("Unable to get domain to check\n");
return -1;
}
- tmp.s = pkg_malloc(domain.len);
- if (!tmp.s) {
- ERR("No memory left\n");
- return -1;
- }
- memcpy(tmp.s, domain.s, domain.len);
- tmp.len = domain.len;
- strlower(&tmp);
-
- if (!db_mode) {
- switch(db_get_did(0, &tmp)) {
- case 1: goto found;
- default: goto not_found;
- }
- } else {
- if (hash_lookup(0, *active_hash, &tmp) == 1) goto found;
- else goto not_found;
- }
-
- found:
- pkg_free(tmp.s);
- return 1;
- not_found:
- pkg_free(tmp.s);
- return -1;
+ return is_domain_local(&domain);
}
Module: sip-router
Branch: master
Commit: c4dbb39571c5e8d801956d8afc5134387de1a59a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c4dbb39…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Fri Jul 17 11:34:24 2009 +0200
domain: Documentation of internal API
Add docbook documentation for the internal API of domain module.
---
modules_s/domain/doc/domain.xml | 1 +
modules_s/domain/doc/domain_api.xml | 47 +++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/modules_s/domain/doc/domain.xml b/modules_s/domain/doc/domain.xml
index 0e4879f..9c8aa57 100644
--- a/modules_s/domain/doc/domain.xml
+++ b/modules_s/domain/doc/domain.xml
@@ -241,5 +241,6 @@ iptel
<xi:include href="params.xml"/>
<xi:include href="functions.xml"/>
<xi:include href="fifo.xml"/>
+ <xi:include href="domain_api.xml"/>
</section>
diff --git a/modules_s/domain/doc/domain_api.xml b/modules_s/domain/doc/domain_api.xml
new file mode 100644
index 0000000..27c2c10
--- /dev/null
+++ b/modules_s/domain/doc/domain_api.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+
+<section id="domain.api" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Internal API</title>
+ <para>The domain module has an internal API which can be used to access
+ additional functions of the module (i.e. functions that are normally not
+ available from the routing script). Currently the API exports only the
+ function <function>is_domain_local</function>. That function can be used
+ to determine whether a given domain name is on the list of locally
+ configured domain names.</para>
+
+ <para>If you want to use the internal API of domain module from your
+ module then you need to include the header file
+ <filename>domain_api.h</filename> and call
+ <function>load_domain_api</function> first.</para>
+
+ <example>
+ <title>Calling <function>load_domain_api</function></title>
+ <programlisting>
+#include "../domain/domain_api.h"
+
+domain_api_t dom_api;
+
+if (load_domain_api(&dom_api) != 0) {
+ /* error */
+}
+</programlisting>
+ </example>
+
+ <para>After that you can call function
+ <function>is_domain_local</function> whose pointer is stored in the
+ initialized data structure:</para>
+
+ <programlisting>
+str tmp = STR_STATIC_INIT("mydomain.com");
+
+if (dom_api.is_domain_local(&tmp) == 1) {
+ /* Domain is local */
+} else {
+ /* Domain is not local or an error was encountered */
+}
+ </programlisting>
+</section>
+
+
\ No newline at end of file
Module: sip-router
Branch: master
Commit: 04938dc72661dfe0c8954f392558812f7aa3da78
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=04938dc…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 16 14:05:50 2009 +0200
core: futexlock include hack for older futex.h
Older non-fixed linux/futex.h version (<2.6.20) cannot be included from
userspace without additional type declarations (which otherwise
are included only if __KERNEL__ is defined).
Note that most distribution fix this problem by distributing a
modified /usr/include/linux/futex.h and not the default kernel
one. However there are other distributions (like CentOS 5) for
which this hack is needed.
---
futexlock.h | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/futexlock.h b/futexlock.h
index 19e816d..df93b81 100644
--- a/futexlock.h
+++ b/futexlock.h
@@ -49,6 +49,12 @@
between linux-libc-dev andlibc headers
in recent (6.08.2008) x86_64 debian sid
installations */
+/* hack to work with old linux/futex.h versions, that depend on sched.h in
+ __KERNEL__ mode (futex.h < 2.6.20) */
+#include <linux/types.h>
+typedef __u32 u32;
+struct task_struct;
+/* end of the hack */
#include <linux/futex.h>
#include <sys/syscall.h>
#include <unistd.h>
Bugs item #2822344, was opened at 2009-07-16 11:06
Message generated for change (Tracker Item Submitted) made by axlh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2822344&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: ver 1.4.x
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alex Hermann (axlh)
Assigned to: Nobody/Anonymous (nobody)
Summary: Branch route has wrong ruri or missing headers
Initial Comment:
The scenario:
In branch route, I rewrite the ruri and add an additional header. When the destination fails and DNS-based failover takes place, the branch route is called again. For this second branch, the ruri is not the same as the ruri at t_relay time. Also the extra header is missing.
So this bug could be either:
- The ruri and rest of variables/packet for each branch should be the same as the ruri at t_relay time
or
- The header added in the first branch route should also be present for the second branch (in the case of DNS-based failover)
I would either expect the ruri and all other variables and headers to be exactly the same as at t_relay time for each branch, or (for DNS-based failover ONLY) the packet sent to a failover destination to be exactly the same as the first branch (including any added headers / from replacement, etc.) Not a mix of both.
Before t_relay:
$rU = "*1234567890"
t_relay("0x03");
my branch route:
xlog("L_NOTICE", "Branch: <$ru> via <$du>\n");
if (is_method("INVITE") and $(rU{s.substr,0,3}) == "*12") {
strip(3);
append_hf("X-Test: 12\r\n");
}
The log:
Jul 15 09:14:38 Branch: <sip:*1234567890@test.domain;transport=udp> via <<null>>
Jul 15 09:14:38 Reply Status: 503 Service Unavailable
Jul 15 09:14:38 Branch: <sip:234567890@test.domain;transport=udp> via <<null>>
Jul 15 09:14:38 Reply Status: 100 Trying
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2822344&group_…
Module: sip-router
Branch: master
Commit: 5ca1a775f63f2b5f905fd89cafb0b614ee44b522
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5ca1a77…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 16 10:45:41 2009 +0200
ctl(s) doc: added the autoconversion parameter
- info about the new autoconversion parameter
- README re-generated
---
modules_s/ctl/README | 24 +++++++++++++++++++++---
modules_s/ctl/doc/params.xml | 26 ++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/modules_s/ctl/README b/modules_s/ctl/README
index 7d538b0..12850b3 100644
--- a/modules_s/ctl/README
+++ b/modules_s/ctl/README
@@ -18,6 +18,7 @@ Andrei Pelinescu-Onciul
1.3.3. user (integer or string)
1.3.4. group (integer or string)
1.3.5. fifo (integer)
+ 1.3.6. autoconversion (integer)
1.4. RPC Functions
@@ -162,6 +163,23 @@ modparam("ctl", "fifo", "/tmp/ser_fifo2")
modparam("ctl", "fifo", "udp:*:2050") # fifo protocol over udp
modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
+1.3.6. autoconversion (integer)
+
+ Enable or disable automatic type conversion globally, for all the
+ methods parameters. If on, a type mismatch in a method parameter will
+ not cause a fault if it is possible to automatically convert it to the
+ expected type.
+
+ Default: off
+
+ It is recommended to leave this parameter to its default off value and
+ fix instead the client application (which should use the proper types)
+ or to modify the target rpc to accept any type (see the rpc scan '.'
+ modifier).
+
+ Example 7. Set the autoconversion parameter
+modparam("ctl", "autoconversion", 1)
+
1.4. RPC Functions
Revision History
@@ -171,7 +189,7 @@ modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
List all the sockets on which the ctl module listens.
- Example 7. print usage
+ Example 8. print usage
$ sercmd -f"[%v] %v:%v %v\n" ctl.listen
[binrpc] unix_stream:/tmp/ser_ctl
@@ -181,7 +199,7 @@ modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
Returns the number of open binrpc connections (to the ctl module).
- Example 8. ctl.connections usage
+ Example 9. ctl.connections usage
$ sercmd ctl.connections
1
@@ -189,7 +207,7 @@ modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
List open binrpc connections (to the ctl module).
- Example 9. ctl.who usage
+ Example 10. ctl.who usage
$ sercmd -f"[%v] %v: %v %v -> %v %v\n" ctl.who
[binrpc] unix_stream: <anonymous unix socket> -> /tmp/ser_ctl
diff --git a/modules_s/ctl/doc/params.xml b/modules_s/ctl/doc/params.xml
index 2b9d807..c2b06c2 100644
--- a/modules_s/ctl/doc/params.xml
+++ b/modules_s/ctl/doc/params.xml
@@ -166,4 +166,30 @@ modparam("ctl", "fifo", "tcp:*:2050") # fifo over tcp
</example>
</section>
+ <section id="autoconversion">
+ <title><varname>autoconversion</varname> (integer)</title>
+ <para>
+ Enable or disable automatic type conversion globally, for all the
+ methods parameters.
+ If on, a type mismatch in a method parameter will not cause a fault
+ if it is possible to automatically convert it to the expected type.
+ </para>
+ <para>
+ Default: off
+ </para>
+ <para>
+ It is recommended to leave this parameter to its default off value
+ and fix instead the client application (which should use the
+ proper types) or to modify the target rpc to accept any type
+ (see the rpc scan '.' modifier).
+ </para>
+ <example>
+ <title>Set the <varname>autoconversion</varname> parameter
+ </title>
+ <programlisting>
+modparam("ctl", "autoconversion", 1)
+ </programlisting>
+ </example>
+ </section>
+
</section>
Module: sip-router
Branch: master
Commit: b15f37fc1eb2fceaf8ea04e35e94850164f06cf5
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b15f37f…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Jul 16 10:39:36 2009 +0200
xmlrpc(s) doc: note about xmlrpclib bug
- added note about xmlrpclib bug (waiting for connection closing)
and workarounds (use a different transport class or make ser
close the tcp connection after each answer).
- list examples/xmlrpc_test.{pl,py} among the client examples
- updated & fixed some links
- README re-generated
---
modules_s/xmlrpc/README | 67 ++++++++++++++++++++++++++++++-----
modules_s/xmlrpc/doc/xmlrpc.xml | 75 ++++++++++++++++++++++++++++++++++-----
2 files changed, 124 insertions(+), 18 deletions(-)
diff --git a/modules_s/xmlrpc/README b/modules_s/xmlrpc/README
index 1961252..b497e66 100644
--- a/modules_s/xmlrpc/README
+++ b/modules_s/xmlrpc/README
@@ -15,11 +15,13 @@ Jan Janak
1.3.2. Replies
1.3.3. Type Conversion
1.3.4. Limitations
+ 1.3.5. Interoperability Problems
1.4. Client Examples
1.5. Parameters
1.5.1. route (string)
+ 1.5.2. autoconversion (string)
1.6. Functions
@@ -217,10 +219,10 @@ if (method == "POST" || method == "GET") {
SER receives GET or POST requests. These two method names indicate
HTTP.
- Step 4. Function dispatch_rpc scans through the list of all exported
- RPC functions searching for statistics function of usrloc module. The
- SER RPC Module API describes in detail how modules export RPC
- functions.
+ Step 4. The function dispatch_rpc scans through the list of all
+ exported RPC functions searching for the statistics function of the
+ usrloc module. The SER RPC Module API describes in detail how modules
+ export RPC functions.
Step 5. As the RPC function from usrloc module is running and gathering
statistics, it calls functions of RPC interface to prepare the result
@@ -366,7 +368,7 @@ Content-Length: 150
If an RPC function adds just a single item (it calls add once with just
one character in the formatting string) then the data will be converted
to XML-RPC representation according to the rules described in SER RPC
- Type Converion and the reply will contain just the single value:
+ Type Conversion and the reply will contain just the single value:
HTTP/1.0 200 OK
Via: SIP/2.0/TCP 127.0.0.1:3793
Server: Sip EXpress router (0.10.99-janakj_experimental (i386/linux))
@@ -438,9 +440,39 @@ Content-Length: 276
need all the bells and whistles of XML-RPC. Parsing and interpreting
nested structures is complex and we try to avoid it.
+1.3.5. Interoperability Problems
+
+ Due to a bug in Python xmlrpclib there is an interoperability problem
+ with basic clients using it: by default an xmlrpclib client expects the
+ server to immediately close the connection after answering and if the
+ server does not close the connections the xmlrpclib client will wait
+ forever.
+
+ There are 2 ways to work around this problem: write a "fixed" Transport
+ class and initialize xmlpclib using it (recommended) or make ser close
+ the tcp connection after each request.
+
+ The examples/xmlrpc_test.py provides a very simple example of using
+ xmlrpclib with a Transport class that works.
+
+ For the second solution (force closing tcp connections after answering)
+ the XMLRPC route should end with a return -1, exit -1 or drop -1.
+
+ Example 1.
+route[XMLRPC]{
+ dispatch_rpc();
+ # close connection only for xmlrpclib user agents
+ if search("^User-Agent:.*xmlrpclib"))
+ return -1 ;
+}
+
1.4. Client Examples
- * ser_ctl (python application that uses the XML-RPC interface
+ * examples/xmlrpc_test.pl (basic perl application that builds and
+ sends an XMLRPC request from its commandline parameters).
+ * examples/xmlrpc_test.py (basic python application that builds and
+ sends an XMLRPC request from its commandline parameters).
+ * ser_ctl (complex python application that uses the XML-RPC interface
implemented by the xmlrpc module).
* serweb (php application that can use the XML-RPC interface to call
ser functions).
@@ -465,9 +497,26 @@ Content-Length: 276
Default: the main route is used.
- Example 1. Set route parameter
+ Example 2. Set route parameter
modparam("xmlrpc", "route", "route_for_xmlrpcs")
+1.5.2. autoconversion (string)
+
+ Enable or disable automatic parameter type conversion globally, for all
+ the methods parameters. If on, a type mismatch in a method parameter
+ will not cause a fault if it is possible to automatically convert it to
+ the type expected by the method.
+
+ Default: off.
+
+ It is recommended to leave this parameter to its default off value and
+ fix instead the client application (which should use the proper types)
+ or to modify the target rpc to accept any type (see the rpc scan '.'
+ modifier).
+
+ Example 3. Set the autoconversion parameter
+modparam("xmlrpc", "autoconversion", 1)
+
1.6. Functions
Revision History
@@ -489,7 +538,7 @@ modparam("xmlrpc", "route", "route_for_xmlrpcs")
function with matching name. If such a function is found then
dispatch_rpc() will pass control to the function to handle the request.
- Example 2. dispatch_rpc usage
+ Example 4. dispatch_rpc usage
#...
modparam("xmlrpc", "route", "XMLRPC");
#...
@@ -502,7 +551,7 @@ route[XMLRPC]{
This function can be called from the config script to directly generate
an XML-RPC reply.
- Example 3. xmlrpc_reply usage
+ Example 5. xmlrpc_reply usage
#...
modparam("xmlrpc", "route", "XMLRPC");
#...
diff --git a/modules_s/xmlrpc/doc/xmlrpc.xml b/modules_s/xmlrpc/doc/xmlrpc.xml
index 4438185..c893e97 100644
--- a/modules_s/xmlrpc/doc/xmlrpc.xml
+++ b/modules_s/xmlrpc/doc/xmlrpc.xml
@@ -302,11 +302,11 @@ if (method == "POST" || method == "GET") {
indicate HTTP.
</para>
<para>
- <emphasis>Step 4.</emphasis> Function
+ <emphasis>Step 4.</emphasis> The function
<function>dispatch_rpc</function> scans through the list of all
- exported RPC functions searching for
- <function>statistics</function> function of usrloc module. The
- <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=doc/rpc/…'>
+ exported RPC functions searching for the
+ <function>statistics</function> function of the usrloc module. The
+ <ulink url='http://sip-router.org/docbook/sip-router/branch/master/rpc/ser_rpc.html'>
SER RPC Module API</ulink>
describes in detail how modules export RPC functions.
</para>
@@ -491,8 +491,8 @@ Content-Length: 150
with just one character in the formatting string) then the data
will be converted to XML-RPC representation according to the
rules described in
- <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=doc/rpc/…'>
- SER RPC Type Converion</ulink> and
+ <ulink url='http://sip-router.org/docbook/sip-router/branch/master/rpc/ser_rpc.html#rpc…'>
+ SER RPC Type Conversion</ulink> and
the reply will contain just the single value:
<programlisting>
<![CDATA[
@@ -655,6 +655,43 @@ Content-Length: 276
complex and we try to avoid it.
</para>
</section>
+ <section id="xmlrpc.interoperability_problems">
+ <title>Interoperability Problems</title>
+ <para>
+ Due to a bug in Python xmlrpclib there is an interoperability
+ problem with basic clients using it: by default an xmlrpclib client
+ expects the server to immediately close the connection after answering
+ and if the server does not close the connections the xmlrpclib client
+ will wait forever.
+ </para>
+ <para>
+ There are 2 ways to work around this problem: write a "fixed"
+ Transport class and initialize xmlpclib using it (recommended) or
+ make ser close the tcp connection after each request.
+ </para>
+ <para>
+ The <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_…'>
+ examples/xmlrpc_test.py
+ </ulink> provides a very simple example of using xmlrpclib with a
+ Transport class that works.
+ </para>
+ <para>
+ For the second solution (force closing tcp connections after answering)
+ the XMLRPC route should end with a return -1, exit -1 or drop -1.
+ <example>
+ <programlisting>
+<![CDATA[
+route[XMLRPC]{
+ dispatch_rpc();
+ # close connection only for xmlrpclib user agents
+ if search("^User-Agent:.*xmlrpclib"))
+ return -1 ;
+}
+]]>
+ </programlisting>
+ </example>
+ </para>
+ </section>
</section>
<section id="xmlrpc.client_examples">
@@ -673,12 +710,32 @@ Content-Length: 276
<para>
<itemizedlist>
<listitem><para>
- <emphasis>ser_ctl</emphasis> (python application that uses the
- <emphasis>XML-RPC</emphasis> interface implemented by the
+ <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_…'>
+ <emphasis>examples/xmlrpc_test.pl</emphasis>
+ </ulink> (basic perl application that builds and sends an
+ <emphasis>XMLRPC</emphasis> request from its commandline
+ parameters).
+ </para></listitem>
+ <listitem><para>
+ <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_…'>
+ <emphasis>examples/xmlrpc_test.py</emphasis>
+ </ulink> (basic python application that builds and sends an
+ <emphasis>XMLRPC</emphasis> request from its commandline
+ parameters).
+ </para></listitem>
+ <listitem><para>
+ <ulink url='http://git.sip-router.org/cgi-bin/gitweb.cgi?p=ser;a=tree;f=ser_ctl'>
+ <emphasis>ser_ctl</emphasis>
+ </ulink>
+ (complex python application that
+ uses the <emphasis>XML-RPC</emphasis> interface implemented by the
<emphasis>xmlrpc</emphasis> module).
</para></listitem>
<listitem><para>
- <emphasis>serweb</emphasis> (php application that can use
+ <ulink uri='http://www.iptel.org/serweb'>
+ <emphasis>serweb</emphasis>
+ </ulink>
+ (php application that can use
the <emphasis>XML-RPC</emphasis> interface to call ser
functions).
</para></listitem>