• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..15-Apr-2021-

doc/H03-May-2022-1,0941,054

examples/H15-Apr-2021-15980

MakefileH A D15-Apr-2021621 3122

READMEH A D15-Apr-202126.2 KiB761613

http.cH A D15-Apr-20215 KiB197100

http.hH A D15-Apr-20211.4 KiB5121

xmlrpc.cH A D15-Apr-202177.4 KiB2,7511,922

xmlrpc.hH A D15-Apr-2021939 284

README

1The XMLRPC Module
2
3Jan Janak
4
5   iptelorg GmbH
6
7   Copyright © 2005 iptelorg GmbH
8     __________________________________________________________________
9
10   Table of Contents
11
12   1. Admin Guide
13
14        1. Dependencies
15
16              1.1. Kamailio modules
17
18        2. Parameters
19
20              2.1. route (string)
21              2.2. autoconversion (string)
22              2.3. escape_cr (integer)
23              2.4. double_lf_to_crlf (integer)
24              2.5. mode (integer)
25              2.6. url_skip (str)
26              2.7. url_match (str)
27              2.8. event_callback (string)
28
29        3. Functions
30
31              3.1. dispatch_rpc()
32              3.2. xmlrpc_reply(code, reason)
33
34   List of Tables
35
36   1. Data Type Conversion
37
38   List of Examples
39
40   1.
41   1.1. Set route parameter
42   1.2. Set the autoconversion parameter
43   1.3. Set the escape_cr parameter
44   1.4. Set the double_lf_to_crlf parameter
45   1.5. Set the mode parameter
46   1.6. Set url_skip parameter
47   1.7. Set url_match parameter
48   1.8. Set event_callback parameter
49   1.9. dispatch_rpc usage
50   1.10. xmlrpc_reply usage
51
521. Design Goals
53
54     * Implemented as a module.
55     * API independent of transport protocols.
56     * Reuse transports available in Kamailio.
57     * The possibility to encrypt all communication.
58     * The possibility to authenticate clients.
59     * Easy integration with existing languages and implementations.
60     * Easy and straightforward implementation of management functions in
61       Kamailio modules.
62
632. Overview of Operation
64
65   This module implements the XML-RPC transport and encoding interface for
66   Kamailio RPCs.
67
68   The XML-RPC protocol encodes the name of the method to be called along
69   with its parameter in an XML document which is then conveyed using HTTP
70   (Hyper Text Transfer Protocol) to the server. The server will extract
71   the name of the function to be called along with its parameters from
72   the XML document, execute the function, and encode any data returned by
73   the function into another XML document which is then returned to the
74   client in the body of a 200 OK reply to the HTTP request.
75
76   XML-RPC is similar to more popular SOAP (Simple Object Access
77   Protocol), which is an XML-based messaging framework used in Web
78   Services developed within the World Wide Web Consortium. Both protocols
79   are using HTTP as the transport protocol for XML documents, but XML-RPC
80   is much simpler and easier to implement than SOAP.
81
82   Here is an example of single XML-RPC function call to determine current
83   time:
84POST /RPC2 HTTP/1.0
85User-Agent: Radio UserLand/7.1b7 (WinNT)
86Host: time.xmlrpc.com
87Content-Type: text/xml
88Content-length: 131
89
90<?xml version="1.0"?>
91<methodCall>
92<methodName>currentTime.getCurrentTime</methodName>
93<params>
94</params>
95</methodCall>
96
97   And the response returned by the server:
98HTTP/1.1 200 OK
99Connection: close
100Content-Length: 183
101Content-Type: text/xml
102Date: Wed, 03 Oct 2001 15:53:38 GMT
103Server: UserLand Frontier/7.0.1-WinNT
104
105<?xml version="1.0"?>
106<methodResponse>
107<params>
108<param>
109<value><dateTime.iso8601>20011003T08:53:38</dateTime.iso8601>
110</value>
111</param>
112</params>
113</methodResponse>
114
115   XML-RPC specification spells HTTP as the official transport protocol
116   for XML-RPC documents. Kamailio does not directly support HTTP, it is a
117   SIP server so SIP is the only protocol supported by Kamailio. Because
118   we would like to reuse all transport protocols available in Kamailio,
119   such as TCP and TLS, it would be natural to use modified version of
120   XML-RPC which would run on top of SIP instead of HTTP. XML-RPC
121   documents would be then encoded in the bodies of SIP requests and
122   replies would be sent by the server in the bodies of SIP replies. This
123   way we could reuse all transport protocols (including UDP) and message
124   parsers available in Kamailio.
125
126   Although this approach seems to be the logical choice, there is one big
127   drawback. No existing XML-RPC implementations support SIP as the
128   transport protocol, and there are many existing implementations
129   available for vast majority of existing languages. See the XML-RPC
130   implementation page for more details. Extending existing
131   implementations with SIP support would not be easy.
132
133   Because extending available XML-RPC implementation would be too
134   expensive, we could also do it the other way around, keep existing
135   XML-RPC implementations and extend Kamailio to support HTTP. Extending
136   Kamailio with HTTP support is easier than it might seem at a first
137   glance, due to the similarity between SIP requests and HTTP requests.
138
139   Kamailio already supports TCP, so existing HTTP implementations can
140   send HTTP requests to it. HTTP requests are missing certain mandatory
141   SIP header fields, such as Via, From, and CSeq. The contents of the
142   header fields is mainly used for transaction matching. A SIP server
143   could perform two basic operations when processing an HTTP request:
144     * Terminate the request, execute the function and send a reply back.
145     * Forward the request to another SIP server.
146
147   Nothing special is needed on the SIP server terminating the request,
148   except that it has to know where it should send the reply. Parsing of
149   HTTP header field bodies would fail because we do not have parsers for
150   them in Kamailio, but that does not matter anyway because all the
151   information is encoded in the body of the request. HTTP requests
152   contain no Via header fields. Via header fields are used by SIP
153   implementations to determine the destination (IP, transport protocol,
154   and port number) for replies. When processing HTTP requests the SIP
155   server needs to create a fake Via header field based on the source IP
156   address and port number of the TCP connection. The SIP server will use
157   this information when sending a reply back.
158
159   Forwarding of HTTP requests by SIP proxies is a little bit more
160   complicated and there are several limitations. First of all, we can
161   only use stateless forwarding, no transactional forwarding, because
162   HTTP requests do not contain all the header fields needed for
163   transaction matching. Any attempt to call t_relay on an HTTP requests
164   would fail. HTTP requests always use TCP and thus we could use
165   stateless forwarding on the SIP server, provided that the request will
166   be also forwarded over TCP. Stateless forwarding does not require the
167   mandatory header fields (which are missing here) and it would work. In
168   addition to that, the SIP server would also append fake Via header
169   field to the request and change the contents of the Request-URI. The
170   Request-URI of HTTP requests sent by XML-RPC implementations typically
171   contain something like "/RPC2" and the first SIP server processing the
172   request should rewrite the value with a valid SIP URI.
173
174   Figure RPC Example shows a scenario which involves two SIP servers, one
175   performs HTTP request "normalization" and forwarding, and the other
176   terminates the request, executes corresponding function, and generates
177   a reply.
178
179                            [xmlrpc_example.png]
180
181   Example RPC Scenario
182
183   Step 1. An HTTP user agent sends an ordinary HTTP request to a SIP
184   server. The user agent can either establish a connection directly to
185   port 5060 or the SIP server can be configured to listen on port 80. The
186   request contains standard HTTP headers and an XML-RPC document in the
187   body:
188POST / HTTP/1.0.
189Host: localhost:5060
190User-Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)
191Content-Type: text/xml
192Content-Length: 111
193
194<?xml version='1.0'?>
195<methodCall>
196<methodName>usrloc.statistics</methodName>
197<params>
198</params>
199</methodCall>
200
201   This particular request calls method "statistics" from from usrloc
202   module of Kamailio. The method has no parameters.
203
204   The outbound SIP server receives the HTTP request and performs a set of
205   actions called "SIP-normalization". This includes creation of fake Via
206   header field based on the source IP and port of the TCP connection,
207   looking up of the target SIP server that should terminate and process
208   the request, and rewriting of the Request-URI with the SIP URI of the
209   target SIP server. Modified HTTP request will be then forwarded
210   statelessly to the target SIP server.
211POST sip:proxy01.sip-server.net HTTP/1.0
212Via: SIP/2.0/TCP 127.0.0.1:3571
213Host: localhost:5060
214User-Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)
215Content-Type: text/xml
216Content-Length: 111
217
218<?xml version='1.0'?>
219<methodCall>
220<methodName>usrloc.statistics</methodName>
221<params>
222</params>
223</methodCall>
224
225   Step 2. "normalized" HTTP request is statelessly forwarded to the
226   target SIP server over TCP.
227
228   Step 3. The target SIP server receives the HTTP request and executes
229   function called dispatch_rpc from xmlrpc Kamailio module. This function
230   will parse the XML-RPC document in the body of the request and lookup
231   the function to be called among all RPC functions exported by the
232   Kamailio core and modules. Function dispatch_rpc will be called from
233   the configuration file just like any other function:
234if (method == "POST" || method == "GET") {
235    dispatch_rpc();
236    break;
237};
238
239   This particular configuration snippet executes the function whenever
240   Kamailio receives GET or POST requests. These two method names indicate
241   HTTP.
242
243   Step 4. The function dispatch_rpc scans through the list of all
244   exported RPC functions searching for the statistics function of the
245   usrloc module. The Kamailio RPC Module API describes in detail how
246   modules export RPC functions.
247
248   Step 5. As the RPC function from usrloc module is running and gathering
249   statistics, it calls functions of RPC interface to prepare the result
250   for the caller.
251
252   Step 6. Once the RPC function finishes, xmlrpc module will build the
253   XML-RPC document from the data received from usrloc module and generate
254   a reply which will be sent to the caller.
255
256   Steps 7. and 8. HTTP reply is sent back to the caller and the remote
257   procedure call finishes.
258HTTP/1.0 200 OK
259Via: SIP/2.0/TCP 127.0.0.1:3571
260Server: Sip EXpress router (0.10.99-janakj_experimental (i386/linux))
261Content-Length: 651
262Warning: 392 127.0.0.1:5060 "Noisy feedback tells:  pid=9975 req_src_ip=127.0.0
2631 req_src_port=3571 in_uri=/ out_uri=sip:proxy01.sip-server.net via_cnt==1"
264
265<?xml version="1.0" encoding="UTF-8"?>
266<methodResponse>
267<params>
268<param><value><array><data>
269<value><struct>
270<member><name>domain</name>
271<value><string>aliases</string></value></member>
272<member><name>users</name>
273<value><i4>0</i4></value></member>
274<member><name>expired</name>
275<value><i4>0</i4></value></member>
276</struct></value>
277<value><struct>
278<member><name>domain</name>
279<value><string>location</string></value></member>
280<member><name>users</name>
281<value><i4>0</i4></value></member>
282<member><name>expired</name>
283<value><i4>0</i4></value></member>
284</struct></value>
285</data></array></value></param>
286</params>
287</methodResponse>
288
289Note
290
291   The scenario described on Figure RPC Example involves two SIP servers.
292   This is just to demonstrate that in setups containing more SIP servers
293   it is possible to forward HTTP requests from one SIP server to another
294   and use standard SIP routing mechanisms to decide which SIP server
295   should process the request. There is no need to have multiple SIP
296   servers in simple setups, because one SIP server can both add fake Via
297   header field and process the RPC at the same time. Modified
298   configuration file snipped could then look like this:
299if (method == "POST" || method == "GET") {
300    dispatch_rpc(); # Process the request
301    break;
302};
303
3043. XML-RPC Implementation
305
306   3.1. Requests
307   3.2. Replies
308   3.3. Type Conversion
309   3.4. Limitations
310   3.5. Interoperability Problems
311
312   The purpose of the functions of this module is to convert XML-RPC
313   document carried in the body of HTTP requests into data returned by the
314   RPC interface and back. The module also contains functions necessary to
315   "normalize" HTTP requests. The module uses xmlrpc-c library to perform
316   XML-RPC related functions.
317
318   The module always returns 200 OK HTTP reply, it will never return any
319   other HTTP reply. Failures are expressed in XML-RPC documents in the
320   body of the reply. There is basic method introspection support in the
321   module. Currently the module can list all functions exported by the
322   server and for each function it can return the documentation string
323   describing the function.
324
3253.1. Requests
326
327   Requests processed by the module are standard XML-RPC requests encoded
328   in bodies of HTTP requests.
329POST / HTTP/1.0
330Host: localhost:5060
331User-Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)
332Content-Type: text/xml
333Content-Length: 112
334
335<?xml version='1.0'?>
336<methodCall>
337<methodName>system.listMethods</methodName>
338<params>
339</params>
340</methodCall>
341
342   The name of the method to be called in this example is "listMethods".
343   This is one of the introspection methods. Kamailio will call
344   dispatch_rpc function of xmlrpc module to handle the request. The
345   function will parse the XML-RPC document, lookup listMethods function
346   in the list of all export RPC functions, prepare the context for the
347   function and execute it.
348
3493.2. Replies
350
351   The module will always generate 200 OK. Other response codes and
352   classes are reserved for Kamailio. The status code of the XML-RPC
353   reply, response code, and additional data will be encoded in the body
354   of the reply. Failure replies do not contain any data, just the
355   response code and reason phrase:
356HTTP/1.0 200 OK
357Via: SIP/2.0/TCP 127.0.0.1:2464
358Server: Sip EXpress router (0.10.99-janakj_experimental (i386/linux))
359Content-Length: 301
360
361<?xml version="1.0" encoding="UTF-8"?>
362<methodResponse>
363
364<fault>
365<value><struct>
366<member><name>faultCode</name>
367<value><i4>501</i4></value></member>
368<member><name>faultString</name>
369<value><string>Method Not Implemented</string></value></member>
370</struct></value>
371</fault>
372
373</methodResponse>
374
375   This particular reply indicates that there is no such RPC method
376   available on the server.
377
378   Success replies always contain at least one return value. In our case
379   the simplest success replies contain single boolean with value 1:
380HTTP/1.0 200 OK
381Via: SIP/2.0/TCP 127.0.0.1:4626
382Server: Sip EXpress router (0.10.99-janakj_experimental (i386/linux))
383Content-Length: 150
384
385<?xml version="1.0" encoding="UTF-8"?>
386<methodResponse>
387<params>
388<param><value><boolean>1</boolean></value></param>
389</params>
390</methodResponse>
391
392   This is exactly how the reply looks like when an RPC function does not
393   add any data to the reply set.
394
395   If an RPC function adds just a single item (it calls add once with just
396   one character in the formatting string) then the data will be converted
397   to XML-RPC representation according to the rules described in Kamailio
398   RPC Type Conversion and the reply will contain just the single value:
399HTTP/1.0 200 OK
400Via: SIP/2.0/TCP 127.0.0.1:3793
401Server: Sip EXpress router (0.10.99-janakj_experimental (i386/linux))
402Content-Length: 216
403
404<?xml version="1.0" encoding="UTF-8"?>
405<methodResponse>
406<params>
407<param><value><string>Server: Sip EXpress router (0.10.99-janakj_experimental (i
408386/linux))</string></value></param>
409</params>
410</methodResponse>
411
412   If an RPC function adds more than one data items to the result set then
413   the module will return an array containing all the data items:
414HTTP/1.0 200 OK
415Via: SIP/2.0/TCP 127.0.0.1:2932
416Server: Sip EXpress router (0.10.99-janakj_experimental (i386/linux))
417Content-Length: 276
418
419<?xml version="1.0" encoding="UTF-8"?>
420<methodResponse>
421<params>
422<param><value><array><data>
423<value><string>./ser</string></value>
424<value><string>-f</string></value>
425<value><string>ser.cfg</string></value>
426</data></array></value></param>
427</params>
428</methodResponse>
429
430   This is probably the most common scenario.
431
4323.3. Type Conversion
433
434   The data types of the RPC API are converted to the data types of
435   XML-RPC and vice versa. Table 1, “Data Type Conversion” shows for each
436   RPC API data type corresponding XML-RPC data type.
437
438   Table 1. Data Type Conversion
439   RPC API XML-RPC RPC Example XML-RPC Example
440   Integer <i4></i4> rpc->add("d", 42) <i4>42</i4>
441   Float <double></double> rpc->add("f", -12.214) <double>-12.214</double>
442   String <string></string> rpc->add("s","Don't panic") <string>Don't
443   panic</string>
444   Struct <struct></struct>
445   rpc->struct_add(handle,"sd","param1",42,"param2",-12.214)
446<struct>
447  <member>
448    <name>param1</name>
449    <value>
450      <i4>42</i4>
451    </value>
452  </member>
453  <member>
454    <name>param2</name>
455    <value>
456      <double>-12.214</i4>
457    </value>
458  </member>
459</struct>
460
4613.4. Limitations
462
463   Kamailio xmlrpc modules does not implement all data types allowed in
464   XML-RPC. As well it does not implement arrays and nested structures.
465   This simplification is a feature, not bug. In our case the XML-RPC
466   interface will be used mainly for management purposes and we do not
467   need all the bells and whistles of XML-RPC. Parsing and interpreting
468   nested structures is complex and we try to avoid it.
469
4703.5. Interoperability Problems
471
472   Due to a bug in Python xmlrpclib there is an interoperability problem
473   with basic clients using it: by default an xmlrpclib client expects the
474   server to immediately close the connection after answering and if the
475   server does not close the connections the xmlrpclib client will wait
476   forever.
477
478   There are 2 ways to work around this problem: write a "fixed" Transport
479   class and initialize xmlpclib using it (recommended) or make ser close
480   the tcp connection after each request.
481
482   The examples/xmlrpc_test.py provides a very simple example of using
483   xmlrpclib with a Transport class that works.
484
485   For the second solution (force closing tcp connections after answering)
486   the XMLRPC route should have a set_reply_close() command before
487   dispatch_rpc(). set_reply_no_connect() is also recommended (avoid
488   trying to open tcp connection to xmlrpc clients that closed it).
489   Alternatively ending the XMLRPC route with return -1, exit -1 or drop
490   -1 can also be used, but note that this will not work for async rpcs
491   (it will close the connection immediately and not on the async
492   response).
493
494   Example 1.
495route[XMLRPC]{
496        # close connection only for xmlrpclib user agents
497        if search("^User-Agent:.*xmlrpclib"))
498                set_reply_close();
499        set_reply_no_connect(); # optional
500        dispatch_rpc();
501}
502
503   Another common problem is CRLF handling. According to the xml spec CR
504   ('\r') must be escaped (to &#xD;) or they will be "normalized" when
505   parsing the xml document. However some xmlrpc clients do not follow
506   this rule (e.g. clients based on the python or php xmlrpclib) and send
507   CRLF unescaped. A possible workaround is to enable automatic LFLF to
508   CRLF conversion (using the double_lf_to_crlf modules parameter) and
509   replace CRLF with LFLF in the client queries.
510
5114. Client Examples
512
513     * examples/xmlrpc_test.pl (basic perl application that builds and
514       sends an XMLRPC request from its commandline parameters).
515     * examples/xmlrpc_test.py (basic python application that builds and
516       sends an XMLRPC request from its commandline parameters).
517     * examples/xmlrpc_test2.py (basic python application that builds and
518       sends an XMLRPC request from its commandline parameters).
519     * ser_ctl (complex python application that uses the XML-RPC interface
520       implemented by the xmlrpc module).
521     * serweb (php application that can use the XML-RPC interface to call
522       ser functions).
523
524Chapter 1. Admin Guide
525
526   Table of Contents
527
528   1. Dependencies
529
530        1.1. Kamailio modules
531
532   2. Parameters
533
534        2.1. route (string)
535        2.2. autoconversion (string)
536        2.3. escape_cr (integer)
537        2.4. double_lf_to_crlf (integer)
538        2.5. mode (integer)
539        2.6. url_skip (str)
540        2.7. url_match (str)
541        2.8. event_callback (string)
542
543   3. Functions
544
545        3.1. dispatch_rpc()
546        3.2. xmlrpc_reply(code, reason)
547
5481. Dependencies
549
550   1.1. Kamailio modules
551
5521.1. Kamailio modules
553
554   The following modules must be loaded before this module:
555     * SL - Stateless request handling
556
5572. Parameters
558
559   2.1. route (string)
560   2.2. autoconversion (string)
561   2.3. escape_cr (integer)
562   2.4. double_lf_to_crlf (integer)
563   2.5. mode (integer)
564   2.6. url_skip (str)
565   2.7. url_match (str)
566   2.8. event_callback (string)
567
5682.1. route (string)
569
570   Name of the route called for XMLRPC messages.
571
572   This route will be called only for HTTP messages whose method is either
573   GET or POST. The message visible inside the route will be a HTTP
574   request converted to SIP (the uri will be fixed and a fake via will be
575   added).
576
577   The route should perform additional security checks to ensure the
578   client is authorized to execute management/RPC functions and then it
579   should call the dispatch_rpc().
580
581   Default: the main route is used.
582
583   Example 1.1. Set route parameter
584modparam("xmlrpc", "route", "route_for_xmlrpcs")
585
5862.2. autoconversion (string)
587
588   Enable or disable automatic parameter type conversion globally, for all
589   the methods parameters. If on, a type mismatch in a method parameter
590   will not cause a fault if it is possible to automatically convert it to
591   the type expected by the method.
592
593   Default: off.
594
595   It is recommended to leave this parameter to its default off value and
596   fix instead the client application (which should use the proper types)
597   or to modify the target rpc to accept any type (see the rpc scan '.'
598   modifier).
599
600   Example 1.2. Set the autoconversion parameter
601modparam("xmlrpc", "autoconversion", 1)
602
6032.3. escape_cr (integer)
604
605   Enable CR ('\r') escaping in replies. If enabled each '\r' in the
606   xmlrpc reply will be replaced with "&#xD;", according to the xml spec.
607
608   It should be turned off only if you suspect interoperability problems
609   with older clients.
610
611   Default: on.
612
613   Example 1.3. Set the escape_cr parameter
614modparam("xmlrpc", "escape_cr", 1)
615
6162.4. double_lf_to_crlf (integer)
617
618   When enabled double LFs ('\n\n') in the input xmlrpc strings will be
619   replaced with CR LF ('\r\n'). This makes LF LF behave like an escape
620   character for CR LF and is needed for compatibility with Kamailio tools
621   and to work around buggy xmlrpc clients that don't escape the CR in CR
622   LF ('\r' should be escaped to "&#xD;" otherwise according to the xml
623   spec "\r\n" will be transformed to '\n'), but need to send CR LF in the
624   strings (e.g. they use tm.t_uac_wait).
625
626   Note: when this option is turned on, there is no way to send a double
627   LF ('\n\n'), it will always be transformed in CR LF ('\r\n').
628
629   Default: off.
630
631   Example 1.4. Set the double_lf_to_crlf parameter
632modparam("xmlrpc", "double_lf_to_crlf", 1)
633
6342.5. mode (integer)
635
636   When set to 1, the xmlrpc module does not register to core the callback
637   functions for non-SIP messages. Useful when another module register a
638   callback for HTTP request, letting the admin decide when to call the
639   XMLRPC route (or functions).
640
641   Default: 0.
642
643   Example 1.5. Set the mode parameter
644modparam("xmlrpc", "mode", 1)
645
6462.6. url_skip (str)
647
648   Regular expression to match the HTTP URL. If there is a match, then the
649   xmlrpc route is not executed.
650
651   Default value is null (don't skip).
652
653   Example 1.6. Set url_skip parameter
654...
655modparam("xmlrpc", "url_skip", "^/sip")
656...
657
6582.7. url_match (str)
659
660   Regular expression to match the HTTP URL. If there is no match, then
661   xmlrpc route is not executed. This check is done after url_skip, so if
662   both url_skip and url_match would match then the xmlrpc route is not
663   executed (url_skip has higher priority).
664
665   Default value is null (match everything).
666
667   Example 1.7. Set url_match parameter
668...
669modparam("xmlrpc", "url_match", "^/RPC2")
670...
671
6722.8. event_callback (string)
673
674   The name of the function in the kemi configuration file (embedded
675   scripting language such as Lua, Python, ...) to be executed instead of
676   route blocks defined by route parameter for xmlrpc request.
677
678   This route will be called only for HTTP messages whose method is either
679   GET or POST. The message visible inside the route will be a HTTP
680   request converted to SIP (the uri will be fixed and a fake via will be
681   added).
682
683   The route should perform additional security checks to ensure the
684   client is authorized to execute management/RPC functions and then it
685   should call the dispatch_rpc().
686
687   Example 1.8. Set event_callback parameter
688...
689modparam("xmlrpc", "event_callback", "ksr_xmlrpc_event")
690...
691-- event callback function implemented in Lua
692function ksr_xmlrpc_event(evname)
693        KSR.info("===== xmlrpc triggered event: " .. evname .. "\n");
694        local rpc_method = KSR.pv.get("$rm") or ""
695        if ((rpc_method == "POST" or rpc_method == "GET")) then
696                if (KSR.xmlrpc.dispatch_rpc() < 0) then
697                        KSR.err("error while executing xmlrpc event")
698                end
699        end
700        return 1;
701end
702...
703
7043. Functions
705
706   3.1. dispatch_rpc()
707   3.2. xmlrpc_reply(code, reason)
708
7093.1.  dispatch_rpc()
710
711   This function processes an XMLRPC request, found in the body of the
712   request.
713
714   It should be used only in a route specified using the "route" module
715   parameter or if the request method is GET or POST (using it for other
716   request methods will not have adverse side-effects, but it will
717   probably not work).
718
719   dispatch_rpc() extracts the XML-RPC document from the body of the
720   request to determine the name of the RPC method to be called and then
721   it searches through the list of all the RPC functions to find a
722   function with matching name. If such a function is found then
723   dispatch_rpc() will pass control to the function to handle the request.
724
725   Example 1.9. dispatch_rpc usage
726#...
727modparam("xmlrpc", "route", "XMLRPC");
728#...
729route[XMLRPC]{
730        if search("^User-Agent:.*xmlrpclib"))
731                set_reply_close();
732        set_reply_no_connect(); # optional
733        dispatch_rpc();
734}
735
7363.2.  xmlrpc_reply(code, reason)
737
738   This function can be called from the config script to directly generate
739   an XML-RPC reply.
740
741   Example 1.10. xmlrpc_reply usage
742#...
743modparam("xmlrpc", "route", "XMLRPC");
744#...
745route[XMLRPC]{
746        # allow XMLRPC requests only on TLS and only if the client
747        # certificate is valid
748        if (proto!=TLS){
749                xmlrpc_reply("400", "xmlrpc allowed only over TLS");
750                return;
751        }
752        if (@tls.peer.verified!=""){
753                xmlrpc_reply("400", "Unauthorized");
754                return;
755        }
756        if search("^User-Agent:.*xmlrpclib"))
757                set_reply_close();
758        set_reply_no_connect(); # optional
759        dispatch_rpc();
760}
761