andrei 2009/07/14 09:36:51 CEST
SER CVS Repository
Modified files:
modules/presence_b2b euac_funcs.c
Log:
presence_b2b: fix from & to header access
Access the parsed part of a From or To header only if non-zero
and/or parse_from_header() returned success.
Revision Changes Path
1.16 +4 -2 sip_router/modules/presence_b2b/euac_funcs.c
http://cvs.berlios.de/cgi-bin/viewcvs.cgi/ser/sip_router/modules/presence_b…
andrei 2009/07/14 09:36:20 CEST
SER CVS Repository
Modified files:
modules/rr loose.c
Log:
rr: fix from header access
get_from() can be used _only_ if parse_from_header() returned
success or if msg->from!=0.
Revision Changes Path
1.53 +3 -3 sip_router/modules/rr/loose.c
http://cvs.berlios.de/cgi-bin/viewcvs.cgi/ser/sip_router/modules/rr/loose.c…
Module: sip-router
Branch: master
Commit: ad12d90508ef5f896ef0327362971cd9afba81f2
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ad12d90…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Jul 13 22:40:33 2009 +0200
sercmd: updated to the new mi_rpc format
- updated to the new mi output format
- support for tab completion for mi_dg, mi_fifo and mi_xmlrpc
---
utils/sercmd/sercmd.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/utils/sercmd/sercmd.c b/utils/sercmd/sercmd.c
index 0c26d9e..9c9edf0 100644
--- a/utils/sercmd/sercmd.c
+++ b/utils/sercmd/sercmd.c
@@ -314,6 +314,9 @@ char* complete_params_cfg_var[]={
/* commands for which we complete the first param with an mi command*/
char* complete_params_mi[]={
"mi",
+ "mi_fifo",
+ "mi_dg",
+ "mi_xmlrpc",
0
};
#endif /* USE_MI */
@@ -1423,10 +1426,10 @@ static int get_mi_list(int s)
for (r=0; r<mi_which_no; r++){
if (mi_which_array[r].type!=BINRPC_T_STR)
continue;
- /* we are interestend only in lines starting with '+', e.g.:
- + :: version */
+ /* we are interestend only in lines starting with ':', e.g.:
+ :: version */
if ((mi_which_array[r].u.strval.len) &&
- (mi_which_array[r].u.strval.s[0]=='+'))
+ (mi_which_array[r].u.strval.s[0]==':'))
mi_which_results++;
}
/* no mi commands */
@@ -1442,29 +1445,26 @@ static int get_mi_list(int s)
continue;
p=mi_which_array[r].u.strval.s;
end=p+mi_which_array[r].u.strval.len;
- /* we are interestend only in lines starting with '+', e.g.:
- + :: version */
- if ((p>=end) || (*p!='+'))
+ /* we are interestend only in lines starting with ':', e.g.:
+ :: version */
+ if ((p>=end) || (*p!=':'))
continue;
p++;
- /* skip over to the first ':' */
- for(;p<end && *p!=':'; p++);
- if (p>=end) continue;
- p++;
/* skip over to the next ':' */
for(;p<end && *p!=':'; p++);
if (p>=end) continue;
p++;
/* skip over spaces */
for(;p<end && (*p==' ' || *p=='\t'); p++);
- if (p>=end) continue;
+ if (p>=end || *p=='\n') continue;
if (mi_cmds_no >= mi_which_results){
fprintf(stderr, "BUG: wrong mi cmds no (%d >= %d)\n",
mi_cmds_no, mi_which_results);
goto error;
}
mi_name.s=p;
- mi_name.len=(int)(long)(end-p);
+ for(; p<end && *p!=' ' && *p!='\t' && *p!='\n'; p++);
+ mi_name.len=(int)(long)(p-mi_name.s);
mi_cmds[mi_cmds_no]=mi_name;
mi_cmds_no++;
}
Daniel-Constantin Mierla writes:
> here is what mi_rpc modules does:
> - it receives a rpc handler form the rpc interface in core
> - reads first parameter and then lookups MI command, if not found then
> returns error, if found:
> - reads all parameters as string and build internal MI tree
ok, after andrei fixed some bug, i got stats working via mi_rpc and
xmlrpc module interface.
all stats except "tm:", which is now implemented using tm.stats command.
res = c.tm.stats()
provides this kind of result:
{'2xx': 0, 'created': 0, '5xx': 0, 'delayed_free': 0, 'current': 0, 'total_local': 0, 'waiting': 0, '6xx': 0, '4xx': 0, '3xx': 0, 'total': 0, 'replied_locally': 0, 'freed': 0}
whereas mi based stat results look like this:
['200 OK\n', '+ :: core:rcv_requests = 3', '+ :: core:rcv_replies = 0', '+ :: core:fwd_requests = 0', '+ :: core:fwd_replies = 0', '+ :: core:drop_requests = 0', '+ :: core:drop_replies = 0', '+ :: core:err_requests = 0', '+ :: core:err_replies = 0', '+ :: core:bad_URIs_rcvd = 0', '+ :: core:unsupported_methods = 3', '+ :: core:bad_msg_hdr = 0']
would it be possible to get the result in same (preferable the former)
format in both cases?
-- juha
Module: sip-router
Branch: master
Commit: 4903fc5f9b5fa2b6047780dc192d6b41fd746d68
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4903fc5…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Jul 13 19:04:52 2009 +0200
xmlrpc(s): added rpc client examples
Added rpc client examples/test scripts in perl and python. The
python script has 2 versions: one with re-defined transport (that
works properly without expecting the server side to immediately
close the connection after answering) and one using the default
xmlrpclib transport (which requires closing the connection from
the ser xmlrpc route).
---
modules_s/xmlrpc/examples/xmlrpc_test.pl | 67 +++++++++++++++++++++++++++++
modules_s/xmlrpc/examples/xmlrpc_test.py | 51 ++++++++++++++++++++++
modules_s/xmlrpc/examples/xmlrpc_test2.py | 29 ++++++++++++
3 files changed, 147 insertions(+), 0 deletions(-)
diff --git a/modules_s/xmlrpc/examples/xmlrpc_test.pl b/modules_s/xmlrpc/examples/xmlrpc_test.pl
new file mode 100644
index 0000000..dbb32b8
--- /dev/null
+++ b/modules_s/xmlrpc/examples/xmlrpc_test.pl
@@ -0,0 +1,67 @@
+#!/usr/bin/perl
+
+# perl script for sending an xmlrpc command to ser's xmlrpc module,
+# extra verbose output
+# Usage: perl xmlrpc_test.pl command [params...]
+#
+# History:
+# --------
+# 2009-07-13 initial version (andrei)
+#
+#
+
+use strict;
+use warnings;
+
+use XMLRPC::Lite;
+
+ my $rpc=shift @ARGV;
+ my @rpc_params=@ARGV;
+ my $k;
+ my %r;
+ my $i;
+
+ if (!defined $rpc) {
+ die "Usage: $0 rpc_command [args..]";
+ }
+
+# actual rpc call
+
+ my($rpc_call) = XMLRPC::Lite
+ -> proxy("http://127.0.0.1:5060") -> call($rpc, @rpc_params);
+
+ my $res= $rpc_call->result;
+
+# extra verbose result printing (could be skipped)
+
+ if (!defined $res){
+ print "fault{\n";
+ $res=$rpc_call->fault;
+ %r=%{$res};
+ foreach $k (sort keys %r) {
+ print("\t$k: $r{$k}\n");
+ }
+ print "}\n";
+ exit -1;
+ }
+ if (ref($res) eq "HASH"){
+ print("{\n");
+ %r=%{$res};
+ foreach $k (keys %r) {
+ print("\t$k: ", $r{$k}, "\n");
+ }
+ print("}\n");
+ } elsif (ref($res) eq "ARRAY"){
+ print "[\n";
+ for ($i=0; $i<@{$res}; $i++){
+ print "\t${$res}[$i]\n";
+ }
+ print "]\n";
+ }elsif (ref($res) eq "SCALAR"){
+ print "${$res}\n";
+ }elsif (!ref($res)){
+ print "$res\n";
+ }else{
+ print("ERROR: reference to ", ref($res), " not handled\n");
+ }
+
diff --git a/modules_s/xmlrpc/examples/xmlrpc_test.py b/modules_s/xmlrpc/examples/xmlrpc_test.py
new file mode 100644
index 0000000..0bf1591
--- /dev/null
+++ b/modules_s/xmlrpc/examples/xmlrpc_test.py
@@ -0,0 +1,51 @@
+import xmlrpclib, httplib, sys
+
+# Usage: python xmlrpc_test.py command [params...]
+#
+# python script for sending an xmlrpc command to ser's xmlrpc module.
+# Note: it uses a re-defined transport class that does not depend on the
+# server side closing the connection (it can be used to send multiple
+# commands without closing the connections and it will work without any
+# special workarounds in the ser.cfg xmlrpc route).
+#
+# Credits: the transport class comes from ser_ctl, heavily trimmed to a very
+# basic version (the ser_ctl version is much more complex, supports
+# authentication, ssl a.s.o). See
+# http://git.sip-router.org/cgi-bin/gitweb.cgi?p=ser;a=blob;f=ser_ctl/serctl/… for the original (better) version.
+#
+#
+# History:
+# --------
+# 2009-07-13 initial version (andrei)
+#
+
+
+XMLRPC_SERVER = "127.0.0.1"
+XMLRPC_PORT = 5060
+
+class Transport:
+ def __init__(self):
+ self.conn=httplib.HTTPConnection(XMLRPC_SERVER, str(XMLRPC_PORT));
+
+ def _http_request(self, uripath, body, host):
+ self.conn.request("POST", uripath, body, {})
+
+ def request(self, host, uripath, body, verbose=0):
+ self._http_request(uripath, body, host)
+ response=self.conn.getresponse()
+ if response.status != 200:
+ raise xmlrpclib.ProtocolError(host+uripath, response.status,
+ response.reason, response.msg)
+ data=response.read()
+ parser, unmarshaller=xmlrpclib.getparser()
+ parser.feed(data)
+ parser.close()
+ return unmarshaller.close()
+
+if len(sys.argv) < 2:
+ sys.exit("Usage: "+sys.argv[0]+" rpc_command [args...]");
+transport=Transport()
+c=xmlrpclib.ServerProxy("http://" + XMLRPC_SERVER+ ":" + str(XMLRPC_PORT),
+ transport)
+res=getattr(c, sys.argv[1])(*sys.argv[2:])
+print res;
diff --git a/modules_s/xmlrpc/examples/xmlrpc_test2.py b/modules_s/xmlrpc/examples/xmlrpc_test2.py
new file mode 100644
index 0000000..0fdee1e
--- /dev/null
+++ b/modules_s/xmlrpc/examples/xmlrpc_test2.py
@@ -0,0 +1,29 @@
+import xmlrpclib, httplib, sys
+
+# Usage: python xmlrpc_test2.py command [params...]
+#
+# python script for sending an xmlrpc command to ser's xmlrpc module.
+# This script uses python xmlrpclib directly and expects the remote side to
+# immediately close the connection after answering (broken xmlrpclib
+# behaviour).
+# There are 2 way to make it work with ser xmlrpc module: define a
+# better transport class (that's what the xmlrpc_test.py script is doing) or
+# change ser xmlrpc route so that it will close the connection after each
+# processes xmlrpc request (e.g. add a drop -1 at the end).
+#
+# See also: xmlrpc_test.py (better version, using a redefined transport class).
+#
+# History:
+# --------
+# 2009-07-13 initial version (andrei)
+#
+
+XMLRPC_SERVER = "127.0.0.1"
+XMLRPC_PORT = 5060
+
+
+if len(sys.argv) < 2:
+ sys.exit("Usage: "+sys.argv[0]+" rpc_command [args...]");
+c=xmlrpclib.ServerProxy("http://" + XMLRPC_SERVER+ ":" + str(XMLRPC_PORT))
+res=getattr(c, sys.argv[1])(*sys.argv[2:])
+print res;
Daniel-Constantin Mierla writes:
> several days ago, a new module named mi_rpc was introduced to source
> tree. The goal is to be able to execute MI commands using RPC interface
> from sip router core.
>
> Back to mi_rpc, one issue that needs to be sorted out is the output
> format. Right now doing a pretty-format printing which is not suitable
> for xmlrpc.
>
> Feedback is very much appreciated, thanks,
i tried to get core stats out using xmlrcp. using serctl, i can do it
like this:
srctl mi get_statistics core:200 OK
+ :: core:rcv_requests = 10
+ :: core:rcv_replies = 0
+ :: core:fwd_requests = 0
+ :: core:fwd_replies = 0
+ :: core:drop_requests = 0
+ :: core:drop_replies = 0
+ :: core:err_requests = 0
+ :: core:err_replies = 0
+ :: core:bad_URIs_rcvd = 0
+ :: core:unsupported_methods = 10
+ :: core:bad_msg_hdr = 0
using xmlrpc interface, i tried by giving command called "mi" with
argument list "get_statistics" and "core":, but it didn't work:
c.mi(['get_statistics', 'core:'])
...
xmlrpclib.Fault: <Fault 500: 'command parameter missing'>
how is the actual command and and its arguments supplied?
-- juha
Module: sip-router
Branch: master
Commit: e792b7614aaa57ddf4482a23e21c959dd2f45f98
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e792b76…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Jul 13 18:00:40 2009 +0200
xmlrpc(s): fix '*' rpc_scan handling
The '*' modifier (marking the next parameters as optional) was not
properly handled (the current input parameter was "eaten").
Reported-by: Juha Heinanen jh at tutpro com
---
modules_s/xmlrpc/xmlrpc.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/modules_s/xmlrpc/xmlrpc.c b/modules_s/xmlrpc/xmlrpc.c
index 56b2151..0de5145 100644
--- a/modules_s/xmlrpc/xmlrpc.c
+++ b/modules_s/xmlrpc/xmlrpc.c
@@ -1220,9 +1220,9 @@ static int rpc_scan(rpc_ctx_t* ctx, char* fmt, ...)
switch(*fmt) {
case '*': /* start of optional parameters */
modifiers++;
- /* no other action needed, for xmlrpc params are treated as
- optionals anyway */
- break;
+ read++;
+ fmt++;
+ continue; /* do not advance ctx->act-param */
case 'b': /* Bool */
case 't': /* Date and time */
case 'd': /* Integer */