Browse code

* Added support for adding extra headers into MESSAGEs sent out from silo by m_dump().

Juha Heinanen authored on 09/05/2009 16:03:52
Showing 6 changed files
... ...
@@ -4,73 +4,85 @@ Daniel-Constantin Mierla
4 4
 
5 5
    <miconda@gmail.com>
6 6
 
7
+Juha Heinanen
8
+
9
+   <jh@tutpro.com>
10
+
7 11
 Edited by
8 12
 
9 13
 Daniel-Constantin Mierla
10 14
 
11 15
    <miconda@gmail.com>
12 16
 
17
+Edited by
18
+
19
+Juha Heinanen
20
+
21
+   <jh@tutpro.com>
22
+
13 23
    Copyright � 2003 FhG FOKUS
24
+
25
+   Copyright � 2009 Juha Heinanen
14 26
    Revision History
15
-   Revision $Revision$ $Date: 2008-08-06 12:08:33 +0200
16
-                              (Mi, 06 Aug 2008) $
17
-     __________________________________________________________
27
+   Revision $Revision$ $Date$
28
+     __________________________________________________________________
18 29
 
19 30
    Table of Contents
20 31
 
21 32
    1. Admin Guide
22 33
 
23
-        1.1. Overview
24
-        1.2. Dependencies
25
-
26
-              1.2.1. Kamailio modules
27
-              1.2.2. External libraries or applications
28
-
29
-        1.3. Exported Parameters
30
-
31
-              1.3.1. db_url (string)
32
-              1.3.2. db_table (string)
33
-              1.3.3. from_address (string)
34
-              1.3.4. contact_hdr (string)
35
-              1.3.5. offline_message (string)
36
-              1.3.6. content_type_hdr (string)
37
-              1.3.7. reminder (string)
38
-              1.3.8. outbound_proxy (string)
39
-              1.3.9. expire_time (int)
40
-              1.3.10. check_time (int)
41
-              1.3.11. send_time (int)
42
-              1.3.12. clean_period (int)
43
-              1.3.13. use_contact (int)
44
-              1.3.14. sc_mid (string)
45
-              1.3.15. sc_from (string)
46
-              1.3.16. sc_to (string)
47
-              1.3.17. sc_uri_user (string)
48
-              1.3.18. sc_uri_host (string)
49
-              1.3.19. sc_body (string)
50
-              1.3.20. sc_ctype (string)
51
-              1.3.21. sc_exp_time (string)
52
-              1.3.22. sc_inc_time (string)
53
-              1.3.23. sc_snd_time (string)
54
-              1.3.24. snd_time_avp (str)
55
-              1.3.25. add_date (int)
56
-              1.3.26. max_messages (int)
57
-
58
-        1.4. Exported Functions
59
-
60
-              1.4.1. m_store([owner])
61
-              1.4.2. m_dump([owner])
62
-
63
-        1.5. Exported Statistics
64
-
65
-              1.5.1. stored_messages
66
-              1.5.2. dumped_messages
67
-              1.5.3. failed_messages
68
-              1.5.4. dumped_reminders
69
-              1.5.5. failed_reminders
70
-
71
-        1.6. Installation and Running
72
-
73
-              1.6.1. Kamailio config file
34
+        1. Overview
35
+        2. Dependencies
36
+
37
+              2.1. Kamailio modules
38
+              2.2. External libraries or applications
39
+
40
+        3. Exported Parameters
41
+
42
+              3.1. db_url (string)
43
+              3.2. db_table (string)
44
+              3.3. from_address (string)
45
+              3.4. contact_hdr (string)
46
+              3.5. extra_hdrs (string)
47
+              3.6. offline_message (string)
48
+              3.7. content_type_hdr (string)
49
+              3.8. reminder (string)
50
+              3.9. outbound_proxy (string)
51
+              3.10. expire_time (int)
52
+              3.11. check_time (int)
53
+              3.12. send_time (int)
54
+              3.13. clean_period (int)
55
+              3.14. use_contact (int)
56
+              3.15. sc_mid (string)
57
+              3.16. sc_from (string)
58
+              3.17. sc_to (string)
59
+              3.18. sc_uri_user (string)
60
+              3.19. sc_uri_host (string)
61
+              3.20. sc_body (string)
62
+              3.21. sc_ctype (string)
63
+              3.22. sc_exp_time (string)
64
+              3.23. sc_inc_time (string)
65
+              3.24. sc_snd_time (string)
66
+              3.25. snd_time_avp (str)
67
+              3.26. add_date (int)
68
+              3.27. max_messages (int)
69
+
70
+        4. Exported Functions
71
+
72
+              4.1. m_store([owner])
73
+              4.2. m_dump([owner])
74
+
75
+        5. Exported Statistics
76
+
77
+              5.1. stored_messages
78
+              5.2. dumped_messages
79
+              5.3. failed_messages
80
+              5.4. dumped_reminders
81
+              5.5. failed_reminders
82
+
83
+        6. Installation and Running
84
+
85
+              6.1. Kamailio config file
74 86
 
75 87
    List of Examples
76 88
 
... ...
@@ -78,86 +90,170 @@ Daniel-Constantin Mierla
78 90
    1.2. Set the "db_table" parameter
79 91
    1.3. Set the "from_address" parameter
80 92
    1.4. Set the "contact_hdr" parameter
