3 # Kamailio (OpenSER) SIP Server v5.5 - default configuration script
4 # - web: https://www.kamailio.org
5 # - git: https://github.com/kamailio/kamailio
7 # Direct your questions about this file to: <sr-users@lists.kamailio.org>
9 # Refer to the Core CookBook at https://www.kamailio.org/wiki/
10 # for an explanation of possible statements, functions and parameters.
12 # Note: the comments can be:
13 # - lines starting with #, but not the pre-processor directives,
14 # which start with #!, like #!define, #!ifdef, #!endif, #!else, #!trydef,
15 # #!subst, #!substdef, ...
16 # - lines starting with //
17 # - blocks enclosed in between /* */
18 # Note: the config performs symmetric SIP signaling
19 # - it sends the reply to the source address of the request
20 # - remove the use of force_rport() for asymmetric SIP signaling
22 # Several features can be enabled using '#!define WITH_FEATURE' directives:
24 # *** To run in debug mode:
26 # - debug level increased to 3, logs still sent to syslog
27 # - debugger module loaded with cfgtrace endabled
29 # *** To enable mysql:
32 # *** To enable authentication execute:
35 # - add users using 'kamctl' or 'kamcli'
37 # *** To enable IP authentication execute:
39 # - enable authentication
40 # - define WITH_IPAUTH
41 # - add IP addresses with group id '1' to 'address' table
43 # *** To enable persistent user location execute:
45 # - define WITH_USRLOCDB
47 # *** To enable presence server execute:
49 # - define WITH_PRESENCE
50 # - if modified headers or body in config must be used by presence handling:
51 # - define WITH_MSGREBUILD
53 # *** To enable nat traversal execute:
55 # - option for NAT SIP OPTIONS keepalives: WITH_NATSIPPING
56 # - install RTPProxy: http://www.rtpproxy.org
58 # rtpproxy -l _your_public_ip_ -s udp:localhost:7722
60 # *** To use RTPEngine (instead of RTPProxy) for nat traversal execute:
61 # - define WITH_RTPENGINE
62 # - install RTPEngine: https://github.com/sipwise/rtpengine
64 # rtpengine --listen-ng=127.0.0.1:2223 ...
66 # *** To enable PSTN gateway routing execute:
68 # - set the value of pstn.gw_ip
69 # - check route[PSTN] for regexp routing condition
71 # *** To enable database aliases lookup execute:
73 # - define WITH_ALIASDB
75 # *** To enable speed dial lookup execute:
77 # - define WITH_SPEEDDIAL
79 # *** To enable multi-domain support execute:
81 # - define WITH_MULTIDOMAIN
83 # *** To enable TLS support execute:
84 # - adjust CFGDIR/tls.cfg as needed
87 # *** To enable JSONRPC over HTTP(S) support execute:
88 # - define WITH_JSONRPC
89 # - adjust event_route[xhttp:request] for access policy
91 # *** To enable anti-flood detection execute:
92 # - adjust pike and htable=>ipban settings as needed (default is
93 # block if more than 16 requests in 2 seconds and ban for 300 seconds)
94 # - define WITH_ANTIFLOOD
96 # *** To block 3XX redirect replies execute:
97 # - define WITH_BLOCK3XX
99 # *** To block 401 and 407 authentication replies execute:
100 # - define WITH_BLOCK401407
102 # *** To enable VoiceMail routing execute:
103 # - define WITH_VOICEMAIL
104 # - set the value of voicemail.srv_ip
105 # - adjust the value of voicemail.srv_port
107 # *** To enhance accounting execute:
109 # - define WITH_ACCDB
110 # - add following columns to database
111 #!ifdef ACCDB_COMMENT
112 ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
113 ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
114 ALTER TABLE acc ADD COLUMN src_ip varchar(64) NOT NULL default '';
115 ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
116 ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
117 ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
118 ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';
119 ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';
120 ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT NULL default '';
121 ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';
122 ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';
123 ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
126 ####### Include Local Config If Exists #########
127 import_file "kamailio-local.cfg"
129 ####### Defined Values #########
131 # *** Value defines - IDs used later in config
139 # - database URL - used to connect to database server by modules such
140 # as: auth_db, acc, usrloc, a.s.o.
141 #!trydef DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
144 #!ifdef WITH_MULTIDOMAIN
145 # - the value for 'use_domain' parameters
146 #!define MULTIDOMAIN 1
148 #!define MULTIDOMAIN 0
152 # FLT_ - per transaction (message) flags
154 #!define FLT_ACCMISSED 2
155 #!define FLT_ACCFAILED 3
158 # FLB_ - per branch flags
160 #!define FLB_NATSIPPING 7
162 ####### Global Parameters #########
164 /* LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR, ... */
167 /* set to 'yes' to print log messages to terminal or use '-E' cli option */
173 log_facility=LOG_LOCAL0
174 log_prefix="{$mt $hdr(CSeq) $ci} "
176 /* number of SIP routing processes for each UDP socket
177 * - value inherited by tcp_children and sctp_children when not set explicitely */
180 /* uncomment the next line to disable TCP (default on) */
183 /* number of SIP routing processes for all TCP/TLS sockets */
186 /* uncomment the next line to disable the auto discovery of local aliases
187 * based on reverse DNS on IPs (default on) */
190 /* add local domain aliases - it can be set many times */
191 # alias="sip.mydomain.com"
193 /* listen sockets - if none set, Kamailio binds to all local IP addresses
194 * - basic prototype (full prototype can be found in Wiki - Core Cookbook):
195 * listen=[proto]:[localip]:[lport] advertise [publicip]:[pport]
196 * - it can be set many times to add more sockets to listen to */
197 # listen=udp:10.0.0.10:5060
199 /* life time of TCP connection when there is no traffic
200 * - a bit higher than registration expires to cope with UA behind NAT */
201 tcp_connection_lifetime=3605
203 /* upper limit for TCP connections (it includes the TLS connections) */
204 tcp_max_connections=2048
213 /* upper limit for TLS connections */
214 tls_max_connections=2048
217 /* set it to yes to enable sctp and load sctp.so module */
220 ####### Custom Parameters #########
222 /* These parameters can be modified runtime via RPC interface
223 * - see the documentation of 'cfg_rpc' module.
225 * Format: group.id = value 'desc' description
226 * Access: $sel(cfg_get.group.id) or @cfg_get.group.id */
231 * - pstn.gw_ip: valid IP or hostname as string value, example:
232 * pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"
234 * - by default is empty to avoid misrouting */
235 pstn.gw_ip = "" desc "PSTN GW Address"
236 pstn.gw_port = "" desc "PSTN GW Port"
239 #!ifdef WITH_VOICEMAIL
240 /* VoiceMail Routing on offline, busy or no answer
242 * - by default Voicemail server IP is empty to avoid misrouting */
243 voicemail.srv_ip = "" desc "VoiceMail IP Address"
244 voicemail.srv_port = "5060" desc "VoiceMail Port"
247 ####### Modules Section ########
249 /* set paths to location of modules */
250 # mpath="/usr/local/lib/kamailio/modules/"
253 loadmodule "db_mysql.so"
257 loadmodule "xhttp.so"
259 loadmodule "jsonrpcs.so"
261 loadmodule "corex.so"
267 loadmodule "maxfwd.so"
268 loadmodule "usrloc.so"
269 loadmodule "registrar.so"
270 loadmodule "textops.so"
271 loadmodule "textopsx.so"
272 loadmodule "siputils.so"
274 loadmodule "sanity.so"
276 loadmodule "cfg_rpc.so"
278 loadmodule "counters.so"
282 loadmodule "auth_db.so"
284 loadmodule "permissions.so"
289 loadmodule "alias_db.so"
292 #!ifdef WITH_SPEEDDIAL
293 loadmodule "speeddial.so"
296 #!ifdef WITH_MULTIDOMAIN
297 loadmodule "domain.so"
300 #!ifdef WITH_PRESENCE
301 loadmodule "presence.so"
302 loadmodule "presence_xml.so"
306 loadmodule "nathelper.so"
307 #!ifdef WITH_RTPENGINE
308 loadmodule "rtpengine.so"
310 loadmodule "rtpproxy.so"
318 #!ifdef WITH_ANTIFLOOD
319 loadmodule "htable.so"
324 loadmodule "debugger.so"
327 # ----------------- setting module-specific parameters ---------------
330 # ----- jsonrpcs params -----
331 modparam("jsonrpcs", "pretty_format", 1)
332 /* set the path to RPC fifo control file */
333 # modparam("jsonrpcs", "fifo_name", "/run/kamailio/kamailio_rpc.fifo")
334 /* set the path to RPC unix socket control file */
335 # modparam("jsonrpcs", "dgram_socket", "/run/kamailio/kamailio_rpc.sock")
337 modparam("jsonrpcs", "transport", 7)
340 # ----- ctl params -----
341 /* set the path to RPC unix socket control file */
342 # modparam("ctl", "binrpc", "unix:/run/kamailio/kamailio_ctl")
344 # ----- sanity params -----
345 modparam("sanity", "autodrop", 0)
347 # ----- tm params -----
348 # auto-discard branches from previous serial forking leg
349 modparam("tm", "failure_reply_mode", 3)
350 # default retransmission timeout: 30sec
351 modparam("tm", "fr_timer", 30000)
352 # default invite retransmission timeout after 1xx: 120sec
353 modparam("tm", "fr_inv_timer", 120000)
355 # ----- rr params -----
356 # set next param to 1 to add value to ;lr param (helps with some UAs)
357 modparam("rr", "enable_full_lr", 0)
358 # do not append from tag to the RR (no need for this script)
359 modparam("rr", "append_fromtag", 0)
361 # ----- registrar params -----
362 modparam("registrar", "method_filtering", 1)
363 /* uncomment the next line to disable parallel forking via location */
364 # modparam("registrar", "append_branches", 0)
365 /* uncomment the next line not to allow more than 10 contacts per AOR */
366 # modparam("registrar", "max_contacts", 10)
367 /* max value for expires of registrations */
368 modparam("registrar", "max_expires", 3600)
369 /* set it to 1 to enable GRUU */
370 modparam("registrar", "gruu_enabled", 0)
371 /* set it to 0 to disable Path handling */
372 modparam("registrar", "use_path", 1)
373 /* save Path even if not listed in Supported header */
374 modparam("registrar", "path_mode", 0)
376 # ----- acc params -----
377 /* what special events should be accounted ? */
378 modparam("acc", "early_media", 0)
379 modparam("acc", "report_ack", 0)
380 modparam("acc", "report_cancels", 0)
381 /* by default ww do not adjust the direct of the sequential requests.
382 * if you enable this parameter, be sure the enable "append_fromtag"
384 modparam("acc", "detect_direction", 0)
385 /* account triggers (flags) */
386 modparam("acc", "log_flag", FLT_ACC)
387 modparam("acc", "log_missed_flag", FLT_ACCMISSED)
388 modparam("acc", "log_extra",
389 "src_user=$fU;src_domain=$fd;src_ip=$si;"
390 "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
391 modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
392 /* enhanced DB accounting */
394 modparam("acc", "db_flag", FLT_ACC)
395 modparam("acc", "db_missed_flag", FLT_ACCMISSED)
396 modparam("acc", "db_url", DBURL)
397 modparam("acc", "db_extra",
398 "src_user=$fU;src_domain=$fd;src_ip=$si;"
399 "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
402 # ----- usrloc params -----
403 modparam("usrloc", "timer_interval", 60)
404 modparam("usrloc", "timer_procs", 1)
405 modparam("usrloc", "use_domain", MULTIDOMAIN)
406 /* enable DB persistency for location entries */
407 #!ifdef WITH_USRLOCDB
408 modparam("usrloc", "db_url", DBURL)
409 modparam("usrloc", "db_mode", 2)
412 # ----- auth_db params -----
414 modparam("auth_db", "db_url", DBURL)
415 modparam("auth_db", "calculate_ha1", yes)
416 modparam("auth_db", "password_column", "password")
417 modparam("auth_db", "load_credentials", "")
418 modparam("auth_db", "use_domain", MULTIDOMAIN)
420 # ----- permissions params -----
422 modparam("permissions", "db_url", DBURL)
423 modparam("permissions", "load_backends", 1)
428 # ----- alias_db params -----
430 modparam("alias_db", "db_url", DBURL)
431 modparam("alias_db", "use_domain", MULTIDOMAIN)
434 # ----- speeddial params -----
435 #!ifdef WITH_SPEEDDIAL
436 modparam("speeddial", "db_url", DBURL)
437 modparam("speeddial", "use_domain", MULTIDOMAIN)
440 # ----- domain params -----
441 #!ifdef WITH_MULTIDOMAIN
442 modparam("domain", "db_url", DBURL)
443 /* register callback to match myself condition with domains list */
444 modparam("domain", "register_myself", 1)
447 #!ifdef WITH_PRESENCE
448 # ----- presence params -----
449 modparam("presence", "db_url", DBURL)
451 # ----- presence_xml params -----
452 modparam("presence_xml", "db_url", DBURL)
453 modparam("presence_xml", "force_active", 1)
457 #!ifdef WITH_RTPENGINE
458 # ----- rtpengine params -----
459 modparam("rtpengine", "rtpengine_sock", "udp:127.0.0.1:2223")
461 # ----- rtpproxy params -----
462 modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
464 # ----- nathelper params -----
465 modparam("nathelper", "natping_interval", 30)
466 modparam("nathelper", "ping_nated_only", 1)
467 modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
468 modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")
470 # params needed for NAT traversal in other modules
471 modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
472 modparam("usrloc", "nat_bflag", FLB_NATB)
476 # ----- tls params -----
477 modparam("tls", "config", "/usr/local/etc/kamailio/tls.cfg")
480 #!ifdef WITH_ANTIFLOOD
481 # ----- pike params -----
482 modparam("pike", "sampling_time_unit", 2)
483 modparam("pike", "reqs_density_per_unit", 16)
484 modparam("pike", "remove_latency", 4)
486 # ----- htable params -----
487 /* ip ban htable with autoexpire after 5 minutes */
488 modparam("htable", "htable", "ipban=>size=8;autoexpire=300;")
492 # ----- debugger params -----
493 modparam("debugger", "cfgtrace", 1)
494 modparam("debugger", "log_level_name", "exec")
497 ####### Routing Logic ########
500 /* Main SIP request routing logic
501 * - processing of any incoming SIP request starts with this route
502 * - note: this is the same as route { ... } */
505 # per request initial checks
512 if (is_method("CANCEL")) {
513 if (t_check_trans()) {
519 # handle retransmissions
520 if (!is_method("ACK")) {
521 if(t_precheck_trans()) {
528 # handle requests within SIP dialogs
531 ### only initial requests (no To tag)
536 # record routing for dialog forming requests (in case they are routed)
537 # - remove preloaded route headers
539 if (is_method("INVITE|SUBSCRIBE")) {
543 # account only INVITEs
544 if (is_method("INVITE")) {
545 setflag(FLT_ACC); # do accounting
548 # dispatch requests to foreign domains
551 ### requests for my local domains
553 # handle presence related requests
556 # handle registrations
560 # request with no Username in RURI
561 sl_send_reply("484","Address Incomplete");
565 # dispatch destinations to PSTN
568 # user location service
572 # Wrapper for relaying requests
575 # enable additional event routes for forwarded requests
576 # - serial forking, RTP relaying handling, a.s.o.
577 if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {
578 if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");
580 if (is_method("INVITE|SUBSCRIBE|UPDATE")) {
581 if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");
583 if (is_method("INVITE")) {
584 if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");
593 # Per SIP request initial checks
595 # no connect for sending replies
596 set_reply_no_connect();
597 # enforce symmetric signaling
598 # - send back replies to the source address of request
601 #!ifdef WITH_ANTIFLOOD
602 # flood detection from same IP and traffic ban for a while
603 # be sure you exclude checking trusted peers, such as pstn gateways
604 # - local host excluded (e.g., loop to self)
606 if($sht(ipban=>$si)!=$null) {
607 # ip is already blocked
608 xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");
611 if (!pike_check_req()) {
612 xlog("L_ALERT","ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n");
613 $sht(ipban=>$si) = 1;
618 if($ua =~ "friendly|scanner|sipcli|sipvicious|VaxSIPUserAgent") {
619 # silent drop for scanners - uncomment next line if want to reply
620 # sl_send_reply("200", "OK");
624 if (!mf_process_maxfwd_header("10")) {
625 sl_send_reply("483","Too Many Hops");
629 if(is_method("OPTIONS") && uri==myself && $rU==$null) {
630 sl_send_reply("200","Keepalive");
634 if(!sanity_check("17895", "7")) {
635 xlog("Malformed SIP request from $si:$sp\n");
640 # Handle requests within SIP dialogs
642 if (!has_totag()) return;
644 # sequential request withing a dialog should
645 # take the path determined by record-routing
648 if (is_method("BYE")) {
649 setflag(FLT_ACC); # do accounting ...
650 setflag(FLT_ACCFAILED); # ... even if the transaction fails
651 } else if ( is_method("ACK") ) {
652 # ACK is forwarded statelessly
654 } else if ( is_method("NOTIFY") ) {
655 # Add Record-Route for in-dialog NOTIFY as per RFC 6665.
662 if (is_method("SUBSCRIBE") && uri == myself) {
663 # in-dialog subscribe requests
667 if ( is_method("ACK") ) {
668 if ( t_check_trans() ) {
669 # no loose-route, but stateful ACK;
670 # must be an ACK after a 487
671 # or e.g. 404 from upstream server
675 # ACK without matching transaction ... ignore and discard
679 sl_send_reply("404","Not here");
683 # Handle SIP registrations
685 if (!is_method("REGISTER")) return;
687 if(isflagset(FLT_NATS)) {
689 #!ifdef WITH_NATSIPPING
691 setbflag(FLB_NATSIPPING);
694 if (!save("location")) {
700 # User location service
703 #!ifdef WITH_SPEEDDIAL
704 # search for short dialing - 2-digit extension
705 if($rU=~"^[0-9][0-9]$") {
706 if(sd_lookup("speed_dial")) {
713 # search in DB-based aliases
714 if(alias_db_lookup("dbaliases")) {
720 if (!lookup("location")) {
727 send_reply("404", "Not Found");
730 send_reply("405", "Method Not Allowed");
735 # when routing via usrloc, log the missed calls also
736 if (is_method("INVITE")) {
737 setflag(FLT_ACCMISSED);
744 # Presence server processing
746 if(!is_method("PUBLISH|SUBSCRIBE")) return;
748 if(is_method("SUBSCRIBE") && $hdr(Event)=="message-summary") {
750 # returns here if no voicemail server is configured
751 sl_send_reply("404", "No voicemail service");
755 #!ifdef WITH_PRESENCE
756 #!ifdef WITH_MSGREBUILD
757 # apply changes in case the request headers or body were modified
765 if(is_method("PUBLISH")) {
768 } else if(is_method("SUBSCRIBE")) {
775 # if presence enabled, this part will not be executed
776 if (is_method("PUBLISH") || $rU==$null) {
777 sl_send_reply("404", "Not here");
783 # IP authorization and user authentication
788 if((!is_method("REGISTER")) && allow_source_address()) {
794 if (is_method("REGISTER") || from_uri==myself) {
795 # authenticate requests
796 if (!auth_check("$fd", "subscriber", "1")) {
797 auth_challenge("$fd", "0");
800 # user authenticated - remove auth header
801 if(!is_method("REGISTER|PUBLISH"))
802 consume_credentials();
804 # if caller is not local subscriber, then check if it calls
805 # a local destination, otherwise deny, not an open relay here
806 if (from_uri!=myself && uri!=myself) {
807 sl_send_reply("403","Not relaying");
813 # authentication not enabled - do not relay at all to foreign networks
815 sl_send_reply("403","Not relaying");
823 # Caller NAT detection
826 if (nat_uac_test("19")) {
827 if (is_method("REGISTER")) {
828 fix_nated_register();
840 # RTPProxy control and signaling updates for NAT traversal
845 if(check_route_param("nat=yes")) {
850 if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) return;
852 #!ifdef WITH_RTPENGINE
853 if(nat_uac_test("8")) {
854 rtpengine_manage("replace-origin replace-session-connection");
856 rtpengine_manage("trust-address replace-origin replace-session-connection");
859 if(nat_uac_test("8")) {
860 rtpproxy_manage("co");
862 rtpproxy_manage("cor");
868 if(t_is_branch_route()) {
869 add_rr_param(";nat=yes");
874 if(isbflagset(FLB_NATB)) {
880 if(isbflagset(FLB_NATB)) {
881 # no connect message in a dialog involving NAT traversal
884 set_forward_no_connect();
892 # URI update for dialog requests
902 # Routing to foreign domains
904 if (uri==myself) return;
906 append_hf("P-Hint: outbound\r\n");
914 # check if PSTN GW IP is defined
915 if (strempty($sel(cfg_get.pstn.gw_ip))) {
916 xlog("SCRIPT: PSTN routing enabled but pstn.gw_ip not defined\n");
920 # route to PSTN dialed numbers starting with '+' or '00'
921 # (international format)
922 # - update the condition to match your dialing rules for PSTN routing
923 if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$")) return;
925 # only local users allowed to call
926 if(from_uri!=myself) {
927 sl_send_reply("403", "Not Allowed");
931 # normalize target number for pstn gateway
932 # - convert leading 00 to +
933 if (starts_with("$rU", "00")) {
938 if (strempty($sel(cfg_get.pstn.gw_port))) {
939 $ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);
941 $ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip) + ":"
942 + $sel(cfg_get.pstn.gw_port);
952 # JSONRPC over HTTP(S) routing
954 event_route[xhttp:request] {
956 set_reply_no_connect();
957 if(src_ip!=127.0.0.1) {
958 xhttp_reply("403", "Forbidden", "text/html",
959 "<html><body>Not allowed from $si</body></html>");
962 if ($hu =~ "^/RPC") {
967 xhttp_reply("200", "OK", "text/html",
968 "<html><body>Wrong URL $hu</body></html>");
973 # Routing to voicemail server
975 #!ifdef WITH_VOICEMAIL
976 if(!is_method("INVITE|SUBSCRIBE")) return;
978 # check if VoiceMail server IP is defined
979 if (strempty($sel(cfg_get.voicemail.srv_ip))) {
980 xlog("SCRIPT: VoiceMail routing enabled but IP not defined\n");
983 if(is_method("INVITE")) {
984 if($avp(oexten)==$null) return;
986 $ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip)
987 + ":" + $sel(cfg_get.voicemail.srv_port);
989 if($rU==$null) return;
991 $ru = "sip:" + $rU + "@" + $sel(cfg_get.voicemail.srv_ip)
992 + ":" + $sel(cfg_get.voicemail.srv_port);
1001 # Manage outgoing branches
1002 branch_route[MANAGE_BRANCH] {
1003 xdbg("new branch [$T_branch_idx] to $ru\n");
1007 # Manage incoming replies
1009 if(!sanity_check("17604", "6")) {
1010 xlog("Malformed SIP response from $si:$sp\n");
1015 # Manage incoming replies in transaction context
1016 onreply_route[MANAGE_REPLY] {
1017 xdbg("incoming reply\n");
1018 if(status=~"[12][0-9][0-9]") {
1023 # Manage failure routing cases
1024 failure_route[MANAGE_FAILURE] {
1027 if (t_is_canceled()) exit;
1029 #!ifdef WITH_BLOCK3XX
1030 # block call redirect based on 3xx replies.
1031 if (t_check_status("3[0-9][0-9]")) {
1032 t_reply("404","Not found");
1037 #!ifdef WITH_BLOCK401407
1038 # block call redirect based on 401, 407 replies.
1039 if (t_check_status("401|407")) {
1040 t_reply("404","Not found");
1045 #!ifdef WITH_VOICEMAIL
1047 # - route to voicemail on busy or no answer (timeout)
1048 if (t_check_status("486|408")) {