| 1 |
TOPOS Module |
| 2 |
|
| 3 |
Daniel-Constantin Mierla |
| 4 |
|
| 5 |
<[email protected]> |
| 6 |
|
| 7 |
Edited by |
| 8 |
|
| 9 |
Daniel-Constantin Mierla |
| 10 |
|
| 11 |
<[email protected]> |
| 12 |
|
| 13 |
Frederic Gaisnon |
| 14 |
|
| 15 |
<[email protected]> |
| 16 |
|
| 17 |
Copyright © 2016 FhG FOKUS |
| 18 |
|
| 19 |
Copyright © 2021 MomentTech |
| 20 |
__________________________________________________________________ |
| 21 |
|
| 22 |
Table of Contents |
| 23 |
|
| 24 |
1. Admin Guide |
| 25 |
|
| 26 |
1. Overview |
| 27 |
2. Dependencies |
| 28 |
|
| 29 |
2.1. Kamailio Modules |
| 30 |
2.2. External Libraries or Applications |
| 31 |
|
| 32 |
3. Parameters |
| 33 |
|
| 34 |
3.1. storage (str) |
| 35 |
3.2. db_url (str) |
| 36 |
3.3. mask_callid (int) |
| 37 |
3.4. sanity_checks (int) |
| 38 |
3.5. branch_expire (int) |
| 39 |
3.6. dialog_expire (int) |
| 40 |
3.7. clean_interval (int) |
| 41 |
3.8. event_callback (str) |
| 42 |
3.9. event_mode (int) |
| 43 |
3.10. contact_host (str) |
| 44 |
3.11. contact_mode (int) |
| 45 |
3.12. cparam_name (int) |
| 46 |
3.13. xavu_cfg (str) |
| 47 |
3.14. xavu_field_a_contact (str) |
| 48 |
3.15. xavu_field_b_contact (str) |
| 49 |
3.16. xavu_field_contact_host (str) |
| 50 |
3.17. rr_update (int) |
| 51 |
3.18. context (str) |
| 52 |
3.19. methods_nocontact (str) |
| 53 |
3.20. header_mode (int) |
| 54 |
3.21. methods_noinitial (str) |
| 55 |
3.22. version_table (integer) |
| 56 |
3.23. methods_update_time (str) |
| 57 |
|
| 58 |
4. Functions |
| 59 |
|
| 60 |
4.1. tps_set_context(ctx) |
| 61 |
|
| 62 |
5. Event Routes |
| 63 |
|
| 64 |
5.1. event_route[topos:msg-outgoing] |
| 65 |
5.2. event_route[topos:msg-sending] |
| 66 |
5.3. event_route[topos:msg-incoming] |
| 67 |
5.4. event_route[topos:msg-receiving] |
| 68 |
|
| 69 |
List of Examples |
| 70 |
|
| 71 |
1.1. Set storage parameter |
| 72 |
1.2. Set db_url parameter |
| 73 |
1.3. Set mask_callid parameter |
| 74 |
1.4. Set sanity_checks parameter |
| 75 |
1.5. Set branch_expire parameter |
| 76 |
1.6. Set dialog_expire parameter |
| 77 |
1.7. Set clean_interval parameter |
| 78 |
1.8. Set event_callback parameter |
| 79 |
1.9. Set event_mode parameter |
| 80 |
1.10. Set contact_host parameter |
| 81 |
1.11. Set contact_mode parameter |
| 82 |
1.12. Set cparam_name parameter |
| 83 |
1.13. Set xavu_cfg parameter |
| 84 |
1.14. Set xavu_field_a_contact parameter |
| 85 |
1.15. Set xavu_field_b_contact parameter |
| 86 |
1.16. Set xavu_field_contact_host parameter |
| 87 |
1.17. Set rr_update parameter |
| 88 |
1.18. Set context parameter |
| 89 |
1.19. Set methods_nocontact parameter |
| 90 |
1.20. Set header_mode parameter |
| 91 |
1.21. Set methods_noinitial parameter |
| 92 |
1.22. version_table parameter usage |
| 93 |
1.23. Set methods_update_time parameter |
| 94 |
1.24. tps_set_context usage |
| 95 |
1.25. Usage of event_route[topos:msg-outgoing] |
| 96 |
1.26. Usage of event_route[topos:msg-sending] |
| 97 |
1.27. Usage of event_route[topos:msg-incoming] |
| 98 |
1.28. Usage of event_route[topos:msg-receiving] |
| 99 |
|
| 100 |
Chapter 1. Admin Guide |
| 101 |
|
| 102 |
Table of Contents |
| 103 |
|
| 104 |
1. Overview |
| 105 |
2. Dependencies |
| 106 |
|
| 107 |
2.1. Kamailio Modules |
| 108 |
2.2. External Libraries or Applications |
| 109 |
|
| 110 |
3. Parameters |
| 111 |
|
| 112 |
3.1. storage (str) |
| 113 |
3.2. db_url (str) |
| 114 |
3.3. mask_callid (int) |
| 115 |
3.4. sanity_checks (int) |
| 116 |
3.5. branch_expire (int) |
| 117 |
3.6. dialog_expire (int) |
| 118 |
3.7. clean_interval (int) |
| 119 |
3.8. event_callback (str) |
| 120 |
3.9. event_mode (int) |
| 121 |
3.10. contact_host (str) |
| 122 |
3.11. contact_mode (int) |
| 123 |
3.12. cparam_name (int) |
| 124 |
3.13. xavu_cfg (str) |
| 125 |
3.14. xavu_field_a_contact (str) |
| 126 |
3.15. xavu_field_b_contact (str) |
| 127 |
3.16. xavu_field_contact_host (str) |
| 128 |
3.17. rr_update (int) |
| 129 |
3.18. context (str) |
| 130 |
3.19. methods_nocontact (str) |
| 131 |
3.20. header_mode (int) |
| 132 |
3.21. methods_noinitial (str) |
| 133 |
3.22. version_table (integer) |
| 134 |
3.23. methods_update_time (str) |
| 135 |
|
| 136 |
4. Functions |
| 137 |
|
| 138 |
4.1. tps_set_context(ctx) |
| 139 |
|
| 140 |
5. Event Routes |
| 141 |
|
| 142 |
5.1. event_route[topos:msg-outgoing] |
| 143 |
5.2. event_route[topos:msg-sending] |
| 144 |
5.3. event_route[topos:msg-incoming] |
| 145 |
5.4. event_route[topos:msg-receiving] |
| 146 |
|
| 147 |
1. Overview |
| 148 |
|
| 149 |
This module offers topology hiding for INVITE-based dialogs, by |
| 150 |
stripping the SIP routing headers that show topology details . The |
| 151 |
script interpreter gets the SIP messages with full content, so all |
| 152 |
existing functionality is preserved. |
| 153 |
|
| 154 |
The module is transparent for the configuration writer. It only needs |
| 155 |
to be loaded (tune the module parameters if needed). |
| 156 |
|
| 157 |
It also works for SIP MESSAGE or other requests that do not create a |
| 158 |
dialog (e.g., OPTIONS) -- record_route() must be used for them as well, |
| 159 |
the headers are not going to be in the messages sent to the network, |
| 160 |
they are needed to know local addresses used to communicate with each |
| 161 |
side. This module is designed to work for presence (SUBSCRIBE-based) |
| 162 |
dialogs too. |
| 163 |
|
| 164 |
The REGISTER and PUBLISH requests are skipped from processing by this |
| 165 |
module, expected to be terminated on a local SIP server. |
| 166 |
|
| 167 |
2. Dependencies |
| 168 |
|
| 169 |
2.1. Kamailio Modules |
| 170 |
2.2. External Libraries or Applications |
| 171 |
|
| 172 |
2.1. Kamailio Modules |
| 173 |
|
| 174 |
The following modules must be loaded before this module: |
| 175 |
* rr module - server must perform record routing to ensure in-dialog |
| 176 |
requests are encoded/decoded (it must be done for all initial |
| 177 |
requests). |
| 178 |
* database module - to store the data for topology stripping and |
| 179 |
restoring. |
| 180 |
* topoh module - in case of Call-ID mask for Call-ID masking. |
| 181 |
|
| 182 |
2.2. External Libraries or Applications |
| 183 |
|
| 184 |
The following libraries or applications must be installed before |
| 185 |
running Kamailio with this module loaded: |
| 186 |
* none. |
| 187 |
|
| 188 |
3. Parameters |
| 189 |
|
| 190 |
3.1. storage (str) |
| 191 |
3.2. db_url (str) |
| 192 |
3.3. mask_callid (int) |
| 193 |
3.4. sanity_checks (int) |
| 194 |
3.5. branch_expire (int) |
| 195 |
3.6. dialog_expire (int) |
| 196 |
3.7. clean_interval (int) |
| 197 |
3.8. event_callback (str) |
| 198 |
3.9. event_mode (int) |
| 199 |
3.10. contact_host (str) |
| 200 |
3.11. contact_mode (int) |
| 201 |
3.12. cparam_name (int) |
| 202 |
3.13. xavu_cfg (str) |
| 203 |
3.14. xavu_field_a_contact (str) |
| 204 |
3.15. xavu_field_b_contact (str) |
| 205 |
3.16. xavu_field_contact_host (str) |
| 206 |
3.17. rr_update (int) |
| 207 |
3.18. context (str) |
| 208 |
3.19. methods_nocontact (str) |
| 209 |
3.20. header_mode (int) |
| 210 |
3.21. methods_noinitial (str) |
| 211 |
3.22. version_table (integer) |
| 212 |
3.23. methods_update_time (str) |
| 213 |
|
| 214 |
3.1. storage (str) |
| 215 |
|
| 216 |
Type of storage, valid types are: |
| 217 |
* db - Database Backend |
| 218 |
* redis - Redis Backend |
| 219 |
* htable - htable module Backend |
| 220 |
|
| 221 |
Default value is “db”. |
| 222 |
|
| 223 |
Example 1.1. Set storage parameter |
| 224 |
... |
| 225 |
modparam("topos", "storage", "redis") |
| 226 |
... |
| 227 |
|
| 228 |
3.2. db_url (str) |
| 229 |
|
| 230 |
Database URL. |
| 231 |
|
| 232 |
Default value is “mysql://kamailio:kamailiorw@localhost/kamailio”. |
| 233 |
|
| 234 |
Example 1.2. Set db_url parameter |
| 235 |
... |
| 236 |
modparam("topos", "db_url", "dbdriver://username:password@dbhost/dbname") |
| 237 |
... |
| 238 |
|
| 239 |
3.3. mask_callid (int) |
| 240 |
|
| 241 |
Whether to encode the Call-id: header. Some SIP extensions include the |
| 242 |
Call-id in the SIP message payload or header, so it is safe to not |
| 243 |
encode Call-id in such cases. Well-known extensions such as call |
| 244 |
transfer or conference join will be added to work with encoded Call-id. |
| 245 |
Topoh module should be loaded with use_mode parameter set to 1 |
| 246 |
|
| 247 |
Default value is 0 (do not mask). |
| 248 |
|
| 249 |
Example 1.3. Set mask_callid parameter |
| 250 |
... |
| 251 |
modparam("topos", "mask_callid", 1) |
| 252 |
... |
| 253 |
|
| 254 |
3.4. sanity_checks (int) |
| 255 |
|
| 256 |
If set to 1, topos module will bind to sanity module in order to |
| 257 |
perform sanity checks over received SIP request. Default sanity checks |
| 258 |
are done. It is useful to check if received request is well formatted |
| 259 |
before proceeding to encoding/decoding. |
| 260 |
|
| 261 |
Default value is 0 (do not bind to sanity module). |
| 262 |
|
| 263 |
Example 1.4. Set sanity_checks parameter |
| 264 |
... |
| 265 |
modparam("topos", "sanity_checks", 1) |
| 266 |
... |
| 267 |
|
| 268 |
3.5. branch_expire (int) |
| 269 |
|
| 270 |
Interval in seconds after which the branch records are deleted. |
| 271 |
|
| 272 |
Default value is 180 (3 min). |
| 273 |
|
| 274 |
Example 1.5. Set branch_expire parameter |
| 275 |
... |
| 276 |
modparam("topos", "branch_expire", 300) |
| 277 |
... |
| 278 |
|
| 279 |
3.6. dialog_expire (int) |
| 280 |
|
| 281 |
Interval in seconds after which the dialog records are deleted. Keep in |
| 282 |
mind that the module does not update the dialog timestamp after the |
| 283 |
initial call setup on re-INVITEs or other in-dialog messages. So set a |
| 284 |
large enough value (according your longest call duration) to prevent |
| 285 |
problems in re-writing messages. This key is only relevant for INVITE |
| 286 |
dialog. SUBSCRIBE dialog records lifetime are based on value set in |
| 287 |
expires header. Moreover each re-SUBSCRIBEs update the dialog |
| 288 |
timestamp. |
| 289 |
|
| 290 |
Default value is 10800 (3 hours). |
| 291 |
|
| 292 |
Example 1.6. Set dialog_expire parameter |
| 293 |
... |
| 294 |
modparam("topos", "dialog_expire", 3600) |
| 295 |
... |
| 296 |
|
| 297 |
3.7. clean_interval (int) |
| 298 |
|
| 299 |
Interval in seconds to run the clean up of stored records. |
| 300 |
|
| 301 |
Default value is 60 (1 min). |
| 302 |
|
| 303 |
Example 1.7. Set clean_interval parameter |
| 304 |
... |
| 305 |
modparam("topos", "clean_interval", 30) |
| 306 |
... |
| 307 |
|
| 308 |
3.8. event_callback (str) |
| 309 |
|
| 310 |
The name of the function in the KEMI configuration file (embedded |
| 311 |
scripting language such as Lua, Python, ...) to be executed instead of |
| 312 |
event_route[...] blocks. |
| 313 |
|
| 314 |
The function receives a string parameter with the name of the event. |
| 315 |
|
| 316 |
Default value is 'empty' (no function is executed for events). |
| 317 |
|
| 318 |
Example 1.8. Set event_callback parameter |
| 319 |
... |
| 320 |
modparam("topos", "event_callback", "ksr_topos_event") |
| 321 |
... |
| 322 |
-- event callback function implemented in Lua |
| 323 |
function ksr_topos_event(evname) |
| 324 |
KSR.info("===== topos module triggered event: " .. evname .. "\n"); |
| 325 |
return 1; |
| 326 |
end |
| 327 |
... |
| 328 |
|
| 329 |
3.9. event_mode (int) |
| 330 |
|
| 331 |
Control what event_route blocks to be executed. It is a bitmask of: |
| 332 |
* 1 - execute event_route[topos:msg-outgoing] |
| 333 |
* 2 - execute event_route[topos:msg-sending] |
| 334 |
* 4 - execute event_route[topos:msg-incoming] |
| 335 |
* 8 - execute event_route[topos:msg-receiving] |
| 336 |
|
| 337 |
Default value is 15 (execute all event_route blocks). |
| 338 |
|
| 339 |
Example 1.9. Set event_mode parameter |
| 340 |
... |
| 341 |
modparam("topos", "event_mode", 2) |
| 342 |
... |
| 343 |
|
| 344 |
3.10. contact_host (str) |
| 345 |
|
| 346 |
You may need to control the host part of the Contact header added by |
| 347 |
topos. If the xavu_field_contact_host parameter is set, this value is |
| 348 |
ignored. For example when using TLS with TOPOS the remote UAS must be |
| 349 |
able to open a new TLS socket to the contact header. In this case, the |
| 350 |
contact header must contain a domain name with a trusted CA signed |
| 351 |
certitificate. |
| 352 |
|
| 353 |
Default value is taken from the Record-Route URI. |
| 354 |
|
| 355 |
Example 1.10. Set contact_host parameter |
| 356 |
... |
| 357 |
modparam("topos", "contact_host", "proxy.domain.com") |
| 358 |
... |
| 359 |
|
| 360 |
3.11. contact_mode (int) |
| 361 |
|
| 362 |
Control the mode where the key to lookup the message data from the |
| 363 |
database or redis server is stored. The default is to use the Contact |
| 364 |
user (0), alternatively a Contact URI parameter can be used (1) with |
| 365 |
values from the SIP message, or from AVP variables (2). Contact mode |
| 366 |
(3) is similar to mode 2, but for the case when we want to alter the |
| 367 |
domain part. This can be useful for interoperating which gateways that |
| 368 |
need a certain user part in the Contact URI. |
| 369 |
|
| 370 |
In mode (1) the a-side contact user is taken from the request URI and |
| 371 |
the b-side contact user from the Contact header of the processed |
| 372 |
initial SIP request. |
| 373 |
|
| 374 |
If you use the mode (2), you need to configure the xavu_field_a_contact |
| 375 |
and xavu_field_b_contact parameter. Furthermore you need to assign |
| 376 |
values to them during the processing of the initial SIP request. |
| 377 |
|
| 378 |
If you use the mode (3), you need to configure the |
| 379 |
xavu_field_a_contact_host and xavu_field_b_contact_host parameter. |
| 380 |
Furthermore you need to assign values to them during the processing of |
| 381 |
the initial SIP request. |
| 382 |
|
| 383 |
The name of the Contact URI parameter can be customized with the |
| 384 |
cparam_name parameter. |
| 385 |
|
| 386 |
Default value is 0 - use the Contact user |
| 387 |
|
| 388 |
Example 1.11. Set contact_mode parameter |
| 389 |
... |
| 390 |
modparam("topos", "contact_mode", 1) |
| 391 |
... |
| 392 |
|
| 393 |
3.12. cparam_name (int) |
| 394 |
|
| 395 |
Name of the Contact URI parameter to store the database or redis server |
| 396 |
key for message lookup. |
| 397 |
|
| 398 |
This parameter is only used when the contact_mode parameter is set to 1 |
| 399 |
or 2. |
| 400 |
|
| 401 |
Default value is “tps”. |
| 402 |
|
| 403 |
Example 1.12. Set cparam_name parameter |
| 404 |
... |
| 405 |
modparam("topos", "cparam_name", "xyz") |
| 406 |
... |
| 407 |
|
| 408 |
3.13. xavu_cfg (str) |
| 409 |
|
| 410 |
Name of root XAVU to hold config-specific values to be used by module |
| 411 |
at runtime. |
| 412 |
|
| 413 |
Note: this parameter must be set if any other parameter prefixed with |
| 414 |
`xavu_field_` is used. |
| 415 |
|
| 416 |
Default value is “NULL” (disabled). |
| 417 |
|
| 418 |
Example 1.13. Set xavu_cfg parameter |
| 419 |
... |
| 420 |
modparam("topos", "xavu_cfg", "_tps_") |
| 421 |
modparam("topos", "xavu_field_a_contact", "a_contact") |
| 422 |
... |
| 423 |
$xavu(_tps_=>a_contact) = "..."; |
| 424 |
... |
| 425 |
|
| 426 |
3.14. xavu_field_a_contact (str) |
| 427 |
|
| 428 |
Name of the field inside root XAVU specified by `xavu_cfg` to evaluate |
| 429 |
for the A-side Contact Header user part. This parameter is only |
| 430 |
necessary in contact_mode (2). |
| 431 |
|
| 432 |
Default value is “NULL” (disabled). |
| 433 |
|
| 434 |
Example 1.14. Set xavu_field_a_contact parameter |
| 435 |
... |
| 436 |
modparam("topos", "xavu_cfg", "_tps_") |
| 437 |
modparam("topos", "xavu_field_a_contact", "a_contact") |
| 438 |
... |
| 439 |
$xavu(_tps_=>a_contact) = "..."; |
| 440 |
... |
| 441 |
|
| 442 |
3.15. xavu_field_b_contact (str) |
| 443 |
|
| 444 |
Name of the field inside root XAVU specified by `xavu_cfg` to evaluate |
| 445 |
for the B-side Contact Header user part. This parameter is only |
| 446 |
necessary in contact_mode (2). |
| 447 |
|
| 448 |
Default value is “NULL” (disabled). |
| 449 |
|
| 450 |
Example 1.15. Set xavu_field_b_contact parameter |
| 451 |
... |
| 452 |
modparam("topos", "xavu_cfg", "_tps_") |
| 453 |
modparam("topos", "xavu_field_b_contact", "b_contact") |
| 454 |
... |
| 455 |
$xavu(_tps_=>b_contact) = "..."; |
| 456 |
|
| 457 |
... |
| 458 |
|
| 459 |
3.16. xavu_field_contact_host (str) |
| 460 |
|
| 461 |
Control from where to take the host part of the Contact header added by |
| 462 |
topos. This parameter allows to take the value from an XAVU during |
| 463 |
run-time, it specifies the field inside XAVU "xavu_cfg". If this |
| 464 |
parameter is set, the contact_host parameter is ignored. For example |
| 465 |
when using TLS with TOPOS the remote UAS must be able to open a new TLS |
| 466 |
socket to the contact header. In this case, the contact header must |
| 467 |
contain a domain name with a trusted CA signed certitificate. |
| 468 |
|
| 469 |
Default value is empty, not set. |
| 470 |
|
| 471 |
Example 1.16. Set xavu_field_contact_host parameter |
| 472 |
... |
| 473 |
modparam("topos", "xavu_cfg", "_tps_") |
| 474 |
modparam("topos", "xavu_field_contact_host", "contact_host") |
| 475 |
... |
| 476 |
$xavu(_tps_=>contact_host) = "kamailio.org"; |
| 477 |
... |
| 478 |
|
| 479 |
3.17. rr_update (int) |
| 480 |
|
| 481 |
If set to 1, topos module will track and update record route changes on |
| 482 |
re-invite. |
| 483 |
|
| 484 |
Default value is 0 (do not update record route changes within dialog). |
| 485 |
|
| 486 |
Example 1.17. Set rr_update parameter |
| 487 |
... |
| 488 |
modparam("topos", "rr_update", 1) |
| 489 |
... |
| 490 |
|
| 491 |
3.18. context (str) |
| 492 |
|
| 493 |
Set the global context for topos instance. |
| 494 |
|
| 495 |
The value has to be maximum 12 characters. |
| 496 |
|
| 497 |
Default value is “NULL” (disabled). |
| 498 |
|
| 499 |
Example 1.18. Set context parameter |
| 500 |
... |
| 501 |
modparam("topos", "context", "srvone") |
| 502 |
... |
| 503 |
|
| 504 |
3.19. methods_nocontact (str) |
| 505 |
|
| 506 |
List of SIP methods to skip adding Contact header for. |
| 507 |
|
| 508 |
Default value is “BYE,CANCEL,PRACK”. |
| 509 |
|
| 510 |
Example 1.19. Set methods_nocontact parameter |
| 511 |
... |
| 512 |
modparam("topos", "methods_nocontact", "CANCEL,PRACK") |
| 513 |
... |
| 514 |
|
| 515 |
3.20. header_mode (int) |
| 516 |
|
| 517 |
List of headers to disable multiple comma separated values inserted in |
| 518 |
compact form. Altough compact form is RFC compliant this parameter |
| 519 |
gives possibilty to disable compact form header values for UA that |
| 520 |
don't support or can't handle it. The following options are available: |
| 521 |
(1) - disable multiple comma separated values for Via header (2) - |
| 522 |
disable multiple comma separated values for Record-Route header (4) - |
| 523 |
disable multiple comma separated values for Route header |
| 524 |
|
| 525 |
Default value is “0”. |
| 526 |
|
| 527 |
Example 1.20. Set header_mode parameter |
| 528 |
... |
| 529 |
modparam("topos", "header_mode", 1) |
| 530 |
... |
| 531 |
|
| 532 |
3.21. methods_noinitial (str) |
| 533 |
|
| 534 |
List of SIP methods to skip doing topos if it is an initial request (no |
| 535 |
To-tag). |
| 536 |
|
| 537 |
Default value is “” (no method). |
| 538 |
|
| 539 |
Example 1.21. Set methods_noinitial parameter |
| 540 |
... |
| 541 |
modparam("topos", "methods_noinitial", "OPTIONS,NOTIFY") |
| 542 |
... |
| 543 |
|
| 544 |
3.22. version_table (integer) |
| 545 |
|
| 546 |
If set to 0, the module will skip checking the version of the tables. |
| 547 |
|
| 548 |
Default value is “1 (check for table version)”. |
| 549 |
|
| 550 |
Example 1.22. version_table parameter usage |
| 551 |
... |
| 552 |
modparam("topos", "version_table", 0) |
| 553 |
... |
| 554 |
|
| 555 |
3.23. methods_update_time (str) |
| 556 |
|
| 557 |
List of SIP methods (comma separated) for which the dialog timestamp |
| 558 |
(rectime) should be updated in the topos_d table when processing |
| 559 |
in-dialog requests. This allows extending the dialog lifetime for |
| 560 |
specific methods beyond the initial INVITE. |
| 561 |
|
| 562 |
Default value is “SUBSCRIBE”. |
| 563 |
|
| 564 |
Example 1.23. Set methods_update_time parameter |
| 565 |
... |
| 566 |
modparam("topos", "methods_update_time", "SUBSCRIBE,UPDATE,INVITE") |
| 567 |
... |
| 568 |
|
| 569 |
4. Functions |
| 570 |
|
| 571 |
4.1. tps_set_context(ctx) |
| 572 |
|
| 573 |
4.1. tps_set_context(ctx) |
| 574 |
|
| 575 |
Update the context at runtime. If the value is empty string, then the |
| 576 |
runtime context is reset. |
| 577 |
|
| 578 |
This function can be used from ANY_ROUTE. |
| 579 |
|
| 580 |
Example 1.24. tps_set_context usage |
| 581 |
... |
| 582 |
request_route { |
| 583 |
... |
| 584 |
tps_set_context("srvone"); |
| 585 |
... |
| 586 |
} |
| 587 |
... |
| 588 |
|
| 589 |
5. Event Routes |
| 590 |
|
| 591 |
5.1. event_route[topos:msg-outgoing] |
| 592 |
5.2. event_route[topos:msg-sending] |
| 593 |
5.3. event_route[topos:msg-incoming] |
| 594 |
5.4. event_route[topos:msg-receiving] |
| 595 |
|
| 596 |
5.1. event_route[topos:msg-outgoing] |
| 597 |
|
| 598 |
It is executed before doing topology stripping processing for an |
| 599 |
outgoing SIP message. If 'drop' is executed inside the event route, |
| 600 |
then the module skips doing the outbound part of topology stripping. |
| 601 |
|
| 602 |
The event route is executed with an internal fake SIP message for the |
| 603 |
purpose of performace (i.e., no parsing of the outgoing message is |
| 604 |
done), therefore the R-URI, headers and body do not reflect the content |
| 605 |
of the outgoing message. However, inside the event route the variables |
| 606 |
$sndto(ip), $sndto(port) and $sndto(proto) point to the real |
| 607 |
destination of the SIP message. |
| 608 |
|
| 609 |
Example 1.25. Usage of event_route[topos:msg-outgoing] |
| 610 |
... |
| 611 |
event_route[topos:msg-outgoing] { |
| 612 |
if($sndto(ip)=="10.1.1.10") { |
| 613 |
drop; |
| 614 |
} |
| 615 |
} |
| 616 |
... |
| 617 |
|
| 618 |
5.2. event_route[topos:msg-sending] |
| 619 |
|
| 620 |
It is executed before doing topology stripping processing for a SIP |
| 621 |
message to be sent out, being executed after |
| 622 |
event_route[topos:msg-outgoing]. If 'drop' is executed inside the event |
| 623 |
route, then the module skips doing the outbound part of topology |
| 624 |
stripping. |
| 625 |
|
| 626 |
A copy of the SIP message to be sent out is made available in this |
| 627 |
event route, thefore the R-URI, headers and body reflect the content of |
| 628 |
the outgoing SIP message. Inside the event route the variables |
| 629 |
$sndto(ip), $sndto(port) and $sndto(proto) point to the real |
| 630 |
destination of the SIP message. |
| 631 |
|
| 632 |
Example 1.26. Usage of event_route[topos:msg-sending] |
| 633 |
... |
| 634 |
event_route[topos:msg-sending] { |
| 635 |
if(is_request() and $fU=="alice") { |
| 636 |
drop; |
| 637 |
} |
| 638 |
} |
| 639 |
... |
| 640 |
|
| 641 |
5.3. event_route[topos:msg-incoming] |
| 642 |
|
| 643 |
It is executed before doing topology stripping processing for an |
| 644 |
incoming SIP message. If 'drop' is executed inside this event route, |
| 645 |
then the module skips doing the inbound part of topology stripping. |
| 646 |
|
| 647 |
The event route is executed with an internal fake SIP message for the |
| 648 |
purpose of performace (i.e., no parsing of the incoming message is |
| 649 |
done), therefore the R-URI, headers and body do not reflect the content |
| 650 |
of the incoming message. However, inside the event route the variables |
| 651 |
$si, $sp and $proto point to the real source address of the SIP |
| 652 |
message, as well as the keywords src_port and dst_port. |
| 653 |
|
| 654 |
Example 1.27. Usage of event_route[topos:msg-incoming] |
| 655 |
... |
| 656 |
event_route[topos:msg-incoming] { |
| 657 |
if($si=="10.1.1.10") { |
| 658 |
drop; |
| 659 |
} |
| 660 |
} |
| 661 |
... |
| 662 |
|
| 663 |
5.4. event_route[topos:msg-receiving] |
| 664 |
|
| 665 |
It is executed before doing topology stripping processing for a SIP |
| 666 |
message that was received, being executed after |
| 667 |
event_route[topos:msg-incoing]. If 'drop' is executed inside this event |
| 668 |
route, then the module skips doing the inbound part of topology hiding. |
| 669 |
|
| 670 |
A copy of the incoming SIP message is made available in this event |
| 671 |
route, thefore the R-URI, headers and body reflect the content of the |
| 672 |
incoming SIP message. Inside the event route the variables $si, $sp and |
| 673 |
$proto point to the real source address of the SIP message, as well as |
| 674 |
the keywords src_port and dst_port. |
| 675 |
|
| 676 |
Example 1.28. Usage of event_route[topos:msg-receiving] |
| 677 |
... |
| 678 |
event_route[topos:msg-receiving] { |
| 679 |
if(is_request() and $fU=="alice") { |
| 680 |
drop; |
| 681 |
} |
| 682 |
|
| 683 |
if($sp==5555 || $si=="1.2.3.4") { |
| 684 |
drop; |
| 685 |
} |
| 686 |
|
| 687 |
if(src_port==1234 || dst_port==5678) { |
| 688 |
drop; |
| 689 |
} |
| 690 |
} |
| 691 |
... |