[Serusers] Looping and sending of multiple requests

Shirley shirleytoh at jpcomputers.com.sg
Thu Apr 29 15:34:05 CEST 2004


Hi, 

Please help! I am trying to do call forwarding when user not online. But I
run the route below, the call went through for the PSTN gateway but I can
see multiple request. Anyone knoe what is happening ...thanks.!!


route{

	# if the request is for other domain use UsrLoc
	# (in case, it does not work, use the following command
	# with proper names and addresses in it)
	if (uri==myself) {

		if (method=="REGISTER") {
			save("location");
			break;
		};
	};

	lookup("aliases");
        if (uri=~"sip:1234[0-9]+ at iptel.org") {
	
	rewritehostport("1.2.3.4:5060");
	# first dump the message to a file using cat command
	exec_msg("printenv SRCIP > /tmp/exectest.txt; cat >>
/tmp/exectest.txt");
	# and then rewrite URI using external utility
	# note that the last echo command trashes input parameter
	  if (exec_dset("echo $SIP_RURI ;echo SIP_SRCIP ;echo>/dev/null")) {
		  sl_send_reply("300", "Redirect");
	  } else {
		sl_reply_error();
		log(1, "alas, rewriting failed\n");
	  };

	};

	if (!uri==myself) {
		t_relay();
		break;
        };


	if (method=="INVITE") {
		fix_nated_sdp("3");
		append_hf("P-hint:Invite");
		# native SIP destinations are handled using our USRLOC DB
		if (!lookup("location")) {
			sl_send_reply("", "Connecting");
			break;
		};
	};

	if (method=="ACK"){
		sl_send_reply("", "ACK");
	 };

	# forward to current uri now; use stateful forwarding; that
	# works reliably even if we forward from TCP to UDP
	if (!t_relay()) {
		sl_reply_error();
		break;
	};
}

# all incoming replies for t_onrepli-ed transactions enter here
onreply_route[1] {
	sdp_mangle_port("-12000");
	 if (isflagset(6) && status=~"2[0-9][0-9]"){
		append_hf("First Route");	
		fix_nated_contact();
		fix_nated_sdp("1");
		force_rtp_proxy();
	 } else if (status=~"2[0-9][0-9]"){
		if (uri=~"sip:019[0-9]+ at iptel.org") {
		  append_hf("019");
		  fix_nated_contact();
		  fix_nated_sdp("3");
	        }
		else{
		  append_hf("2nd Route");
        	  fix_nated_contact();
		  fix_nated_sdp("2");
		  fix_nated_sdp("3");
		  force_rtp_proxy();
		}
	 } else if (status=~"3[0-9][0-9]"){
		append_hf("019");
		fix_nated_contact();
		fix_nated_sdp("3");
	 };
}





More information about the sr-users mailing list