2
0
Эх сурвалжийг харах

more debug info in data_lump, iptel. cfg extended

Jiri Kuthan 23 жил өмнө
parent
commit
ea4fd4cd0e
3 өөрчлөгдсөн 151 нэмэгдсэн , 26 устгасан
  1. 2 2
      data_lump_rpl.c
  2. 143 18
      etc/iptel.cfg
  3. 6 6
      modules/tm/t_fwd.c

+ 2 - 2
data_lump_rpl.c

@@ -12,14 +12,14 @@ struct lump_rpl* build_lump_rpl( char* text, int len )
 	lump = (struct lump_rpl*) pkg_malloc(sizeof(struct lump_rpl));
 	lump = (struct lump_rpl*) pkg_malloc(sizeof(struct lump_rpl));
 	if (!lump)
 	if (!lump)
 	{
 	{
-		LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n");
+		LOG(L_ERR,"ERROR:build_lump_rpl : no free memory (struct)!\n");
 		goto error;
 		goto error;
 	}
 	}
 
 
 	lump->text.s = pkg_malloc( len );
 	lump->text.s = pkg_malloc( len );
 	if (!lump->text.s)
 	if (!lump->text.s)
 	{
 	{
-		LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n");
+		LOG(L_ERR,"ERROR:build_lump_rpl : no free memory (%d)!\n", len );
 		goto error;
 		goto error;
 	}
 	}
 
 

+ 143 - 18
etc/iptel.cfg

@@ -48,7 +48,7 @@ modparam("usrloc", "expires_column", "expires")
 modparam("usrloc", "q_column",       "q")
 modparam("usrloc", "q_column",       "q")
 modparam("usrloc", "callid_column",  "callid")
 modparam("usrloc", "callid_column",  "callid")
 modparam("usrloc", "cseq_column",    "cseq")
 modparam("usrloc", "cseq_column",    "cseq")
-modparam("usrloc", "flush_interval", 60)
+modparam("usrloc", "flush_interval", 10)
 modparam("usrloc", "db_url",         "sql://csps:47csps11@dbhost/csps107")
 modparam("usrloc", "db_url",         "sql://csps:47csps11@dbhost/csps107")
 
 
 # -- auth params --
 # -- auth params --