81
-   1.5. Set the "offline_message" parameter
82
-   1.6. Set the "content_type_hdr" parameter
83
-   1.7. Set the "reminder" parameter
84
-   1.8. Set the "outbound_proxy" parameter
85
-   1.9. Set the "expire_time" parameter
86
-   1.10. Set the "check_time" parameter
87
-   1.11. Set the "send_time" parameter
88
-   1.12. Set the "clean_period" parameter
89
-   1.13. Set the "use_contact" parameter
90
-   1.14. Set the "sc_mid" parameter
91
-   1.15. Set the "sc_from" parameter
92
-   1.16. Set the "sc_to" parameter
93
-   1.17. Set the "sc_uri_user" parameter
94
-   1.18. Set the "sc_uri_host" parameter
95
-   1.19. Set the "sc_body" parameter
96
-   1.20. Set the "sc_ctype" parameter
97
-   1.21. Set the "sc_exp_time" parameter
98
-   1.22. Set the "sc_inc_time" parameter
99
-   1.23. Set the "sc_snd_time" parameter
100
-   1.24. Set the "snd_time_avp" parameter
101
-   1.25. Set the "add_date" parameter
102
-   1.26. Set the "max_messages" parameter
103
-   1.27. m_store usage
104
-   1.28. m_dump usage
105
-   1.29. Kamailio config script - sample msilo usage
93
+   1.5. Set the "extra_hdrs" parameter
94
+   1.6. Set the "offline_message" parameter
95
+   1.7. Set the "content_type_hdr" parameter
96
+   1.8. Set the "reminder" parameter
97
+   1.9. Set the "outbound_proxy" parameter
98
+   1.10. Set the "expire_time" parameter
99
+   1.11. Set the "check_time" parameter
100
+   1.12. Set the "send_time" parameter
101
+   1.13. Set the "clean_period" parameter
102
+   1.14. Set the "use_contact" parameter
103
+   1.15. Set the "sc_mid" parameter
104
+   1.16. Set the "sc_from" parameter
105
+   1.17. Set the "sc_to" parameter
106
+   1.18. Set the "sc_uri_user" parameter
107
+   1.19. Set the "sc_uri_host" parameter
108
+   1.20. Set the "sc_body" parameter
109
+   1.21. Set the "sc_ctype" parameter
110
+   1.22. Set the "sc_exp_time" parameter
111
+   1.23. Set the "sc_inc_time" parameter
112
+   1.24. Set the "sc_snd_time" parameter
113
+   1.25. Set the "snd_time_avp" parameter
114
+   1.26. Set the "add_date" parameter
115
+   1.27. Set the "max_messages" parameter
116
+   1.28. m_store usage
117
+   1.29. m_dump usage
118
+   1.30. Kamailio config script - sample msilo usage
106 119
 
107 120
 Chapter 1. Admin Guide
108 121
 
109
-1.1. Overview
122
+   Table of Contents
110 123
 
111
-   This modules provides offline message storage for the Kamailio
112
-   SIP Router. It stores received messages for an offline user and
124
+   1. Overview
125
+   2. Dependencies
126
+
127
+        2.1. Kamailio modules
128
+        2.2. External libraries or applications
129
+
130
+   3. Exported Parameters
131
+
132
+        3.1. db_url (string)
133
+        3.2. db_table (string)
134
+        3.3. from_address (string)
135
+        3.4. contact_hdr (string)
136
+        3.5. extra_hdrs (string)
137
+        3.6. offline_message (string)
138
+        3.7. content_type_hdr (string)
139
+        3.8. reminder (string)
140
+        3.9. outbound_proxy (string)
141
+        3.10. expire_time (int)
142
+        3.11. check_time (int)
143
+        3.12. send_time (int)
144
+        3.13. clean_period (int)
145
+        3.14. use_contact (int)
146
+        3.15. sc_mid (string)
147
+        3.16. sc_from (string)
148
+        3.17. sc_to (string)
149
+        3.18. sc_uri_user (string)
150
+        3.19. sc_uri_host (string)
151
+        3.20. sc_body (string)
152
+        3.21. sc_ctype (string)
153
+        3.22. sc_exp_time (string)
154
+        3.23. sc_inc_time (string)
155
+        3.24. sc_snd_time (string)
156
+        3.25. snd_time_avp (str)
157
+        3.26. add_date (int)
158
+        3.27. max_messages (int)
159
+
160
+   4. Exported Functions
161
+
162
+        4.1. m_store([owner])
163
+        4.2. m_dump([owner])
164
+
165
+   5. Exported Statistics
166
+
167
+        5.1. stored_messages
168
+        5.2. dumped_messages
169
+        5.3. failed_messages
170
+        5.4. dumped_reminders
171
+        5.5. failed_reminders
172
+
173
+   6. Installation and Running
174
+
175
+        6.1. Kamailio config file
176
+
177
+1. Overview
178
+
179
+   This modules provides offline message storage for the Kamailio SIP
180
+   Server Platform. It stores received messages for an offline user and
113 181
    sends them when the user becomes online.
114 182
 
115
-   For each message, the modules stores "Request-URI" ("R-URI")
116
-   only if it is a complete address of record
117
-   ("username@hostname"), URI from "To" header, URI from "From"
118
-   header, incoming time, expiration time, content type and body
119
-   of the message. If "R-URI" is not an address of record (it
120
-   might be the contact address for current SIP session) the URI
121
-   from "To" header will be used as R-URI.
183
+   For each message, the modules stores "Request-URI" ("R-URI") only if it
184
+   is a complete address of record ("username@hostname"), URI from "To"
185
+   header, URI from "From" header, incoming time, expiration time, content
186
+   type and body of the message. If "R-URI" is not an address of record
187
+   (it might be the contact address for current SIP session) the URI from
188
+   "To" header will be used as R-URI.
122 189
 
123 190
    When the expiration time passed, the message is discarded from
124
-   database. Expiration time is computed based on incoming time
125
-   and one of the module's parameters.
191
+   database. Expiration time is computed based on incoming time and one of
192
+   the module's parameters.
126 193
 
127
-   Every time when a user registers with Kamailio, the module is
128
-   looking in database for offline messages intended for that
129
-   user. All of them will be sent to contact address provided in
130
-   REGISTER request.
194
+   Every time when a user registers with Kamailio, the module is looking
195
+   in database for offline messages intended for that user. All of them
196
+   will be sent to contact address provided in REGISTER request.
131 197
 
