<div dir="ltr"><div>Hi,</div><div><br></div><div>Please take a look at msilo module:</div><div><a href="http://kamailio.org/docs/modules/5.0.x/modules/msilo.html">http://kamailio.org/docs/modules/5.0.x/modules/msilo.html</a></div><div><br></div><div>Regards,</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 16, 2017 at 8:28 PM, Jango <span dir="ltr"><<a href="mailto:jhango@protonmail.com" target="_blank">jhango@protonmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>I need help about offline messages<br></div><div><br></div><div>this is my full working kamailio.cfg with audio/video call & instant messaging but i need features to receive user offline messages.<br></div><div><br></div><div>kamailio.cfg<br></div><div>#!KAMAILIO<br></div><div>#!define WITH_MYSQL<br></div><div>#!define WITH_AUTH<br></div><div>#!define WITH_USRLOCDB<br></div><div>#!define WITH_PRESENCE<br></div><div>#!define WITH_NAT<br></div><div>#!define WITH_TLS<br></div><div>#!define WITH_ACCDB<br></div><div>#<br></div><div># Kamailio (OpenSER) SIP Server v4.2 - default configuration script<br></div><div># - web: <a href="http://www.kamailio.org" target="_blank">http://www.kamailio.org</a><br></div><div># - git: <a href="http://sip-router.org" target="_blank">http://sip-router.org</a><br></div><div>#<br></div><div># Direct your questions about this file to: <<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><wbr>><br></div><div>#<br></div><div># Refer to the Core CookBook at <a href="http://www.kamailio.org/wiki/" target="_blank">http://www.kamailio.org/wiki/</a><br></div><div># for an explanation of possible statements, functions and parameters.<br></div><div>#<br></div><div># Several features can be enabled using '#!define WITH_FEATURE' directives:<br></div><div>#<br></div><div># *** To run in debug mode:<br></div><div># - define WITH_DEBUG<br></div><div>#<br></div><div># *** To enable mysql:<br></div><div># - define WITH_MYSQL<br></div><div>#<br></div><div># *** To enable authentication execute:<br></div><div># - enable mysql<br></div><div># - define WITH_AUTH<br></div><div># - add users using 'kamctl'<br></div><div>#<br></div><div># *** To enable IP authentication execute:<br></div><div># - enable mysql<br></div><div># - enable authentication<br></div><div># - define WITH_IPAUTH<br></div><div># - add IP addresses with group id '1' to 'address' table<br></div><div>#<br></div><div># *** To enable persistent user location execute:<br></div><div># - enable mysql<br></div><div># - define WITH_USRLOCDB<br></div><div>#<br></div><div># *** To enable presence server execute:<br></div><div># - enable mysql<br></div><div># - define WITH_PRESENCE<br></div><div>#<br></div><div># *** To enable nat traversal execute:<br></div><div># - define WITH_NAT<br></div><div># - install RTPProxy: <a href="http://www.rtpproxy.org" target="_blank">http://www.rtpproxy.org</a><br></div><div># - start RTPProxy:<br></div><div># rtpproxy -l _your_public_ip_ -s udp:localhost:7722<br></div><div># - option for NAT SIP OPTIONS keepalives: WITH_NATSIPPING<br></div><div>#<br></div><div># *** To enable PSTN gateway routing execute:<br></div><div># - define WITH_PSTN<br></div><div># - set the value of pstn.gw_ip<br></div><div># - check route[PSTN] for regexp routing condition<br></div><div>#<br></div><div># *** To enable database aliases lookup execute:<br></div><div># - enable mysql<br></div><div># - define WITH_ALIASDB<br></div><div>#<br></div><div># *** To enable speed dial lookup execute:<br></div><div># - enable mysql<br></div><div># - define WITH_SPEEDDIAL<br></div><div>#<br></div><div># *** To enable multi-domain support execute:<br></div><div># - enable mysql<br></div><div># - define WITH_MULTIDOMAIN<br></div><div>#<br></div><div># *** To enable TLS support execute:<br></div><div># - adjust CFGDIR/tls.cfg as needed<br></div><div># - define WITH_TLS<br></div><div>#<br></div><div># *** To enable XMLRPC support execute:<br></div><div># - define WITH_XMLRPC<br></div><div># - adjust route[XMLRPC] for access policy<br></div><div>#<br></div><div># *** To enable anti-flood detection execute:<br></div><div># - adjust pike and htable=>ipban settings as needed (default is<br></div><div># block if more than 16 requests in 2 seconds and ban for 300 seconds)<br></div><div># - define WITH_ANTIFLOOD<br></div><div>#<br></div><div># *** To block 3XX redirect replies execute:<br></div><div># - define WITH_BLOCK3XX<br></div><div>#<br></div><div># *** To enable VoiceMail routing execute:<br></div><div># - define WITH_VOICEMAIL<br></div><div># - set the value of voicemail.srv_ip<br></div><div># - adjust the value of voicemail.srv_port<br></div><div>#<br></div><div># *** To enhance accounting execute:<br></div><div># - enable mysql<br></div><div># - define WITH_ACCDB<br></div><div># - add following columns to database<br></div><div>#!ifdef ACCDB_COMMENT<br></div><div> ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';<br></div><div> ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';<br></div><div> ALTER TABLE acc ADD COLUMN src_ip varchar(64) NOT NULL default '';<br></div><div> ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';<br></div><div> ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';<br></div><div> ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';<br></div><div> ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';<br></div><div> ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';<br></div><div> ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT NULL default '';<br></div><div> ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';<br></div><div> ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';<br></div><div> ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';<br></div><div>#!endif<br></div><div><br></div><div>####### Include Local Config If Exists #########<br></div><div>import_file "kamailio-local.cfg"<br></div><div><br></div><div>####### Defined Values #########<br></div><div><br></div><div># *** Value defines - IDs used later in config<br></div><div>#!ifdef WITH_MYSQL<br></div><div># - database URL - used to connect to database server by modules such<br></div><div># as: auth_db, acc, usrloc, a.s.o.<br></div><div>#!ifndef DBURL<br></div><div>#!define DBURL "mysql://kamailio:kamailiorw@<wbr>localhost/kamailio"<br></div><div>#!endif<br></div><div>#!endif<br></div><div>#!ifdef WITH_MULTIDOMAIN<br></div><div># - the value for 'use_domain' parameters<br></div><div>#!define MULTIDOMAIN 1<br></div><div>#!else<br></div><div>#!define MULTIDOMAIN 0<br></div><div>#!endif<br></div><div><br></div><div># - flags<br></div><div># FLT_ - per transaction (message) flags<br></div><div># FLB_ - per branch flags<br></div><div>#!define FLT_ACC 1<br></div><div>#!define FLT_ACCMISSED 2<br></div><div>#!define FLT_ACCFAILED 3<br></div><div>#!define FLT_NATS 5<br></div><div><br></div><div>#!define FLB_NATB 6<br></div><div>#!define FLB_NATSIPPING 7<br></div><div><br></div><div>####### Global Parameters #########<br></div><div><br></div><div>### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR<br></div><div>#!ifdef WITH_DEBUG<br></div><div>debug=4<br></div><div>log_stderror=yes<br></div><div>#!else<br></div><div>debug=2<br></div><div>log_stderror=no<br></div><div>#!endif<br></div><div><br></div><div>memdbg=5<br></div><div>memlog=5<br></div><div><br></div><div>log_facility=LOG_LOCAL0<br></div><div><br></div><div>fork=yes<br></div><div>children=4<br></div><div><br></div><div>/* uncomment the next line to disable TCP (default on) */<br></div><div>#disable_tcp=yes<br></div><div><br></div><div>/* uncomment the next line to disable the auto discovery of local aliases<br></div><div> based on reverse DNS on IPs (default on) */<br></div><div>#auto_aliases=no<br></div><div><br></div><div>/* add local domain aliases */<br></div><div>alias="<a href="http://jsrver.tk" target="_blank">jsrver.tk</a>"<br></div><div><br></div><div>/* uncomment and configure the following line if you want Kamailio to<br></div><div> bind on a specific interface/port/proto (default bind on all available) */<br></div><div>#listen=udp:<a href="http://10.0.0.10:5060" target="_blank">10.0.0.10:5060</a><br></div><div><br></div><div>/* port to listen to<br></div><div>* - can be specified more than once if needed to listen on many ports */<br></div><div>port=5060<br></div><div><br></div><div>#!ifdef WITH_TLS<br></div><div>enable_tls=yes<br></div><div>#!endif<br></div><div><br></div><div># life time of TCP connection when there is no traffic<br></div><div># - a bit higher than registration expires to cope with UA behind NAT<br></div><div>tcp_connection_lifetime=3605<br></div><div><br></div><div>####### Custom Parameters #########<br></div><div><br></div><div># These parameters can be modified runtime via RPC interface<br></div><div># - see the documentation of 'cfg_rpc' module.<br></div><div>#<br></div><div># Format: <a href="http://group.id" target="_blank">group.id</a> = value 'desc' description<br></div><div># Access: $sel(<a href="http://cfg_get.group.id" target="_blank">cfg_get.group.id</a>) or @<a href="http://cfg_get.group.id" target="_blank">cfg_get.group.id</a><br></div><div>#<br></div><div><br></div><div>#!ifdef WITH_PSTN<br></div><div># PSTN GW Routing<br></div><div>#<br></div><div># - pstn.gw_ip: valid IP or hostname as string value, example:<br></div><div># pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"<br></div><div>#<br></div><div># - by default is empty to avoid misrouting<br></div><div>pstn.gw_ip = "" desc "PSTN GW Address"<br></div><div>pstn.gw_port = "" desc "PSTN GW Port"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_VOICEMAIL<br></div><div># VoiceMail Routing on offline, busy or no answer<br></div><div>#<br></div><div># - by default Voicemail server IP is empty to avoid misrouting<br></div><div>voicemail.srv_ip = "" desc "VoiceMail IP Address"<br></div><div>voicemail.srv_port = "5060" desc "VoiceMail Port"<br></div><div>#!endif<br></div><div><br></div><div>####### Modules Section ########<br></div><div><br></div><div># set paths to location of modules (to sources or installation folders)<br></div><div>#!ifdef WITH_SRCPATH<br></div><div>mpath="modules/"<br></div><div>#!else<br></div><div>mpath="/usr/lib64/kamailio/<wbr>modules/"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_MYSQL<br></div><div>loadmodule "db_mysql.so"<br></div><div>#!endif<br></div><div><br></div><div>loadmodule "mi_fifo.so"<br></div><div>loadmodule "kex.so"<br></div><div>loadmodule "corex.so"<br></div><div>loadmodule "tm.so"<br></div><div>loadmodule "tmx.so"<br></div><div>loadmodule "sl.so"<br></div><div>loadmodule "rr.so"<br></div><div>loadmodule "pv.so"<br></div><div>loadmodule "maxfwd.so"<br></div><div>loadmodule "usrloc.so"<br></div><div>loadmodule "registrar.so"<br></div><div>loadmodule "textops.so"<br></div><div>loadmodule "siputils.so"<br></div><div>loadmodule "xlog.so"<br></div><div>loadmodule "sanity.so"<br></div><div>loadmodule "ctl.so"<br></div><div>loadmodule "cfg_rpc.so"<br></div><div>loadmodule "mi_rpc.so"<br></div><div>loadmodule "acc.so"<br></div><div><br></div><div># -- for siremis CDRs --------------<br></div><div>loadmodule "rtimer.so"<br></div><div>loadmodule "sqlops.so"<br></div><div><br></div><div>#!ifdef WITH_AUTH<br></div><div>loadmodule "auth.so"<br></div><div>loadmodule "auth_db.so"<br></div><div>#!ifdef WITH_IPAUTH<br></div><div>loadmodule "permissions.so"<br></div><div>#!endif<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_ALIASDB<br></div><div>loadmodule "alias_db.so"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_SPEEDDIAL<br></div><div>loadmodule "speeddial.so"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_MULTIDOMAIN<br></div><div>loadmodule "domain.so"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_PRESENCE<br></div><div>loadmodule "presence.so"<br></div><div>loadmodule "presence_xml.so"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_NAT<br></div><div>loadmodule "nathelper.so"<br></div><div>loadmodule "rtpproxy.so"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_TLS<br></div><div>loadmodule "tls.so"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_ANTIFLOOD<br></div><div>loadmodule "htable.so"<br></div><div>loadmodule "pike.so"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_XMLRPC<br></div><div>loadmodule "xmlrpc.so"<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_DEBUG<br></div><div>loadmodule "debugger.so"<br></div><div>#!endif<br></div><div><br></div><div># ----------------- setting module-specific parameters ---------------<br></div><div><br></div><div><br></div><div># ----- mi_fifo params -----<br></div><div>modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")<br></div><div><br></div><div><br></div><div># ----- tm params -----<br></div><div># auto-discard branches from previous serial forking leg<br></div><div>modparam("tm", "failure_reply_mode", 3)<br></div><div># default retransmission timeout: 30sec<br></div><div>modparam("tm", "fr_timer", 30000)<br></div><div># default invite retransmission timeout after 1xx: 120sec<br></div><div>modparam("tm", "fr_inv_timer", 120000)<br></div><div><br></div><div><br></div><div># ----- rr params -----<br></div><div># set next param to 1 to add value to ;lr param (helps with some UAs)<br></div><div>modparam("rr", "enable_full_lr", 0)<br></div><div># do not append from tag to the RR (no need for this script)<br></div><div>modparam("rr", "append_fromtag", 0)<br></div><div><br></div><div><br></div><div># ----- registrar params -----<br></div><div>modparam("registrar", "method_filtering", 1)<br></div><div>/* uncomment the next line to disable parallel forking via location */<br></div><div># modparam("registrar", "append_branches", 0)<br></div><div>/* uncomment the next line not to allow more than 10 contacts per AOR */<br></div><div>#modparam("registrar", "max_contacts", 10)<br></div><div># max value for expires of registrations<br></div><div>modparam("registrar", "max_expires", 3600)<br></div><div># set it to 1 to enable GRUU<br></div><div>modparam("registrar", "gruu_enabled", 0)<br></div><div><br></div><div><br></div><div># ----- acc params -----<br></div><div>/* what special events should be accounted ? */<br></div><div>modparam("acc", "early_media", 0)<br></div><div>modparam("acc", "report_ack", 0)<br></div><div>modparam("acc", "report_cancels", 0)<br></div><div>/* by default ww do not adjust the direct of the sequential requests.<br></div><div> if you enable this parameter, be sure the enable "append_fromtag"<br></div><div> in "rr" module */<br></div><div>modparam("acc", "detect_direction", 0)<br></div><div>/* account triggers (flags) */<br></div><div>modparam("acc", "log_flag", FLT_ACC)<br></div><div>modparam("acc", "log_missed_flag", FLT_ACCMISSED)<br></div><div>modparam("acc", "log_extra",<br></div><div>"src_user=$fU;src_domain=$fd;<wbr>src_ip=$si;"<br></div><div>"dst_ouser=$tU;dst_user=$rU;<wbr>dst_domain=$rd")<br></div><div>modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)<br></div><div>/* enhanced DB accounting */<br></div><div>#!ifdef WITH_ACCDB<br></div><div>modparam("acc", "db_flag", FLT_ACC)<br></div><div>modparam("acc", "db_missed_flag", FLT_ACCMISSED)<br></div><div>modparam("acc", "db_url", DBURL)<br></div><div>modparam("acc", "db_extra",<br></div><div>"src_user=$fU;src_domain=$fd;<wbr>src_ip=$si;"<br></div><div>"dst_ouser=$tU;dst_user=$rU;<wbr>dst_domain=$rd")<br></div><div>#!endif<br></div><div><br></div><div><br></div><div># ----- usrloc params -----<br></div><div>/* enable DB persistency for location entries */<br></div><div>#!ifdef WITH_USRLOCDB<br></div><div>modparam("usrloc", "db_url", DBURL)<br></div><div>modparam("usrloc", "db_mode", 2)<br></div><div>modparam("usrloc", "use_domain", MULTIDOMAIN)<br></div><div>#!endif<br></div><div><br></div><div><br></div><div># ----- auth_db params -----<br></div><div>#!ifdef WITH_AUTH<br></div><div>modparam("auth_db", "db_url", DBURL)<br></div><div>modparam("auth_db", "calculate_ha1", yes)<br></div><div>modparam("auth_db", "password_column", "password")<br></div><div>modparam("auth_db", "load_credentials", "")<br></div><div>modparam("auth_db", "use_domain", MULTIDOMAIN)<br></div><div><br></div><div># ----- permissions params -----<br></div><div>#!ifdef WITH_IPAUTH<br></div><div>modparam("permissions", "db_url", DBURL)<br></div><div>modparam("permissions", "db_mode", 1)<br></div><div>#!endif<br></div><div><br></div><div>#!endif<br></div><div><br></div><div><br></div><div># ----- alias_db params -----<br></div><div>#!ifdef WITH_ALIASDB<br></div><div>modparam("alias_db", "db_url", DBURL)<br></div><div>modparam("alias_db", "use_domain", MULTIDOMAIN)<br></div><div>#!endif<br></div><div><br></div><div><br></div><div># ----- speeddial params -----<br></div><div>#!ifdef WITH_SPEEDDIAL<br></div><div>modparam("speeddial", "db_url", DBURL)<br></div><div>modparam("speeddial", "use_domain", MULTIDOMAIN)<br></div><div>#!endif<br></div><div><br></div><div><br></div><div># ----- domain params -----<br></div><div>#!ifdef WITH_MULTIDOMAIN<br></div><div>modparam("domain", "db_url", DBURL)<br></div><div># register callback to match myself condition with domains list<br></div><div>modparam("domain", "register_myself", 1)<br></div><div>#!endif<br></div><div><br></div><div><br></div><div>#!ifdef WITH_PRESENCE<br></div><div># ----- presence params -----<br></div><div>modparam("presence", "db_url", DBURL)<br></div><div><br></div><div># ----- presence_xml params -----<br></div><div>modparam("presence_xml", "db_url", DBURL)<br></div><div>modparam("presence_xml", "force_active", 1)<br></div><div>#!endif<br></div><div><br></div><div><br></div><div>#!ifdef WITH_NAT<br></div><div># ----- rtpproxy params -----<br></div><div>modparam("rtpproxy", "rtpproxy_sock", "udp:<a href="http://127.0.0.1:7722" target="_blank">127.0.0.1:7722</a>")<br></div><div><br></div><div># ----- nathelper params -----<br></div><div>modparam("nathelper", "natping_interval", 30)<br></div><div>modparam("nathelper", "ping_nated_only", 1)<br></div><div>modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)<br></div><div>modparam("nathelper", "sipping_from", "sip:<a href="mailto:pinger@kamailio.org" target="_blank">pinger@kamailio.org</a>")<br></div><div><br></div><div># params needed for NAT traversal in other modules<br></div><div>modparam("nathelper|registrar"<wbr>, "received_avp", "$avp(RECEIVED)")<br></div><div>modparam("usrloc", "nat_bflag", FLB_NATB)<br></div><div>#!endif<br></div><div><br></div><div><br></div><div>#!ifdef WITH_TLS<br></div><div># ----- tls params -----<br></div><div>modparam("tls", "config", "//etc/kamailio/tls.cfg")<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_ANTIFLOOD<br></div><div># ----- pike params -----<br></div><div>modparam("pike", "sampling_time_unit", 2)<br></div><div>modparam("pike", "reqs_density_per_unit", 16)<br></div><div>modparam("pike", "remove_latency", 4)<br></div><div><br></div><div># ----- htable params -----<br></div><div># ip ban htable with autoexpire after 5 minutes<br></div><div>modparam("htable", "htable", "ipban=>size=8;autoexpire=300;<wbr>")<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_XMLRPC<br></div><div># ----- xmlrpc params -----<br></div><div>modparam("xmlrpc", "route", "XMLRPC");<br></div><div>modparam("xmlrpc", "url_match", "^/RPC")<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_DEBUG<br></div><div># ----- debugger params -----<br></div><div>modparam("debugger", "cfgtrace", 1)<br></div><div>modparam("debugger", "log_level_name", "exec")<br></div><div>#!endif<br></div><div><br></div><div>modparam("rtimer", "timer", "name=cdr;interval=300;mode=1;<wbr>")<br></div><div>modparam("rtimer", "exec", "timer=cdr;route=CDRS")<br></div><div>modparam("sqlops", "sqlcon", "cb=>mysql://kamailio:<wbr>kamailiorw@localhost/kamailio"<wbr>)<br></div><div><br></div><div>####### Routing Logic ########<br></div><div><br></div><div><br></div><div># Main SIP request routing logic<br></div><div># - processing of any incoming SIP request starts with this route<br></div><div># - note: this is the same as route { ... }<br></div><div>request_route {<br></div><div><br></div><div># per request initial checks<br></div><div>route(REQINIT);<br></div><div><br></div><div># NAT detection<br></div><div>route(NATDETECT);<br></div><div><br></div><div># CANCEL processing<br></div><div>if (is_method("CANCEL")) {<br></div><div>if (t_check_trans()) {<br></div><div>route(RELAY);<br></div><div>}<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div># handle requests within SIP dialogs<br></div><div>route(WITHINDLG);<br></div><div><br></div><div>### only initial requests (no To tag)<br></div><div><br></div><div># handle retransmissions<br></div><div>if(t_precheck_trans()) {<br></div><div>t_check_trans();<br></div><div>exit;<br></div><div>}<br></div><div>t_check_trans();<br></div><div><br></div><div># authentication<br></div><div>route(AUTH);<br></div><div><br></div><div># record routing for dialog forming requests (in case they are routed)<br></div><div># - remove preloaded route headers<br></div><div>remove_hf("Route");<br></div><div>if (is_method("INVITE|SUBSCRIBE")<wbr>)<br></div><div>record_route();<br></div><div><br></div><div># account only INVITEs<br></div><div>if (is_method("INVITE")) {<br></div><div>setflag(FLT_ACC); # do accounting<br></div><div>}<br></div><div><br></div><div># dispatch requests to foreign domains<br></div><div>route(SIPOUT);<br></div><div><br></div><div>### requests for my local domains<br></div><div><br></div><div># handle presence related requests<br></div><div>route(PRESENCE);<br></div><div><br></div><div># handle registrations<br></div><div>route(REGISTRAR);<br></div><div><br></div><div>if ($rU==$null) {<br></div><div># request with no Username in RURI<br></div><div>sl_send_reply("484","Address Incomplete");<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div># dispatch destinations to PSTN<br></div><div>route(PSTN);<br></div><div><br></div><div># user location service<br></div><div>route(LOCATION);<br></div><div>}<br></div><div><br></div><div># Wrapper for relaying requests<br></div><div>route[RELAY] {<br></div><div><br></div><div># enable additional event routes for forwarded requests<br></div><div># - serial forking, RTP relaying handling, a.s.o.<br></div><div>if (is_method("INVITE|BYE|<wbr>SUBSCRIBE|UPDATE")) {<br></div><div>if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");<br></div><div>}<br></div><div>if (is_method("INVITE|SUBSCRIBE|<wbr>UPDATE")) {<br></div><div>if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");<br></div><div>}<br></div><div>if (is_method("INVITE")) {<br></div><div>if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE")<wbr>;<br></div><div>}<br></div><div><br></div><div>if (!t_relay()) {<br></div><div>sl_reply_error();<br></div><div>}<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div># Per SIP request initial checks<br></div><div>route[REQINIT] {<br></div><div>#!ifdef WITH_ANTIFLOOD<br></div><div># flood dection from same IP and traffic ban for a while<br></div><div># be sure you exclude checking trusted peers, such as pstn gateways<br></div><div># - local host excluded (e.g., loop to self)<br></div><div>if(src_ip!=myself) {<br></div><div>if($sht(ipban=>$si)!=$null) {<br></div><div># ip is already blocked<br></div><div>xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");<br></div><div>exit;<br></div><div>}<br></div><div>if (!pike_check_req()) {<br></div><div>xlog("L_ALERT","ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n");<br></div><div>$sht(ipban=>$si) = 1;<br></div><div>exit;<br></div><div>}<br></div><div>}<br></div><div>if($ua =~ "friendly-scanner") {<br></div><div>sl_send_reply("200", "OK");<br></div><div>exit;<br></div><div>}<br></div><div>#!endif<br></div><div><br></div><div>if (!mf_process_maxfwd_header("<wbr>10")) {<br></div><div>sl_send_reply("483","Too Many Hops");<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div>if(is_method("OPTIONS") && uri==myself && $rU==$null) {<br></div><div>sl_send_reply("200","<wbr>Keepalive");<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div>if(!sanity_check("1511", "7")) {<br></div><div>xlog("Malformed SIP message from $si:$sp\n");<br></div><div>exit;<br></div><div>}<br></div><div>}<br></div><div><br></div><div># Handle requests within SIP dialogs<br></div><div>route[WITHINDLG] {<br></div><div>if (!has_totag()) return;<br></div><div><br></div><div># sequential request withing a dialog should<br></div><div># take the path determined by record-routing<br></div><div>if (loose_route()) {<br></div><div>route(DLGURI);<br></div><div>if (is_method("BYE")) {<br></div><div>setflag(FLT_ACC); # do accounting ...<br></div><div>setflag(FLT_ACCFAILED); # ... even if the transaction fails<br></div><div>}<br></div><div>else if ( is_method("ACK") ) {<br></div><div># ACK is forwarded statelessy<br></div><div>route(NATMANAGE);<br></div><div>}<br></div><div>else if ( is_method("NOTIFY") ) {<br></div><div># Add Record-Route for in-dialog NOTIFY as per RFC 6665.<br></div><div>record_route();<br></div><div>}<br></div><div>route(RELAY);<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div>if (is_method("SUBSCRIBE") && uri == myself) {<br></div><div># in-dialog subscribe requests<br></div><div>route(PRESENCE);<br></div><div>exit;<br></div><div>}<br></div><div>if ( is_method("ACK") ) {<br></div><div>if ( t_check_trans() ) {<br></div><div># no loose-route, but stateful ACK;<br></div><div># must be an ACK after a 487<br></div><div># or e.g. 404 from upstream server<br></div><div>route(RELAY);<br></div><div>exit;<br></div><div>} else {<br></div><div># ACK without matching transaction ... ignore and discard<br></div><div>exit;<br></div><div>}<br></div><div>}<br></div><div>sl_send_reply("404","Not here");<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div># Handle SIP registrations<br></div><div>route[REGISTRAR] {<br></div><div>if (!is_method("REGISTER")) return;<br></div><div><br></div><div>if(isflagset(FLT_NATS)) {<br></div><div>setbflag(FLB_NATB);<br></div><div>#!ifdef WITH_NATSIPPING<br></div><div># do SIP NAT pinging<br></div><div>setbflag(FLB_NATSIPPING);<br></div><div>#!endif<br></div><div>}<br></div><div>if (!save("location"))<br></div><div>sl_reply_error();<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div># User location service<br></div><div>route[LOCATION] {<br></div><div><br></div><div>#!ifdef WITH_SPEEDDIAL<br></div><div># search for short dialing - 2-digit extension<br></div><div>if($rU=~"^[0-9][0-9]$")<br></div><div>if(sd_lookup("speed_dial"))<br></div><div>route(SIPOUT);<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_ALIASDB<br></div><div># search in DB-based aliases<br></div><div>if(alias_db_lookup("dbaliases"<wbr>))<br></div><div>route(SIPOUT);<br></div><div>#!endif<br></div><div><br></div><div>$avp(oexten) = $rU;<br></div><div>if (!lookup("location")) {<br></div><div>$var(rc) = $rc;<br></div><div>route(TOVOICEMAIL);<br></div><div>t_newtran();<br></div><div>switch ($var(rc)) {<br></div><div>case -1:<br></div><div>case -3:<br></div><div>send_reply("404", "Not Found");<br></div><div>exit;<br></div><div>case -2:<br></div><div>send_reply("405", "Method Not Allowed");<br></div><div>exit;<br></div><div>}<br></div><div>}<br></div><div><br></div><div># when routing via usrloc, log the missed calls also<br></div><div>if (is_method("INVITE")) {<br></div><div>setflag(FLT_ACCMISSED);<br></div><div>}<br></div><div><br></div><div>route(RELAY);<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div># Presence server processing<br></div><div>route[PRESENCE] {<br></div><div>if(!is_method("PUBLISH|<wbr>SUBSCRIBE"))<br></div><div>return;<br></div><div><br></div><div>if(is_method("SUBSCRIBE") && $hdr(Event)=="message-summary"<wbr>) {<br></div><div>route(TOVOICEMAIL);<br></div><div># returns here if no voicemail server is configured<br></div><div>sl_send_reply("404", "No voicemail service");<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div>#!ifdef WITH_PRESENCE<br></div><div>if (!t_newtran()) {<br></div><div>sl_reply_error();<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div>if(is_method("PUBLISH")) {<br></div><div>handle_publish();<br></div><div>t_release();<br></div><div>} else if(is_method("SUBSCRIBE")) {<br></div><div>handle_subscribe();<br></div><div>t_release();<br></div><div>}<br></div><div>exit;<br></div><div>#!endif<br></div><div><br></div><div># if presence enabled, this part will not be executed<br></div><div>if (is_method("PUBLISH") || $rU==$null) {<br></div><div>sl_send_reply("404", "Not here");<br></div><div>exit;<br></div><div>}<br></div><div>return;<br></div><div>}<br></div><div><br></div><div># IP authorization and user authentication<br></div><div>route[AUTH] {<br></div><div>#!ifdef WITH_AUTH<br></div><div><br></div><div>#!ifdef WITH_IPAUTH<br></div><div>if((!is_method("REGISTER")) && allow_source_address()) {<br></div><div># source IP allowed<br></div><div>return;<br></div><div>}<br></div><div>#!endif<br></div><div><br></div><div>if (is_method("REGISTER") || from_uri==myself)<br></div><div>{<br></div><div># authenticate requests<br></div><div>if (!auth_check("$fd", "subscriber", "1")) {<br></div><div>auth_challenge("$fd", "0");<br></div><div>exit;<br></div><div>}<br></div><div># user authenticated - remove auth header<br></div><div>if(!is_method("REGISTER|<wbr>PUBLISH"))<br></div><div>consume_credentials();<br></div><div>}<br></div><div># if caller is not local subscriber, then check if it calls<br></div><div># a local destination, otherwise deny, not an open relay here<br></div><div>if (from_uri!=myself && uri!=myself) {<br></div><div>sl_send_reply("403","Not relaying");<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div>#!endif<br></div><div>return;<br></div><div>}<br></div><div><br></div><div># Caller NAT detection<br></div><div>route[NATDETECT] {<br></div><div>#!ifdef WITH_NAT<br></div><div>force_rport();<br></div><div>if (nat_uac_test("19")) {<br></div><div>if (is_method("REGISTER")) {<br></div><div>fix_nated_register();<br></div><div>} else {<br></div><div>if(is_first_hop())<br></div><div>set_contact_alias();<br></div><div>}<br></div><div>setflag(FLT_NATS);<br></div><div>}<br></div><div>#!endif<br></div><div>return;<br></div><div>}<br></div><div><br></div><div># RTPProxy control and singaling updates for NAT traversal<br></div><div>route[NATMANAGE] {<br></div><div>#!ifdef WITH_NAT<br></div><div>if (is_request()) {<br></div><div>if(has_totag()) {<br></div><div>if(check_route_param("nat=yes"<wbr>)) {<br></div><div>setbflag(FLB_NATB);<br></div><div>}<br></div><div>}<br></div><div>}<br></div><div>if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))<br></div><div>return;<br></div><div><br></div><div>rtpproxy_manage("co");<br></div><div><br></div><div>if (is_request()) {<br></div><div>if (!has_totag()) {<br></div><div>if(t_is_branch_route()) {<br></div><div>add_rr_param(";nat=yes");<br></div><div>}<br></div><div>}<br></div><div>}<br></div><div>if (is_reply()) {<br></div><div>if(isbflagset(FLB_NATB)) {<br></div><div>if(is_first_hop())<br></div><div>set_contact_alias();<br></div><div>}<br></div><div>}<br></div><div>#!endif<br></div><div>return;<br></div><div>}<br></div><div><br></div><div># URI update for dialog requests<br></div><div>route[DLGURI] {<br></div><div>#!ifdef WITH_NAT<br></div><div>if(!isdsturiset()) {<br></div><div>handle_ruri_alias();<br></div><div>}<br></div><div>#!endif<br></div><div>return;<br></div><div>}<br></div><div><br></div><div># Routing to foreign domains<br></div><div>route[SIPOUT] {<br></div><div>if (uri==myself) return;<br></div><div><br></div><div>append_hf("P-hint: outbound\r\n");<br></div><div>route(RELAY);<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div># PSTN GW routing<br></div><div>route[PSTN] {<br></div><div>#!ifdef WITH_PSTN<br></div><div># check if PSTN GW IP is defined<br></div><div>if (strempty($sel(cfg_get.pstn.<wbr>gw_ip))) {<br></div><div>xlog("SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n");<br></div><div>return;<br></div><div>}<br></div><div><br></div><div># route to PSTN dialed numbers starting with '+' or '00'<br></div><div># (international format)<br></div><div># - update the condition to match your dialing rules for PSTN routing<br></div><div>if(!($rU=~"^(\+|00)[1-9][0-9]{<wbr>3,20}$"))<br></div><div>return;<br></div><div><br></div><div># only local users allowed to call<br></div><div>if(from_uri!=myself) {<br></div><div>sl_send_reply("403", "Not Allowed");<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div>if (strempty($sel(cfg_get.pstn.<wbr>gw_port))) {<br></div><div>$ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);<br></div><div>} else {<br></div><div>$ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip) + ":"<br></div><div>+ $sel(cfg_get.pstn.gw_port);<br></div><div>}<br></div><div><br></div><div>route(RELAY);<br></div><div>exit;<br></div><div>#!endif<br></div><div><br></div><div>return;<br></div><div>}<br></div><div><br></div><div># XMLRPC routing<br></div><div>#!ifdef WITH_XMLRPC<br></div><div>route[XMLRPC] {<br></div><div># allow XMLRPC from localhost<br></div><div>if ((method=="POST" || method=="GET")<br></div><div>&& (src_ip==127.0.0.1)) {<br></div><div># close connection only for xmlrpclib user agents (there is a bug in<br></div><div># xmlrpclib: it waits for EOF before interpreting the response).<br></div><div>if ($hdr(User-Agent) =~ "xmlrpclib")<br></div><div>set_reply_close();<br></div><div>set_reply_no_connect();<br></div><div>dispatch_rpc();<br></div><div>exit;<br></div><div>}<br></div><div>send_reply("403", "Forbidden");<br></div><div>exit;<br></div><div>}<br></div><div>#!endif<br></div><div><br></div><div># Routing to voicemail server<br></div><div>route[TOVOICEMAIL] {<br></div><div>#!ifdef WITH_VOICEMAIL<br></div><div>if(!is_method("INVITE|<wbr>SUBSCRIBE"))<br></div><div>return;<br></div><div><br></div><div># check if VoiceMail server IP is defined<br></div><div>if (strempty($sel(cfg_get.<wbr>voicemail.srv_ip))) {<br></div><div>xlog("SCRIPT: VoiceMail rotuing enabled but IP not defined\n");<br></div><div>return;<br></div><div>}<br></div><div>if(is_method("INVITE")) {<br></div><div>if($avp(oexten)==$null)<br></div><div>return;<br></div><div>$ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip)<br></div><div>+ ":" + $sel(cfg_get.voicemail.srv_<wbr>port);<br></div><div>} else {<br></div><div>if($rU==$null)<br></div><div>return;<br></div><div>$ru = "sip:" + $rU + "@" + $sel(cfg_get.voicemail.srv_ip)<br></div><div>+ ":" + $sel(cfg_get.voicemail.srv_<wbr>port);<br></div><div>}<br></div><div>route(RELAY);<br></div><div>exit;<br></div><div>#!endif<br></div><div><br></div><div>return;<br></div><div>}<br></div><div><br></div><div># ==============================<wbr>========================<br></div><div># Populate CDRs Table of Siremis<br></div><div># ==============================<wbr>========================<br></div><div>route[CDRS] {<br></div><div>sql_query("cb","call kamailio_cdrs()","rb");<br></div><div>sql_query("cb","call kamailio_rating('default')","<wbr>rb");<br></div><div>}<br></div><div><br></div><div># Manage outgoing branches<br></div><div>branch_route[MANAGE_BRANCH] {<br></div><div>xdbg("new branch [$T_branch_idx] to $ru\n");<br></div><div>route(NATMANAGE);<br></div><div>}<br></div><div><br></div><div># Manage incoming replies<br></div><div>onreply_route[MANAGE_REPLY] {<br></div><div>xdbg("incoming reply\n");<br></div><div>if(status=~"[12][0-9][0-9]")<br></div><div>route(NATMANAGE);<br></div><div>}<br></div><div><br></div><div># Manage failure routing cases<br></div><div>failure_route[MANAGE_FAILURE] {<br></div><div>route(NATMANAGE);<br></div><div><br></div><div>if (t_is_canceled()) {<br></div><div>exit;<br></div><div>}<br></div><div><br></div><div>#!ifdef WITH_BLOCK3XX<br></div><div># block call redirect based on 3xx replies.<br></div><div>if (t_check_status("3[0-9][0-9]")<wbr>) {<br></div><div>t_reply("404","Not found");<br></div><div>exit;<br></div><div>}<br></div><div>#!endif<br></div><div><br></div><div>#!ifdef WITH_VOICEMAIL<br></div><div># serial forking<br></div><div># - route to voicemail on busy or no answer (timeout)<br></div><div>if (t_check_status("486|408")) {<br></div><div>$du = $null;<br></div><div>route(TOVOICEMAIL);<br></div><div>exit;<br></div><div>}<br></div><div>#!endif<br></div><div>}<br></div><br>______________________________<wbr>_________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:12.8px">Regards,</span><br></div><div><br></div><div>Arsen Semionov</div><div>Eurolan.info</div><div>cell: +442035198881</div></div></div>
</div>