Merge kamailio modules into sip-router master branch
[sip-router] / examples / msilo.cfg
1 #
2 # MSILO usage example
3 #
4 # $ID: daniel $
5 #
6
7
8
9 children=2
10 check_via=no      # (cmd. line: -v)
11 dns=off           # (cmd. line: -r)
12 rev_dns=off       # (cmd. line: -R)
13
14
15 # ------------------ module loading ----------------------------------
16
17 loadmodule "../sip_router/modules/print/print.so"
18 loadmodule "../sip_router/modules/textops/textops.so"
19
20 loadmodule "../sip_router/modules/sl/sl.so"
21 loadmodule "../sip_router/modules/mysql/mysql.so"
22 loadmodule "../sip_router/modules/maxfwd/maxfwd.so"
23 loadmodule "../sip_router/modules/msilo/msilo.so"
24 loadmodule "../sip_router/modules/tm/tm.so"
25 loadmodule "../sip_router/modules/registrar/registrar.so"
26 loadmodule "../sip_router/modules/usrloc/usrloc.so"
27
28 # ----------------- setting module-specific parameters ---------------
29
30 # -- registrar params --
31
32 modparam("registrar", "default_expires", 120)
33
34 # -- registrar params --
35
36 modparam("usrloc", "db_mode", 0)
37
38 # -- msilo params --
39
40 modparam("msilo","db_url","mysql://user:xxx@127.0.0.1/msilo")
41 modparam("msilo","registrar","sip:registrar@mydomain.com")
42
43 # -- tm params --
44
45 modparam("tm", "fr_timer", 10 )
46 modparam("tm", "fr_inv_timer", 15 )
47 modparam("tm", "wt_timer", 10 )
48
49
50 route{
51         if ( !mf_process_maxfwd_header("10") )
52         {
53                 sl_send_reply("483","To Many Hops");
54                 drop();
55         };
56
57
58         if (uri==myself) {
59                 # for testing purposes, simply okay all REGISTERs
60                 if (method=="REGISTER")
61                 {
62                         save("location");
63                         log("REGISTER received -> dumping messages with MSILO\n");
64
65                         # MSILO - dumping user's offline messages
66                         if (m_dump())
67                         {
68                                 log("MSILO: offline messages dumped - if they were\n");
69                         }else{
70                                 log("MSILO: no offline messages dumped\n");
71                         };
72                         break;
73                 };
74
75                 # domestic SIP destinations are handled using our USRLOC DB
76                 
77                 if(!lookup("location")) 
78                 {
79                         if (! t_newtran())
80                         {
81                                 sl_reply_error();
82                                 break;
83                         };
84                         # we do not care about anything else but MESSAGEs
85                         if (!method=="MESSAGE")
86                         {
87                                 if (!t_reply("404", "Not found")) 
88                                 {
89                                         sl_reply_error();
90                                 };
91                         break;
92                         };
93                         log("MESSAGE received -> storing using MSILO\n");
94                         # MSILO - storing as offline message
95                         if (m_store("0"))
96                         {
97                                 log("MSILO: offline message stored\n");
98                                 if (!t_reply("202", "Accepted")) 
99                                 {
100                                         sl_reply_error();
101                                 };
102                         }else{
103                                 log("MSILO: offline message NOT stored\n");
104                                 if (!t_reply("503", "Service Unavailable")) 
105                                 {
106                                         sl_reply_error();
107                                 };
108                         };
109                         break;
110                 };
111                 # if the downstream UA does not support MESSAGE requests
112                 # go to failure_route[1]
113                 t_on_failure("1");
114                 t_relay();
115                 break;
116         };
117
118         # forward anything else
119         t_relay();
120 }
121
122 failure_route[1] {
123         # forwarding failed -- check if the request was a MESSAGE 
124         if (!method=="MESSAGE")
125         {
126         break;
127         };
128         
129         log(1,"MSILO: the downstream UA does not support MESSAGE requests ...\n");
130         # we have changed the R-URI with the contact address -- ignore it now
131         if (m_store("1"))
132         {
133                 log("MSILO: offline message stored\n");
134                 t_reply("202", "Accepted"); 
135         }else{
136                 log("MSILO: offline message NOT stored\n");
137                 t_reply("503", "Service Unavailable");
138         };
139 }
140
141