132
-   It may happen the SIP user to be registered but his SIP User
133
-   Agent to have no support for MESSAGE request. In this case it
134
-   should be used the "failure_route" to store the undelivered
135
-   requests.
198
+   It may happen the SIP user to be registered but his SIP User Agent to
199
+   have no support for MESSAGE request. In this case it should be used the
200
+   "failure_route" to store the undelivered requests.
136 201
 
137
-   Another functionality provided by the modules is to send
138
-   messages at a certain time -- the reminder functionality. Using
139
-   config logic, a received message can be stored and delivered at
140
-   a time specified while storing with the 'snd_time_avp'.
202
+   Another functionality provided by the modules is to send messages at a
203
+   certain time -- the reminder functionality. Using config logic, a
204
+   received message can be stored and delivered at a time specified while
205
+   storing with the 'snd_time_avp'.
141 206
 
142
-1.2. Dependencies
207
+2. Dependencies
143 208
 
144
-1.2.1. Kamailio modules
209
+   2.1. Kamailio modules
210
+   2.2. External libraries or applications
211
+
212
+2.1. Kamailio modules
145 213
 
146 214
    The following modules must be loaded before this module:
147
-     * database module - mysql, dbtext or other module that
148
-       implements the "db" interface and provides support for
149
-       storing/receiving data to/from a database system.
215
+     * database module - mysql, dbtext or other module that implements the
216
+       "db" interface and provides support for storing/receiving data
217
+       to/from a database system.
150 218
      * TM--transaction module--is used to send SIP requests.
151 219
 
152
-1.2.2. External libraries or applications
220
+2.2. External libraries or applications
153 221
 
154
-   The following libraries or applications must be installed
155
-   before running Kamailio with this module:
222
+   The following libraries or applications must be installed before
223
+   running Kamailio with this module:
156 224
      * none.
157 225
 
158
-1.3. Exported Parameters
159
-
160
-1.3.1. db_url (string)
226
+3. Exported Parameters
227
+
228
+   3.1. db_url (string)
229
+   3.2. db_table (string)
230
+   3.3. from_address (string)
231
+   3.4. contact_hdr (string)
232
+   3.5. extra_hdrs (string)
233
+   3.6. offline_message (string)
234
+   3.7. content_type_hdr (string)
235
+   3.8. reminder (string)
236
+   3.9. outbound_proxy (string)
237
+   3.10. expire_time (int)
238
+   3.11. check_time (int)
239
+   3.12. send_time (int)
240
+   3.13. clean_period (int)
241
+   3.14. use_contact (int)
242
+   3.15. sc_mid (string)
243
+   3.16. sc_from (string)
244
+   3.17. sc_to (string)
245
+   3.18. sc_uri_user (string)
246
+   3.19. sc_uri_host (string)
247
+   3.20. sc_body (string)
248
+   3.21. sc_ctype (string)
249
+   3.22. sc_exp_time (string)
250
+   3.23. sc_inc_time (string)
251
+   3.24. sc_snd_time (string)
252
+   3.25. snd_time_avp (str)
253
+   3.26. add_date (int)
254
+   3.27. max_messages (int)
255
+
256
+3.1. db_url (string)
161 257
 
162 258
    Database URL.
163 259
 
... ...
@@ -168,7 +264,7 @@ Chapter 1. Admin Guide
168 264
 modparam("msilo", "db_url", "mysql://user:passwd@host.com/dbname")
169 265
 ...
170 266
 
171
-1.3.2. db_table (string)
267
+3.2. db_table (string)
172 268
 
173 269
    The name of table where to store the messages.
174 270
 
... ...
@@ -179,13 +275,12 @@ modparam("msilo", "db_url", "mysql://user:passwd@host.com/dbname")
179 275
 modparam("msilo", "db_table", "silo")
180 276
 ...
181 277
 
182
-1.3.3. from_address (string)
278
+3.3. from_address (string)
183 279
 
184
-   The SIP address used to inform users that destination of their
185
-   message is not online and the message will be delivered next
186
-   time when that user goes online. If the parameter is not set,
187
-   the module will not send any notification. It can contain
188
-   pseudo-variables.
280
+   The SIP address used to inform users that destination of their message
281
+   is not online and the message will be delivered next time when that
282
+   user goes online. If the parameter is not set, the module will not send
283
+   any notification. It can contain pseudo-variables.
189 284
 
190 285
    Default value is "NULL".
191 286
 
... ...
@@ -195,11 +290,10 @@ modparam("msilo", "from_address", "sip:registrar@example.org")
195 290
 modparam("msilo", "from_address", "sip:$rU@example.org")
196 291
 ...
197 292
 
198
-1.3.4. contact_hdr (string)
293
+3.4. contact_hdr (string)
199 294
 
200
-   The value of the Contact header (including header name and
201
-   ending \r\n) to be added in notification messages. It can
202
-   contain pseudo-variables.
295
+   The value of the Contact header (including header name and ending \r\n)
296
+   to be added in notification messages. It can contain pseudo-variables.
203 297
 
204 298
    Default value is "NULL".
205 299
 
... ...
@@ -208,356 +302,370 @@ modparam("msilo", "from_address", "sip:$rU@example.org")
208 302
 modparam("msilo", "contact_hdr", "Contact: <sip:null@example.com>\r\n")
209 303
 ...
210 304
 
211
-1.3.5. offline_message (string)
305
+3.5. extra_hdrs (string)
212 306
 
213
-   The body of the notification message. It can contain
214
-   pseudo-variables.
307
+   Extra headers (each ending with \r\n) to be added in messages sent from
308
+   silo by m_dump. It can contain pseudo-variables.
215 309
 
216 310
    Default value is "NULL".
217 311
 
218
-   Example 1.5. Set the "offline_message" parameter
312
+   Example 1.5. Set the "extra_hdrs" parameter
313
+...
314
+modparam("msilo", "contact_hdr", "X-Extra: $tu\r\nY-Extra: foo\r\n")
315
+...
316
+
317
+3.6. offline_message (string)
318
+
319
+   The body of the notification message. It can contain pseudo-variables.
320
+
321
+   Default value is "NULL".
322
+
323
+   Example 1.6. Set the "offline_message" parameter
219 324
 ...
