[sr-dev] git:master: kamailio.cfg: cfg flags values set via defines

Daniel-Constantin Mierla miconda at gmail.com
Wed Sep 8 10:29:26 CEST 2010


Module: sip-router
Branch: master
Commit: aa60ed0d344f4fde4484ae4073c179cbf4c2b71d
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=aa60ed0d344f4fde4484ae4073c179cbf4c2b71d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Sep  8 10:16:02 2010 +0200

kamailio.cfg: cfg flags values set via defines

---

 etc/kamailio.cfg |   54 +++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/etc/kamailio.cfg b/etc/kamailio.cfg
index a7dd259..9c468a0 100644
--- a/etc/kamailio.cfg
+++ b/etc/kamailio.cfg
@@ -76,6 +76,8 @@
   ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';
 #!endif
 
+####### Defined Values #########
+
 # *** Value defines - IDs used later in config
 #!ifdef WITH_MYSQL
 # - database URL - used to connect to database server by modules such
@@ -89,6 +91,17 @@
 #!define MULTIDOMAIN 0
 #!endif
 
+# - flags
+#   FLT_ - per transaction (message) flags
+#	FLB_ - per branch flags
+#!define FLT_ACC 1
+#!define FLT_ACCMISSED 2
+#!define FLT_ACCFAILED 3
+#!define FLT_NATS 5
+
+#!define FLB_NATB 6
+#!define FLB_NATSIPPING 7
+
 ####### Global Parameters #########
 
 #!ifdef WITH_DEBUG
@@ -256,15 +269,15 @@ modparam("acc", "report_cancels", 0)
    in "rr" module */
 modparam("acc", "detect_direction", 0)
 /* account triggers (flags) */
-modparam("acc", "failed_transaction_flag", 3)
-modparam("acc", "log_flag", 1)
-modparam("acc", "log_missed_flag", 2)
+modparam("acc", "log_flag", FLT_ACC)
+modparam("acc", "log_missed_flag", FLT_ACCMISSED)
 modparam("acc", "log_extra", 
 	"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
+modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
 /* enhanced DB accounting */
 #!ifdef WITH_ACCDB
-modparam("acc", "db_flag", 1)
-modparam("acc", "db_missed_flag", 2)
+modparam("acc", "db_flag", FLT_ACC)
+modparam("acc", "db_missed_flag", FLT_ACCMISSED)
 modparam("acc", "db_url", DBURL)
 modparam("acc", "db_extra",
 	"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
@@ -331,10 +344,12 @@ modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
 # ----- nathelper params -----
 modparam("nathelper", "natping_interval", 30)
 modparam("nathelper", "ping_nated_only", 1)
-modparam("nathelper", "sipping_bflag", 7)
+modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
 modparam("nathelper", "sipping_from", "sip:pinger at kamailio.org")
+
+# params needed for NAT traversal in other modules
 modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
-modparam("usrloc", "nat_bflag", 6)
+modparam("usrloc", "nat_bflag", FLB_NATB)
 #!endif
 
 
@@ -384,7 +399,7 @@ route {
 	# account only INVITEs
 	if (is_method("INVITE"))
 	{
-		setflag(1); # do accounting
+		setflag(FLT_ACC); # do accounting
 	}
 
 	# dispatch requests to foreign domains
@@ -418,9 +433,9 @@ route {
 route[RELAY] {
 #!ifdef WITH_NAT
 	if (check_route_param("nat=yes")) {
-		setbflag("6");
+		setbflag(FLB_NATB);
 	}
-	if (isflagset(5) || isbflagset("6")) {
+	if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) {
 		route(RTPPROXY);
 	}
 #!endif
@@ -459,8 +474,8 @@ route[WITHINDLG] {
 		# take the path determined by record-routing
 		if (loose_route()) {
 			if (is_method("BYE")) {
-				setflag(1); # do accounting ...
-				setflag(3); # ... even if the transaction fails
+				setflag(FLT_ACC); # do accounting ...
+				setflag(FLT_ACCFAILED); # ... even if the transaction fails
 			}
 			route(RELAY);
 		} else {
@@ -491,11 +506,11 @@ route[WITHINDLG] {
 route[REGISTRAR] {
 	if (is_method("REGISTER"))
 	{
-		if(isflagset(5))
+		if(isflagset(FLT_NATS))
 		{
-			setbflag("6");
+			setbflag(FLB_NATB);
 			# uncomment next line to do SIP NAT pinging 
-			## setbflag("7");
+			## setbflag(FLB_SIPPING);
 		}
 		if (!save("location"))
 			sl_reply_error();
@@ -528,7 +543,7 @@ route[LOCATION] {
 	# when routing via usrloc, log the missed calls also
 	if (is_method("INVITE"))
 	{
-		setflag(2);
+		setflag(FLT_ACCMISSED);
 	}
 }
 
@@ -640,7 +655,7 @@ route[NAT] {
 		} else {
 			fix_nated_contact();
 		}
-		setflag(5);
+		setflag(FLT_NATS);
 	}
 #!endif
 	return;
@@ -707,7 +722,8 @@ branch_route[BRANCH_ONE] {
 onreply_route[REPLY_ONE] {
 	xdbg("incoming reply\n");
 #!ifdef WITH_NAT
-	if ((isflagset(5) || isbflagset("6")) && status=~"(183)|(2[0-9][0-9])") {
+	if ((isflagset(FLT_NATS) || isbflagset(FLB_NATB))
+			&& status=~"(183)|(2[0-9][0-9])") {
 		force_rtp_proxy();
 	}
 	if (isbflagset("6")) {
@@ -720,7 +736,7 @@ onreply_route[REPLY_ONE] {
 failure_route[FAIL_ONE] {
 #!ifdef WITH_NAT
 	if (is_method("INVITE")
-			&& (isbflagset("6") || isflagset(5))) {
+			&& (isbflagset(FLB_NATB) || isflagset(FLT_NATS))) {
 		unforce_rtp_proxy();
 	}
 #!endif




More information about the sr-dev mailing list