A simple patch to make the code look more consistent
Signed-off-by: Paul Belanger <paul.belanger(a)polybeacon.com>
---
etc/kamailio.cfg | 115 +++++++++++++++++++++++++-----------------------------
1 file changed, 54 insertions(+), 61 deletions(-)
diff --git a/etc/kamailio.cfg b/etc/kamailio.cfg
index 0c90f5d..63e5ca2 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);
}
@@ -482,12 +481,12 @@ request_route {
# record routing for dialog forming requests (in case they are routed)
# - remove preloaded route headers
remove_hf("Route");
- if (is_method("INVITE|SUBSCRIBE"))
+ if (is_method("INVITE|SUBSCRIBE")) {
record_route();
+ }
# account only INVITEs
- if (is_method("INVITE"))
- {
+ if (is_method("INVITE")) {
setflag(FLT_ACC); # do accounting
}
@@ -502,8 +501,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;
@@ -530,7 +528,6 @@ route[RELAY] {
if (is_method("INVITE")) {
if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");
}
-
if (!t_relay()) {
sl_reply_error();
}
@@ -543,16 +540,13 @@ route[REQINIT] {
# flood dection from same IP and traffic ban for a while
# be sure you exclude checking trusted peers, such as pstn gateways
# - local host excluded (e.g., loop to self)
- if(src_ip!=myself)
- {
- if($sht(ipban=>$si)!=$null)
- {
+ if (src_ip!=myself) {
+ if ($sht(ipban=>$si)!=$null) {
# ip is already blocked
xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");
exit;
}
- if (!pike_check_req())
- {
+ if (!pike_check_req()) {
xlog("L_ALERT","ALERT: pike blocking $rm from $fu
(IP:$si:$sp)\n");
$sht(ipban=>$si) = 1;
exit;
@@ -565,8 +559,7 @@ route[REQINIT] {
exit;
}
- if(!sanity_check("1511", "7"))
- {
+ if (!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
@@ -583,11 +576,11 @@ route[WITHINDLG] {
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
}
- else if ( is_method("ACK") ) {
+ else if (is_method("ACK")) {
# ACK is forwarded statelessy
route(NATMANAGE);
}
- else if ( is_method("NOTIFY") ) {
+ else if (is_method("NOTIFY")) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
@@ -598,8 +591,8 @@ route[WITHINDLG] {
route(PRESENCE);
exit;
}
- if ( is_method("ACK") ) {
- if ( t_check_trans() ) {
+ 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
@@ -618,17 +611,15 @@ route[WITHINDLG] {
# Handle SIP registrations
route[REGISTRAR] {
- if (is_method("REGISTER"))
- {
- if(isflagset(FLT_NATS))
- {
+ 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"))
+ if (!save("location")) {
sl_reply_error();
-
+ }
exit;
}
}
@@ -638,15 +629,18 @@ route[LOCATION] {
#!ifdef WITH_SPEEDIAL
# search for short dialing - 2-digit extension
- if($rU=~"^[0-9][0-9]$")
- if(sd_lookup("speed_dial"))
+ if ($rU=~"^[0-9][0-9]$") {
+ if (sd_lookup("speed_dial")) {
route(SIPOUT);
+ }
+ }
#!endif
#!ifdef WITH_ALIASDB
# search in DB-based aliases
- if(alias_db_lookup("dbaliases"))
+ if (alias_db_lookup("dbaliases")) {
route(SIPOUT);
+ }
#!endif
$avp(oexten) = $rU;
@@ -666,8 +660,7 @@ route[LOCATION] {
}
# when routing via usrloc, log the missed calls also
- if (is_method("INVITE"))
- {
+ if (is_method("INVITE")) {
setflag(FLT_ACCMISSED);
}
@@ -677,24 +670,22 @@ route[LOCATION] {
# Presence server route
route[PRESENCE] {
- if(!is_method("PUBLISH|SUBSCRIBE"))
+ if (!is_method("PUBLISH|SUBSCRIBE")) {
return;
+ }
#!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"))
- {
+ if (is_method("SUBSCRIBE")) {
handle_subscribe();
t_release();
}
@@ -702,8 +693,7 @@ 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;
}
@@ -715,28 +705,26 @@ 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;
}
#!endif
- if (is_method("REGISTER") || from_uri==myself)
- {
+ if (is_method("REGISTER") || from_uri==myself) {
# authenticate requests
if (!auth_check("$fd", "subscriber", "1")) {
auth_challenge("$fd", "0");
exit;
}
# user authenticated - remove auth header
- if(!is_method("REGISTER|PUBLISH"))
+ if (!is_method("REGISTER|PUBLISH")) {
consume_credentials();
+ }
}
# 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;
}
@@ -765,14 +753,15 @@ route[NATDETECT] {
route[NATMANAGE] {
#!ifdef WITH_NAT
if (is_request()) {
- if(has_totag()) {
- if(check_route_param("nat=yes")) {
+ if (has_totag()) {
+ if (check_route_param("nat=yes")) {
setbflag(FLB_NATB);
}
}
}
- if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))
+ if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) {
return;
+ }
rtpproxy_manage();
@@ -782,7 +771,7 @@ route[NATMANAGE] {
}
}
if (is_reply()) {
- if(isbflagset(FLB_NATB)) {
+ if (isbflagset(FLB_NATB)) {
add_contact_alias();
}
}
@@ -793,7 +782,7 @@ route[NATMANAGE] {
# URI update for dialog requests
route[DLGURI] {
#!ifdef WITH_NAT
- if(!isdsturiset()) {
+ if (!isdsturiset()) {
handle_ruri_alias();
}
#!endif
@@ -802,8 +791,7 @@ route[DLGURI] {
# Routing to foreign domains
route[SIPOUT] {
- if (!uri==myself)
- {
+ if (!uri==myself) {
append_hf("P-hint: outbound\r\n");
route(RELAY);
}
@@ -821,11 +809,12 @@ route[PSTN] {
# route to PSTN dialed numbers starting with '+' or '00'
# (international format)
# - update the condition to match your dialing rules for PSTN routing
- if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$"))
+ if (!($rU=~"^(\+|00)[1-9][0-9]{3,20}$")) {
return;
+ }
# only local users allowed to call
- if(from_uri!=myself) {
+ if (from_uri!=myself) {
sl_send_reply("403", "Not Allowed");
exit;
}
@@ -852,8 +841,9 @@ route[XMLRPC] {
&& (src_ip==127.0.0.1)) {
# close connection only for xmlrpclib user agents (there is a bug in
# xmlrpclib: it waits for EOF before interpreting the response).
- if ($hdr(User-Agent) =~ "xmlrpclib")
+ if ($hdr(User-Agent) =~ "xmlrpclib") {
set_reply_close();
+ }
set_reply_no_connect();
dispatch_rpc();
exit;
@@ -866,16 +856,18 @@ route[XMLRPC] {
# route to voicemail server
route[TOVOICEMAIL] {
#!ifdef WITH_VOICEMAIL
- if(!is_method("INVITE"))
+ if (!is_method("INVITE")) {
return;
+ }
# check if VoiceMail server IP is defined
if (strempty($sel(cfg_get.voicemail.srv_ip))) {
xlog("SCRIPT: VoiceMail rotuing enabled but IP not defined\n");
return;
}
- if($avp(oexten)==$null)
+ if ($avp(oexten)==$null) {
return;
+ }
$ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip)
+ ":" + $sel(cfg_get.voicemail.srv_port);
@@ -895,8 +887,9 @@ branch_route[MANAGE_BRANCH] {
# manage incoming replies
onreply_route[MANAGE_REPLY] {
xdbg("incoming reply\n");
- if(status=~"[12][0-9][0-9]")
+ if (status=~"[12][0-9][0-9]") {
route(NATMANAGE);
+ }
}
# manage failure routing cases
--
1.7.9.5