فهرست منبع

oob script fixes

Adjusted tm module related stuff, t_newtran, t_release, t_reply etc.
Tomas Mandys 14 سال پیش
والد
کامیت
c810736e97

+ 4 - 6
modules/iptrtpproxy/iptrtpproxy.c

@@ -464,7 +464,7 @@ struct sdp_session {
 	str oline_addr_s;
 	str oline_addr_s;
 	unsigned int media_count;
 	unsigned int media_count;
 	struct {
 	struct {
-		int active;  /* íf SDP has been parsed correctly, has a IP (even 0.0.0.0), port!=0 and has supported params */
+		int active;  /* if SDP has been parsed correctly, has a IP (even 0.0.0.0), port!=0 and has supported params */
 		unsigned short port;
 		unsigned short port;
 		unsigned int ip;
 		unsigned int ip;
 		str ip_s;
 		str ip_s;
@@ -1265,7 +1265,7 @@ static int rtpproxy_alloc(struct sip_msg* msg, char* _flags, char* _dummy) {
 	}
 	}
 	if (check_parse_sdp_content(msg, &global_sdp_sess) < 0) return -1;
 	if (check_parse_sdp_content(msg, &global_sdp_sess) < 0) return -1;
 
 
-ERR("RTPPROXY_DEBUG: flags: %d\n", flags);
+ERR("RTPPROXY_DEBUG: sdp.media_count: %d, flags: %d\n", global_sdp_sess.media_count, flags);
 	if (global_params.protected_sess.switchboard) {  /* any protected ? */
 	if (global_params.protected_sess.switchboard) {  /* any protected ? */
 		/* get session source address from kernel module and compare with SDP content */
 		/* get session source address from kernel module and compare with SDP content */
 		for (i = 0; i < global_params.protected_sess.session_count; i++) {
 		for (i = 0; i < global_params.protected_sess.session_count; i++) {
@@ -1292,10 +1292,6 @@ ERR("RTPPROXY_DEBUG: xt_RTPPROXY_update_sessions(sess#:%d, sdp#:%d, XT_RTPPROXY_
 			int j;
 			int j;
 			for (j = 0; j < i; j++) {
 			for (j = 0; j < i; j++) {
 				/* if two media streams have equal source address than we will allocate only one ipt session */
 				/* if two media streams have equal source address than we will allocate only one ipt session */
-				if (global_sdp_sess.media[j].active && global_sdp_sess.media[i].ip == global_sdp_sess.media[j].ip && global_sdp_sess.media[i].port == global_sdp_sess.media[j].port) {
-					ipt_sess.sdp_media[i] = ipt_sess.sdp_media[j];
-					goto cont;
-				}
 				if (global_sdp_sess.media[j].active) {
 				if (global_sdp_sess.media[j].active) {
 					if (global_sdp_sess.media[i].ip == global_sdp_sess.media[j].ip && global_sdp_sess.media[i].port == global_sdp_sess.media[j].port) {
 					if (global_sdp_sess.media[i].ip == global_sdp_sess.media[j].ip && global_sdp_sess.media[i].port == global_sdp_sess.media[j].port) {
 						if (global_sdp_sess.media[i].ip != 0) {
 						if (global_sdp_sess.media[i].ip != 0) {
@@ -1389,6 +1385,8 @@ ERR("DEBUG_RTPPROXY: module: do not allocate session for on-hold stream unless r
 	}
 	}
 	ipt_sess.sdp_media_count = global_sdp_sess.media_count;
 	ipt_sess.sdp_media_count = global_sdp_sess.media_count;
 
 
+ERR("RTPPROXY_DEBUG: session_count: %d, reuse_existing_count: %d\n", global_sdp_sess.media_count, reuse_existing_count);
+
 	if (ipt_sess.session_count > reuse_existing_count) {
 	if (ipt_sess.session_count > reuse_existing_count) {
 		stamp = time(NULL);
 		stamp = time(NULL);
 		if (reuse_existing_count > 0) {
 		if (reuse_existing_count > 0) {

+ 4 - 1
modules/iptrtpproxy/oob/sip-router-oob-RTPPROXY.cfg.inc

@@ -35,7 +35,7 @@ loadmodule "iptrtpproxy"
 modparam("iptrtpproxy", "config", "/etc/iptrtpproxy.cfg");
 modparam("iptrtpproxy", "config", "/etc/iptrtpproxy.cfg");
 
 
 #DEBCONF-RTTPPROXY-START
 #DEBCONF-RTTPPROXY-START
-modparam("iptrtpproxy", "switchboard", "name=*;sip-addr=213.192.59.91");   ## TODO change back to .75
+modparam("iptrtpproxy", "switchboard", "name=*;sip-addr=213.192.59.75");   ## TODO change back to .75
 #modparam("iptrtpproxy", "switchboard", "name=gate_a;sip-addr=1.2.3.4;aggregation=AA")
 #modparam("iptrtpproxy", "switchboard", "name=gate_a;sip-addr=1.2.3.4;aggregation=AA")
 #modparam("iptrtpproxy", "switchboard", "name=gate_b;aggregation=A")
 #modparam("iptrtpproxy", "switchboard", "name=gate_b;aggregation=A")
 modparam("iptrtpproxy", "codec_set", "name=any;media_type=*;rights=0;codecs=*;max_streams=9999");
 modparam("iptrtpproxy", "codec_set", "name=any;media_type=*;rights=0;codecs=*;max_streams=9999");
@@ -86,6 +86,7 @@ route[RTPPROXY_PROCESS_REQUEST] {
 		drop;
 		drop;
 	}
 	}
 	xlog("L_EDEBUG", "RTPPROXY_PROCESS_REQUEST:\n%mb");
 	xlog("L_EDEBUG", "RTPPROXY_PROCESS_REQUEST:\n%mb");
+	xlog("L_EDEBUG", "RTPPROXY_PROCESS_REQUEST: SDP\n%@msg.content.sdp\n");
 	if (isflagset(FLAG_INIT_DLG)) {
 	if (isflagset(FLAG_INIT_DLG)) {
 		# if init request then test RTP proxy is to by applied
 		# if init request then test RTP proxy is to by applied
 		if (@cfg_get.rtp_proxy.enabled == "0") {
 		if (@cfg_get.rtp_proxy.enabled == "0") {
@@ -267,6 +268,7 @@ route[RTPPROXY_PROCESS_REQUEST] {
 route[RTPPROXY_PROCESS_REPLY] {
 route[RTPPROXY_PROCESS_REPLY] {
 	if (!defined $dialog_id || strempty($rtp_method_flag) || strempty(@msg.body)) break;
 	if (!defined $dialog_id || strempty($rtp_method_flag) || strempty(@msg.body)) break;
 	xlog("L_EDEBUG", "RTPPROXY_PROCESS_REPLY:\n%mb\n");
 	xlog("L_EDEBUG", "RTPPROXY_PROCESS_REPLY:\n%mb\n");
+	xlog("L_EDEBUG", "RTPPROXY_PROCESS_REPLY: SDP\n%@msg.content.sdp\n");
 
 
 	if ($rtp_method_flag == "INVITE" && (status=~"18[0-9]" || status=~"2[0-9][0-9]")) {
 	if ($rtp_method_flag == "INVITE" && (status=~"18[0-9]" || status=~"2[0-9][0-9]")) {
 		# If RTP proxy was activated and this is a 18x or 2xx reply with a
 		# If RTP proxy was activated and this is a 18x or 2xx reply with a
@@ -373,6 +375,7 @@ route[RTPPROXY_PROCESS_FAILURE] {
 	if (!defined $dialog_id || strempty($rtp_method_flag)) break;
 	if (!defined $dialog_id || strempty($rtp_method_flag)) break;
 
 
 	xlog("L_EDEBUG", "RTPPROXY_PROCESS_FAILURE:\n%mb\n");
 	xlog("L_EDEBUG", "RTPPROXY_PROCESS_FAILURE:\n%mb\n");
+	xlog("L_EDEBUG", "RTPPROXY_PROCESS_FAILURE: SDP\n%@msg.content.sdp\n");
 
 
 	if (isflagset(FLAG_INIT_DLG) && $rtp_method_flag == "INVITE") {
 	if (isflagset(FLAG_INIT_DLG) && $rtp_method_flag == "INVITE") {
 		route("RTPPROXY_LOAD_ATTRS");
 		route("RTPPROXY_LOAD_ATTRS");

+ 234 - 13
modules/iptrtpproxy/oob/sip-router-oob-RTPPROXY.cfg.patch

@@ -1,6 +1,6 @@
---- sip-router-oob.cfg.1st_phase	2011-03-03 14:07:56.000000000 +0100
-+++ sip-router-oob.cfg	2011-03-03 14:07:56.000000000 +0100
-@@ -283,18 +283,6 @@
+--- /root/sip-router/etc/sip-router-oob.cfg	2011-04-05 21:11:22.000000000 +0200
++++ sip-router-oob-RTPPROXY.cfg-pre_flexroute	2011-04-05 21:03:19.000000000 +0200
+@@ -283,23 +287,11 @@
  #
  #
  session_timer.min_se = "90" desc "minimum session interval (in s)"
  session_timer.min_se = "90" desc "minimum session interval (in s)"
  
  
@@ -19,7 +19,13 @@
  # ------------------ Module Loading -----------------------------------------
  # ------------------ Module Loading -----------------------------------------
  #!ifdef LOCAL_TEST_RUN
  #!ifdef LOCAL_TEST_RUN
  loadpath "modules:modules_s"
  loadpath "modules:modules_s"
-@@ -456,7 +444,7 @@
+ #!else
+-loadpath "/usr/lib/sip-router/modules:/usr/lib/sip-router/modules_s"
++loadpath "/usr/local/lib/ser/modules:/usr/local/lib/ser/modules_s"
+ #!endif
+ 
+ # load a SQL database for authentication, domains, user AVPs etc.
+@@ -457,7 +449,7 @@
  modparam("rr", "enable_full_lr", 1)
  modparam("rr", "enable_full_lr", 1)
  
  
  # Limit the length of the AVP cookie to necessary attributes only
  # Limit the length of the AVP cookie to necessary attributes only
@@ -28,7 +34,7 @@
  
  
  # You probably do not want that someone can simply read and change
  # You probably do not want that someone can simply read and change
  # the AVP cookie in your Routes, thus should really change this
  # the AVP cookie in your Routes, thus should really change this
-@@ -466,7 +454,7 @@
+@@ -467,7 +459,7 @@
  # The ftag Route parameter may be used to easily determine if a BYE
  # The ftag Route parameter may be used to easily determine if a BYE
  # is coming from caller or callee, but we prefer shorter messages
  # is coming from caller or callee, but we prefer shorter messages
  # Enable when FLAG_REVERSE_DIR is to be used
  # Enable when FLAG_REVERSE_DIR is to be used
@@ -37,7 +43,7 @@
  
  
  
  
  # -- gflags --
  # -- gflags --
-@@ -526,7 +514,7 @@
+@@ -529,7 +521,7 @@
  
  
  # RTP Proxy address
  # RTP Proxy address
  #DEBCONF-RTTPPROXY-START
  #DEBCONF-RTTPPROXY-START
@@ -46,7 +52,16 @@
  #DEBCONF-RTTPPROXY-END
  #DEBCONF-RTTPPROXY-END
  
  
  # TCP keepalives as simple as CRLF
  # TCP keepalives as simple as CRLF
-@@ -665,7 +653,8 @@
+@@ -649,7 +641,7 @@
+ 	route(PSTN);
+ 
+ 	# nothing matched
+-	sl_reply("404", "No route matched");
++	t_reply("404", "No route matched");
+ }
+ 
+ # Forward a request to the destination set.
+@@ -668,7 +660,8 @@
  	# If this is an initial INVITE (without a To-tag) we might try
  	# If this is an initial INVITE (without a To-tag) we might try
  	# another target (call forwarding or voicemail) after receiving
  	# another target (call forwarding or voicemail) after receiving
  	# an error.
  	# an error.
@@ -56,7 +71,7 @@
  		t_on_failure("FAILURE_ROUTE");
  		t_on_failure("FAILURE_ROUTE");
  	}
  	}
  
  
-@@ -679,7 +668,7 @@
+@@ -682,7 +675,7 @@
  
  
  	# Activate the RTP proxy as the second last step because it modifies the
  	# Activate the RTP proxy as the second last step because it modifies the
  	# body but also sets an dialog AVP cookie.
  	# body but also sets an dialog AVP cookie.
@@ -65,7 +80,30 @@
  
  
  	# Insert a Record-Route header into all requests.
  	# Insert a Record-Route header into all requests.
  	# This has to be done as one of the last steps to include all the
  	# This has to be done as one of the last steps to include all the
-@@ -874,47 +863,7 @@
+@@ -742,10 +735,10 @@
+ 	# if needed then we MUST put after force_rport() which is located in NAT_DETECTION!!!
+ 	# also must be called after FLAG_ACC is set !!!
+ 	# Check t_reply() vs. sl_reply() usage in script
+-	#if (!t_newtran()) {
+-	#	sl_reply("500", "Internal tm error");
+-	#	drop;
+-	#}
++	if (!t_newtran()) {
++		sl_reply("500", "Internal tm error");
++		drop;
++	}
+ 														
+ 	# Set flag and use it instead of the attribute.
+ 	if ($replicate==1) {
+@@ -765,6 +758,7 @@
+ 		(uri == myself || $t.did != ""))
+ 	{
+ 		options_reply();
++		t_release();
+ 		drop;
+ 	}
+ }
+@@ -879,47 +873,7 @@
  	}
  	}
  }
  }
  
  
@@ -114,8 +152,17 @@
  
  
  # Handling of Route headers
  # Handling of Route headers
  #
  #
-@@ -948,11 +897,6 @@
- 			setflag(FLAG_ACC);
+@@ -934,7 +888,7 @@
+ 		xlog("L_DEBUG", "\n%mb\n\ndialogid -/from/to=%$dialog_id/%$f.dialog_id/%$t.dialog_id");
+ 		if (method == "INVITE" || method == "UPDATE" || method == "ACK" || method == "BYE") {
+ 			if (!defined $dialog_id) {
+-				sl_reply("400", "Missing cookie");
++				t_reply("400", "Missing cookie");
+ 				drop;
+ 			}
+ 		}
+@@ -954,11 +908,6 @@
+ 			setflag(FLAG_ACC_MISSED);
  		}
  		}
  
  
 -		# Restore the RTP proxy flag if present
 -		# Restore the RTP proxy flag if present
@@ -126,7 +173,181 @@
  		# Restore Session Timer flag and headers.
  		# Restore Session Timer flag and headers.
  		if ( defined $stimer && ($stimer != "0")) {
  		if ( defined $stimer && ($stimer != "0")) {
  			route(SESSION_TIMER);
  			route(SESSION_TIMER);
-@@ -1586,6 +1530,7 @@
+@@ -1039,7 +988,7 @@
+ 	# then From b@B and To a@A. There is no mentioning of c@C despite
+ 	# legitimate behaviour of c@C).
+ 	if (!isflagset(FLAG_TOTAG) && strempty($t.did) && strempty($f.did)) {
+-		sl_reply("403", "Relaying Forbidden");
++		t_reply("403", "Relaying Forbidden");
+ 		drop;
+ 	}
+ }
+@@ -1057,6 +1006,7 @@
+ 	# If this is a replica (sent to the multicast address), trust it to
+ 	# be secure and store it in usrloc
+ 	if (dst_ip==224.0.1.75) {
++		t_release();
+ 		if (!isflagset(FLAG_REPL_ENABLED)) {
+ 			# Multicast replication administratively disabled.
+ 			# Ignore.
+@@ -1097,13 +1047,13 @@
+ 
+ 	# Check if the REGISTER if for one of our local domains.
+ 	if (strempty($t.did)) {
+-		sl_reply("403", "Register Forwarding Forbidden");
++		t_reply("403", "Register Forwarding Forbidden");
+ 		drop;
+ 	}
+ 
+ 	# The REGISTER target is in the To header, so reload the domain.
+ 	if (!lookup_domain("$td", "@to.uri.host")) {
+-		sl_reply("404", "Unknown Domain");
++		t_reply("404", "Unknown Domain");
+ 		drop;
+ 	}
+ 
+@@ -1115,29 +1065,29 @@
+ 	# We want only authenticated users to be registered.
+ 	if (!www_authenticate("$fd.digest_realm", "credentials")) {
+ 		if ($? == -2) {
+-			sl_reply("500", "Internal Server Error");
++			t_reply("500", "Internal Server Error");
+ 		}
+ 		else if ($? == -3) {
+-			sl_reply("400", "Bad Request");
++			t_reply("400", "Bad Request");
+ 		}
+ 		else {
+ 			if ($digest_challenge != "") {
+ 				append_to_reply("%$digest_challenge");
+ 			}
+-			sl_reply("401", "Unauthorized");
++			t_reply("401", "Unauthorized");
+ 		}
+ 		drop;
+ 	}
+ 
+ 	# Check if the authenticated user is the same as the target user.
+ 	if (!lookup_user("$tu.uid", "@to.uri")) {
+-		sl_reply("404", "Unknown user in To");
++		t_reply("404", "Unknown user in To");
+ 		drop;
+ 	}
+ 
+ 	# the authentication ID does not match the ID in the To header
+ 	if ($f.uid != $t.uid) {
+-		sl_reply("403", "Authentication and To-Header mismatch");
++		t_reply("403", "Authentication and To-Header mismatch");
+ 		drop;
+ 	}
+ 
+@@ -1145,11 +1095,11 @@
+ 	# originator. You may uncomment it if you care, which URI is in
+ 	# the From header.
+ 	#if (!lookup_user("$fr.uid", "@from.uri")) {
+-	#	sl_reply("404", "Unknown user in From");
++	#	t_reply("404", "Unknown user in From");
+ 	#	drop;
+ 	#}
+ 	#if ($fu.uid != $fr.uid) {
+-	#	sl_reply("403", "Authentication and From-Header mismatch");
++	#	t_reply("403", "Authentication and From-Header mismatch");
+ 	#	drop;
+ 	#}
+ 
+@@ -1158,7 +1108,7 @@
+ 	}
+ 	# Everything is fine. Store the binding.
+ 	if (!save_contacts("location")) {
+-		sl_reply("400", "Invalid REGISTER Request");
++		t_reply("400", "Invalid REGISTER Request");
+ 		drop;
+ 	}
+ # do not delete the following 3 lines, they are used by debconf
+@@ -1190,7 +1140,7 @@
+ #DEBCONF-REPLICATION2-START
+ #
+ #DEBCONF-REPLICATION2-END
+-
++	t_release();
+ 	drop;
+ }
+ 
+@@ -1221,16 +1171,16 @@
+ 
+ 	if (!proxy_authenticate("$fd.digest_realm", "credentials")) {
+ 		if ($? == -2) {
+-			sl_reply("500", "Internal Server Error");
++			t_reply("500", "Internal Server Error");
+ 		}
+ 		else if ($? == -3) {
+-			sl_reply("400", "Bad Request");
++			t_reply("400", "Bad Request");
+ 		}
+ 		else {
+ 			if (defined $digest_challenge && $digest_challenge != "") {
+ 				append_to_reply("%$digest_challenge");
+ 			}
+-			sl_reply("407", "Proxy Authentication Required");
++			t_reply("407", "Proxy Authentication Required");
+ 		}
+ 		drop;
+ 	}
+@@ -1238,11 +1188,11 @@
+ 	# Check if the UID derived from authentication matches that from
+ 	# the From header.
+ 	if (!lookup_user("$fr.uid", "@from.uri")) {
+-		sl_reply("403", "Fake Identity");
++		t_reply("403", "Fake Identity");
+ 		drop;
+ 	}
+ 	if ($fu.uid != $fr.uid) {
+-		sl_reply("403", "Fake Identity");
++		t_reply("403", "Fake Identity");
+ 		drop;
+ 	}
+ 	setflag(FLAG_AUTH_OK);
+@@ -1274,10 +1224,10 @@
+ 	# UA to the real target.
+ 	if ($fd.did != "" && uri =~ "sip:[0-9][0-9]@") {
+ 		if (sd_lookup("speed_dial")) {
+-			sl_reply("302", "Speed Dial Redirect");
++			t_reply("302", "Speed Dial Redirect");
+ 		}
+ 		else {
+-			sl_reply("404", "Speed Dial Not Found");
++			t_reply("404", "Speed Dial Not Found");
+ 		}
+ 		drop;
+ 	}
+@@ -1392,7 +1342,7 @@
+ 	# Check permissions of the caller for initial INVITEs.
+ 	if (isflagset(FLAG_INIT_DLG)) {
+ 		if ($f.gw_acl != "1") {
+-			sl_reply("403", "PSTN Not Permitted");
++			t_reply("403", "PSTN Not Permitted");
+ 			drop;
+ 		}
+ 	}
+@@ -1431,7 +1381,7 @@
+ 		xlog("L_DEBUG", "catching cancel dialogid=%$dialog_id\n");
+ 		if (!t_relay_cancel()) {
+ 			# An INVITE was found but some error occurred.
+-			sl_reply("500", "Internal Server Error");
++			t_reply("500", "Internal Server Error");
+ 			drop;
+ 		}
+ 		# Bad luck, no corresponding INVITE was found, we have to
+@@ -1486,7 +1436,7 @@
+ 				# Session interval is lower than the
+ 				# configured Min-SE
+ 				append_to_reply("Min-SE: %@cfg_get.session_timer.min_se\r\n");
+-				sl_reply("422", "Session Interval Too Small");
++				t_reply("422", "Session Interval Too Small");
+ 				drop;
+ 			}
+ 
+@@ -1592,6 +1542,7 @@
  			}
  			}
  		}
  		}
  	} # if (isflagset...
  	} # if (isflagset...
@@ -134,7 +355,7 @@
  }
  }
  
  
  
  
-@@ -1597,14 +1542,7 @@
+@@ -1603,14 +1554,7 @@
  	# allow proper routing of in-dialog messages.
  	# allow proper routing of in-dialog messages.
  	route(UAS_NAT_DETECTION);
  	route(UAS_NAT_DETECTION);