Module: sip-router
Branch: master
Commit: c3b2a816518dafe72ea4d6496ede943f2e685b5f
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c3b2a81…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sat Sep 20 22:23:14 2014 +0200
kamailio-basic.cfg: updates to track minimal common parts with kamailio.cfg
---
etc/kamailio-basic.cfg | 128 +++++++++++++++++++++++++++--------------------
1 files changed, 73 insertions(+), 55 deletions(-)
diff --git a/etc/kamailio-basic.cfg b/etc/kamailio-basic.cfg
index 43309f3..3f072b3 100644
--- a/etc/kamailio-basic.cfg
+++ b/etc/kamailio-basic.cfg
@@ -37,6 +37,7 @@
# - install RTPProxy:
http://www.rtpproxy.org
# - start RTPProxy:
# rtpproxy -l _your_public_ip_ -s udp:localhost:7722
+# - option for NAT SIP OPTIONS keepalives: WITH_NATSIPPING
#
# *** To enable TLS support execute:
# - adjust CFGDIR/tls.cfg as needed
@@ -136,9 +137,9 @@ tcp_connection_lifetime=3605
# set paths to location of modules (to sources or installation folders)
#!ifdef WITH_SRCPATH
-mpath="modules_k:modules"
+mpath="modules"
#!else
-mpath="/usr/local/lib/kamailio/modules_k/:/usr/local/lib/kamailio/modules/"
+mpath="/usr/local/lib/kamailio/modules/"
#!endif
#!ifdef WITH_MYSQL
@@ -327,6 +328,11 @@ request_route {
### only initial requests (no To tag)
+ # handle retransmissions
+ if(t_precheck_trans()) {
+ t_check_trans();
+ exit;
+ }
t_check_trans();
# authentication
@@ -399,6 +405,10 @@ route[REQINIT] {
exit;
}
}
+ if($ua =~ "friendly-scanner") {
+ sl_send_reply("200", "OK");
+ exit;
+ }
#!endif
if (!mf_process_maxfwd_header("10")) {
@@ -406,6 +416,11 @@ route[REQINIT] {
exit;
}
+ if(is_method("OPTIONS") && uri==myself && $rU==$null) {
+ sl_send_reply("200","Keepalive");
+ exit;
+ }
+
if(!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
@@ -414,59 +429,60 @@ route[REQINIT] {
# Handle requests within SIP dialogs
route[WITHINDLG] {
- if (has_totag()) {
- # sequential request withing a dialog should
- # take the path determined by record-routing
- if (loose_route()) {
- route(DLGURI);
- if (is_method("BYE")) {
- setflag(FLT_ACC); # do accounting ...
- setflag(FLT_ACCFAILED); # ... even if the transaction fails
- }
- else if ( is_method("ACK") ) {
- # ACK is forwarded statelessy
- route(NATMANAGE);
- }
- else if ( is_method("NOTIFY") ) {
- # Add Record-Route for in-dialog NOTIFY as per RFC 6665.
- record_route();
- }
+ if (!has_totag()) return;
+
+ # sequential request withing a dialog should
+ # take the path determined by record-routing
+ if (loose_route()) {
+ route(DLGURI);
+ if (is_method("BYE")) {
+ setflag(FLT_ACC); # do accounting ...
+ setflag(FLT_ACCFAILED); # ... even if the transaction fails
+ }
+ else if ( is_method("ACK") ) {
+ # ACK is forwarded statelessy
+ route(NATMANAGE);
+ }
+ else if ( is_method("NOTIFY") ) {
+ # Add Record-Route for in-dialog NOTIFY as per RFC 6665.
+ record_route();
+ }
+ route(RELAY);
+ exit;
+ }
+ if ( is_method("ACK") ) {
+ if ( t_check_trans() ) {
+ # no loose-route, but stateful ACK;
+ # must be an ACK after a 487
+ # or e.g. 404 from upstream server
route(RELAY);
+ exit;
} else {
- if ( is_method("ACK") ) {
- if ( t_check_trans() ) {
- # no loose-route, but stateful ACK;
- # must be an ACK after a 487
- # or e.g. 404 from upstream server
- route(RELAY);
- exit;
- } else {
- # ACK without matching transaction ... ignore and discard
- exit;
- }
- }
- sl_send_reply("404","Not here");
+ # ACK without matching transaction ... ignore and discard
+ exit;
}
- exit;
}
+ sl_send_reply("404", "Not here");
+ exit;
}
# Handle SIP registrations
route[REGISTRAR] {
- if (is_method("REGISTER")) {
- if(isflagset(FLT_NATS)) {
- setbflag(FLB_NATB);
- # uncomment next line to do SIP NAT pinging
- ## setbflag(FLB_NATSIPPING);
- }
- if (!save("location"))
- sl_reply_error();
-
- exit;
+ if (!is_method("REGISTER")) return;
+ if(isflagset(FLT_NATS)) {
+ setbflag(FLB_NATB);
+#!ifdef WITH_NATSIPPING
+ # do SIP NAT pinging
+ setbflag(FLB_NATSIPPING);
+#!endif
}
+ if (!save("location"))
+ sl_reply_error();
+
+ exit;
}
-# USER location service
+# User location service
route[LOCATION] {
if (!lookup("location")) {
$var(rc) = $rc;
@@ -492,7 +508,7 @@ route[LOCATION] {
}
-# Authentication route
+# IP authorization and user uthentication
route[AUTH] {
#!ifdef WITH_AUTH
@@ -524,7 +540,7 @@ route[AUTH] {
return;
}
-# Caller NAT detection route
+# Caller NAT detection
route[NATDETECT] {
#!ifdef WITH_NAT
force_rport();
@@ -532,7 +548,8 @@ route[NATDETECT] {
if (is_method("REGISTER")) {
fix_nated_register();
} else {
- add_contact_alias();
+ if(is_first_hop())
+ set_contact_alias();
}
setflag(FLT_NATS);
}
@@ -564,7 +581,7 @@ route[NATMANAGE] {
}
if (is_reply()) {
if(isbflagset(FLB_NATB)) {
- add_contact_alias();
+ set_contact_alias();
}
}
#!endif
@@ -583,26 +600,27 @@ route[DLGURI] {
# Routing to foreign domains
route[SIPOUT] {
- if (!uri==myself) {
- append_hf("P-hint: outbound\r\n");
- route(RELAY);
- }
+ if (uri==myself) return;
+
+ append_hf("P-hint: outbound\r\n");
+ route(RELAY);
+ exit;
}
-# manage outgoing branches
+# Manage outgoing branches
branch_route[MANAGE_BRANCH] {
xdbg("new branch [$T_branch_idx] to $ru\n");
route(NATMANAGE);
}
-# manage incoming replies
+# Manage incoming replies
onreply_route[MANAGE_REPLY] {
xdbg("incoming reply\n");
if(status=~"[12][0-9][0-9]")
route(NATMANAGE);
}
-# manage failure routing cases
+# Manage failure routing cases
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);