| 1 |
SipCapture Module |
| 2 |
|
| 3 |
Alexandr Dubovikov |
| 4 |
|
| 5 |
<[email protected]> |
| 6 |
|
| 7 |
Edited by |
| 8 |
|
| 9 |
Alexandr Dubovikov |
| 10 |
|
| 11 |
<[email protected]> |
| 12 |
|
| 13 |
Copyright © 2011-15 SIPCAPTURE ORG |
| 14 |
|
| 15 |
Copyright © 2011 QSC AG |
| 16 |
|
| 17 |
Copyright © 2011 http://www.qsc.de |
| 18 |
__________________________________________________________________ |
| 19 |
|
| 20 |
Table of Contents |
| 21 |
|
| 22 |
1. Admin Guide |
| 23 |
|
| 24 |
1. Overview |
| 25 |
2. Dependencies |
| 26 |
|
| 27 |
2.1. Kamailio Modules |
| 28 |
2.2. External Libraries or Applications |
| 29 |
|
| 30 |
3. Parameters |
| 31 |
|
| 32 |
3.1. db_url (str) |
| 33 |
3.2. table_name (str) |
| 34 |
3.3. mt_mode (str) |
| 35 |
3.4. hash_source (str) |
| 36 |
3.5. db_insert_mode (integer) |
| 37 |
3.6. capture_on (integer) |
| 38 |
3.7. capture_mode (str) |
| 39 |
3.8. hep_capture_on (integer) |
| 40 |
3.9. raw_ipip_capture_on (integer) |
| 41 |
3.10. raw_moni_capture_on (integer) |
| 42 |
3.11. raw_socket_listen (string) |
| 43 |
3.12. raw_interface (string) |
| 44 |
3.13. raw_sock_children (integer) |
| 45 |
3.14. promiscuous_on (integer) |
| 46 |
3.15. raw_moni_bpf_on (integer) |
| 47 |
3.16. capture_node (str) |
| 48 |
3.17. insert_retries (integer) |
| 49 |
3.18. insert_retry_timeout (integer) |
| 50 |
3.19. callid_aleg_header (str) |
| 51 |
3.20. topoh_unmask (int) |
| 52 |
3.21. nonsip_hook (int) |
| 53 |
3.22. event_callback (str) |
| 54 |
3.23. capture_bad_msgs (int) |
| 55 |
|
| 56 |
4. Functions |
| 57 |
|
| 58 |
4.1. sip_capture([table], [cmode]) |
| 59 |
4.2. report_capture([table], [cid], [data]) |
| 60 |
4.3. float2int(fval, ival) |
| 61 |
4.4. sip_capture_forward(uri) |
| 62 |
|
| 63 |
5. Event Routes |
| 64 |
|
| 65 |
5.1. event_route[sipcapture:request] |
| 66 |
|
| 67 |
6. RPC Commands |
| 68 |
|
| 69 |
6.1. sipcapture.status param |
| 70 |
|
| 71 |
7. Database setup |
| 72 |
8. Limitations |
| 73 |
|
| 74 |
List of Examples |
| 75 |
|
| 76 |
1.1. Set db_url parameter |
| 77 |
1.2. Set sip_capture parameter |
| 78 |
1.3. Set mt_mode parameter |
| 79 |
1.4. Set mt_mode parameter |
| 80 |
1.5. db_insert_mode example |
| 81 |
1.6. Set capture_on parameter |
| 82 |
1.7. capture_mode example |
| 83 |
1.8. Set hep_capture_on parameter |
| 84 |
1.9. Set raw_ipip_capture_on parameter |
| 85 |
1.10. Set raw_moni_capture_on parameter |
| 86 |
1.11. Set raw_socket_listen parameter |
| 87 |
1.12. Set raw_interface parameter |
| 88 |
1.13. Set raw_sock_children parameter |
| 89 |
1.14. Set promiscuous_on parameter |
| 90 |
1.15. Set raw_moni_bpf_on parameter |
| 91 |
1.16. Set capture_node parameter |
| 92 |
1.17. Set insert_retries parameter |
| 93 |
1.18. Set insert_retry_timeout parameter |
| 94 |
1.19. Set callid_aleg_header parameter |
| 95 |
1.20. Set topoh_unmask parameter |
| 96 |
1.21. Set nonsip_hook parameter |
| 97 |
1.22. Set event_callback parameter |
| 98 |
1.23. Set capture_bad_msgs parameter |
| 99 |
1.24. sip_capture() usage |
| 100 |
1.25. report_capture() usage |
| 101 |
1.26. report_capture() usage |
| 102 |
1.27. sip_capture_forward() usage |
| 103 |
1.28. event_route[sipcapture:request] usage |
| 104 |
|
| 105 |
Chapter 1. Admin Guide |
| 106 |
|
| 107 |
Table of Contents |
| 108 |
|
| 109 |
1. Overview |
| 110 |
2. Dependencies |
| 111 |
|
| 112 |
2.1. Kamailio Modules |
| 113 |
2.2. External Libraries or Applications |
| 114 |
|
| 115 |
3. Parameters |
| 116 |
|
| 117 |
3.1. db_url (str) |
| 118 |
3.2. table_name (str) |
| 119 |
3.3. mt_mode (str) |
| 120 |
3.4. hash_source (str) |
| 121 |
3.5. db_insert_mode (integer) |
| 122 |
3.6. capture_on (integer) |
| 123 |
3.7. capture_mode (str) |
| 124 |
3.8. hep_capture_on (integer) |
| 125 |
3.9. raw_ipip_capture_on (integer) |
| 126 |
3.10. raw_moni_capture_on (integer) |
| 127 |
3.11. raw_socket_listen (string) |
| 128 |
3.12. raw_interface (string) |
| 129 |
3.13. raw_sock_children (integer) |
| 130 |
3.14. promiscuous_on (integer) |
| 131 |
3.15. raw_moni_bpf_on (integer) |
| 132 |
3.16. capture_node (str) |
| 133 |
3.17. insert_retries (integer) |
| 134 |
3.18. insert_retry_timeout (integer) |
| 135 |
3.19. callid_aleg_header (str) |
| 136 |
3.20. topoh_unmask (int) |
| 137 |
3.21. nonsip_hook (int) |
| 138 |
3.22. event_callback (str) |
| 139 |
3.23. capture_bad_msgs (int) |
| 140 |
|
| 141 |
4. Functions |
| 142 |
|
| 143 |
4.1. sip_capture([table], [cmode]) |
| 144 |
4.2. report_capture([table], [cid], [data]) |
| 145 |
4.3. float2int(fval, ival) |
| 146 |
4.4. sip_capture_forward(uri) |
| 147 |
|
| 148 |
5. Event Routes |
| 149 |
|
| 150 |
5.1. event_route[sipcapture:request] |
| 151 |
|
| 152 |
6. RPC Commands |
| 153 |
|
| 154 |
6.1. sipcapture.status param |
| 155 |
|
| 156 |
7. Database setup |
| 157 |
8. Limitations |
| 158 |
|
| 159 |
1. Overview |
| 160 |
|
| 161 |
The sipcapture module stores incoming/outgoing SIP messages in a |
| 162 |
database. |
| 163 |
|
| 164 |
Kamailio can capture SIP messages in three modes |
| 165 |
* IPIP encapsulation. (ETHHDR+IPHDR+IPHDR+UDPHDR). |
| 166 |
* Monitoring/mirroring port. |
| 167 |
* Homer encapsulation protocol mode (HEP v1, v2, v3). |
| 168 |
|
| 169 |
The capturing can be turned on/off using rpc commands. Example: |
| 170 |
|
| 171 |
kamctl rpc sipcapture.status on |
| 172 |
|
| 173 |
kamctl rpc sipcapture.status off |
| 174 |
|
| 175 |
2. Dependencies |
| 176 |
|
| 177 |
2.1. Kamailio Modules |
| 178 |
2.2. External Libraries or Applications |
| 179 |
|
| 180 |
2.1. Kamailio Modules |
| 181 |
|
| 182 |
The following modules must be loaded before this module: |
| 183 |
* database module - mysql, postgres, dbtext, unixodbc... |
| 184 |
|
| 185 |
2.2. External Libraries or Applications |
| 186 |
|
| 187 |
The following libraries or applications must be installed before |
| 188 |
running Kamailio with this module loaded: |
| 189 |
* None. |
| 190 |
|
| 191 |
3. Parameters |
| 192 |
|
| 193 |
3.1. db_url (str) |
| 194 |
3.2. table_name (str) |
| 195 |
3.3. mt_mode (str) |
| 196 |
3.4. hash_source (str) |
| 197 |
3.5. db_insert_mode (integer) |
| 198 |
3.6. capture_on (integer) |
| 199 |
3.7. capture_mode (str) |
| 200 |
3.8. hep_capture_on (integer) |
| 201 |
3.9. raw_ipip_capture_on (integer) |
| 202 |
3.10. raw_moni_capture_on (integer) |
| 203 |
3.11. raw_socket_listen (string) |
| 204 |
3.12. raw_interface (string) |
| 205 |
3.13. raw_sock_children (integer) |
| 206 |
3.14. promiscuous_on (integer) |
| 207 |
3.15. raw_moni_bpf_on (integer) |
| 208 |
3.16. capture_node (str) |
| 209 |
3.17. insert_retries (integer) |
| 210 |
3.18. insert_retry_timeout (integer) |
| 211 |
3.19. callid_aleg_header (str) |
| 212 |
3.20. topoh_unmask (int) |
| 213 |
3.21. nonsip_hook (int) |
| 214 |
3.22. event_callback (str) |
| 215 |
3.23. capture_bad_msgs (int) |
| 216 |
|
| 217 |
3.1. db_url (str) |
| 218 |
|
| 219 |
Database URL. |
| 220 |
|
| 221 |
Default value is “mysql://kamailio:kamailiorw@localhost/kamailio”. |
| 222 |
|
| 223 |
Example 1.1. Set db_url parameter |
| 224 |
... |
| 225 |
modparam("sipcapture", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio |
| 226 |
") |
| 227 |
... |
| 228 |
|
| 229 |
3.2. table_name (str) |
| 230 |
|
| 231 |
Name of the table's name used to store the SIP messages. Can contain |
| 232 |
multiple tables, separated by "|". |
| 233 |
|
| 234 |
Default value is "sip_capture". Only for Homer 3. For Homer 5, please |
| 235 |
use an argument for the sip_capture function. |
| 236 |
|
| 237 |
Example 1.2. Set sip_capture parameter |
| 238 |
... |
| 239 |
modparam("sipcapture", "table_name", "homer_capture") |
| 240 |
... |
| 241 |
modparam("sipcapture", "table_name", "homer_capture1|homer_capture2"); |
| 242 |
... |
| 243 |
|
| 244 |
3.3. mt_mode (str) |
| 245 |
|
| 246 |
Name of the mode used for storing data in multiple tables. Modes can be |
| 247 |
"rand" (random), "round_robin" (use a round_robin algorithm) or "hash" |
| 248 |
(use hashing to determine the table to store). These modes are only |
| 249 |
triggered if there is more than one table specified in table_name |
| 250 |
parameter, separated by "|". |
| 251 |
|
| 252 |
Default value is "rand". |
| 253 |
|
| 254 |
Example 1.3. Set mt_mode parameter |
| 255 |
... |
| 256 |
modparam("sipcapture", "mt_mode", "hash") |
| 257 |
... |
| 258 |
|
| 259 |
3.4. hash_source (str) |
| 260 |
|
| 261 |
The field of the SIP message used for hashing, when mt_mode is set to |
| 262 |
"hash". The value can be "call_id", "to_user" or "from_user". |
| 263 |
|
| 264 |
Default value is "call_id". |
| 265 |
|
| 266 |
Example 1.4. Set mt_mode parameter |
| 267 |
... |
| 268 |
modparam("sipcapture", "hash_source", "to_user") |
| 269 |
... |
| 270 |
|
| 271 |
3.5. db_insert_mode (integer) |
| 272 |
|
| 273 |
If set to 1, use INSERT DELAYED to store sip message into capture table |
| 274 |
when the DB driver has support for it. If no INSERT DELAYED support is |
| 275 |
offered by DB driver, then standard INSERT is used. |
| 276 |
|
| 277 |
If set to 2, use ASYNC INSERT to store sip message into capture table |
| 278 |
when the DB driver has support for it. If no ASYNC INSERT support is |
| 279 |
offered by DB driver, then standard INSERT is used. |
| 280 |
|
| 281 |
Default value is 0 (no INSERT DELAYED). |
| 282 |
|
| 283 |
Example 1.5. db_insert_mode example |
| 284 |
modparam("sipcapture", "db_insert_mode", 1) |
| 285 |
|
| 286 |
3.6. capture_on (integer) |
| 287 |
|
| 288 |
Parameter to enable/disable capture globally (on(1)/off(0)) |
| 289 |
|
| 290 |
Default value is "0". |
| 291 |
|
| 292 |
Example 1.6. Set capture_on parameter |
| 293 |
... |
| 294 |
modparam("sipcapture", "capture_on", 1) |
| 295 |
... |
| 296 |
|
| 297 |
3.7. capture_mode (str) |
| 298 |
|
| 299 |
This parameter can be used for defining a capture mode which can be |
| 300 |
used in the sip_capture calls as a parameter. A capture mode has a name |
| 301 |
and some parameters. It must be defined in the format: |
| 302 |
name=>param1=val1;param2=val2;... The parameters are db_url, |
| 303 |
table_name, mt_mode and hash_source (optional). Multiple capture modes |
| 304 |
can be defined by using this parameter multiple times. After this, the |
| 305 |
capture modes can be used like: sip_capture ("", "CAPTURE_MODE"); |
| 306 |
|
| 307 |
Example 1.7. capture_mode example |
| 308 |
modparam("sipcapture", "capture_mode", "mode1=>db_url=mysql://user:passwd@host/d |
| 309 |
bname1;table_name=homer_capture1|homer_capture2;mt_mode=hash;hash_source=call_id |
| 310 |
;") |
| 311 |
modparam("sipcapture", "capture_mode", "mode2=>db_url=mysql://user:passwd@host/d |
| 312 |
bname2;table_name=homer_capture3|homer_capture4;mt_mode=rand;") |
| 313 |
|
| 314 |
3.8. hep_capture_on (integer) |
| 315 |
|
| 316 |
Parameter to enable/disable capture of HEP (on(1)/off(0)) |
| 317 |
|
| 318 |
Default value is "0". |
| 319 |
|
| 320 |
Example 1.8. Set hep_capture_on parameter |
| 321 |
... |
| 322 |
modparam("sipcapture", "hep_capture_on", 1) |
| 323 |
... |
| 324 |
|
| 325 |
3.9. raw_ipip_capture_on (integer) |
| 326 |
|
| 327 |
Parameter to enable/disable IPIP capturing (on(1)/off(0)) |
| 328 |
|
| 329 |
Default value is "0". |
| 330 |
|
| 331 |
Example 1.9. Set raw_ipip_capture_on parameter |
| 332 |
... |
| 333 |
modparam("sipcapture", "raw_ipip_capture_on", 1) |
| 334 |
... |
| 335 |
|
| 336 |
3.10. raw_moni_capture_on (integer) |
| 337 |
|
| 338 |
Parameter to enable/disable monitoring/mirroring port capturing |
| 339 |
(on(1)/off(0)) Only one mode on raw socket can be enabled! Monitoring |
| 340 |
port capturing currently supported only on Linux. |
| 341 |
|
| 342 |
Default value is "0". |
| 343 |
|
| 344 |
Example 1.10. Set raw_moni_capture_on parameter |
| 345 |
... |
| 346 |
modparam("sipcapture", "raw_moni_capture_on", 1) |
| 347 |
... |
| 348 |
|
| 349 |
3.11. raw_socket_listen (string) |
| 350 |
|
| 351 |
Parameter indicate a listen IP address of RAW socket for IPIP |
| 352 |
capturing. You can also define a port/portrange for IPIP/Mirroring |
| 353 |
mode, to capture SIP messages in specific ports: |
| 354 |
|
| 355 |
"10.0.0.1:5060" - the source/destination port of the SIP message must |
| 356 |
be equal 5060 |
| 357 |
|
| 358 |
"10.0.0.1:5060-5090" - the source/destination port of the SIP message |
| 359 |
must be equal or be between 5060 and 5090. |
| 360 |
|
| 361 |
The port/portrange must be defined if you are planning to use mirroring |
| 362 |
capture! In this case, the part with IP address will be ignored, but to |
| 363 |
make parser happy, use i.e. 10.0.0.0 |
| 364 |
|
| 365 |
Default value is "". |
| 366 |
|
| 367 |
Example 1.11. Set raw_socket_listen parameter |
| 368 |
... |
| 369 |
modparam("sipcapture", "raw_socket_listen", "10.0.0.1:5060-5090") |
| 370 |
... |
| 371 |
modparam("sipcapture", "raw_socket_listen", "10.0.0.1:5060") |
| 372 |
... |
| 373 |
|
| 374 |
3.12. raw_interface (string) |
| 375 |
|
| 376 |
Name of the interface to bind on the raw socket. |
| 377 |
|
| 378 |
Default value is "". |
| 379 |
|
| 380 |
Example 1.12. Set raw_interface parameter |
| 381 |
... |
| 382 |
modparam("sipcapture", "raw_interface", "eth0") |
| 383 |
... |
| 384 |
|
| 385 |
3.13. raw_sock_children (integer) |
| 386 |
|
| 387 |
Parameter define how many children that must be created to listen the |
| 388 |
raw socket. |
| 389 |
|
| 390 |
Default value is "1". |
| 391 |
|
| 392 |
Example 1.13. Set raw_sock_children parameter |
| 393 |
... |
| 394 |
modparam("sipcapture", "raw_sock_children", 6) |
| 395 |
... |
| 396 |
|
| 397 |
3.14. promiscuous_on (integer) |
| 398 |
|
| 399 |
Parameter to enable/disable promiscuous mode on the raw socket. Linux |
| 400 |
only. |
| 401 |
|
| 402 |
Default value is "0". |
| 403 |
|
| 404 |
Example 1.14. Set promiscuous_on parameter |
| 405 |
... |
| 406 |
modparam("sipcapture", "promiscuous_on", 1) |
| 407 |
... |
| 408 |
|
| 409 |
3.15. raw_moni_bpf_on (integer) |
| 410 |
|
| 411 |
Activate Linux Socket Filter (LSF based on BPF) on the mirroring |
| 412 |
interface. The structure is defined in linux/filter.h. The default LSF |
| 413 |
accept a port/portrange from the raw_socket_listen param. Currently LSF |
| 414 |
supported only on Linux. |
| 415 |
|
| 416 |
Default value is "0". |
| 417 |
|
| 418 |
Example 1.15. Set raw_moni_bpf_on parameter |
| 419 |
... |
| 420 |
modparam("sipcapture", "raw_moni_bpf_on", 1) |
| 421 |
... |
| 422 |
|
| 423 |
3.16. capture_node (str) |
| 424 |
|
| 425 |
Name of the capture node. |
| 426 |
|
| 427 |
Default value is "homer01". |
| 428 |
|
| 429 |
Example 1.16. Set capture_node parameter |
| 430 |
... |
| 431 |
modparam("sipcapture", "capture_node", "homer03") |
| 432 |
... |
| 433 |
|
| 434 |
3.17. insert_retries (integer) |
| 435 |
|
| 436 |
The number of times Kamailio should retry to write to the Homer |
| 437 |
database in case the first attempt failed. The retry is also limited |
| 438 |
timewise by the insert_retry_timeout parameter. Values allowed range |
| 439 |
from 0 to 500. |
| 440 |
|
| 441 |
Default value is 0 (no retries). |
| 442 |
|
| 443 |
Example 1.17. Set insert_retries parameter |
| 444 |
... |
| 445 |
modparam("sipcapture", "insert_retries", 5) |
| 446 |
... |
| 447 |
|
| 448 |
3.18. insert_retry_timeout (integer) |
| 449 |
|
| 450 |
The time limit in seconds Kamailio retries to write to the Homer |
| 451 |
database in case the first attempt failed. This parameter is only used |
| 452 |
together with the insert_retries parameter. Values allowed range from 0 |
| 453 |
to 300. |
| 454 |
|
| 455 |
Default value is 60 seconds. |
| 456 |
|
| 457 |
Example 1.18. Set insert_retry_timeout parameter |
| 458 |
... |
| 459 |
modparam("sipcapture", "insert_retry_timeout", 10) |
| 460 |
... |
| 461 |
|
| 462 |
3.19. callid_aleg_header (str) |
| 463 |
|
| 464 |
Header name used to correlate A-leg with B-leg. It can take a list of |
| 465 |
headers, separated by semicolon, e.g. "X-CID0;X-CID1". First match |
| 466 |
wins. |
| 467 |
|
| 468 |
Default value is "X-CID". |
| 469 |
|
| 470 |
Example 1.19. Set callid_aleg_header parameter |
| 471 |
... |
| 472 |
modparam("sipcapture", "callid_aleg_header", "X-CallIDALeg") |
| 473 |
... |
| 474 |
|
| 475 |
3.20. topoh_unmask (int) |
| 476 |
|
| 477 |
If set to 1, call-id will be unmasked using topoh module api (topoh |
| 478 |
module must be loaded in this case). |
| 479 |
|
| 480 |
Default value is 0. |
| 481 |
|
| 482 |
Example 1.20. Set topoh_unmask parameter |
| 483 |
... |
| 484 |
modparam("sipcapture", "topoh_unmask", 1) |
| 485 |
... |
| 486 |
|
| 487 |
3.21. nonsip_hook (int) |
| 488 |
|
| 489 |
If set to 1, event route sipcapture:siprequest is run when HEP message |
| 490 |
is received. |
| 491 |
|
| 492 |
Default value is 0. |
| 493 |
|
| 494 |
Example 1.21. Set nonsip_hook parameter |
| 495 |
... |
| 496 |
modparam("sipcapture", "nonsip_hook", 1) |
| 497 |
... |
| 498 |
|
| 499 |
3.22. event_callback (str) |
| 500 |
|
| 501 |
The name of the function in the kemi configuration file (embedded |
| 502 |
scripting language such as Lua, Python, ...) to be executed instead of |
| 503 |
event_route[...] blocks. |
| 504 |
|
| 505 |
The function receives a string parameter with the name of the event, |
| 506 |
the values can be: 'sipcapture:request'. |
| 507 |
|
| 508 |
Default value is 'empty' (no function is executed for events). |
| 509 |
|
| 510 |
Example 1.22. Set event_callback parameter |
| 511 |
... |
| 512 |
modparam("sipcapture", "event_callback", "ksr_sipcapture_event") |
| 513 |
... |
| 514 |
-- event callback function implemented in Lua |
| 515 |
function ksr_sipcapture_event(evname) |
| 516 |
KSR.info("===== sipcapture module triggered event: " .. evname .. "\n"); |
| 517 |
return 1; |
| 518 |
end |
| 519 |
... |
| 520 |
|
| 521 |
3.23. capture_bad_msgs (int) |
| 522 |
|
| 523 |
If set to something different than 0, tries to capture also the broken |
| 524 |
SIP messages. |
| 525 |
|
| 526 |
Default value is 0. |
| 527 |
|
| 528 |
Example 1.23. Set capture_bad_msgs parameter |
| 529 |
... |
| 530 |
modparam("sipcapture", "capture_bad_msgs", 1) |
| 531 |
... |
| 532 |
|
| 533 |
4. Functions |
| 534 |
|
| 535 |
4.1. sip_capture([table], [cmode]) |
| 536 |
4.2. report_capture([table], [cid], [data]) |
| 537 |
4.3. float2int(fval, ival) |
| 538 |
4.4. sip_capture_forward(uri) |
| 539 |
|
| 540 |
4.1. sip_capture([table], [cmode]) |
| 541 |
|
| 542 |
Store the current processed HEP/IPIP SIP message in a database. It is |
| 543 |
stored in the form prior applying changes made to it. |
| 544 |
|
| 545 |
Meaning of the parameters is as follows: |
| 546 |
* table - The table where HEP SIP message will be stored. Homer 5 use |
| 547 |
now tables with datestamp. To generate an automatic table's name |
| 548 |
please use strftime parameters. I.e. $var(table) = |
| 549 |
"sip_capture_call_%Y%m%d" and set the variable as an argument of |
| 550 |
the sip_capture function. |
| 551 |
* cmode - The reference to the capture_mode parameter. |
| 552 |
|
| 553 |
This function can be used from ANY_ROUTE. |
| 554 |
Default value is "NULL". |
| 555 |
|
| 556 |
Example 1.24. sip_capture() usage |
| 557 |
... |
| 558 |
sip_capture(); |
| 559 |
... |
| 560 |
sip_capture("sip_capture_call_20160124"); |
| 561 |
... |
| 562 |
sip_capture("", "cmode"); |
| 563 |
... |
| 564 |
|
| 565 |
4.2. report_capture([table], [cid], [data]) |
| 566 |
|
| 567 |
Store the current processed HEP REPORT message in a database. |
| 568 |
|
| 569 |
Meaning of the parameters is as follows: |
| 570 |
* table - The table where REPORT message will be stored. |
| 571 |
* cid - The correlation id. |
| 572 |
* data - The custom report data in JSON format. |
| 573 |
|
| 574 |
This function can be used from ANY_ROUTE. |
| 575 |
Default value is "NULL". |
| 576 |
|
| 577 |
Example 1.25. report_capture() usage |
| 578 |
... |
| 579 |
report_capture(); |
| 580 |
... |
| 581 |
report_capture("report_data", "$ci"); |
| 582 |
... |
| 583 |
report_capture("report_data", "$ci", "{\"MOS\":4.1,\"PACKET_LOST\":100"}); |
| 584 |
... |
| 585 |
|
| 586 |
4.3. float2int(fval, ival) |
| 587 |
|
| 588 |
Return the value of atof(fval) * atoi(ival). On case the result is 0, |
| 589 |
then -1 is returned. |
| 590 |
|
| 591 |
This function can be used from ANY_ROUTE. |
| 592 |
|
| 593 |
Example 1.26. report_capture() usage |
| 594 |
... |
| 595 |
$var(res) = float2int("10.5", "1"); |
| 596 |
... |
| 597 |
|
| 598 |
4.4. sip_capture_forward(uri) |
| 599 |
|
| 600 |
Forward the HEP packet to an address specified by the parameter uri (it |
| 601 |
has to be a sip uri format). The function should be used inside |
| 602 |
event_route[sipcapture:request]. After using this function, add a |
| 603 |
return 0 in order to stop processing further the packet in the local |
| 604 |
Kamailio instance. |
| 605 |
|
| 606 |
This function can be used from ANY_ROUTE. |
| 607 |
|
| 608 |
Example 1.27. sip_capture_forward() usage |
| 609 |
... |
| 610 |
event_route[sipcapture:request] { |
| 611 |
... |
| 612 |
if(src_ip==1.2.3.4) { |
| 613 |
sip_capture_forward("sip:2.3.4.5:5090"); |
| 614 |
return 0; |
| 615 |
} |
| 616 |
... |
| 617 |
} |
| 618 |
... |
| 619 |
|
| 620 |
5. Event Routes |
| 621 |
|
| 622 |
5.1. event_route[sipcapture:request] |
| 623 |
|
| 624 |
5.1. event_route[sipcapture:request] |
| 625 |
|
| 626 |
Event route block to be executed when HEP packet is received. It |
| 627 |
requires module parameter 'nonsip_hook' to be set to 1. |
| 628 |
|
| 629 |
Example 1.28. event_route[sipcapture:request] usage |
| 630 |
... |
| 631 |
# new event sipcapture socket |
| 632 |
modparam("sipcapture", "nonsip_hook", 1) |
| 633 |
... |
| 634 |
|
| 635 |
event_route[sipcapture:request] { |
| 636 |
|
| 637 |
xlog("HEP Request!\n"); |
| 638 |
xlog("received sipcapture request from $si:$sp\n"); |
| 639 |
xlog("HEP VERSION $hep(version) request from $si:$sp\n"); |
| 640 |
xlog("HEP CHUNK Source IP $hep(0x002) request from $si:$sp\n"); |
| 641 |
|
| 642 |
# is it SIP ? |
| 643 |
if($hep(0x00b) == 1) { |
| 644 |
|
| 645 |
# do parsing internal |
| 646 |
return 1; |
| 647 |
} else { |
| 648 |
# if report lets proceed here with payload |
| 649 |
xlog("HEP CHUNK PAYLOAD $hep(0x00f) request from $si:$sp\n"); |
| 650 |
return 0; |
| 651 |
} |
| 652 |
} |
| 653 |
... |
| 654 |
|
| 655 |
6. RPC Commands |
| 656 |
|
| 657 |
6.1. sipcapture.status param |
| 658 |
|
| 659 |
6.1. sipcapture.status param |
| 660 |
|
| 661 |
Name: sipcapture.status |
| 662 |
|
| 663 |
Parameters: |
| 664 |
* on or off: turns on/off SIP message capturing. Possible values are: |
| 665 |
+ on |
| 666 |
+ off |
| 667 |
* “check” does not change sipcapture status, just reports the current |
| 668 |
status. |
| 669 |
|
| 670 |
RPC Command Format: |
| 671 |
... |
| 672 |
kamctl rpc sipcapture.status on |
| 673 |
kamctl rpc sipcapture.status off |
| 674 |
kamctl rpc sipcapture.status check |
| 675 |
... |
| 676 |
|
| 677 |
7. Database setup |
| 678 |
|
| 679 |
Before running Kamailio with the sipcapture module, you have to set up |
| 680 |
the database tables where the module will store the data. For that, if |
| 681 |
the table were not created by the installation script or you choose to |
| 682 |
install everything by yourself you can use the homer_databases.sql, SQL |
| 683 |
script in the sql folder of sipcapture module as template. You can also |
| 684 |
find the complete database documentation on the project webpage, |
| 685 |
https://www.kamailio.org/docs/db-tables/kamailio-db-devel.html. |
| 686 |
|
| 687 |
8. Limitations |
| 688 |
|
| 689 |
* 1. Only one capturing mode on RAW socket is supported: IPIP or |
| 690 |
monitoring/mirroring port. Don't activate both at the same time. |
| 691 |
Obsolete. Please use HEP mirroring now. |
| 692 |
* 2. Mirroring port capturing works only on Linux. |