Module: sip-router
Branch: master
Commit: be1ed10d61918285bdbb3686ac8d43a31f5e63bc
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=be1ed10…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Sep 19 21:55:24 2014 +0200
kamailio.cfg: coherent formating
- compacted some sub-routes by reducing if-block identation with returns
---
etc/kamailio.cfg | 151 +++++++++++++++++++++++++----------------------------
1 files changed, 71 insertions(+), 80 deletions(-)
diff --git a/etc/kamailio.cfg b/etc/kamailio.cfg
index 0070520..4125c47 100644
--- a/etc/kamailio.cfg
+++ b/etc/kamailio.cfg
@@ -461,8 +461,7 @@ request_route {
route(NATDETECT);
# CANCEL processing
- if (is_method("CANCEL"))
- {
+ if (is_method("CANCEL")) {
if (t_check_trans()) {
route(RELAY);
}
@@ -491,8 +490,7 @@ request_route {
record_route();
# account only INVITEs
- if (is_method("INVITE"))
- {
+ if (is_method("INVITE")) {
setflag(FLT_ACC); # do accounting
}
@@ -507,8 +505,7 @@ request_route {
# handle registrations
route(REGISTRAR);
- if ($rU==$null)
- {
+ if ($rU==$null) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
exit;
@@ -521,7 +518,7 @@ request_route {
route(LOCATION);
}
-
+# Wrapper for relaying requests
route[RELAY] {
# enable additional event routes for forwarded requests
@@ -584,66 +581,66 @@ 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("SUBSCRIBE") && uri == myself) {
+ # in-dialog subscribe requests
+ route(PRESENCE);
+ 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("SUBSCRIBE") && uri == myself) {
- # in-dialog subscribe requests
- route(PRESENCE);
- 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 {
- # 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();
+ if (!is_method("REGISTER")) return;
- exit;
+ 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] {
#!ifdef WITH_SPEEDDIAL
@@ -676,8 +673,7 @@ route[LOCATION] {
}
# when routing via usrloc, log the missed calls also
- if (is_method("INVITE"))
- {
+ if (is_method("INVITE")) {
setflag(FLT_ACCMISSED);
}
@@ -685,7 +681,7 @@ route[LOCATION] {
exit;
}
-# Presence server route
+# Presence server processing
route[PRESENCE] {
if(!is_method("PUBLISH|SUBSCRIBE"))
return;
@@ -698,14 +694,12 @@ route[PRESENCE] {
}
#!ifdef WITH_PRESENCE
- if (!t_newtran())
- {
+ if (!t_newtran()) {
sl_reply_error();
exit;
}
- if(is_method("PUBLISH"))
- {
+ if(is_method("PUBLISH")) {
handle_publish();
t_release();
} else if(is_method("SUBSCRIBE")) {
@@ -716,21 +710,19 @@ route[PRESENCE] {
#!endif
# if presence enabled, this part will not be executed
- if (is_method("PUBLISH") || $rU==$null)
- {
+ if (is_method("PUBLISH") || $rU==$null) {
sl_send_reply("404", "Not here");
exit;
}
return;
}
-# Authentication route
+# IP authorization and user uthentication
route[AUTH] {
#!ifdef WITH_AUTH
#!ifdef WITH_IPAUTH
- if((!is_method("REGISTER")) && allow_source_address())
- {
+ if((!is_method("REGISTER")) && allow_source_address()) {
# source IP allowed
return;
}
@@ -749,8 +741,7 @@ route[AUTH] {
}
# if caller is not local subscriber, then check if it calls
# a local destination, otherwise deny, not an open relay here
- if (from_uri!=myself && uri!=myself)
- {
+ if (from_uri!=myself && uri!=myself) {
sl_send_reply("403","Not relaying");
exit;
}
@@ -759,7 +750,7 @@ route[AUTH] {
return;
}
-# Caller NAT detection route
+# Caller NAT detection
route[NATDETECT] {
#!ifdef WITH_NAT
force_rport();
@@ -776,7 +767,7 @@ route[NATDETECT] {
return;
}
-# RTPProxy control
+# RTPProxy control and singaling updates for NAT traversal
route[NATMANAGE] {
#!ifdef WITH_NAT
if (is_request()) {
@@ -820,11 +811,11 @@ 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;
}
# PSTN GW routing
@@ -881,7 +872,7 @@ route[XMLRPC] {
}
#!endif
-# route to voicemail server
+# Routing to voicemail server
route[TOVOICEMAIL] {
#!ifdef WITH_VOICEMAIL
if(!is_method("INVITE|SUBSCRIBE"))
@@ -910,20 +901,20 @@ route[TOVOICEMAIL] {
return;
}
-# 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);