1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
|
MSILO Module
Daniel-Constantin Mierla
voice-system.ro
Edited by
Daniel-Constantin Mierla
Copyright 2003 FhG FOKUS
_________________________________________________________
Table of Contents
1. User's Guide
1.1. Overview
1.2. Dependencies
1.2.1. OpenSER modules
1.2.2. External libraries or applications
1.3. Exported Parameters
1.3.1. db_url (string)
1.3.2. db_table (string)
1.3.3. registrar (string)
1.3.4. reminder (string)
1.3.5. expire_time (int)
1.3.6. check_time (int)
1.3.7. send_time (int)
1.3.8. clean_period (int)
1.3.9. use_contact (int)
1.3.10. userid_avp (int)
1.3.11. snd_time_avp (int)
1.4. Exported Functions
1.4.1. m_store(mode)
1.4.2. m_dump()
1.5. Installation & Running
1.5.1. Database setup
1.5.2. OpenSER config file
2. Developer's Guide
3. Frequently Asked Questions
List of Examples
1-1. Set the "db_url" parameter
1-2. Set the "db_table" parameter
1-3. Set the "registrar" parameter
1-4. Set the "reminder" parameter
1-5. Set the "expire_time" parameter
1-6. Set the "check_time" parameter
1-7. Set the "send_time" parameter
1-8. Set the "clean_period" parameter
1-9. Set the "use_contact" parameter
1-10. Set the "userid_avp" parameter
1-11. Set the "snd_time_avp" parameter
1-12. msilo sql script
1-13. OpenSER config script - sample msilo usage
_________________________________________________________
Chapter 1. User's Guide
1.1. Overview
This modules provides offline message storage for the Open SIP
Express Router. It stores received messages for an offline
user and sends them when the user becomes online.
For each message, the modules stores "Request-URI" ("R-URI")
only if it is a complete address of record
("username@hostname"), URI from "To" header, URI from "From"
header, incoming time, expiration time, content type and body
of the message. If "R-URI" is not an address of record (it
might be the contact address for current SIP session) the URI
from "To" header will be used as R-URI.
When the expiration time passed, the message is discarded from
database. Expiration time is computed based on incoming time
and one of the module's parameters.
Every time when a user registers with OpenSER, the module is
looking in database for offline messages intended for that
user. All of them will be sent to contact address provided in
REGISTER request.
It may happen the SIP user to be registered but his SIP User
Agent to have no support for MESSAGE request. In this case it
should be used the "failure_route" to store the undelivered
requests.
_________________________________________________________
1.2. Dependencies
1.2.1. OpenSER modules
The following modules must be loaded before this module:
* database module - mysql, dbtext or other module that
implements the "db" interface and provides support for
storing/receiving data to/from a database system.
* TM--transaction module--is used to send SIP requests.
_________________________________________________________
1.2.2. External libraries or applications
The following libraries or applications must be installed
before running OpenSER with this module:
* none.
_________________________________________________________
1.3. Exported Parameters
1.3.1. db_url (string)
Database URL.
Default value is
"mysql://openser:openserrw@localhost/openser".
Example 1-1. Set the "db_url" parameter
...
modparam("msilo", "db_url", "mysql://user:passwd@host.com/dbname")
...
_________________________________________________________
1.3.2. db_table (string)
The name of table where to store the messages.
Default value is "silo".
Example 1-2. Set the "db_table" parameter
...
modparam("msilo", "db_table", "silo")
...
_________________________________________________________
1.3.3. registrar (string)
The SIP address used to inform users that destination of their
message is not online and the message will be delivered next
time when that user goes online. If the parameter is not set,
the module will not send any notification. All requests
intended for this SIP address will not be stored for lately
delivery.
Default value is "NULL".
Example 1-3. Set the "registrar" parameter
...
modparam("msilo", "registrar", "sip:registrar@example.org")
...
_________________________________________________________
1.3.4. reminder (string)
The SIP address used to send reminder messages. If this value
is not set, the reminder feature is disabled.
Default value is "NULL".
Example 1-4. Set the "reminder" parameter
...
modparam("msilo", "reminder", "sip:registrar@example.org")
...
_________________________________________________________
1.3.5. expire_time (int)
Expire time of stored messages - seconds. When this time
passed, the message is silently discarded from database.
Default value is "259200 (72 hours = 3 days)".
Example 1-5. Set the "expire_time" parameter
...
modparam("msilo", "expire_time", 36000)
...
_________________________________________________________
1.3.6. check_time (int)
Timer interval to check if dumped messages are sent OK -
seconds. The module keeps each request send by itself for a
new online user and if the reply is 2xx then the message is
deleted from database.
Default value is "30".
Example 1-6. Set the "check_time" parameter
...
modparam("msilo", "check_time", 10)
...
_________________________________________________________
1.3.7. send_time (int)
Timer interval in seconds to check if there are reminder
messages. The module takes all reminder messages that must be
sent at that moment or before that moment.
If the value is 0, the reminder feature is disabled.
Default value is "0".
Example 1-7. Set the "send_time" parameter
...
modparam("msilo", "send_time", 60)
...
_________________________________________________________
1.3.8. clean_period (int)
Number of "check_time" cycles when to check if there are
expired messages in database.
Default value is "5".
Example 1-8. Set the "clean_period" parameter
...
modparam("msilo", "clean_period", "3")
...
_________________________________________________________
1.3.9. use_contact (int)
Turns on/off the usage of the Contact address to send
notification back to sender whose message is stored by MSILO.
Default value is "1 (0 = off, 1 = on)".
Example 1-9. Set the "use_contact" parameter
...
modparam("msilo", "use_contact", 0)
...
_________________________________________________________
1.3.10. userid_avp (int)
The integer ID of an AVP which may contain the SIP URI of the
user to whom the message was sent. It is better to store it in
an AVP in the case of speed dial or aliases usage, so you do
not need second processing of R-URI in failure route. The AVP
is used ony by m_store().
If the parameter is not set to a value different than 0, the
module does not look for this AVP. If the value is set to a
number different than 0, then the module expects in the AVP
with that ID a SIP URI.
Default value is "0".
Example 1-10. Set the "userid_avp" parameter
...
modparam("msilo", "userid_avp", 34)
...
_________________________________________________________
1.3.11. snd_time_avp (int)
The integer ID of an AVP which may contain the time when to
sent the received message as reminder.The AVP is used ony by
m_store().
If the parameter is not set to a value different than 0, the
module does not look for this AVP. If the value is set to a
number different than 0, then the module expects in the AVP
with that ID to be a time in format YYYYMMDDHHMMSS (e.g.,
20060101201500).
Default value is "0".
Example 1-11. Set the "snd_time_avp" parameter
...
modparam("msilo", "snd_time_avp", 35)
...
_________________________________________________________
1.4. Exported Functions
1.4.1. m_store(mode)
The method stores certain parts of the current SIP request (it
should be called when the request type is MESSAGE and the
destination user is offline or his UA does not support MESSAGE
requests). If the user is registered with a UA which does not
support MESSAGE requests you should not use mode="0" if you
have changed the request uri with the contact address of
user's UA.
Meaning of the parameters is as follows:
* mode - specifies what to save as R-URI.
+ "0" - first check if new_uri is an address of record.
If yes, then use it and store it as R-URI, otherwise
look at R-URI and, if necessary, at URI from "To"
header.
+ "1" - look first at R-URI and then at URI from "To"
header.
+ "2" - look only at URI form "To" header.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
_________________________________________________________
1.4.2. m_dump()
The method sends stored messages for the SIP user that is
going to register to his actual contact address. The method
should be called when a REGISTER request is received and the
"Expire" header has a value greater than zero.
This function can be used from REQUEST_ROUTE.
_________________________________________________________
1.5. Installation & Running
1.5.1. Database setup
Before running OpenSER with msilo, you have to setup the
database table where the module will store the message. For
that, if the table was not created by the installation script
or you choose to install everything by yourself you can use
the following SQL script (good for MySQL) as template.
Database and table name can be set with module parameters so
they can be changed, but the name of the columns must be as
they are in the next SQL script.
Example 1-12. msilo sql script
...
-- SQL script for MSILO module
DROP DATABASE IF EXISTS msilo;
-- create a database for storage
CREATE DATABASE msilo;
USE msilo;
-- create the table
CREATE TABLE silo(
-- unique ID per message
mid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
-- src address - From URI
src_addr VARCHAR(255) NOT NULL DEFAULT "",
-- dst address - To URI
dst_addr VARCHAR(255) NOT NULL DEFAULT "",
-- r-uri == username@domain (for compatibility with old version)
r_uri VARCHAR(255) NOT NULL DEFAULT "",
-- username
username VARCHAR(64) NOT NULL DEFAULT "",
-- domain
domain VARCHAR(128) NOT NULL DEFAULT "",
-- incoming time
inc_time INTEGER NOT NULL DEFAULT 0,
-- expiration time
exp_time INTEGER NOT NULL DEFAULT 0,
-- reminder send time
snd_time INTEGER NOT NULL DEFAULT 0,
-- content type
ctype VARCHAR(32) NOT NULL DEFAULT "text/plain",
-- body of the message
body BLOB NOT NULL DEFAULT ""
);
...
_________________________________________________________
1.5.2. OpenSER config file
Next picture displays a sample usage of msilo.
Example 1-13. OpenSER config script - sample msilo usage
...
# $Id: README,v 1.6 2006/07/10 13:51:46 bogdan_iancu Exp $
#
# MSILO usage example
#
#
debug=9 # debug level (cmd line: -dddddddddd)
fork=no # don't fork
log_stderror=yes # log to stderr (cmd line: -E)
children=2 # number of children
check_via=no # (cmd. line: -v)
dns=off # (cmd. line: -r)
rev_dns=off # (cmd. line: -R)
port=5060
listen=10.0.0.2 # listen address
# ------------------ module loading ----------------------------------
loadmodule "modules/print/print.so"
loadmodule "modules/textops/textops.so"
loadmodule "modules/sl/sl.so"
loadmodule "modules/mysql/mysql.so"
loadmodule "modules/maxfwd/maxfwd.so"
loadmodule "modules/msilo/msilo.so"
loadmodule "modules/tm/tm.so"
loadmodule "modules/registrar/registrar.so"
loadmodule "modules/usrloc/usrloc.so"
# ----------------- setting module-specific parameters ---------------
# -- registrar params --
modparam("registrar", "default_expires", 120)
# -- registrar params --
modparam("usrloc", "db_mode", 0)
# -- msilo params --
modparam("msilo","db_url","mysql://user:xxx@127.0.0.1/msilo")
modparam("msilo","registrar","sip:registrar@mydomain.com")
# -- tm params --
modparam("tm", "fr_timer", 10 )
modparam("tm", "fr_inv_timer", 15 )
modparam("tm", "wt_timer", 10 )
route{
if ( !mf_process_maxfwd_header("10") )
{
sl_send_reply("483","To Many Hops");
drop();
};
if (uri==myself) {
{
# for testing purposes, simply okay all REGISTERs
if (method=="REGISTER")
{
save("location");
log("REGISTER received -> dumping messages with MSILO\n");
# MSILO - dumping user's offline messages
if (m_dump())
{
log("MSILO: offline messages dumped - if they were\n");
}else{
log("MSILO: no offline messages dumped\n");
};
break;
};
# domestic SIP destinations are handled using our USRLOC DB
if(!lookup("location"))
{
if (! t_newtran())
{
sl_reply_error();
break;
};
# we do not care about anything else but MESSAGEs
if (!method=="MESSAGE")
{
if (!t_reply("404", "Not found"))
{
sl_reply_error();
};
break;
};
log("MESSAGE received -> storing using MSILO\n");
# MSILO - storing as offline message
if (m_store("0"))
{
log("MSILO: offline message stored\n");
if (!t_reply("202", "Accepted"))
{
sl_reply_error();
};
}else{
log("MSILO: offline message NOT stored\n");
if (!t_reply("503", "Service Unavailable"))
{
sl_reply_error();
};
};
break;
};
# if the downstream UA does not support MESSAGE requests
# go to failure_route[1]
t_on_failure("1");
t_relay();
break;
};
# forward anything else
t_relay();
}
failure_route[1] {
# forwarding failed -- check if the request was a MESSAGE
if (!method=="MESSAGE")
{
break;
};
log(1,"MSILO:the downstream UA doesn't support MESSAGEs\n");
# we have changed the R-URI with the contact address, ignore it now
if (m_store("1"))
{
log("MSILO: offline message stored\n");
t_reply("202", "Accepted");
}else{
log("MSILO: offline message NOT stored\n");
t_reply("503", "Service Unavailable");
};
}
...
_________________________________________________________
Chapter 2. Developer's Guide
The module does not provide any API to use in other OpenSER
modules.
_________________________________________________________
Chapter 3. Frequently Asked Questions
3.1. Where can I find more about OpenSER?
3.2. Where can I post a question about this module?
3.3. How can I report a bug?
3.1. Where can I find more about OpenSER?
Take a look at http://openser.org/.
3.2. Where can I post a question about this module?
First at all check if your question was already answered on
one of our mailing lists:
* User Mailing List -
http://openser.org/cgi-bin/mailman/listinfo/users
* Developer Mailing List -
http://openser.org/cgi-bin/mailman/listinfo/devel
E-mails regarding any stable OpenSER release should be sent to
<users@openser.org> and e-mails regarding development versions
should be sent to <devel@openser.org>.
If you want to keep the mail private, send it to
<team@openser.org>.
3.3. How can I report a bug?
Please follow the guidelines provided at:
http://sourceforge.net/tracker/?group_id=139143.
|