Debian Codegraph @

src/modules/xhttp_pi/README

raw
1 xHTTP_PI Module
2
3 Ovidiu Sas
4
5 <[email protected]>
6
7 Edited by
8
9 Ovidiu Sas
10
11 <[email protected]>
12
13 Copyright © 2012-2013 VoIP Embedded Inc.
14 __________________________________________________________________
15
16 Table of Contents
17
18 1. Admin Guide
19
20 1. Overview
21 2. Usage
22 3. Framework
23
24 3.1. Database connection definition block
25 3.2. Table definition block
26 3.3. Command definition block
27
28 4. To-do
29 5. Dependencies
30
31 5.1. Kamailio Modules
32 5.2. External Libraries or Applications
33
34 6. Parameters
35
36 6.1. xhttp_pi_root (str)
37 6.2. xhttp_pi_buf_size (int)
38 6.3. framework (string)
39
40 7. Functions
41
42 7.1. dispatch_xhttp_pi()
43
44 8. RPC Commands
45
46 8.1. xhttp_pi.reload
47
48 List of Examples
49
50 1.1. Set xhttp_pi_root parameter
51 1.2. Set xhttp_pi_buf_size parameter
52 1.3. Set framework parameter
53 1.4. dispatch_xhttp_pi usage
54
55 Chapter 1. Admin Guide
56
57 Table of Contents
58
59 1. Overview
60 2. Usage
61 3. Framework
62
63 3.1. Database connection definition block
64 3.2. Table definition block
65 3.3. Command definition block
66
67 4. To-do
68 5. Dependencies
69
70 5.1. Kamailio Modules
71 5.2. External Libraries or Applications
72
73 6. Parameters
74
75 6.1. xhttp_pi_root (str)
76 6.2. xhttp_pi_buf_size (int)
77 6.3. framework (string)
78
79 7. Functions
80
81 7.1. dispatch_xhttp_pi()
82
83 8. RPC Commands
84
85 8.1. xhttp_pi.reload
86
87 1. Overview
88
89 This module provides a web provisioning interface for Kamailio. It is
90 using the Kamailio's internal database API to provide a simple way of
91 manipulating records inside Kamailio's tables.
92
93 The module offers:
94 * ability to connect to multiple/different databases through
95 Kamailio's db API; (all Kamailio's databases are supported);
96 * ability to perform data input validation through Kamailio API;
97 * ability to reconfigure the interface layout on the fly by reloading
98 the config from the xml framework via the rpc command interface.
99
100 Note: when provisioning tables using db_text, any change made to a
101 db_text table will not be reflected on the actual text file. In order
102 to force a write out to the disk of the cached tables, the db_text rpc
103 command db_text.dump must be used.
104
105 2. Usage
106
107 The layout of the provisioning interface is controlled via an external
108 xml file (see the framework parameter). An example of a framework xml
109 file is provided inside the Kamailio's examples directory. A simple
110 framework file can be generated by the kamdbctl command:
111 kamdbctl pframework create
112
113 The generated framework will be saved inside Kamailio's config
114 directory as pi_framework_sample. The list of configurable tables will
115 be based on the STANDARD_MODULES and EXTRA_MODULES vars from kamctlrc
116 file. The sample framework file will provide the ability to inspect
117 tables. In order to add/modify/remove records to/from tables, new
118 commands must be added by the admin.
119
120 3. Framework
121
122 3.1. Database connection definition block
123 3.2. Table definition block
124 3.3. Command definition block
125
126 The xml framework file is organized in three distinctive blocks:
127 * database connection definition block
128 * table definition block
129 * command definition block
130
131 3.1. Database connection definition block
132
133 Each connection to a particular database must be defined here with a
134 unique database connection id. The connection parameters are defined
135 following the db_url param pattern for all Kamailio modules that are
136 using a database.
137
138 Supported databases:
139 * cassandra
140 * cluster
141 * flatstore
142 * mysql
143 * oracle
144 * postgres
145 * sqlite
146 * text
147 * unixodbc
148
149 3.2. Table definition block
150
151 Each table managed through the Kamailio provisioning interface must be
152 defined here with a unique table id. For each table, the database
153 connection id must be specified. Each table must list all columns that
154 will be managed by the Kamailio provisioning interface. Each column
155 must have a unique field name and a type. Each column may have a
156 validation tag for validating input data.
157
158 Supported column types:
159 * DB1_INT
160 * DB1_BIGINT
161 * DB1_DOUBLE
162 * DB1_STRING
163 * DB1_STR
164 * DB1_DATETIME
165 + Note: input field must be provided in 'YEAR-MM-DD HH:MM:SS'
166 format.
167 * DB1_BLOB
168 * DB1_BITMAP
169
170 Supported validation methods:
171 * IPV4 - represents an IPv4 address
172 * URI - represents a SIP URI
173 * URI_IPV4HOST - represents a SIP URI with an IPV4 as a host
174 * P_HOST_PORT - represents [proto:]host[:port]
175 * P_IPV4_PORT - represents [proto:]IPv4[:port]
176
177 3.3. Command definition block
178
179 Multiple provisioning commands can be grouped together. Each group can
180 have multiple commands. Each command definition in a group must have
181 the table id of the table that is operating on along with the command
182 type to be performed.
183
184 The command type can have up to three type of column parameters:
185 * clause columns
186 * query columns
187 * order by columns
188
189 Each column parameter must define the name(s) of the column(s) (must
190 match a field name in the description table identified by the table
191 id). A column can accept a list of imposed values. Each imposed value
192 will have an id that will be displayed on the web interface and the
193 actual value that will be used for db operations. Clause columns must
194 define operators. Here's the list of supported operators: '<', '>',
195 '=', '<=', '>=', '!='.
196
197 Supported database command types:
198 * DB1_QUERY - performs an SQL query and supports three type of
199 columns:
200 + clause: 0 or more columns
201 + query: 1 column
202 + order: 0 or 1 column
203 * DB1_INSERT - performs an SQL insert and supports one type of
204 column:
205 + query: 1 or more columns
206 * DB1_DELETE - performs an SQL delete and supports one type of
207 column:
208 + clause: 1 or more columns
209 * DB1_UPDATE - performs an SQL update and supports two type of
210 columns:
211 + clause: 0 or more columns
212 + query: 1 or more columns
213 * DB1_REPLACE - performs an SQL replace and supports one type of
214 column:
215 + query: 1 or more columns
216
217 Please note that some databases have a restricted set of database
218 command types.
219
220 4. To-do
221
222 Features to be added in the future:
223 * full subscriber provisioning with automatic ha1/ha1b fields.
224
225 5. Dependencies
226
227 5.1. Kamailio Modules
228 5.2. External Libraries or Applications
229
230 5.1. Kamailio Modules
231
232 The following modules must be loaded before this module:
233 * xhttp - xHTTP.
234
235 5.2. External Libraries or Applications
236
237 The following libraries or applications must be installed before
238 running Kamailio with this module loaded:
239 * libxml2
240
241 6. Parameters
242
243 6.1. xhttp_pi_root (str)
244 6.2. xhttp_pi_buf_size (int)
245 6.3. framework (string)
246
247 6.1. xhttp_pi_root (str)
248
249 It specifies the root path for provisioning http requests. The link to
250 the provisioning web interface must be constructed using the following
251 pattern: http://[server_IP]:[tcp_port]/[xhttp_pi_root]
252
253 Default value is "pi".
254
255 Example 1.1. Set xhttp_pi_root parameter
256 ...
257 modparam("xhttp_pi", "xhttp_pi_root", "pi")
258 ...
259
260 6.2. xhttp_pi_buf_size (int)
261
262 It specifies the maximum length of the buffer (in bytes) used to write
263 in the HTML reply information in order to build the HTML response.
264
265 Default value is 0 (auto set to 1/3 of the size of the configured pkg
266 mem).
267
268 Example 1.2. Set xhttp_pi_buf_size parameter
269 ...
270 modparam("xhttp_pi", "xhttp_pi_buf_size", 1024)
271 ...
272
273 6.3. framework (string)
274
275 It specifies the full path for xml framework descriptor.
276
277 There's no default value. This parameter is mandatory.
278
279 Example 1.3. Set framework parameter
280 ...
281 modparam("xhttp_pi", "framework", "/usr/local/etc/kamailio/pi_framework.xml")
282 ...
283
284 7. Functions
285
286 7.1. dispatch_xhttp_pi()
287
288 7.1. dispatch_xhttp_pi()
289
290 Handle the HTTP request and generate a response.
291
292 Example 1.4. dispatch_xhttp_pi usage
293 ...
294 tcp_accept_no_cl=yes
295 ...
296 loadmodule "sl.so"
297 loadmodule "xhttp.so"
298 loadmodule "xhttp_pi.so"
299 ...
300 modparam("xhttp_pi", "framework", "/usr/local/etc/kamailio/pi_framework.xml")
301 ...
302 event_route[xhttp:request] {
303 $var(xhttp_root) = $(hu{s.substr,0,3});
304 if ($var(xhttp_root) == "/pi")
305 dispatch_xhttp_pi();
306 else
307 xhttp_reply("200", "OK", "text/html",
308 "<html><body>Wrong URL $hu</body></html>");
309 }
310 ...
311
312 8. RPC Commands
313
314 8.1. xhttp_pi.reload
315
316 8.1. xhttp_pi.reload
317
318 Reloads the xml framework.
319
320 Name: xhttp_pi.reload
321
322 Parameters: none
323
324 RPC Command Format:
325 kamctl xhttp_pi.reload