| 1 |
xHTTP_RPC Module |
| 2 |
|
| 3 |
Ovidiu Sas |
| 4 |
|
| 5 |
<[email protected]> |
| 6 |
|
| 7 |
Edited by |
| 8 |
|
| 9 |
Ovidiu Sas |
| 10 |
|
| 11 |
<[email protected]> |
| 12 |
|
| 13 |
Alex Balashov |
| 14 |
|
| 15 |
<[email protected]> |
| 16 |
|
| 17 |
Copyright © 2011 VoIPEmbedded Inc. |
| 18 |
__________________________________________________________________ |
| 19 |
|
| 20 |
Table of Contents |
| 21 |
|
| 22 |
1. Admin Guide |
| 23 |
|
| 24 |
1. Overview |
| 25 |
2. Limitations |
| 26 |
3. Dependencies |
| 27 |
|
| 28 |
3.1. Kamailio Modules |
| 29 |
3.2. External Libraries or Applications |
| 30 |
|
| 31 |
4. Parameters |
| 32 |
|
| 33 |
4.1. xhttp_rpc_root (str) |
| 34 |
4.2. xhttp_rpc_buf_size (str) |
| 35 |
|
| 36 |
5. Functions |
| 37 |
|
| 38 |
5.1. dispatch_xhttp_rpc() |
| 39 |
|
| 40 |
6. Usage |
| 41 |
|
| 42 |
List of Examples |
| 43 |
|
| 44 |
1.1. Set xhttp_rpc_root parameter |
| 45 |
1.2. Set xhttp_rpc_buf_size parameter |
| 46 |
1.3. dispatch_xhttp_rpc usage |
| 47 |
|
| 48 |
Chapter 1. Admin Guide |
| 49 |
|
| 50 |
Table of Contents |
| 51 |
|
| 52 |
1. Overview |
| 53 |
2. Limitations |
| 54 |
3. Dependencies |
| 55 |
|
| 56 |
3.1. Kamailio Modules |
| 57 |
3.2. External Libraries or Applications |
| 58 |
|
| 59 |
4. Parameters |
| 60 |
|
| 61 |
4.1. xhttp_rpc_root (str) |
| 62 |
4.2. xhttp_rpc_buf_size (str) |
| 63 |
|
| 64 |
5. Functions |
| 65 |
|
| 66 |
5.1. dispatch_xhttp_rpc() |
| 67 |
|
| 68 |
6. Usage |
| 69 |
|
| 70 |
1. Overview |
| 71 |
|
| 72 |
This module provides an HTTP transport layer implementation for the RPC |
| 73 |
management interface in a human-readable format. |
| 74 |
|
| 75 |
The xHTTP_RPC module uses the xHTTP module to handle HTTP requests. |
| 76 |
Read the documentation of the xHTTP module for more details. |
| 77 |
|
| 78 |
2. Limitations |
| 79 |
|
| 80 |
* This module does not implement asynchronous RPC commands. It is |
| 81 |
unlikely that asynchronous RPC commands will be executed from an |
| 82 |
RPC web interface. |
| 83 |
* This module does not accept parameters embedded in a structure (see |
| 84 |
RPC documentation for more info about how parameters can be passed |
| 85 |
to RPC). |
| 86 |
* At startup, all RPC commands are sorted and grouped based on their |
| 87 |
format. The expected format is [group].[subcommand]. The initial |
| 88 |
xhttp_rpc webpage displays all the retrieved groups. All RPC |
| 89 |
commands are available as sub-menus of each [group]. If an RPC |
| 90 |
command is not in the expected format, it will be dropped from the |
| 91 |
initial xhttp_rpc home page menu. |
| 92 |
|
| 93 |
3. Dependencies |
| 94 |
|
| 95 |
3.1. Kamailio Modules |
| 96 |
3.2. External Libraries or Applications |
| 97 |
|
| 98 |
3.1. Kamailio Modules |
| 99 |
|
| 100 |
The following modules must be loaded before this module: |
| 101 |
* xhttp - xHTTP. |
| 102 |
|
| 103 |
3.2. External Libraries or Applications |
| 104 |
|
| 105 |
The following libraries or applications must be installed before |
| 106 |
running Kamailio with this module loaded: |
| 107 |
* None |
| 108 |
|
| 109 |
4. Parameters |
| 110 |
|
| 111 |
4.1. xhttp_rpc_root (str) |
| 112 |
4.2. xhttp_rpc_buf_size (str) |
| 113 |
|
| 114 |
4.1. xhttp_rpc_root (str) |
| 115 |
|
| 116 |
Specifies the root path for RPC http requests. The link to the RPC web |
| 117 |
interface must be constructed using the following pattern: |
| 118 |
http://[server_IP]:[tcp_port]/[xhttp_rpc_root] |
| 119 |
|
| 120 |
Default value is "rpc". |
| 121 |
|
| 122 |
Example 1.1. Set xhttp_rpc_root parameter |
| 123 |
... |
| 124 |
modparam("xhttp_rpc", "xhttp_rpc_root", "http_rpc") |
| 125 |
... |
| 126 |
|
| 127 |
4.2. xhttp_rpc_buf_size (str) |
| 128 |
|
| 129 |
Specifies the maximum length of the buffer (in bytes) used to write the |
| 130 |
RPC reply information in order to build the HTML response. |
| 131 |
|
| 132 |
Default value is 0 (auto set to 1/3 of the size of the configured pkg |
| 133 |
mem). |
| 134 |
|
| 135 |
Example 1.2. Set xhttp_rpc_buf_size parameter |
| 136 |
... |
| 137 |
modparam("xhttp_rpc", "xhttp_rpc_buf_size", 1024) |
| 138 |
... |
| 139 |
|
| 140 |
5. Functions |
| 141 |
|
| 142 |
5.1. dispatch_xhttp_rpc() |
| 143 |
|
| 144 |
5.1. dispatch_xhttp_rpc() |
| 145 |
|
| 146 |
Handle the HTTP request and generate a response. |
| 147 |
|
| 148 |
Example 1.3. dispatch_xhttp_rpc usage |
| 149 |
... |
| 150 |
tcp_accept_no_cl=yes |
| 151 |
... |
| 152 |
loadmodule "sl.so" |
| 153 |
loadmodule "xhttp.so" |
| 154 |
loadmodule "xhttp_rpc.so" |
| 155 |
... |
| 156 |
modparam("xhttp_rpc", "xhttp_rpc_root", "http_rpc") |
| 157 |
... |
| 158 |
event_route[xhttp:request] { |
| 159 |
$var(xhttp_rpc_root) = $(hu{s.substr,0,9}); |
| 160 |
if ($var(xhttp_rpc_root) == "/http_rpc") |
| 161 |
dispatch_xhttp_rpc(); |
| 162 |
else |
| 163 |
xhttp_reply("200", "OK", "text/html", |
| 164 |
"<html><body>Wrong URL $hu</body></html>"); |
| 165 |
} |
| 166 |
... |
| 167 |
|
| 168 |
6. Usage |
| 169 |
|
| 170 |
The module is not intended to be used in a "scripted" mode with command |
| 171 |
line tools. It only provides a simple web interface with all the |
| 172 |
available RPC commands. Point a web browser to |
| 173 |
http://serverip:port/http_rpc and browse through the available rpc |
| 174 |
commands. |
| 175 |
|
| 176 |
If you don't configure a dedicated port for HTTP, then you have to use |
| 177 |
same port as for SIP TCP. If you load and configure TLS module, then |
| 178 |
you can browse using HTTPS to the SIP TLS port. |