220 325
 modparam("msilo", "offline_message", "*** User $rU is offline!")
221 326
 modparam("msilo", "offline_message", "<em>I am offline!</em>")
222 327
 ...
223 328
 
224
-1.3.6. content_type_hdr (string)
329
+3.7. content_type_hdr (string)
225 330
 
226
-   The value of the Content-Type header (including header name and
227
-   ending \r\n) to be added in notification messages. It must
228
-   reflect what the 'offline_message' contains. It can contain
229
-   pseudo-variables.
331
+   The value of the Content-Type header (including header name and ending
332
+   \r\n) to be added in notification messages. It must reflect what the
333
+   'offline_message' contains. It can contain pseudo-variables.
230 334
 
231 335
    Default value is "NULL".
232 336
 
233
-   Example 1.6. Set the "content_type_hdr" parameter
337
+   Example 1.7. Set the "content_type_hdr" parameter
234 338
 ...
235 339
 modparam("msilo", "content_type_hdr", "Content-Type: text/plain\r\n")
236 340
 modparam("msilo", "content_type_hdr", "Content-Type: text/html\r\n")
237 341
 ...
238 342
 
239
-1.3.7. reminder (string)
343
+3.8. reminder (string)
240 344
 
241
-   The SIP address used to send reminder messages. If this value
242
-   is not set, the reminder feature is disabled.
345
+   The SIP address used to send reminder messages. If this value is not
346
+   set, the reminder feature is disabled.
243 347
 
244 348
    Default value is "NULL".
245 349
 
246
-   Example 1.7. Set the "reminder" parameter
350
+   Example 1.8. Set the "reminder" parameter
247 351
 ...
248 352
 modparam("msilo", "reminder", "sip:registrar@example.org")
249 353
 ...
250 354
 
251
-1.3.8. outbound_proxy (string)
355
+3.9. outbound_proxy (string)
252 356
 
253
-   The SIP address used as next hop when sending the message. Very
254
-   useful when using Kamailio with a domain name not in DNS, or
255
-   when using a separate Kamailio instance for msilo processing.
256
-   If not set, the message will be sent to the address in
257
-   destination URI.
357
+   The SIP address used as next hop when sending the message. Very useful
358
+   when using Kamailio with a domain name not in DNS, or when using a
359
+   separate Kamailio instance for msilo processing. If not set, the
360
+   message will be sent to the address in destination URI.
258 361
 
259 362
    Default value is "NULL".
260 363
 
261
-   Example 1.8. Set the "outbound_proxy" parameter
364
+   Example 1.9. Set the "outbound_proxy" parameter
262 365
 ...
263 366
 modparam("msilo", "outbound_proxy", "sip:kamailio.org;transport=tcp")
264 367
 ...
265 368
 
266
-1.3.9. expire_time (int)
369
+3.10. expire_time (int)
267 370
 
268
-   Expire time of stored messages - seconds. When this time
269
-   passed, the message is silently discarded from database.
371
+   Expire time of stored messages - seconds. When this time passed, the
372
+   message is silently discarded from database.
270 373
 
271 374
    Default value is "259200 (72 hours = 3 days)".
272 375
 
273
-   Example 1.9. Set the "expire_time" parameter
376
+   Example 1.10. Set the "expire_time" parameter
274 377
 ...
275 378
 modparam("msilo", "expire_time", 36000)
276 379
 ...
277 380
 
278
-1.3.10. check_time (int)
381
+3.11. check_time (int)
279 382
 
280
-   Timer interval to check if dumped messages are sent OK -
281
-   seconds. The module keeps each request send by itself for a new
282
-   online user and if the reply is 2xx then the message is deleted
283
-   from database.
383
+   Timer interval to check if dumped messages are sent OK - seconds. The
384
+   module keeps each request send by itself for a new online user and if
385
+   the reply is 2xx then the message is deleted from database.
284 386
 
285 387
    Default value is "30".
286 388
 
287
-   Example 1.10. Set the "check_time" parameter
389
+   Example 1.11. Set the "check_time" parameter
288 390
 ...
289 391
 modparam("msilo", "check_time", 10)
290 392
 ...
291 393
 
292
-1.3.11. send_time (int)
394
+3.12. send_time (int)
293 395
 
294
-   Timer interval in seconds to check if there are reminder
295
-   messages. The module takes all reminder messages that must be
296
-   sent at that moment or before that moment.
396
+   Timer interval in seconds to check if there are reminder messages. The
397
+   module takes all reminder messages that must be sent at that moment or
398
+   before that moment.
297 399
 
298 400
    If the value is 0, the reminder feature is disabled.
299 401
 
300 402
    Default value is "0".
301 403
 
302
-   Example 1.11. Set the "send_time" parameter
404
+   Example 1.12. Set the "send_time" parameter
303 405
 ...
304 406
 modparam("msilo", "send_time", 60)
305 407
 ...
306 408
 
307
-1.3.12. clean_period (int)
409
+3.13. clean_period (int)
308 410
 
309
-   Number of "check_time" cycles when to check if there are
310
-   expired messages in database.
411
+   Number of "check_time" cycles when to check if there are expired
412
+   messages in database.
311 413
 
312 414
    Default value is "5".
313 415
 
314
-   Example 1.12. Set the "clean_period" parameter
416
+   Example 1.13. Set the "clean_period" parameter
315 417
 ...
316 418
 modparam("msilo", "clean_period", 3)
317 419
 ...
318 420
 
319
-1.3.13. use_contact (int)
421
+3.14. use_contact (int)
320 422
 
321
-   Turns on/off the usage of the Contact address to send
322
-   notification back to sender whose message is stored by MSILO.
423
+   Turns on/off the usage of the Contact address to send notification back
424
+   to sender whose message is stored by MSILO.
323 425
 
