<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.26.0">
</HEAD>
<BODY>
<TT><FONT COLOR="#1a1a1a">Hello,</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">I'm trying to test rtpproxy with nathelper module to forward RTP traffic between two networks, my architecture is as follow:</FONT></TT><BR>
<BR>
<BLOCKQUOTE>
<BR>
</BLOCKQUOTE>
<TT>------------------- -------------------------------------- --------------------</TT><BR>
<TT>UAC (172.23.1.22) | | | | UAC (172.1.1.21) |</TT><BR>
<TT> |=======>| 172.23.1.20 (OpenSIPS) 172.1.1.166 |=======>| |</TT><BR>
<TT>Internal Network | | | | External Network |</TT><BR>
<TT>------------------- -------------------------------------- --------------------</TT><BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<BR>
</BLOCKQUOTE>
</BLOCKQUOTE>
<BR>
<BR>
<TT><FONT COLOR="#1a1a1a">I run rtpproxy:</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">rtpproxy -fF -l 172.1.1.166/172.23.1.20</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">Then I tried to establish a call from internal net (172.23.1.22) to external net(172.1.1.21) and the connection established succussfully with perfect RTP relay through (172.1.1.166) interface.</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">But when I tried to call from external network towards internal, the RTP traffic relay didn't work?.</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">Following is the part related to nathelper and routing logic in my configuration file:</FONT></TT><BR>
<BR>
<BR>
<BR>
<TT><FONT COLOR="#1a1a1a">loadmodule "nathelper.so"</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">modparam("nathelper", "natping_interval", 30)</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">modparam("nathelper", "ping_nated_only", 1)</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">modparam("nathelper", "rtpproxy_sock", "unix:/var/run/rtpproxy.sock")</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">modparam("nathelper", "received_avp", "$avp(i:42)")</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">modparam("registrar", "received_avp", "$avp(i:42)")</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">modparam("usrloc", "nat_bflag", 6)</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">modparam("registrar", "method_filtering", 1)</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">mhomed=1</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">route {</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # Sanity Check Section</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> if (!mf_process_maxfwd_header("10")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> sl_send_reply("483", "Too Many Hops");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (msg:len > max_len) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> sl_send_reply("513", "Message Overflow");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # Record Route Section</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> if (method!="REGISTER") {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> record_route();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (method=="BYE" || method=="CANCEL") {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> unforce_rtp_proxy();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> }</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # Loose Route Section</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (loose_route()) {</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if ((method=="INVITE" || method=="REFER") && !has_totag()) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> sl_send_reply("403", "Forbidden");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (method=="INVITE") {</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> #if (!proxy_authorize("","subscriber")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # proxy_challenge("","0");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #} else if (!check_from()) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # sl_send_reply("403", "Use From=ID");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #};</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> #consume_credentials();</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (nat_uac_test("19")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> setflag(6);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> force_rport();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> fix_nated_contact();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> force_rtp_proxy("l");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> route(1);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # Call Type Processing Section</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> if (uri!=myself) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(4);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(1);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (method=="ACK") {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(1);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> } if (method=="CANCEL") {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(1);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> } else if (method=="INVITE") {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(3);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> } else if (method=="REGISTER") {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(2);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> lookup("aliases");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> if (uri!=myself) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(4);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(1);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (!lookup("location")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> sl_send_reply("404", "User Not Found");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> route(1);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">}</FONT></TT><BR>
<BR>
<BR>
<TT><FONT COLOR="#1a1a1a">route[1] {</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # Default Message Handler</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> t_on_reply("1");</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (!t_relay()) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> if (method=="INVITE" && isflagset(6)) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> unforce_rtp_proxy();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> sl_reply_error();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">}</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">route[2] {</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # REGISTER Message Handler</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # ----------------------------------------------------------------</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (!search("^Contact:[ ]*\*") && nat_uac_test("19")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> setflag(6);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> fix_nated_register();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> force_rport();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> sl_send_reply("100", "Trying");</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> #if (!www_authorize("","subscriber")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # www_challenge("","0");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #};</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> #if (!check_to()) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # sl_send_reply("401", "Unauthorized");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #};</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # consume_credentials();</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (!save("location")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> sl_reply_error();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">}</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">route[3] {</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # INVITE Message Handler</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> #if (!proxy_authorize("","subscriber")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # proxy_challenge("","0");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #} else if (!check_from()) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # sl_send_reply("403", "Use From=ID");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #};</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # consume_credentials();</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (nat_uac_test("19")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> setflag(6);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> }</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> lookup("aliases");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> if (uri!=myself) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(4);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(1);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (!lookup("location")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> sl_send_reply("404", "User Not Found");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> #break;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> return();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> route(4);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> route(1);</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">}</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">route[4] {</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # NAT Traversal Section</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # -----------------------------------------------------------------</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (isflagset(6)) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> force_rport();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> fix_nated_contact();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> force_rtp_proxy();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> }</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">}</FONT></TT><BR>
<BR>
<BR>
<TT><FONT COLOR="#1a1a1a">onreply_route[1] {</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (isflagset(6) && status=~"(180)|(183)|2[0-9][0-9]") {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> if (!search("^Content-Length:[ ]*0")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> force_rtp_proxy();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> if (nat_uac_test("1")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> fix_nated_contact();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> };</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">}#end of route.</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a">branch_route[2] {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> xlog("new branch at $ru\n");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">}</FONT></TT><BR>
<BR>
<BR>
<TT><FONT COLOR="#1a1a1a">onreply_route[2] {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> xlog("incoming reply\n");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">}</FONT></TT><BR>
<BR>
<BR>
<TT><FONT COLOR="#1a1a1a">failure_route[1] {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> if (t_was_cancelled()) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> exit;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> }</FONT></TT><BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # uncomment the following lines if you want to block client</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # redirect based on 3xx replies.</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> ##if (t_check_status("3[0-9][0-9]")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> ##t_reply("404","Not found");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> ## exit;</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> ##}</FONT></TT><BR>
<BR>
<BR>
<TT><FONT COLOR="#1a1a1a"> # uncomment the following lines if you want to redirect the failed</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> # calls to a different new destination</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> ##if (t_check_status("486|408")) {</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> ## sethostport("192.168.2.100:5060");</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> ## # do not set the missed call flag again</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> ## t_relay();</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a"> ##}</FONT></TT><BR>
<TT><FONT COLOR="#1a1a1a">}</FONT></TT><BR>
<BR>
<BR>
<BR>
</BODY>
</HTML>