[RTPproxy Users] Kamilio integration with rtpproxy

Joan aseques at gmail.com
Fri Nov 21 01:31:03 PST 2008


2008/11/20 Maxim Sobolev <sobomax at sippysoft.com>:
> Joan wrote:
>> Hello, I've been trying to setup a testing scenario to offer voip services.
>> At this point I've a phone behind a nat, and I am trying to
>> communicate to the openser, that in turns forwards the calls to an
>> asterisk server.
>> Before nating the phone and starting with the rtpproxy everything was
>> working properly.
>> The current scenario would be:
>>     IP Phone (192.168.2.50) -> NAT server masking as 192.168.253.12)
>> -> Kamailio (192.168.253.98) -> Asterisk (192.168.253.2)
>>
>> The working scenario was:
>>     IP Phone 192.168.253.25 -> Kamailio (192.168.253.98) -> Asterisk
>> (192.168.253.2)
>>
>> I've configured everthing in kamailio as the examples I saw, but I
>> suspect there's something wrong with my rtpproxy (I'm using
>> rtpproxy-1.2.alpha.20081104)
>> The fact is that when I sniff the traffic in localhost, having started
>> rtpproxy as "rtpproxy -s udp:localhost 15000 -f -u openser -l
>> 192.168.253.98 &"
>>
>> ###################################################################################
>> test:~# ngrep -lqtt -W byline port 15000 -d lo
>> interface: lo (127.0.0.0/255.0.0.0)
>> filter: (ip or ip6) and ( port 15000 )
>>
>> U 2008/11/20 16:46:13.466299 127.0.0.1:59654 -> 127.0.0.1:15000
>> 19694_4 L e9f2a818-d99e70b5 at 192.168.2.50 192.168.253.2 17790
>> 4e178bc90eb3861o0;1 as64b2e8a6;1
>>
>> U 2008/11/20 16:46:13.466376 127.0.0.1:15000 -> 127.0.0.1:59654
>> 19694_4 0 192.168.253.98
>> ###################################################################################
>>
>> I see that rtpproxy is returning 0 to the openser doesn't like it and
>> it says "ERROR:nathelper:force_rtp_proxy2_f: incorrect port 0 in reply
>> from rtp proxy"
>>
>> Do i have a broken rtpproxy, or it's a matter of configuration?
>
> Joan,
>
> It looks like misconfiguration to me, can you please send your
> openser.cfg config?
>


This is basically most of the config ...
This is the original config from kamailio adapted to work with db +
some nat detection/correction



# -- nathelper
modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:15000")


####### Routing Logic ########


# main request routing logic

route{

	if (!mf_process_maxfwd_header("10")) {
		sl_send_reply("483","Too Many Hops");
		exit;
	}

	if (has_totag()) {
		# sequential request withing a dialog should
		# take the path determined by record-routing
		if (loose_route()) {
			if (is_method("BYE")) {
				log(1, "MIS: Allibero el proxy \n");
				unforce_rtp_proxy();
				setflag(1); # do accouting ...
				setflag(3); # ... even if the transaction fails
			}
			route(1);
		} else {
			if ( is_method("ACK") ) {
				if ( t_check_trans() ) {
					# non loose-route, but stateful ACK; must be an ACK after a 487
or e.g. 404 from upstream server
					t_relay();
					exit;
				} else {
					# ACK without matching transaction ... ignore and discard.\n");
					exit;
				}
			}
			sl_send_reply("404","Not here");
		}
		exit;
	}

	#initial requests

	# CANCEL processing
	if (is_method("CANCEL"))
	{
		#Freeing proxy
		unforce_rtp_proxy();
		if (t_check_trans())
			t_relay();
		exit;
	}
	t_check_trans();

	# authenticate if from local subscriber (uncomment to enable auth)
	if (!(method=="REGISTER") && from_uri==myself)
	{
		if (!proxy_authorize("", "subscriber")) {
			proxy_challenge("", "0");
			exit;
		}
		if (!check_from()) {
			sl_send_reply("403","Forbidden auth ID");
			exit;
		}
	
		consume_credentials();
		# caller authenticated
	}

	# record routing
	if (!is_method("REGISTER|MESSAGE"))
		record_route();

	# account only INVITEs
	if (is_method("INVITE")) {
		setflag(1); # do accouting
		if (uri =~ "sip:[69][0-9]{8}@.*")
			{
		        rewritehost("192.168.253.2");
		        log(1, "MIS: Redirecting call to internal asterisk \n");
			route(1);
			return;
			}

	}

	if (!is_uri_host_local())
	{
		append_hf("P-hint: outbound\r\n");
		# if you have some interdomain connections via TLS
		##if($rd=="tls_domain1.net") {
		##	t_relay("tls:domain1.net");
		##	exit;
		##} else if($rd=="tls_domain2.net") {
		##	t_relay("tls:domain2.net");
		##	exit;
		##}
		route(1);
	}

	# requests for my domain

	if (is_method("PUBLISH"))
	{
		sl_send_reply("503", "Service Unavailable");
		exit;
	}
	

	if (is_method("REGISTER"))
	{
		# authenticate the REGISTER requests (uncomment to enable auth)
		if (!www_authorize("", "subscriber"))
		{
			www_challenge("", "0");
			exit;
		}
		
		if (!check_to())
		{
			sl_send_reply("403","Forbidden auth ID");
			exit;
		}

		if (!save("location"))
			sl_reply_error();

		exit;
	}

	if ($rU==NULL) {
		# request with no Username in RURI
		sl_send_reply("484","Address Incomplete");
		exit;
	}

	# apply DB based aliases (uncomment to enable)
	alias_db_lookup("dbaliases");


	if (!lookup("location")) {
		switch ($retcode) {
			case -1:
			case -3:
				t_newtran();
				t_reply("404", "Not Found");
				exit;
			case -2:
				sl_send_reply("405", "Method Not Allowed");
				exit;
		}
	}

	# when routing via usrloc, log the missed calls also
	setflag(2);

	route(1);
}


route[1] {
	# for INVITEs enable some additional helper routes
	if (is_method("INVITE")) {
		if(isbflagset(2)) {##########      # behind a NAT
			log("MIS: Forcing proxy within router 1")
			force_rtp_proxy();
		};
		t_on_branch("2");
		t_on_reply("2");
		t_on_failure("1");
	}
	
	if (!t_relay()) {
		sl_reply_error();
	};
	exit;
}



branch_route[2] {
	xlog("MIS: new branch at $ru\n");
}


onreply_route[2] {
	xlog("MIS: incoming reply\n");
        force_rport();
        if (status =~ "(183)|(2[0-9][0-9])") {
                if(nat_uac_test("19")) {
			log("MIS: Hem detectat NAT");
                        setbflag(2); # flag for NAT
                        fix_nated_contact();
			fix_nated_sdp("11");
                        force_rtp_proxy();
                };
        };
}


failure_route[1] {
	if (t_was_cancelled()) {
		exit;
	}
}


More information about the Users mailing list