--- ser_config_2_0.txt.orig	2007-05-10 21:25:20.000000000 +0200
+++ ser_config_2_0.txt	2007-05-10 21:38:33.000000000 +0200
@@ -29,10 +29,10 @@
 #memlog=10 # memory statistics log level
 #log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3))
 
-#/* Uncomment these lines to enter debugging mode 
-#fork=no
-#log_stderror=yes
-#*/
+/* Uncomment these lines to enter debugging mode 
+fork=no
+log_stderror=yes
+*/
 
 check_via=no    # (cmd. line: -v)
 dns=no          # (cmd. line: -r)
@@ -141,11 +141,13 @@
 # comment the next line if you dont want to have accouting to DB
 modparam("acc_db", "log_flag", "FLAG_ACC")
 
-# -- nathelper params --
+# -- registrar params --
 modparam("registrar", "save_nat_flag", "FLAG_NAT_UAC")
 modparam("registrar", "load_nat_flag", "FLAG_NAT_UAS")
-modparam("nathelper", "natping_interval", 30) 
-modparam("nathelper", "ping_nated_only", 1)   
+
+# -- nathelper params --
+modparam("nathelper", "natping_interval", 30)
+modparam("nathelper", "ping_nated_only", 1)
 modparam("nathelper", "rtpproxy_sock", "unix:/var/run/rtpproxy.sock")
 
 # -- tm params --
@@ -169,14 +171,14 @@
 
 	# first do some initial sanity checks
 	route(INIT);
-	
+
 	# check if the request is routed via Route header or
 	# needs a Record-Route header
 	route(RR);
 
 	# check if the request belongs to our proxy
 	route(DOMAIN);
-	
+
 	# check if any UA participating in the call is behind NAT	
 	route(NAT_DETECT);
 
@@ -208,7 +210,7 @@
 	# here you could decide wether this call needs a RTP relay or not
 
 	route(NAT_MANGLE);
-    	t_on_reply("NAT_MANGLE");
+	t_on_reply("NAT_MANGLE");
 
 	# for NATed clients record route following cookies except it has already been loose routed
 	if ($record_route_nated && !$loose_route) {
@@ -219,7 +221,6 @@
 	if (!$loose_route)
 		record_route();
 
-
 	# if this is called from the failure route we need to open a new branch
 	if (isflagset(FLAG_FAILUREROUTE)) {
 		append_branch();
@@ -298,17 +299,17 @@
 		if ($account == "yes") {
 			setflag(FLAG_ACC);
 		}
-		
+
 		# this attribute is used for check in route[FORWARD]
 		$loose_route = true;
-		
+
 		# for broken devices which overwrite their Route's with each
 		# (not present) RR from within dialog requests it is better
 		# to repeat the RRing
 		# and if we call rr after loose_route the AVP cookies are restored
 		# automatically :)
 		record_route();
-		
+
 		route(FORWARD);
 
 	} else if (!method=="REGISTER") {
@@ -449,22 +450,23 @@
 
 route[NAT_DETECT]
 {
- xlog("L_ERR","LXLOG: SIP message trace - entered nat.detect route");
+#	xlog("L_NOTICE","route[NAT_DETECT] entered NAT_DETECT route");
  
-    # Skip spiralling requets
-    if (src_ip == 127.0.0.1) return;
+	# Skip spiralling requets
+	if (src_ip == 127.0.0.1) return;
+
+	# Skip requests that already passed a proxy
+	if (is_present_hf("^Record-Route:")) {
+		return;
+	}
+
+	if (nat_uac_test("3")) {
+		force_rport();
+		setflag("FLAG_NAT_UAC");
+		$nated_caller = true;
+	}
 
-    # Skip requests that already passed a proxy
-    if (is_present_hf("^Record-Route:")) {
-    return;
-    }
-     
-    if (nat_uac_test("3")) {
-	force_rport();
-        setflag("FLAG_NAT_UAC");
-        $nated_caller = true;
-    }
-    return;
+	return;
 }
 
 route[NAT_MANGLE]
@@ -491,12 +493,11 @@
 		# Force record routing if either party is behind NAT
 		$record_route_nated = true;
 
-		# rewrites IP address and port in SDP body	
+		# rewrites IP address and port in SDP body
 		force_rtp_proxy();
 	}
     
-return 1;
-
+	return 1;
 }
 
 onreply_route["NAT_MANGLE"]
@@ -508,19 +509,18 @@
 	}
 
 	# Apply RTP proxy if necessary, but only for INVITE transactions
-	# and 183 or 2xx replie
+	# and 183 or 2xx replies
 	if (!$f.nated_caller && !$t.nated_callee) return;
-    
-	# checks if both UAC and UAS are in the same connectivity realm
-    
+
 	if (@cseq.method != "INVITE") return;
-	if ((status =~ "(183)|2[0-9][0-9]") && !search("^Content-Length: 0")) {
+
+	if ((status =~ "(183)|2[0-9][0-9]") && search("^(Content-Type|c):.*application/sdp")) {
+		xlog("L_NOTICE","onreply_route[NAT_MANGLE] force rtp proxy");
 		force_rtp_proxy();
 	}
 	return;
 }
 
-
 route[OUTBOUND]
 {
 	# if a local user calls to a foreign domain we play outbound proxy for him
@@ -571,9 +571,9 @@
 					t_set_fr("$t.fr_inv_timer");
 				}
 			}
-			
+
 			if (isflagset("FLAG_NAT_UAS")) {
-				xlog("L_ERR","LXLOG: callee is 	behind NAT - setting t.nat = true");
+				xlog("L_NOTICE","route[INBOUND] callee is behind NAT - setting $nated_callee = true");
 				$nated_callee = true;
 			}
 			