324 426
    Default value is "1 (0 = off, 1 = on)".
325 427
 
326
-   Example 1.13. Set the "use_contact" parameter
428
+   Example 1.14. Set the "use_contact" parameter
327 429
 ...
328 430
 modparam("msilo", "use_contact", 0)
329 431
 ...
330 432
 
331
-1.3.14. sc_mid (string)
433
+3.15. sc_mid (string)
332 434
 
333 435
    The name of the column in silo table, storing message id.
334 436
 
335 437
    Default value is "mid".
336 438
 
337
-   Example 1.14. Set the "sc_mid" parameter
439
+   Example 1.15. Set the "sc_mid" parameter
338 440
 ...
339 441
 modparam("msilo", "sc_mid", "other_mid")
340 442
 ...
341 443
 
342
-1.3.15. sc_from (string)
444
+3.16. sc_from (string)
343 445
 
344
-   The name of the column in silo table, storing the source
345
-   address.
446
+   The name of the column in silo table, storing the source address.
346 447
 
347 448
    Default value is "src_addr".
348 449
 
349
-   Example 1.15. Set the "sc_from" parameter
450
+   Example 1.16. Set the "sc_from" parameter
350 451
 ...
351 452
 modparam("msilo", "sc_from", "source_address")
352 453
 ...
353 454
 
354
-1.3.16. sc_to (string)
455
+3.17. sc_to (string)
355 456
 
356
-   The name of the column in silo table, storing the destination
357
-   address.
457
+   The name of the column in silo table, storing the destination address.
358 458
 
359 459
    Default value is "dst_addr".
360 460
 
361
-   Example 1.16. Set the "sc_to" parameter
461
+   Example 1.17. Set the "sc_to" parameter
362 462
 ...
363 463
 modparam("msilo", "sc_to", "destination_address")
364 464
 ...
365 465
 
366
-1.3.17. sc_uri_user (string)
466
+3.18. sc_uri_user (string)
367 467
 
368 468
    The name of the column in silo table, storing the user name.
369 469
 
370 470
    Default value is "username".
371 471
 
372
-   Example 1.17. Set the "sc_uri_user" parameter
472
+   Example 1.18. Set the "sc_uri_user" parameter
373 473
 ...
374 474
 modparam("msilo", "sc_uri_user", "user")
375 475
 ...
376 476
 
377
-1.3.18. sc_uri_host (string)
477
+3.19. sc_uri_host (string)
378 478
 
379 479
    The name of the column in silo table, storing the domain.
380 480
 
381 481
    Default value is "domain".
382 482
 
383
-   Example 1.18. Set the "sc_uri_host" parameter
483
+   Example 1.19. Set the "sc_uri_host" parameter
384 484
 ...
385 485
 modparam("msilo", "sc_uri_host", "domain")
386 486
 ...
387 487
 
388
-1.3.19. sc_body (string)
488
+3.20. sc_body (string)
389 489
 
390 490
    The name of the column storing the message body in silo table.
391 491
 
392 492
    Default value is "body".
393 493
 
394
-   Example 1.19. Set the "sc_body" parameter
494
+   Example 1.20. Set the "sc_body" parameter
395 495
 ...
396 496
 modparam("msilo", "sc_body", "message_body")
397 497
 ...
398 498
 
399
-1.3.20. sc_ctype (string)
499
+3.21. sc_ctype (string)
400 500
 
401 501
    The name of the column in silo table, storing content type.
402 502
 
403 503
    Default value is "ctype".
404 504
 
405
-   Example 1.20. Set the "sc_ctype" parameter
505
+   Example 1.21. Set the "sc_ctype" parameter
406 506
 ...
407 507
 modparam("msilo", "sc_ctype", "content_type")
408 508
 ...
409 509
 
410
-1.3.21. sc_exp_time (string)
510
+3.22. sc_exp_time (string)
411 511
 
412
-   The name of the column in silo table, storing the expire time
413
-   of the message.
512
+   The name of the column in silo table, storing the expire time of the
513
+   message.
414 514
 
415 515
    Default value is "exp_time".
416 516
 
417
-   Example 1.21. Set the "sc_exp_time" parameter
517
+   Example 1.22. Set the "sc_exp_time" parameter
418 518
 ...
419 519
 modparam("msilo", "sc_exp_time", "expire_time")
420 520
 ...
421 521
 
422
-1.3.22. sc_inc_time (string)
522
+3.23. sc_inc_time (string)
423 523
 
424
-   The name of the column in silo table, storing the incoming time
425
-   of the message.
524
+   The name of the column in silo table, storing the incoming time of the
525
+   message.
426 526
 
427 527
    Default value is "inc_time".
428 528
 
429
-   Example 1.22. Set the "sc_inc_time" parameter
529
+   Example 1.23. Set the "sc_inc_time" parameter
430 530
 ...
431 531
 modparam("msilo", "sc_inc_time", "incoming_time")
432 532
 ...
433 533
 
434
-1.3.23. sc_snd_time (string)
534
+3.24. sc_snd_time (string)
435 535
 
436
-   The name of the column in silo table, storing the send time for
437
-   the reminder.
536
+   The name of the column in silo table, storing the send time for the
537
+   reminder.
438 538
 
439 539
    Default value is "snd_time".
440 540
 
441
-   Example 1.23. Set the "sc_snd_time" parameter
541
+   Example 1.24. Set the "sc_snd_time" parameter
442 542
 ...
443 543
 modparam("msilo", "sc_snd_time", "send_reminder_time")
444 544
 ...
445 545
 
446
-1.3.24. snd_time_avp (str)
546
+3.25. snd_time_avp (str)
447 547
 
448
-   The name of an AVP which may contain the time when to sent the
449
-   received message as reminder.The AVP is used ony by m_store().
548
+   The name of an AVP which may contain the time when to sent the received
549
+   message as reminder.The AVP is used ony by m_store().
450 550
 
