Debian Codegraph @

src/modules/msilo/README

raw
1 MSILO Module
2
3 Daniel-Constantin Mierla
4
5 <[email protected]>
6
7 Juha Heinanen
8
9 <[email protected]>
10
11 Edited by
12
13 Daniel-Constantin Mierla
14
15 <[email protected]>
16
17 Juha Heinanen
18
19 <[email protected]>
20
21 Copyright © 2003 FhG FOKUS
22
23 Copyright © 2009 Juha Heinanen
24 __________________________________________________________________
25
26 Table of Contents
27
28 1. Admin Guide
29
30 1. Overview
31 2. Dependencies
32
33 2.1. Kamailio modules
34 2.2. External libraries or applications
35
36 3. Parameters
37
38 3.1. db_url (string)
39 3.2. db_table (string)
40 3.3. sc_mid (string)
41 3.4. sc_from (string)
42 3.5. sc_to (string)
43 3.6. sc_uri_user (string)
44 3.7. sc_uri_host (string)
45 3.8. sc_body (string)
46 3.9. sc_ctype (string)
47 3.10. sc_exp_time (string)
48 3.11. sc_inc_time (string)
49 3.12. sc_snd_time (string)
50 3.13. sc_stored_hdrs (string)
51 3.14. sc_callid (string)
52 3.15. sc_callid (string)
53 3.16. from_address (string)
54 3.17. contact_hdr (string)
55 3.18. extra_hdrs (string)
56 3.19. offline_message (string)
57 3.20. content_type_hdr (string)
58 3.21. reminder (string)
59 3.22. outbound_proxy (string)
60 3.23. expire_time (int)
61 3.24. check_time (int)
62 3.25. send_time (int)
63 3.26. clean_period (int)
64 3.27. use_contact (int)
65 3.28. snd_time_avp (str)
66 3.29. add_date (int)
67 3.30. max_messages (int)
68 3.31. add_contact (int)
69 3.32. extra_hdrs_avp (str)
70 3.33. skip_notification_flag (int)
71 3.34. use_mode (int)
72
73 4. Functions
74
75 4.1. m_store([owner])
76 4.2. m_store_addrs(owner, srcaddr, dstaddr)
77 4.3. m_dump([owner])
78
79 5. Statistics
80
81 5.1. stored_messages
82 5.2. dumped_messages
83 5.3. failed_messages
84 5.4. dumped_reminders
85 5.5. failed_reminders
86
87 6. Installation and Running
88
89 6.1. Kamailio config file
90
91 List of Examples
92
93 1.1. Set the “db_url” parameter
94 1.2. Set the “db_table” parameter
95 1.3. Set the “sc_mid” parameter
96 1.4. Set the “sc_from” parameter
97 1.5. Set the “sc_to” parameter
98 1.6. Set the “sc_uri_user” parameter
99 1.7. Set the “sc_uri_host” parameter
100 1.8. Set the “sc_body” parameter
101 1.9. Set the “sc_ctype” parameter
102 1.10. Set the “sc_exp_time” parameter
103 1.11. Set the “sc_inc_time” parameter
104 1.12. Set the “sc_snd_time” parameter
105 1.13. Set the “sc_stored_hdrs” parameter
106 1.14. Set the “sc_callid” parameter
107 1.15. Set the “sc_status” parameter
108 1.16. Set the “from_address” parameter
109 1.17. Set the “contact_hdr” parameter
110 1.18. Set the “extra_hdrs” parameter
111 1.19. Set the “offline_message” parameter
112 1.20. Set the “content_type_hdr” parameter
113 1.21. Set the “reminder” parameter
114 1.22. Set the “outbound_proxy” parameter
115 1.23. Set the “expire_time” parameter
116 1.24. Set the “check_time” parameter
117 1.25. Set the “send_time” parameter
118 1.26. Set the “clean_period” parameter
119 1.27. Set the “use_contact” parameter
120 1.28. Set the “snd_time_avp” parameter
121 1.29. Set the “add_date” parameter
122 1.30. Set the “max_messages” parameter
123 1.31. Set the “add_contact” parameter
124 1.32. Set the “extra_hdrs_avp” parameter
125 1.33. Set the “skip_notification_flag” parameter
126 1.34. Set the “use_mode” parameter
127 1.35. m_store usage
128 1.36. m_store_addrs usage
129 1.37. m_dump usage
130 1.38. Kamailio config script - sample msilo usage
131
132 Chapter 1. Admin Guide
133
134 Table of Contents
135
136 1. Overview
137 2. Dependencies
138
139 2.1. Kamailio modules
140 2.2. External libraries or applications
141
142 3. Parameters
143
144 3.1. db_url (string)
145 3.2. db_table (string)
146 3.3. sc_mid (string)
147 3.4. sc_from (string)
148 3.5. sc_to (string)
149 3.6. sc_uri_user (string)
150 3.7. sc_uri_host (string)
151 3.8. sc_body (string)
152 3.9. sc_ctype (string)
153 3.10. sc_exp_time (string)
154 3.11. sc_inc_time (string)
155 3.12. sc_snd_time (string)
156 3.13. sc_stored_hdrs (string)
157 3.14. sc_callid (string)
158 3.15. sc_callid (string)
159 3.16. from_address (string)
160 3.17. contact_hdr (string)
161 3.18. extra_hdrs (string)
162 3.19. offline_message (string)
163 3.20. content_type_hdr (string)
164 3.21. reminder (string)
165 3.22. outbound_proxy (string)
166 3.23. expire_time (int)
167 3.24. check_time (int)
168 3.25. send_time (int)
169 3.26. clean_period (int)
170 3.27. use_contact (int)
171 3.28. snd_time_avp (str)
172 3.29. add_date (int)
173 3.30. max_messages (int)
174 3.31. add_contact (int)
175 3.32. extra_hdrs_avp (str)
176 3.33. skip_notification_flag (int)
177 3.34. use_mode (int)
178
179 4. Functions
180
181 4.1. m_store([owner])
182 4.2. m_store_addrs(owner, srcaddr, dstaddr)
183 4.3. m_dump([owner])
184
185 5. Statistics
186
187 5.1. stored_messages
188 5.2. dumped_messages
189 5.3. failed_messages
190 5.4. dumped_reminders
191 5.5. failed_reminders
192
193 6. Installation and Running
194
195 6.1. Kamailio config file
196
197 1. Overview
198
199 This module provides offline message storage for Kamailio SIP Server
200 Platform. It stores received messages for an offline user and sends
201 them when the user comes back online. It can also send reminders and
202 auto-expire messages.
203
204 For each message, the module stores “Request-URI” (“R-URI”) only if it
205 is a complete address of record (“username@hostname”), URI from “To”
206 header, URI from “From” header, incoming time, expiration time, content
207 type and body of the message. If “R-URI” is not an address of record
208 (it might be the contact address for current SIP session) the URI from
209 “To” header will be used as R-URI.
210
211 When the expiration time is passed, the message is discarded from
212 database. Expiration time is computed based on incoming time and one of
213 the module's parameters.
214
215 Every time when a user registers with Kamailio, the module is looking
216 in database for offline messages intended for that user. All of them
217 will be sent to contact address provided in REGISTER request and then
218 be deleted.
219
220 It may happen that the SIP user registering use a SIP User Agent that
221 has no support for MESSAGE requests. In this case the “failure_route”
222 should be used to re-store the undelivered requests.
223
224 Another functionality provided by the MSILO module is to send messages
225 at a certain time -- the reminder functionality. Using config logic, a
226 received message can be stored and delivered at a time specified while
227 storing with the 'snd_time_avp'.
228
229 2. Dependencies
230
231 2.1. Kamailio modules
232 2.2. External libraries or applications
233
234 2.1. Kamailio modules
235
236 The following modules must be loaded before this module:
237 * database module - mysql, dbtext or other module that implements the
238 “db” interface and provides support for storing/receiving data
239 to/from a database system.
240 * TM--transaction module-- used to send SIP requests.
241
242 2.2. External libraries or applications
243
244 The following libraries or applications must be installed before
245 running Kamailio with this module:
246 * none.
247
248 3. Parameters
249
250 3.1. db_url (string)
251 3.2. db_table (string)
252 3.3. sc_mid (string)
253 3.4. sc_from (string)
254 3.5. sc_to (string)
255 3.6. sc_uri_user (string)
256 3.7. sc_uri_host (string)
257 3.8. sc_body (string)
258 3.9. sc_ctype (string)
259 3.10. sc_exp_time (string)
260 3.11. sc_inc_time (string)
261 3.12. sc_snd_time (string)
262 3.13. sc_stored_hdrs (string)
263 3.14. sc_callid (string)
264 3.15. sc_callid (string)
265 3.16. from_address (string)
266 3.17. contact_hdr (string)
267 3.18. extra_hdrs (string)
268 3.19. offline_message (string)
269 3.20. content_type_hdr (string)
270 3.21. reminder (string)
271 3.22. outbound_proxy (string)
272 3.23. expire_time (int)
273 3.24. check_time (int)
274 3.25. send_time (int)
275 3.26. clean_period (int)
276 3.27. use_contact (int)
277 3.28. snd_time_avp (str)
278 3.29. add_date (int)
279 3.30. max_messages (int)
280 3.31. add_contact (int)
281 3.32. extra_hdrs_avp (str)
282 3.33. skip_notification_flag (int)
283 3.34. use_mode (int)
284
285 3.1. db_url (string)
286
287 Database URL.
288
289 Default value is “mysql://kamailio:kamailiorw@localhost/kamailio”.
290
291 Example 1.1. Set the “db_url” parameter
292 ...
293 modparam("msilo", "db_url", "dbdriver://username:password@dbhost/dbname")
294 ...
295
296 3.2. db_table (string)
297
298 The name of table where to store the messages.
299
300 Default value is “silo”.
301
302 Example 1.2. Set the “db_table” parameter
303 ...
304 modparam("msilo", "db_table", "silo")
305 ...
306
307 3.3. sc_mid (string)
308
309 The name of the column in silo table used to store the message id.
310
311 Default value is “mid”.
312
313 Example 1.3. Set the “sc_mid” parameter
314 ...
315 modparam("msilo", "sc_mid", "other_mid")
316 ...
317
318 3.4. sc_from (string)
319
320 The name of the column in silo table, storing the source address.
321
322 Default value is “src_addr”.
323
324 Example 1.4. Set the “sc_from” parameter
325 ...
326 modparam("msilo", "sc_from", "source_address")
327 ...
328
329 3.5. sc_to (string)
330
331 The name of the column in silo table, storing the destination address.
332
333 Default value is “dst_addr”.
334
335 Example 1.5. Set the “sc_to” parameter
336 ...
337 modparam("msilo", "sc_to", "destination_address")
338 ...
339
340 3.6. sc_uri_user (string)
341
342 The name of the column in silo table, storing the user name.
343
344 Default value is “username”.
345
346 Example 1.6. Set the “sc_uri_user” parameter
347 ...
348 modparam("msilo", "sc_uri_user", "user")
349 ...
350
351 3.7. sc_uri_host (string)
352
353 The name of the column in silo table, storing the domain.
354
355 Default value is “domain”.
356
357 Example 1.7. Set the “sc_uri_host” parameter
358 ...
359 modparam("msilo", "sc_uri_host", "domain")
360 ...
361
362 3.8. sc_body (string)
363
364 The name of the column storing the message body in silo table.
365
366 Default value is “body”.
367
368 Example 1.8. Set the “sc_body” parameter
369 ...
370 modparam("msilo", "sc_body", "message_body")
371 ...
372
373 3.9. sc_ctype (string)
374
375 The name of the column in silo table, storing content type.
376
377 Default value is “ctype”.
378
379 Example 1.9. Set the “sc_ctype” parameter
380 ...
381 modparam("msilo", "sc_ctype", "content_type")
382 ...
383
384 3.10. sc_exp_time (string)
385
386 The name of the column in silo table, storing the expire time of the
387 message.
388
389 Default value is “exp_time”.
390
391 Example 1.10. Set the “sc_exp_time” parameter
392 ...
393 modparam("msilo", "sc_exp_time", "expire_time")
394 ...
395
396 3.11. sc_inc_time (string)
397
398 The name of the column in silo table, storing the incoming time of the
399 message.
400
401 Default value is “inc_time”.
402
403 Example 1.11. Set the “sc_inc_time” parameter
404 ...
405 modparam("msilo", "sc_inc_time", "incoming_time")
406 ...
407
408 3.12. sc_snd_time (string)
409
410 The name of the column in silo table, storing the send time for the
411 reminder.
412
413 Default value is “snd_time”.
414
415 Example 1.12. Set the “sc_snd_time” parameter
416 ...
417 modparam("msilo", "sc_snd_time", "send_reminder_time")
418 ...
419
420 3.13. sc_stored_hdrs (string)
421
422 The name of the column in silo table, storing the extra headers.
423
424 Default value is “extra_hdrs”.
425
426 Example 1.13. Set the “sc_stored_hdrs” parameter
427 ...
428 modparam("msilo", "sc_stored_hdrs", "extra_headers")
429 ...
430
431 3.14. sc_callid (string)
432
433 The name of the column in silo table, storing callid.
434
435 Default value is “callid”.
436
437 Example 1.14. Set the “sc_callid” parameter
438 ...
439 modparam("msilo", "sc_callid", "call_id")
440 ...
441
442 3.15. sc_callid (string)
443
444 The name of the column in silo table, storing status.
445
446 Default value is “status”.
447
448 Example 1.15. Set the “sc_status” parameter
449 ...
450 modparam("msilo", "sc_status", "st")
451 ...
452
453 3.16. from_address (string)
454
455 The SIP address used to inform users that destination of their message
456 is not online and the message will be delivered next time when that
457 user goes online. If the parameter is not set, the module will not send
458 any notification. This parameter may contain pseudo-variables.
459
460 Default value is “NULL”.
461
462 Example 1.16. Set the “from_address” parameter
463 ...
464 modparam("msilo", "from_address", "sip:[email protected]")
465 modparam("msilo", "from_address", "sip:[email protected]")
466 ...
467
468 3.17. contact_hdr (string)
469
470 The value of the “Contact” header (including header name and ending
471 \r\n) to be added in notification messages. It can contain
472 pseudo-variables.
473
474 Default value is “NULL”.
475
476 Example 1.17. Set the “contact_hdr” parameter
477 ...
478 modparam("msilo", "contact_hdr", "Contact: <sip:[email protected]>\r\n")
479 ...
480
481 3.18. extra_hdrs (string)
482
483 Extra headers (each ending with \r\n) to be added in messages sent from
484 silo by m_dump. It can contain pseudo-variables.
485
486 Default value is “NULL”.
487
488 Example 1.18. Set the “extra_hdrs” parameter
489 ...
490 modparam("msilo", "extra_hdrs", "X-Extra: $tu\r\nY-Extra: foo\r\n")
491 ...
492
493 3.19. offline_message (string)
494
495 The body of the notification message. It can contain pseudo-variables.
496
497 Default value is “NULL”.
498
499 Example 1.19. Set the “offline_message” parameter
500 ...
501 modparam("msilo", "offline_message", "*** User $rU is offline!")
502 modparam("msilo", "offline_message", "<em>I am offline!</em>")
503 ...
504
505 3.20. content_type_hdr (string)
506
507 The value of the Content-Type header (including header name and ending
508 \r\n) to be added in notification messages. It must reflect what the
509 'offline_message' contains. It can contain pseudo-variables.
510
511 Default value is “NULL”.
512
513 Example 1.20. Set the “content_type_hdr” parameter
514 ...
515 modparam("msilo", "content_type_hdr", "Content-Type: text/plain\r\n")
516 modparam("msilo", "content_type_hdr", "Content-Type: text/html\r\n")
517 ...
518
519 3.21. reminder (string)
520
521 The SIP address used to send reminder messages. If this value is not
522 set, the reminder feature is disabled.
523
524 Default value is “NULL”.
525
526 Example 1.21. Set the “reminder” parameter
527 ...
528 modparam("msilo", "reminder", "sip:[email protected]")
529 ...
530
531 3.22. outbound_proxy (string)
532
533 The SIP address used as next hop when sending the message. Very useful
534 when using Kamailio with a domain name not in DNS, or when using a
535 separate Kamailio instance for msilo processing. If not set, the
536 message will be sent to the address in destination URI.
537
538 Default value is “NULL”.
539
540 Example 1.22. Set the “outbound_proxy” parameter
541 ...
542 modparam("msilo", "outbound_proxy", "sip:kamailio.org;transport=tcp")
543 ...
544
545 3.23. expire_time (int)
546
547 Expire time of stored messages - seconds. When this time passed, the
548 message is silently discarded from database.
549
550 Default value is “259200 (72 hours = 3 days)”.
551
552 Example 1.23. Set the “expire_time” parameter
553 ...
554 modparam("msilo", "expire_time", 36000)
555 ...
556
557 3.24. check_time (int)
558
559 Timer interval to check if dumped messages are sent OK - seconds. The
560 module keeps each request send by itself for a new online user and if
561 the reply is 2xx then the message is deleted from database.
562
563 Default value is “60”.
564
565 Example 1.24. Set the “check_time” parameter
566 ...
567 modparam("msilo", "check_time", 10)
568 ...
569
570 3.25. send_time (int)
571
572 Timer interval in seconds to check if there are reminder messages. The
573 module takes all reminder messages that must be sent at that moment or
574 before that moment.
575
576 If the value is 0, the reminder feature is disabled.
577
578 Default value is “0”.
579
580 Example 1.25. Set the “send_time” parameter
581 ...
582 modparam("msilo", "send_time", 60)
583 ...
584
585 3.26. clean_period (int)
586
587 Number of “check_time” cycles when to check if there are expired
588 messages in database.
589
590 Default value is “10”.
591
592 Example 1.26. Set the “clean_period” parameter
593 ...
594 modparam("msilo", "clean_period", 3)
595 ...
596
597 3.27. use_contact (int)
598
599 Turns on/off the usage of the “Contact” address to send notification
600 back to sender whose message is stored by MSILO.
601
602 Default value is “1 (0 = off, 1 = on)”.
603
604 Example 1.27. Set the “use_contact” parameter
605 ...
606 modparam("msilo", "use_contact", 0)
607 ...
608
609 3.28. snd_time_avp (str)
610
611 The name of an AVP which may contain the time when to send the received
612 message as reminder. The AVP is used only by m_store().
613
614 If the parameter is not set, the module does not look for this AVP. If
615 the value is set to a valid AVP name, then the module expects in the
616 AVP to be a time value in format “YYYYMMDDHHMMSS” (e.g.,
617 20060101201500).
618
619 Default value is “null”.
620
621 Example 1.28. Set the “snd_time_avp” parameter
622 ...
623 modparam("msilo", "snd_time_avp", "$avp(i:123)")
624 ...
625
626 3.29. add_date (int)
627
628 Whether to add as prefix the date when the message was stored.
629
630 Default value is “1” (1==on/0==off).
631
632 Example 1.29. Set the “add_date” parameter
633 ...
634 modparam("msilo", "add_date", 0)
635 ...
636
637 3.30. max_messages (int)
638
639 Maximum number of stored message for an AoR. Value 0 equals to no
640 limit.
641
642 Default value is 0.
643
644 Example 1.30. Set the “max_messages” parameter
645 ...
646 modparam("msilo", "max_messages", 0)
647 ...
648
649 3.31. add_contact (int)
650
651 Whether to add contact header to generated messages. The contact
652 address is the From URI.
653
654 Default value is “0” (1==on; 0==off as per RFC3428).
655
656 Example 1.31. Set the “add_contact” parameter
657 ...
658 modparam("msilo", "add_contact", 1)
659 ...
660
661 3.32. extra_hdrs_avp (str)
662
663 Name of an AVP which may contain extra headers that are stored with the
664 message when m_store() is called. These extra headers (if any) are then
665 included in MESSAGE request generated by m_dump().
666
667 If the parameter is not set, m_store() does not look for extra headers
668 from any AVP.
669
670 Default value is “null”.
671
672 Example 1.32. Set the “extra_hdrs_avp” parameter
673 ...
674 modparam("msilo", "extra_hdrs_avp", "$avp(msilo_extra_hdrs)")
675 ...
676
677 3.33. skip_notification_flag (int)
678
679 Flag to mark the message for which no notification should be sent back
680 to sender when storing in msilo. Valid value is in between 0 and 31.
681
682 Default value is “-1” (feature disabled).
683
684 Example 1.33. Set the “skip_notification_flag” parameter
685 ...
686 modparam("msilo", "skip_notification_flag", 18)
687 ...
688 setflag(18);
689 m_store(...);
690 ...
691
692 3.34. use_mode (int)
693
694 If set to 1, the call-id header of incoming MESSAGE is stored and
695 reused later for delivery MESSAGE.
696
697 Default value is “0”.
698
699 Example 1.34. Set the “use_mode” parameter
700 ...
701 modparam("msilo", "use_mode", 1)
702 ...
703
704 4. Functions
705
706 4.1. m_store([owner])
707 4.2. m_store_addrs(owner, srcaddr, dstaddr)
708 4.3. m_dump([owner])
709
710 4.1. m_store([owner])
711
712 The method stores certain parts of the current SIP request (it should
713 be called when the request type is MESSAGE and the destination user is
714 offline or his UA does not support MESSAGE requests). If the user is
715 registered with a UA which does not support MESSAGE requests you should
716 not use mode=“0” if you have changed the request uri with the contact
717 address of user's UA.
718
719 Meaning of the parameters is as follows:
720 * owner - is a string that must contain a SIP URI in whose inbox the
721 message will be stored. It can have any pseudo variable. If "owner"
722 is missing, the SIP address is taken from R-URI.
723
724 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
725
726 Example 1.35. m_store usage
727 ...
728 m_store();
729 m_store("$tu");
730 ...
731
732 4.2. m_store_addrs(owner, srcaddr, dstaddr)
733
734 Similar to m_store(), but instead of getting source user address from
735 From-URI and destination user address from To_URI, this function allows
736 to give them via parameters.
737
738 Meaning of the parameters is as follows:
739 * owner - is a string that must contain a SIP URI in whose inbox the
740 message will be stored. It can have any pseudo variable.
741 * srcaddr - is a string that must contain a SIP URI corresponding to
742 From user. It can have any pseudo variable.
743 * dstaddr - is a string that must contain a SIP URI correspinding to
744 To user. It can have any pseudo variable.
745
746 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
747
748 Example 1.36. m_store_addrs usage
749 ...
750 m_store_addrs("sip:[email protected]", "sip:[email protected]", "sip:[email protected]");
751 ...
752
753 4.3. m_dump([owner])
754
755 The method sends stored messages for the SIP user that has registered
756 to the contact address in the registration. The method should be called
757 when a REGISTER request is received and the “Expire” header has a value
758 greater than zero.
759
760 Meaning of the parameters is as follows:
761 * owner - is a string that must contain a SIP URI whose inbox will be
762 dumped. It can have any pseudo variable. If "owner" is missing, the
763 SIP address is taken from To URI.
764
765 This function can be used from REQUEST_ROUTE.
766
767 Example 1.37. m_dump usage
768 ...
769 m_dump();
770 m_dump("$fu");
771 ...
772
773 5. Statistics
774
775 5.1. stored_messages
776 5.2. dumped_messages
777 5.3. failed_messages
778 5.4. dumped_reminders
779 5.5. failed_reminders
780
781 5.1. stored_messages
782
783 The number of messages stored by msilo.
784
785 5.2. dumped_messages
786
787 The number of dumped messages.
788
789 5.3. failed_messages
790
791 The number of failed dumped messages.
792
793 5.4. dumped_reminders
794
795 The number of dumped reminder messages.
796
797 5.5. failed_reminders
798
799 The number of failed reminder messages.
800
801 6. Installation and Running
802
803 6.1. Kamailio config file
804
805 6.1. Kamailio config file
806
807 Next picture displays a sample usage of msilo.
808
809 Example 1.38. Kamailio config script - sample msilo usage
810 ...
811 #
812 # MSILO usage example
813 #
814 #
815
816
817 debug=9 # debug level (cmd line: -dddddddddd)
818 fork=no # don't fork
819 log_stderror=yes # log to stderr (cmd line: -E)
820
821
822 children=2 # number of children
823 check_via=no # (cmd. line: -v)
824 dns=off # (cmd. line: -r)
825 rev_dns=off # (cmd. line: -R)
826 port=5060
827
828 listen=10.0.0.2 # listen address
829
830 # ------------------ module loading ----------------------------------
831 mpath="/usr/local/lib/kamailio/modules/"
832
833 loadmodule "textops.so"
834
835 loadmodule "sl.so"
836 loadmodule "mysql.so"
837 loadmodule "maxfwd.so"
838 loadmodule "msilo.so"
839 loadmodule "tm.so"
840 loadmodule "registrar.so"
841 loadmodule "usrloc.so"
842
843 # ----------------- setting module-specific parameters ---------------
844
845 # -- registrar params --
846
847 modparam("registrar", "default_expires", 120)
848
849 # -- registrar params --
850
851 modparam("usrloc", "db_mode", 0)
852
853 # -- msilo params --
854
855 modparam("msilo","db_url","mysql://kamailio:kamailiorw@localhost/kamailio")
856 modparam("msilo","from_address","sip:[email protected]")
857 modparam("msilo","contact_hdr","Contact: [email protected]:5060;msilo=yes\r\
858 n")
859 modparam("msilo","content_type_hdr","Content-Type: text/plain\r\n")
860 modparam("msilo","offline_message","*** User $rU is offline!")
861
862
863 route{
864 if ( !mf_process_maxfwd_header("10") )
865 {
866 sl_send_reply("483","To Many Hops");
867 exit;
868 };
869
870
871 if (uri==myself) {
872 {
873 # for testing purposes, simply okay all REGISTERs
874 if (method=="REGISTER")
875 {
876 save("location");
877 log("REGISTER received -> dumping messages with MSILO\n");
878
879 # MSILO - dumping user's offline messages
880 if (m_dump())
881 {
882 log("MSILO: offline messages dumped - if they were\n");
883 }else{
884 log("MSILO: no offline messages dumped\n");
885 };
886 exit;
887 };
888
889 # domestic SIP destinations are handled using our USRLOC DB
890
891 if(!lookup("location"))
892 {
893 if (! t_newtran())
894 {
895 sl_reply_error();
896 exit;
897 };
898 # we do not care about anything else but MESSAGEs
899 if (!method=="MESSAGE")
900 {
901 if (!t_reply("404", "Not found"))
902 {
903 sl_reply_error();
904 };
905 exit;
906 };
907 log("MESSAGE received -> storing using MSILO\n");
908 # MSILO - storing as offline message
909 if (m_store("$ru"))
910 {
911 log("MSILO: offline message stored\n");
912 if (!t_reply("202", "Accepted"))
913 {
914 sl_reply_error();
915 };
916 }else{
917 log("MSILO: offline message NOT stored\n");
918 if (!t_reply("503", "Service Unavailable"))
919 {
920 sl_reply_error();
921 };
922 };
923 exit;
924 };
925 # if the downstream UA does not support MESSAGE requests
926 # go to failure_route[1]
927 t_on_failure("1");
928 t_relay();
929 exit;
930 };
931
932 # forward anything else
933 t_relay();
934 }
935
936 failure_route[1] {
937 # forwarding failed -- check if the request was a MESSAGE
938 if (!method=="MESSAGE")
939 {
940 exit;
941 };
942
943 log(1,"MSILO:the downstream UA doesn't support MESSAGEs\n");
944 # we have changed the R-URI with the contact address, ignore it now
945 if (m_store("$ou"))
946 {
947 log("MSILO: offline message stored\n");
948 t_reply("202", "Accepted");
949 }else{
950 log("MSILO: offline message NOT stored\n");
951 t_reply("503", "Service Unavailable");
952 };
953 }
954
955
956
957 ...