[OpenSIPS-Users] RTP Proxy and opensip 1.7

sawyerzhang sawyerzhangdev at gmail.com
Wed Apr 18 04:55:52 CEST 2012


Hi Folks, 

I forgot to attach my configs, here it is.

Thanks
Sawyer


route{

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

#---- NAT Detection ----#
	force_rport();
	if (nat_uac_test("18")) {
		if (method=="REGISTER")
		#is_()
	{
	fix_nated_register();
	}
	else {
	fix_nated_contact();
	}
	setflag(5);
	}

if (has_totag()) {
      if (loose_route()) {
              if (is_method("BYE")) {
                      setflag(1); # do accounting ...
                      setflag(3); # ... even if the transaction fails
              } else if (is_method("INVITE")) {
              record_route();
              }
              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
              exit;
              }
      }
      sl_send_reply("404","Not here");
      }
      exit;
}

      #initial requests

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

      t_check_trans();


      # preloaded route checking
      if (loose_route()) {
              xlog("L_ERR",
              "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
              if (!is_method("ACK"))
                      sl_send_reply("403","Preload Route denied");
              exit;
      }

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

      # account only INVITEs
      if (is_method("INVITE")) {
              setflag(1); # do accounting
      }
      if (!uri==myself)

      {
              append_hf("P-hint: outbound\r\n");

              route(1);
      }

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


      if (is_method("REGISTER"))
      {

      #-- Request is behind NAT(flag5) save with bflag 6 -#
      #---- Use bflag 7 to start SIP pinging (Options) ---#
      if (isflagset(5)) {
      setbflag(6);
      setbflag(7);
      };
              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");

      # do lookup with method filtering
      if (!lookup("location","m")) {
              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

      #---- Helper route, if nat=yes in the R-URI set flag 6 ----#
      #---- This is used to Process REINVITES ----#
      if (subst_uri('/(sip:.*);nat=yes/\1/')){
      setbflag(6);
      };
      #-- If caller(flag 5) or callee(flag 6) are behind NAT --#
      #-- Call the route(6) to force the use of the RTP Proxy --#
      if (isflagset(5)||isbflagset(6)) {
      route(6);
      };
      if (isflagset(5)){
      search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
      }
      if (is_method("INVITE")) {
              t_on_branch("2");
              t_on_reply("2");
              t_on_failure("1");
      }

      if (!t_relay()) {
              sl_reply_error();
      };
      exit;
}



route[6] {
      #---- RTP Proxy handling ---#
      if (is_method("BYE|CANCEL")) {
      unforce_rtp_proxy();

      }
      else if (is_method("INVITE")){
      #---- Activates the RTP Proxy for the CALLEE ---#
#checnged       force_rtp_proxy();
rtpproxy_answer();
      t_on_failure("1");
      };
      }

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


onreply_route[2] {
      xlog("incoming reply\n");
if ((isflagset(5) || isbflagset(6)) && status=~"(183)|(2[0-9][0-9])"){


rtpproxy_offer();
append_hf("P-hint: onreply_route|force_rtp_proxy \r\n");
}

if (isbflagset(6)) {

search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
append_hf("P-hint: Onreply-route - fixcontact \r\n");
fix_nated_contact();
}
exit;
}


failure_route[1] {

      if (isflagset(5) || isbflagset(6)){
      unforce_rtp_proxy();
      }

      if (t_was_cancelled()) {
              exit;
      }

}
On 17 Apr, 2012, at 2:24 PM, sawyerzhang wrote:

> Hi Folks,
> 
> I have installed opensips 1.7 without TLS support. Everything was fine expect there was an issue with nated clients. The RTPproxy did a trick and things were ok for a while. Now, sometime I am experiencing very strange behaviour. I just can't send or receive messages across the clients. And its so random that its hard to know what exactly went wrong. I have a strong feeling that it got to be something with routing logic.
> 
> Any thoughts?
> 
> Here is how I do it (X.Y.Z public IP), starting the rtprpxy:
> 
> rtpproxy -l X.Y.Z -s udp:X.Y.Z:8888 -F
> 
> And then I restart opensips:
> 
> opensipsctl start
> 
> I can see opensip can talk to rtpproxy in /var/log/syslog :
> 
> INFO:rtpproxy:rtpp_test: rtp proxy <udp:X.Y.Z:8888> found, support for it enabled
> DBG:rtpproxy:raise_rtpproxy_event: no event sent
> DBG:core:init_m
> 
> And here is snip from log while a UA is trying to send a message;
> 
> DBG:uri:has_totag: no totag
> DBG:core:parse_headers: flags=78
> DBG:tm:t_lookup_request: start searching: hash=42124, isACK=0
> DBG:tm:matching_3261: RFC3261 transaction matching failed
> DBG:tm:t_lookup_request: no transaction found
> DBG:core:parse_headers: flags=200
> DBG:rr:find_first_route: No Route headers found
> DBG:rr:loose_route: There is no Route HF
> 
> It seem routing part is broken but I wonder how come it can work sometime?
> 
> thanks,
> sawyer


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20120418/b3c1d238/attachment.htm>


More information about the Users mailing list