451
-   If the parameter is not set, the module does not look for this
452
-   AVP. If the value is set to a valid AVP name, then the module
453
-   expects in the AVP to be a time value in format YYYYMMDDHHMMSS
454
-   (e.g., 20060101201500).
551
+   If the parameter is not set, the module does not look for this AVP. If
552
+   the value is set to a valid AVP name, then the module expects in the
553
+   AVP to be a time value in format YYYYMMDDHHMMSS (e.g., 20060101201500).
455 554
 
456 555
    Default value is "null".
457 556
 
458
-   Example 1.24. Set the "snd_time_avp" parameter
557
+   Example 1.25. Set the "snd_time_avp" parameter
459 558
 ...
460 559
 modparam("msilo", "snd_time_avp", "$avp(i:123)")
461 560
 ...
462 561
 
463
-1.3.25. add_date (int)
562
+3.26. add_date (int)
464 563
 
465 564
    Wheter to add as prefix the date when the message was stored.
466 565
 
467 566
    Default value is "1" (1==on/0==off).
468 567
 
469
-   Example 1.25. Set the "add_date" parameter
568
+   Example 1.26. Set the "add_date" parameter
470 569
 ...
471 570
 modparam("msilo", "add_date", 0)
472 571
 ...
473 572
 
474
-1.3.26. max_messages (int)
573
+3.27. max_messages (int)
475 574
 
476
-   Maximum number of stored message for an AoR. Value 0 equals to
477
-   no limit.
575
+   Maximum number of stored message for an AoR. Value 0 equals to no
576
+   limit.
478 577
 
479 578
    Default value is 0.
480 579
 
481
-   Example 1.26. Set the "max_messages" parameter
580
+   Example 1.27. Set the "max_messages" parameter
482 581
 ...
483 582
 modparam("msilo", "max_messages", 0)
484 583
 ...
485 584
 
486
-1.4. Exported Functions
585
+4. Exported Functions
586
+
587
+   4.1. m_store([owner])
588
+   4.2. m_dump([owner])
487 589
 
488
-1.4.1. m_store([owner])
590
+4.1. m_store([owner])
489 591
 
490
-   The method stores certain parts of the current SIP request (it
491
-   should be called when the request type is MESSAGE and the
492
-   destination user is offline or his UA does not support MESSAGE
493
-   requests). If the user is registered with a UA which does not
494
-   support MESSAGE requests you should not use mode="0" if you
495
-   have changed the request uri with the contact address of user's
496
-   UA.
592
+   The method stores certain parts of the current SIP request (it should
593
+   be called when the request type is MESSAGE and the destination user is
594
+   offline or his UA does not support MESSAGE requests). If the user is
595
+   registered with a UA which does not support MESSAGE requests you should
596
+   not use mode="0" if you have changed the request uri with the contact
597
+   address of user's UA.
497 598
 
498 599
    Meaning of the parameters is as follows:
499
-     * owner - is a string that must contain a SIP URI in whose
500
-       inbox the message will be stored. It can have any pseudo
501
-       variable. If "owner" is missing, the SIP address is taken
502
-       from R-URI.
600
+     * owner - is a string that must contain a SIP URI in whose inbox the
601
+       message will be stored. It can have any pseudo variable. If "owner"
602
+       is missing, the SIP address is taken from R-URI.
503 603
 
504 604
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
505 605
 
506
-   Example 1.27. m_store usage
606
+   Example 1.28. m_store usage
507 607
 ...
508 608
 m_store();
509 609
 m_store("$tu");
510 610
 ...
511 611
 
512
-1.4.2. m_dump([owner])
612
+4.2. m_dump([owner])
513 613
 
514
-   The method sends stored messages for the SIP user that is going
515
-   to register to his actual contact address. The method should be
516
-   called when a REGISTER request is received and the "Expire"
517
-   header has a value greater than zero.
614
+   The method sends stored messages for the SIP user that is going to
615
+   register to his actual contact address. The method should be called
616
+   when a REGISTER request is received and the "Expire" header has a value
617
+   greater than zero.
518 618
 
519 619
    Meaning of the parameters is as follows:
520
-     * owner - is a string that must contain a SIP URI whose inbox
521
-       will be dumped. It can have any pseudo variable. If "owner"
522
-       is missing, the SIP address is taken from To URI.
620
+     * owner - is a string that must contain a SIP URI whose inbox will be
621
+       dumped. It can have any pseudo variable. If "owner" is missing, the
622
+       SIP address is taken from To URI.
523 623
 
524 624
    This function can be used from REQUEST_ROUTE.
525 625
 
526
-   Example 1.28. m_dump usage
626
+   Example 1.29. m_dump usage
527 627
 ...
528 628
 m_dump();
529 629
 m_dump("$fu");
530 630
 ...
531 631
 
532
-1.5. Exported Statistics
632
+5. Exported Statistics
533 633
 
534
-1.5.1. stored_messages
634
+   5.1. stored_messages
635
+   5.2. dumped_messages
636
+   5.3. failed_messages
637
+   5.4. dumped_reminders
638
+   5.5. failed_reminders
639
+
640
+5.1. stored_messages
535 641
 
536 642
    The number of messages stored by msilo.
537 643
 
538
-1.5.2. dumped_messages
644
+5.2. dumped_messages
539 645
 
540 646
    The number of dumped messages.
541 647
 
542
-1.5.3. failed_messages
648
+5.3. failed_messages
543 649
 
544 650
    The number of failed dumped messages.
545 651
 
546
-1.5.4. dumped_reminders
652
+5.4. dumped_reminders
547 653
 
548 654
    The number of dumped reminder messages.
549 655
 
550
-1.5.5. failed_reminders
656
+5.5. failed_reminders
551 657
 
552 658
    The number of failed reminder messages.
553 659
 
