Debian Codegraph @

src/modules/sl/README

raw
1 The SL Module - Stateless request handling
2
3 Bogdan Iancu
4
5 FhG FOKUS
6
7 Daniel-Constantin Mierla
8
9 asipto.com
10
11 Copyright © 2003 FhG FOKUS
12 __________________________________________________________________
13
14 Table of Contents
15
16 1. Admin Guide
17
18 1. Overview
19 2. Parameters
20
21 2.1. default_code (int)
22 2.2. default_reason (str)
23 2.3. bind_tm (int)
24 2.4. rich_redirect (int)
25 2.5. event_callback_fl_ack (str)
26 2.6. event_callback_lres_sent (str)
27
28 3. Functions
29
30 3.1. sl_send_reply(code, reason)
31 3.2. send_reply(code, reason)
32 3.3. send_reply_mode(code, reason, mode)
33 3.4. sl_reply_error()
34 3.5. sl_forward_reply([ code, [ reason ] ])
35 3.6. send_reply_error()
36
37 4. Statistics
38
39 4.1. 1xx_replies
40 4.2. 200_replies
41 4.3. 202_replies
42 4.4. 2xx_replies
43 4.5. 300_replies
44 4.6. 301_replies
45 4.7. 302_replies
46 4.8. 3xx_replies
47 4.9. 400_replies
48 4.10. 401_replies
49 4.11. 403_replies
50 4.12. 404_replies
51 4.13. 407_replies
52 4.14. 408_replies
53 4.15. 483_replies
54 4.16. 4xx_replies
55 4.17. 500_replies
56 4.18. 5xx_replies
57 4.19. 6xx_replies
58 4.20. xxx_replies
59 4.21. sent_replies
60 4.22. sent_err_replies
61 4.23. failures
62 4.24. received_ACKs
63
64 5. Event routes
65
66 5.1. sl:filtered-ack
67 5.2. sl:local-response
68
69 List of Examples
70
71 1.1. default_code example
72 1.2. default_reason example
73 1.3. bind_tm example
74 1.4. rich_redirect example
75 1.5. event_callback_fl_ack example
76 1.6. event_callback_lres_sent example
77 1.7. sl_send_reply usage
78 1.8. send_reply usage
79 1.9. send_reply_mode usage
80 1.10. sl_reply_error usage
81 1.11. send_reply usage
82 1.12. send_reply_error usage
83
84 Chapter 1. Admin Guide
85
86 Table of Contents
87
88 1. Overview
89 2. Parameters
90
91 2.1. default_code (int)
92 2.2. default_reason (str)
93 2.3. bind_tm (int)
94 2.4. rich_redirect (int)
95 2.5. event_callback_fl_ack (str)
96 2.6. event_callback_lres_sent (str)
97
98 3. Functions
99
100 3.1. sl_send_reply(code, reason)
101 3.2. send_reply(code, reason)
102 3.3. send_reply_mode(code, reason, mode)
103 3.4. sl_reply_error()
104 3.5. sl_forward_reply([ code, [ reason ] ])
105 3.6. send_reply_error()
106
107 4. Statistics
108
109 4.1. 1xx_replies
110 4.2. 200_replies
111 4.3. 202_replies
112 4.4. 2xx_replies
113 4.5. 300_replies
114 4.6. 301_replies
115 4.7. 302_replies
116 4.8. 3xx_replies
117 4.9. 400_replies
118 4.10. 401_replies
119 4.11. 403_replies
120 4.12. 404_replies
121 4.13. 407_replies
122 4.14. 408_replies
123 4.15. 483_replies
124 4.16. 4xx_replies
125 4.17. 500_replies
126 4.18. 5xx_replies
127 4.19. 6xx_replies
128 4.20. xxx_replies
129 4.21. sent_replies
130 4.22. sent_err_replies
131 4.23. failures
132 4.24. received_ACKs
133
134 5. Event routes
135
136 5.1. sl:filtered-ack
137 5.2. sl:local-response
138
139 1. Overview
140
141 The SL module allows the SIP server to act as a stateless UA server and
142 generate replies to SIP requests without keeping state. That is
143 beneficial in many scenarios, in which you wish not to burden server's
144 memory and scale well.
145
146 The SL module needs to filter ACKs sent after a local stateless reply
147 to an INVITE was generated. To recognize such ACKs, Kamailio adds a
148 special "signature" in to-tags. This signature is sought for in
149 incoming ACKs, and if included, the ACKs are absorbed.
150
151 To speed up the filtering process, the module uses a timeout mechanism.
152 When a reply is sent, a timer is set. As long as the timer is valid,
153 the incoming ACK requests will be checked using TO tag value. Once the
154 timer expires, all the ACK messages are let through - a long time
155 passed till it sent a reply, so it does not expect any ACK that have to
156 be blocked.
157
158 The ACK filtering may fail in some rare cases. If you think these
159 matter to you, better use stateful processing (TM module) for INVITE
160 processing. Particularly, the problem happens when a UA sends an INVITE
161 which already has a to-tag in it (e.g., a re-INVITE) and the server
162 wants to reply to it. Then, it will keep the current to-tag, which will
163 be mirrored in ACK. Kamailio will not see its signature and forward the
164 ACK downstream. Caused harm is not bad, just a useless ACK is
165 forwarded.
166
167 2. Parameters
168
169 2.1. default_code (int)
170 2.2. default_reason (str)
171 2.3. bind_tm (int)
172 2.4. rich_redirect (int)
173 2.5. event_callback_fl_ack (str)
174 2.6. event_callback_lres_sent (str)
175
176 2.1. default_code (int)
177
178 Default reply status code.
179
180 Default value is 500.
181
182 Example 1.1. default_code example
183 ...
184 modparam("sl", "default_code", 505)
185 ...
186
187 2.2. default_reason (str)
188
189 Default reply reason phrase.
190
191 Default value is 'Internal Server Error'.
192
193 Example 1.2. default_reason example
194 ...
195 modparam("sl", "default_reason", "Server Error")
196 ...
197
198 2.3. bind_tm (int)
199
200 Controls if SL module should attempt to bind to TM module in order to
201 send stateful reply when the transaction is created.
202
203 Default value is 1 (enabled).
204
205 Example 1.3. bind_tm example
206 ...
207 modparam("sl", "bind_tm", 0) # feature disabled
208 ...
209
210 2.4. rich_redirect (int)
211
212 When sending a 3xx class reply, include additional branch info to the
213 contacts such as path vector and branch flags.
214 * 0 - no extra info is added (default)
215 * 1 - include branch flags as contact header parameter
216 * 2 - include path as contact uri Route header
217
218 Values may be combined (added).
219
220 Example 1.4. rich_redirect example
221 ...
222 modparam("sl", "rich_redirect", 3)
223 ...
224
225 2.5. event_callback_fl_ack (str)
226
227 The name of the KEMI callback function to be executed instead of
228 event_route[sl:filtered-ack]. This function receives a string
229 parameter.
230
231 Default value: not set.
232
233 Example 1.5. event_callback_fl_ack example
234 ...
235 modparam("sl", "event_callback_fl_ack", "ksr_event_sl_filtered_ack")
236 ...
237
238 2.6. event_callback_lres_sent (str)
239
240 The name of the KEMI callback function to be executed instead of
241 event_route[sl:local-response]. This function receives a string
242 parameter.
243
244 Default value: not set.
245
246 Example 1.6. event_callback_lres_sent example
247 ...
248 modparam("sl", "event_callback_lres_sent", "ksr_event_sl_local_response")
249 ...
250
251 3. Functions
252
253 3.1. sl_send_reply(code, reason)
254 3.2. send_reply(code, reason)
255 3.3. send_reply_mode(code, reason, mode)
256 3.4. sl_reply_error()
257 3.5. sl_forward_reply([ code, [ reason ] ])
258 3.6. send_reply_error()
259
260 3.1. sl_send_reply(code, reason)
261
262 For the current request, a reply is sent back having the given code and
263 text reason. The reply is sent stateless, totally independent of the
264 Transaction module and with no retransmission for the INVITE's replies.
265
266 If the code is in the range 300-399 (redirect reply), the current
267 destination set is appended to the reply as Contact headers. The
268 destination set contains the request URI (R-URI), if it is modified
269 compared to the received one, plus the branches added to the request
270 (e.g., after an append_branch() or lookup("location")). If the R-URI
271 was changed but it is not desired to be part of the destination set, it
272 can be reverted using the function revert_uri().
273
274 Custom headers to the reply can be added using append_to_reply()
275 function from textops module.
276
277 Meaning of the parameters is as follows:
278 * code - Return code.
279 * reason - Reason phrase.
280
281 Example 1.7. sl_send_reply usage
282 ...
283 sl_send_reply("404", "Not found");
284 ...
285
286 3.2. send_reply(code, reason)
287
288 For the current request, a reply is sent back having the given code and
289 text reason. The reply is sent stateful or stateless, depending of the
290 TM module: if a transaction exists for the current request, then the
291 reply is sent statefully, otherwise stateless.
292
293 Meaning of the parameters is as follows:
294 * code - Return code.
295 * reason - Reason phrase.
296
297 This function can be used from REQUEST_ROUTE and FAILURE_ROUTE. It can
298 be used on ONREPLY_ROUTE executed by tm module (upon a t_on_reply()
299 callback).
300
301 Example 1.8. send_reply usage
302 ...
303 send_reply("404", "Not found");
304 ...
305 send_reply("403", "Invalid user - $fU");
306 ...
307
308 3.3. send_reply_mode(code, reason, mode)
309
310 Similar to send_reply() function, with additional third parameter mode,
311 which can specify extra operations to be done along with sending the
312 SIP response.
313
314 The parameter mode is a flag-based value and can be a combination of:
315 * 1 - do not connect to send the response (similar to
316 set_reply_no_connect()).
317 * 2 - close the connection after sending the response (similar to
318 set_reply_close()).
319
320 Example 1.9. send_reply_mode usage
321 ...
322 send_reply_mode("404", "Not found", "3");
323 ...
324 send_reply_mode("403", "Invalid user - $fU", "3");
325 ...
326
327 3.4. sl_reply_error()
328
329 Sends back an error reply describing the nature of the last internal
330 error. Usually this function should be used after a script function
331 that returned an error code.
332
333 Example 1.10. sl_reply_error usage
334 ...
335 sl_reply_error();
336 ...
337
338 3.5. sl_forward_reply([ code, [ reason ] ])
339
340 Forward statelessly the current received SIP reply, with the option to
341 change the status code and reason text. The new code has to be in the
342 same class. The received reply is forwarded as well by core when the
343 config execution ended, unless it is dropped from config.
344
345 Meaning of the parameters is as follows:
346 * code - Status code.
347 * reason - Reason phrase.
348
349 This function can be used from ONREPLY_ROUTE.
350
351 Example 1.11. send_reply usage
352 ...
353 if(status=="408")
354 sl_forward_reply("404", "Not found");
355 ...
356
357 3.6. send_reply_error()
358
359 For the current request, the internal error code reply is sent back
360 stateful or stateless, depending of the TM module: if a transaction
361 exists for the current request, then the reply is sent statefully,
362 otherwise stateless.
363
364 It can be used from REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
365
366 Example 1.12. send_reply_error usage
367 ...
368 send_reply_error();
369 ...
370
371 4. Statistics
372
373 4.1. 1xx_replies
374 4.2. 200_replies
375 4.3. 202_replies
376 4.4. 2xx_replies
377 4.5. 300_replies
378 4.6. 301_replies
379 4.7. 302_replies
380 4.8. 3xx_replies
381 4.9. 400_replies
382 4.10. 401_replies
383 4.11. 403_replies
384 4.12. 404_replies
385 4.13. 407_replies
386 4.14. 408_replies
387 4.15. 483_replies
388 4.16. 4xx_replies
389 4.17. 500_replies
390 4.18. 5xx_replies
391 4.19. 6xx_replies
392 4.20. xxx_replies
393 4.21. sent_replies
394 4.22. sent_err_replies
395 4.23. failures
396 4.24. received_ACKs
397
398 4.1. 1xx_replies
399
400 Number of 1xx replies.
401
402 4.2. 200_replies
403
404 Number of 201 replies.
405
406 4.3. 202_replies
407
408 Number of 202 replies.
409
410 4.4. 2xx_replies
411
412 Number of 2xx replies.
413
414 4.5. 300_replies
415
416 Number of 300 replies.
417
418 4.6. 301_replies
419
420 Number of 301 replies.
421
422 4.7. 302_replies
423
424 Number of 302 replies.
425
426 4.8. 3xx_replies
427
428 Number of 3xx replies.
429
430 4.9. 400_replies
431
432 Number of 400 replies.
433
434 4.10. 401_replies
435
436 Number of 401 replies.
437
438 4.11. 403_replies
439
440 Number of 403 replies.
441
442 4.12. 404_replies
443
444 Number of 404 replies.
445
446 4.13. 407_replies
447
448 Number of 407 replies.
449
450 4.14. 408_replies
451
452 Number of 408 replies.
453
454 4.15. 483_replies
455
456 Number of 483 replies.
457
458 4.16. 4xx_replies
459
460 Number of 4xx replies.
461
462 4.17. 500_replies
463
464 Number of 500 replies.
465
466 4.18. 5xx_replies
467
468 Number of 5xx replies.
469
470 4.19. 6xx_replies
471
472 Number of 6xx replies.
473
474 4.20. xxx_replies
475
476 Number of replies whose code don't match any above.
477
478 4.21. sent_replies
479
480 Number of all sent replies.
481
482 4.22. sent_err_replies
483
484 Number of sent error replies.
485
486 4.23. failures
487
488 Number of failures.
489
490 4.24. received_ACKs
491
492 Number of received ACKs filtered by SL module.
493
494 5. Event routes
495
496 5.1. sl:filtered-ack
497 5.2. sl:local-response
498
499 5.1. sl:filtered-ack
500
501 Executed when ACK to locally generated reply is recognized and
502 absorbed.
503 ...
504 event_route[sl:filtered-ack] {
505 xlog("sl:filtered-ack ACK to local reply absorbed\n");
506 }
507 ...
508
509 5.2. sl:local-response
510
511 Executed after sl module reply function has sent local reply.
512 ...
513 event_route[sl:local-response] {
514 xlog("sl:local-response replied locally\n");
515 }
516 ...