@@ -107,6 +107,11 @@ route{
 	# filter local stateless ACK generated by authentication of mf replies
 	# filter local stateless ACK generated by authentication of mf replies
 	sl_filter_ACK();
 	sl_filter_ACK();
 
 
+	if (len_gt( max_len )) {
+		sl_send_reply("513", "Riesengross -- Message too large");
+		break;
+	};
+
 	# filter too old messages
 	# filter too old messages
 	log("LOG: Checking maxfwd\n");
 	log("LOG: Checking maxfwd\n");
 	if (!mf_process_maxfwd_header("10")) {
 	if (!mf_process_maxfwd_header("10")) {
@@ -115,6 +120,74 @@ route{
 		break;
 		break;
 	};
 	};
 
 
+	# -------------------- testing accounts ----------------
+#XX
+	if (uri=~"sip:333.*@iptel\.org") {
+		forward( 195.113.147.6, 5060 );
+		break;
+	} ;
+
+	if (uri=~"sip:everloop@iptel\.org") {
+		t_relay();
+		break;
+	}	;
+
+	if (uri=~"sip:looptester@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt0@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt1@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt2@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt3@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt4@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt5@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt6@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt7@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} ; if (uri=~"sip:lt8@iptel\.org") {
+#	}   else if (uri=~"sip:lt8@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt9@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lt0@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	} else if (uri=~"sip:lta@iptel\.org") {
+		seturi("sip:[email protected]");
+		t_relay();
+		break;
+	};
+	# -------------------- Eo testing account ----------------
+
 	# Do strict routing if route headers present
 	# Do strict routing if route headers present
 	rewriteFromRoute();
 	rewriteFromRoute();
 
 
@@ -124,6 +197,8 @@ route{
 		sethost("iptel.org");
 		sethost("iptel.org");
 #		t_relay_to("fox.iptel.org", "5066");
 #		t_relay_to("fox.iptel.org", "5066");
 		t_relay_to("fox.iptel.org", "6060");
 		t_relay_to("fox.iptel.org", "6060");
+#XX
+# { sl_reply_error(); break; }
 		break;
 		break;
 	};
 	};
 
 
@@ -135,7 +210,9 @@ route{
 
 
 	# sign of our domain: there is @ (username), :
 	# sign of our domain: there is @ (username), :
     # (nothing) or . (host) in front of our domain name	
     # (nothing) or . (host) in front of our domain name	
-	if (!(uri=~"[@:\.]iptel\.org([;:].*)*" 
+#XX
+#	if (!(uri=~"[@:\.]iptel\.org([;:].*)*" 
+	if (!(uri=~"[@:]iptel\.org([;:].*)*" 
 		| uri=~"[@:\.]195\.37\.77\.101([;:].*)*" |
 		| uri=~"[@:\.]195\.37\.77\.101([;:].*)*" |
 		uri=~"@195\.37\.77\.110([;:].*)*" )) {
 		uri=~"@195\.37\.77\.110([;:].*)*" )) {
 		route(2);
 		route(2);
@@ -145,17 +222,26 @@ route{
 	# here we continue with requests for our domain...
 	# here we continue with requests for our domain...
 
 
 	# various aliases (might use a database in future)
 	# various aliases (might use a database in future)
+#	lookup_contact("aliases");
 	if (uri=~"sip:9040@") {
 	if (uri=~"sip:9040@") {
-		seturi("[email protected]");
+		seturi("sip:[email protected]");
+	};
+	if (uri=~"sip:9042@") {
+		seturi("sip:[email protected]");
 	};
 	};
 	if (uri=~"sip:17@") {
 	if (uri=~"sip:17@") {
 		seturi("sip:[email protected]");
 		seturi("sip:[email protected]");
 	};
 	};
-	if (uri=~"sip:jirim@") {
+	if (uri=~"sip:jirim@"  ) {
 		seturi("sip:[email protected]");
 		seturi("sip:[email protected]");
 	};
 	};
+	if ( uri=~"sip:info@" ) {
+		seturi("sip:[email protected]");
+	};
 	# check again, if it is still for our domain after aliases
 	# check again, if it is still for our domain after aliases
-	if ( !(uri=~"[@:\.]iptel\.org([;:].*)*" | 
+#XX
+#	if ( !(uri=~"[@:\.]iptel\.org([;:].*)*" | 
+	if ( !(uri=~"[@:]iptel\.org([;:].*)*" | 
 		uri=~"[@:\.]195\.37\.77\.101([;:].*)*" |
 		uri=~"[@:\.]195\.37\.77\.101([;:].*)*" |
 		uri=~"@195\.37\.77\.110([;:].*)*" )) {
 		uri=~"@195\.37\.77\.110([;:].*)*" )) {
 		route(2);
 		route(2);
@@ -168,23 +254,26 @@ route{
 	# avoid stealing incoming calls	
 	# avoid stealing incoming calls	
 	if (method=="REGISTER") {
 	if (method=="REGISTER") {
 		log("LOG Request is REGISTER\n");
 		log("LOG Request is REGISTER\n");
+		# prohibit attempts to grab someone else's To address 
+		# using  valid credentials; the only exception is the user
+		# 'replciator' permitted to generate 3-rd party registrations
+
+
 		if (!www_authorize(	"iptel.org" /* realm */, 
 		if (!www_authorize(	"iptel.org" /* realm */, 
-#		if (!proxy_authorize(	"iptel.org" /* realm */, 
 			 				"subscriber" /* table name */ )) {
 			 				"subscriber" /* table name */ )) {
 			log("LOG: REGISTER has no credentials, sending challenge\n");
 			log("LOG: REGISTER has no credentials, sending challenge\n");
  			www_challenge(	"iptel.org" /* realm */, 
  			www_challenge(	"iptel.org" /* realm */, 
-#			proxy_challenge(	"iptel.org" /* realm */, 
 							"0" /* no qop -- M$ can't deal with it */);
 							"0" /* no qop -- M$ can't deal with it */);
 			break;
 			break;
 		};
 		};
-		# prohibit attempts to grab someone else's To address 
-		# using  valid credentials
-		if (!check_to()) {
+
+		if (!is_user("replicator") & !check_to()) {
 			log("LOG: To Cheating attempt\n");
 			log("LOG: To Cheating attempt\n");
 			sl_send_reply("403", "That is ugly -- use To=id next time");
 			sl_send_reply("403", "That is ugly -- use To=id next time");
 			break;
 			break;
 		};
 		};
 			
 			
+
 		# update Contact database
 		# update Contact database
        	log("LOG: REGISTER is authorized, saving location\n");
        	log("LOG: REGISTER is authorized, saving location\n");
 		save_contact("location");
 		save_contact("location");
@@ -201,7 +290,7 @@ route{
 
 
 	# ---------- CPL demo - begin --------------
 	# ---------- CPL demo - begin --------------
 	/* added by Bogdan for cpl demo - Dorgham request*/
 	/* added by Bogdan for cpl demo - Dorgham request*/
-	if (uri=~"sip:test@.*" && method=="INVITE")
+	if (uri=~"sip:test@.*" & method=="INVITE")
 	{
 	{
 		log("SER : runing CPL!! :)\n");
 		log("SER : runing CPL!! :)\n");
 		if ( !cpl_run_script() )
 		if ( !cpl_run_script() )
@@ -222,23 +311,25 @@ route{
 	};
 	};
 	# -------------- CPL demo - end -------------
 	# -------------- CPL demo - end -------------
 	# ---------- forking demo2 - begin --------------
 	# ---------- forking demo2 - begin --------------
-	if (uri=~"sip:cebit@.*" && method=="INVITE") {
+	if (uri=~"sip:cebit@.*" & method=="INVITE") {
 		# Cisco phone on Jiri's desktop; Caution: DHCP address,
 		# Cisco phone on Jiri's desktop; Caution: DHCP address,
 		#  subject to change
 		#  subject to change
-		seturi("sip:[email protected]");
+		seturi("sip:[email protected]");
 		# Jiri's desktop PC; Caution: DHCP address,
 		# Jiri's desktop PC; Caution: DHCP address,
 		#  subject to change
 		#  subject to change
-		t_fork_to_uri("sip:[email protected]");
+		# t_fork_to_uri("sip:[email protected]");
 		# gateway address; Caution: is PSTN number changes, it must
 		# gateway address; Caution: is PSTN number changes, it must
 		#   on the list of free destination bellow; otherwise the
 		#   on the list of free destination bellow; otherwise the
 		#   caller will be challenged!
 		#   caller will be challenged!
-		#t_fork_to_uri("sip:[email protected]");
-		t_fork_to_uri( "sip:[email protected]");
+		t_fork_to_uri("sip:[email protected]");
+		#t_fork_to_uri( "sip:[email protected]");
 
 
 
 
 		t_fork_on_no_response("sip:[email protected]");
 		t_fork_on_no_response("sip:[email protected]");
 	
 	
 		t_relay();
 		t_relay();
+#XX
+#{ sl_reply_error(); break; }
 		break;
 		break;
 	};
 	};
 	# ---------- forking demo2 - end  --------------
 	# ---------- forking demo2 - end  --------------
@@ -263,12 +354,14 @@ route{
 	};
 	};
 
 
 	# requests from gateway should be RR-ed too
 	# requests from gateway should be RR-ed too
-	if (src_ip==195.37.77.110 && method=="INVITE")  {
+	if (src_ip==195.37.77.110 & method=="INVITE")  {
 		addRecordRoute();
 		addRecordRoute();
 	};
 	};
 
 
 	# we now know we may, we know where, let it go out now!
 	# we now know we may, we know where, let it go out now!
 	t_relay();
 	t_relay();
+#XX
+#{ sl_reply_error(); break; }
 }
 }
 
 
 # routing logic for outbound requests targeted out of our domain
 # routing logic for outbound requests targeted out of our domain
@@ -301,13 +394,16 @@ route[2] {
 		};
 		};
 
 
 		t_relay();
 		t_relay();
+#XX
+#{ sl_reply_error(); break; }
 }
 }
 
 
 # logic for calls through our PSTN gateway
 # logic for calls through our PSTN gateway
 route[3] {
 route[3] {
 	# free call destinations ... no authentication needed
 	# free call destinations ... no authentication needed
 	if (uri=~"sip:001795061546@.*" | uri=~"sip:0016097265544.*" 
 	if (uri=~"sip:001795061546@.*" | uri=~"sip:0016097265544.*" 
-		| uri=~"sip:[79][0-9][0-9][0-9]@.*") {
+		| uri=~"sip:[79][0-9][0-9][0-9]@.*" 
+		| uri=~"sip:98[0-9][0-9][0-9][0-9]") {
 		log("LOG: Free PSTN\n");
 		log("LOG: Free PSTN\n");
 		# let's log free calls for now too ...
 		# let's log free calls for now too ...
 		setflag(1);
 		setflag(1);
@@ -387,4 +483,33 @@ route[3] {
 
 
 
 
 	t_relay();
 	t_relay();
+#XX
+#{ sl_reply_error(); break; }
 }
 }
+
+/*
+
+if (! t_newtran()) { 
+	# # retransmit whatever we have 
+	t_retransmit_reply(); 
+} else {
+	# do what you want to do 
+	if (send_sms()) { 
+		# things went well, send ok upstream
+		if (!t_send_reply("200", "yes sir, SMS sent over")) {
+			# if replying failed, retry statelessly 
+			sl_reply_error(); 
+		};
+	} else {
+		if (!t_send_reply("500", "SMS error :-(")) {
+			# if replying failed, retry statelessly 
+			sl_reply_error(); 
+		};
+	};
+	# transaction concluded -- junk it now
+	t_release(); 
+}
+t_unref();
+
+*/
+

+ 6 - 6
modules/tm/t_fwd.c

@@ -320,13 +320,13 @@ int t_forward_ack( struct sip_msg* p_msg  )
 	}
 	}
 #endif
 #endif
 
 
-	/* check for bizzar race condition if two processes receive
-	   two ACKs concurrently; use shmem semaphore for protection
-	   -- we have to enter it here anyway (the trick with inACKed
-	   inside the protection region) */
+	/* we relay an ACK for second time, hmmm -- noticable; anyway,
+	   keep relaying; it may be for example spiraled ACK mistakenly
+	   matching the first transaction in second cycle (there is
+	   no way to distinguish) */
 	if  (T->uas.isACKed ) {
 	if  (T->uas.isACKed ) {
 		LOG(L_WARN,"Warning: ACK received when there's one; check upstream\n");
 		LOG(L_WARN,"Warning: ACK received when there's one; check upstream\n");
-		return 1;
+		/* return 1; */
 	}
 	}
 	ack = shm_malloc( len );
 	ack = shm_malloc( len );
 	memcpy(ack , buf , len);
 	memcpy(ack , buf , len);
@@ -372,7 +372,7 @@ int forward_serial_branch(struct cell* Trans,int branch)
 			shm_free_lump(b);
 			shm_free_lump(b);
 		}
 		}
 
 
-	DBG("DEBUG: t_forward_serial_branch: building req for branch"
+	LOG(L_ERR,"DEBUG: t_forward_serial_branch: building req for branch"
 		"%d; uri=|%.*s|.\n", branch, Trans->uac[branch].uri.len,
 		"%d; uri=|%.*s|.\n", branch, Trans->uac[branch].uri.len,
 		Trans->uac[branch].uri.s);
 		Trans->uac[branch].uri.s);
 	/* updates the new uri*/
 	/* updates the new uri*/