554
-1.6. Installation and Running
660
+6. Installation and Running
661
+
662
+   6.1. Kamailio config file
555 663
 
556
-1.6.1. Kamailio config file
664
+6.1. Kamailio config file
557 665
 
558 666
    Next picture displays a sample usage of msilo.
559 667
 
560
-   Example 1.29. Kamailio config script - sample msilo usage
668
+   Example 1.30. Kamailio config script - sample msilo usage
561 669
 ...
562 670
 # $Id$
563 671
 #
... ...
@@ -606,8 +714,8 @@ modparam("usrloc", "db_mode", 0)
606 714
 
607 715
 modparam("msilo","db_url","mysql://openser:openserrw@localhost/openser")
608 716
 modparam("msilo","from_address","sip:registrar@kamailio.org")
609
-modparam("msilo","contact_hdr","Contact: registrar@192.168.1.2:5060;msil
610
-o=yes\r\n")
717
+modparam("msilo","contact_hdr","Contact: registrar@192.168.1.2:5060;msilo=yes\r\
718
+n")
611 719
 modparam("msilo","content_type_hdr","Content-Type: text/plain\r\n")
612 720
 modparam("msilo","offline_message","*** User $rU is offline!")
613 721
 
... ...
@@ -18,16 +18,30 @@
18 18
 		<surname>Mierla</surname>
19 19
 		<email>miconda@gmail.com</email>
20 20
 	    </author>
21
+	    <author>
22
+		<firstname>Juha</firstname>
23
+		<surname>Heinanen</surname>
24
+		<email>jh@tutpro.com</email>
25
+	    </author>
21 26
 	    <editor>
22 27
 		<firstname>Daniel-Constantin</firstname>
23 28
 		<surname>Mierla</surname>
24 29
 		<email>miconda@gmail.com</email>
25 30
 	    </editor>
31
+	    <editor>
32
+		<firstname>Juha</firstname>
33
+		<surname>Heinanen</surname>
34
+		<email>jh@tutpro.com</email>
35
+	    </editor>
26 36
 	</authorgroup>
27 37
 	<copyright>
28 38
 	    <year>2003</year>
29 39
 	    <holder>&fhg;</holder>
30 40
 	</copyright>
41
+	<copyright>
42
+	    <year>2009</year>
43
+	    <holder>Juha Heinanen</holder>
44
+	</copyright>
31 45
 	<revhistory>
32 46
 	    <revision>
33 47
 		<revnumber>$Revision$</revnumber>
... ...
@@ -173,6 +173,27 @@ modparam("msilo", "from_address", "sip:$rU@example.org")
173 173
 ...
174 174
 modparam("msilo", "contact_hdr", "Contact: &lt;sip:null@example.com&gt;\r\n")
175 175
 ...
176
+</programlisting>
177
+		</example>
178
+	</section>
179
+	<section>
180
+		<title><varname>extra_hdrs</varname> (string)</title>
181
+		<para>
182
+		Extra headers (each ending with	\r\n) to be added in
183
+	messages sent from silo by m_dump.
184
+		It can contain pseudo-variables.
185
+		</para>
186
+		<para>
187
+		<emphasis>
188
+			Default value is <quote>NULL</quote>.
189
+		</emphasis>
190
+		</para>
191
+		<example>
192
+		<title>Set the <quote>extra_hdrs</quote> parameter</title>
193
+<programlisting format="linespecific">
194
+...
195
+modparam("msilo", "contact_hdr", "X-Extra: $tu\r\nY-Extra: foo\r\n")
196
+...
176 197
 </programlisting>
177 198
 		</example>
178 199
 	</section>
... ...
@@ -186,19 +186,20 @@ error:
186 186
 
187 187
 /** build MESSAGE headers 
188 188
  *
189
- * Add Content-Type, Contact and Date headers if they exist
189
+ * Add Content-Type, Contact, Date, and extra headers if they exist
190 190
  * expects - max buf len of the resulted body in body->len
191 191
  *         - body->s MUST be allocated
192 192
  * return: 0 OK ; -1 error
193 193
  * */
194
-int m_build_headers(str *buf, str ctype, str contact, time_t date)
194
+int m_build_headers(str *buf, str ctype, str contact, time_t date, str extra)
195 195
 {
196 196
 	char *p;
197 197
 	char strDate[48];
198 198
 	int lenDate = 0;
199 199
 
200 200
 	if(!buf || !buf->s || buf->len <= 0 || ctype.len < 0 || contact.len < 0
201
-			|| buf->len <= ctype.len+contact.len+14 /*Content-Type: */
201
+			|| buf->len <= ctype.len+contact.len+extra.len+14
202
+	   /*Content-Type: */
202 203
 				+CRLF_LEN+CONTACT_PREFIX_LEN+CONTACT_SUFFIX_LEN)
203 204
 		goto error;
204 205
 
... ...
@@ -228,6 +229,10 @@ int m_build_headers(str *buf, str ctype, str contact, time_t date)
228 229
 		strncpy(p, CONTACT_SUFFIX, CONTACT_SUFFIX_LEN);
229 230
 		p += CONTACT_SUFFIX_LEN;
230 231
 	}
232
+	if (extra.len > 0) {
233
+	    strncpy(p, extra.s, extra.len);
234
+	    p += extra.len;
235
+	}
231 236
 	buf->len = p - buf->s;	
232 237
 	return 0;
233 238
 error:
... ...
@@ -49,7 +49,7 @@ int m_apo_escape(char*, int, char*, int);
49 49
 int m_extract_content_type(char*, int, content_type_t*, int);
50 50
 
51 51
 /** build MESSAGE headers */
52
-int m_build_headers(str *buf, str ctype, str contact, time_t date);
52
+int m_build_headers(str *buf, str ctype, str contact, time_t date, str extra);
53 53
 
54 54
 /** build MESSAGE body */
55 55
 int m_build_body(str *body, time_t date, str msg, time_t sdate);
... ...
@@ -129,10 +129,12 @@ str  ms_outbound_proxy = {NULL, 0};
129 129
 
130 130
 char*  ms_from = NULL; /*"sip:registrar@example.org";*/
131 131
 char*  ms_contact = NULL; /*"Contact: <sip:registrar@example.org>\r\n";*/
132
+char*  ms_extra_hdrs = NULL; /*"X-foo: bar\r\nX-bar: foo\r\n";*/
132 133
 char*  ms_content_type = NULL; /*"Content-Type: text/plain\r\n";*/
133 134
 char*  ms_offline_message = NULL; /*"<em>I'm offline.</em>"*/
134 135
 void**  ms_from_sp = NULL;
135 136
 void**  ms_contact_sp = NULL;
137
+void**  ms_extra_hdrs_sp = NULL;
136 138
 void**  ms_content_type_sp = NULL;
137 139
 void**  ms_offline_message_sp = NULL;
138 140
 
... ...
@@ -185,6 +187,7 @@ static param_export_t params[]={
185 187
 	{ "db_table",         STR_PARAM, &ms_db_table.s           },
186 188
 	{ "from_address",     STR_PARAM, &ms_from                 },
187 189
 	{ "contact_hdr",      STR_PARAM, &ms_contact              },
190
+	{ "extra_hdrs",       STR_PARAM, &ms_extra_hdrs           },
188 191
 	{ "content_type_hdr", STR_PARAM, &ms_content_type         },
189 192
 	{ "offline_message",  STR_PARAM, &ms_offline_message      },
190 193
 	{ "reminder",         STR_PARAM, &ms_reminder.s           },
... ...
@@ -359,6 +362,21 @@ static int mod_init(void)
359 362
 			return -1;
360 363
 		}
361 364
 	}
365
+	if(ms_extra_hdrs!=NULL)
366
+	{
367
+		ms_extra_hdrs_sp = (void**)pkg_malloc(sizeof(void*));
368
+		if(ms_extra_hdrs_sp==NULL)
369
+		{
370
+			LM_ERR("no more pkg\n");
371
+			return -1;
372
+		}
373
+		*ms_extra_hdrs_sp = (void*)ms_extra_hdrs;
374
+		if(fixup_spve_null(ms_extra_hdrs_sp, 1)!=0)
375
+		{
376
+			LM_ERR("bad extra_hdrs parameter\n");
377
+			return -1;
378
+		}
379
+	}
362 380
 	if(ms_content_type!=NULL)
363 381
 	{
364 382
 		ms_content_type_sp = (void**)pkg_malloc(sizeof(void*));
... ...
@@ -849,7 +867,7 @@ static int m_dump(struct sip_msg* msg, char* owner, char* str2)
849 867
 	struct sip_uri puri;
850 868
 	str owner_s;
851 869
 	uac_req_t uac_r;
852
-	str str_vals[4], hdr_str , body_str;
870
+	str str_vals[4], hdr_str, body_str, extra_hdrs_str;
853 871
 	time_t rtime;
854 872
 	
855 873
 	/* init */
... ...
@@ -1011,10 +1029,21 @@ static int m_dump(struct sip_msg* msg, char* owner, char* str2)
1011 1029
 		SET_STR_VAL(str_vals[3], db_res, i, 4); /* ctype */
1012 1030
 		rtime = 
1013 1031
 			(time_t)RES_ROWS(db_res)[i].values[5/*inc time*/].val.int_val;
1014
-
1032
+		
1033
+		if (ms_extra_hdrs != NULL) {
1034
+		    if (fixup_get_svalue(msg, (gparam_p)*ms_extra_hdrs_sp,
1035
+					 &extra_hdrs_str) != 0) {
1036
+			LM_ERR("unable to get extra_hdrs value\n");
1037
+			goto error;
1038
+		    }
1039
+		} else {
1040
+		    extra_hdrs_str.len = 0;
1041
+		}
1042
+		
1015 1043
 		hdr_str.len = 1024;
1016 1044
 		if(m_build_headers(&hdr_str, str_vals[3] /*ctype*/,
1017
-				str_vals[0]/*from*/, rtime /*Date*/) < 0)
1045
+				   str_vals[0]/*from*/, rtime /*Date*/,
1046
+				   extra_hdrs_str /*extra_hdrs*/) < 0)
1018 1047
 		{
1019 1048
 			LM_ERR("headers building failed [%d]\n", mid);
1020 1049
 			if (msilo_dbf.free_result(db_con, db_res) < 0)
... ...
@@ -1196,7 +1225,7 @@ void m_send_ontimer(unsigned int ticks, void *param)
1196 1225
 	str puri;
1197 1226
 	time_t ttime;
1198 1227
 	uac_req_t uac_r;
1199
-	str str_vals[4], hdr_str , body_str;
1228
+	str str_vals[4], hdr_str, body_str, extra_hdrs_str;
1200 1229
 	time_t stime;
1201 1230
 
1202 1231
 	if(ms_reminder.s==NULL)
... ...
@@ -1265,9 +1294,12 @@ void m_send_ontimer(unsigned int ticks, void *param)
1265 1294
 		SET_STR_VAL(str_vals[2], db_res, i, 3); /* body */
1266 1295
 		SET_STR_VAL(str_vals[3], db_res, i, 4); /* ctype */
1267 1296
 
1297
+		extra_hdrs_str.len = 0;
1268 1298
 		hdr_str.len = 1024;
1269 1299
 		if(m_build_headers(&hdr_str, str_vals[3] /*ctype*/,
1270
-				ms_reminder/*from*/,0/*Date*/) < 0)
1300
+				   ms_reminder/*from*/,0/*Date*/,
1301
+				   extra_hdrs_str/*extra*/)
1302
+		   < 0)
1271 1303
 		{
1272 1304
 			LM_ERR("headers building failed [%d]\n", mid);
1273 1305
 			if (msilo_dbf.free_result(db_con, db_res) < 0)