<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Ha`,<br>
<br>
The excerpt from your script shows that you don't have a good
understanding of the opensips scripting logic. First, the <b>route</b>
block will only be called for SIP Requests. <br>
Calling this is not right:<br>
&nbsp;&nbsp;<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(status=="200")<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; route("b2b_reply");<br>
<br>
</i>The replies will go into reply route blocks. You can have a default
reply route ( one without an index or with index 0), or you can specify
a certain reply route for a request by calling&nbsp; t_on_reply.<br>
<br>
Second, you don't understand what happens with b2b request and replies.
It is explained in the documentation:<br>
<br>
<i>The requests and replies that are received by the B2BUA server,
belonging to the dialogs it is handling will not go into the script as
normal request do. The reason for this is that this are not normal
requests where the server is a proxy, but the server is an endpoint in
the dialog and therefore they should not go through the same routes.
However, it is normal for this request to be seen from the script and
allow the script writer to do the processing it desires based on them.
For this, it is possible to define two special B2B routes - one for
requests and one for replies. The routes are of type <strong>route</strong>
and have their name defined in the modules parameters <strong>script_req_route</strong>
and <strong>script_reply_route</strong>.
</i><br>
<br>
In other words, there are two important things:<br>
1. the B2B requests/replies will not go into the default request/reply
route block. <br>
2. the b2b_request/b2_reply route will be called automatically for
every request/reply targeted to the b2b agent<br>
<br>
So, for your script, you don't need this lines:<br>
<br>
&nbsp;&nbsp;&nbsp;<i>&nbsp; if(is_method("INVITE")) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; route("b2b_request");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t_on_reply("2");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(status=="200")<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; route("b2b_reply");</i><br>
<br>
Hope this made things a bit clearer.<br>
<br>
Regards,<br>
<pre class="moz-signature" cols="72">-- 
Anca Vamanu
<a class="moz-txt-link-abbreviated" href="http://www.voice-system.ro">www.voice-system.ro</a></pre>
<br>
ha do wrote:
<blockquote cite="mid:485103.67801.qm@web32404.mail.mud.yahoo.com"
 type="cite">
  <table border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td
 style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;"
 valign="top">HI Anca<br>
        <br>
i am trying to use the b2b_request + b2b_reply<br>
        <br>
route{<br>
...<br>
if(is_method("INVITE") &amp;&amp;&nbsp; !(src_ip == 192.168.1.249 &amp;&amp;
src_port ==5060)) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! t_newtran()){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sl_reply_error();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br>
        <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b2b_init_request("top hiding");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br>
....<br>
route("1");<br>
}<br>
route[1] {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(is_method("INVITE")) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; route("b2b_request");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t_on_reply("2");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(status=="200")<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; route("b2b_reply");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!t_relay()) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sl_reply_error();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<br>
}<br>
route[b2b_request] {<br>
&nbsp; xlog("b2b_request cucku ($ci)\n");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; force_rtp_proxy();<br>
}<br>
route[b2b_reply] {<br>
&nbsp; xlog("b2b_reply cucku ($ci)\n");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; force_rtp_proxy();<br>
}<br>
        <br>
i get the errors :&nbsp; <br>
ERROR:nathelper:force_rtp_proxy: Unable to parse body <br>
and<br>
&nbsp;DBG:tm:utimer_routine: timer routine:4,tl=0xb615e9a8 next=(nil),
timeout=29000000<br>
&nbsp;DBG:tm:timer_routine: timer routine:3,tl=0xb615c6f4 next=(nil),
timeout=29<br>
&nbsp;DBG:tm:delete_handler: removing 0xb615c690<br>
&nbsp;DBG:tm:delete_cell: delete_cell 0xb615c690: can't delete -- still
reffed (1)<br>
        <br>
        <br>
=======<br>
&nbsp;DBG:core:get_hdr_field: cseq &lt;CSeq&gt;: &lt;2&gt; &lt;INVITE&gt;<br>
&nbsp;DBG:core:parse_headers: flags=8<br>
&nbsp;DBG:tm:t_reply_matching: hash 21530 label 76806763 branch 0<br>
&nbsp;DBG:tm:t_reply_matching: REF_UNSAFE: after is 2<br>
&nbsp;DBG:tm:t_reply_matching: reply matched (T=0xb615e85c)!<br>
&nbsp;DBG:tm:t_check: end=0xb615e85c<br>
&nbsp;DBG:tm:reply_received: org. status uas=0, uac[0]=100 local=2
is_invite=1)<br>
&nbsp;DBG:tm:t_should_relay_response: T_code=0, new_code=180<br>
&nbsp;DBG:tm:local_reply: branch=0, save=0, winner=0<br>
&nbsp;DBG:tm:local_reply: Passing provisional reply 180 to FIFO application<br>
&nbsp;DBG:tm:run_trans_callbacks: trans=0xb615e85c, callback type 1024, id 0
entered<br>
&nbsp;DBG:b2b_entities:b2b_parse_key: hash_index = [111]&nbsp; - local_index= [0]<br>
&nbsp;DBG:core:parse_headers: flags=ffffffffffffffff<br>
&nbsp;DBG:core:get_hdr_field: content_length=0<br>
&nbsp;DBG:core:get_hdr_field: found end of header<br>
&nbsp;DBG:b2b_entities:b2b_tm_cback: Received a reply with statuscode = 180<br>
&nbsp;DBG:core:parse_headers: flags=ffffffffffffffff<br>
&nbsp;DBG:b2b_entities:b2b_new_dlg: 'To' header ALREADY PARSED:
<a class="moz-txt-link-rfc2396E" href="sip:1012@192.168.1.249">&lt;sip:1012@192.168.1.249&gt;</a><br>
&nbsp;DBG:b2b_entities:b2b_new_dlg: Not an initial request<br>
&nbsp;DBG:core:parse_to_param: tag=bfad35cdb22f09f741816636d344f54b-19f0<br>
&nbsp;DBG:core:parse_to: end of header reached, state=29<br>
&nbsp;DBG:core:parse_to: display={},
ruri={<a class="moz-txt-link-freetext" href="sip:0873000003@192.168.1.249;user=phone">sip:0873000003@192.168.1.249;user=phone</a>}<br>
&nbsp;DBG:core:print_rr_body: current rr is <a class="moz-txt-link-rfc2396E" href="sip:192.168.1.249;lr=on">&lt;sip:192.168.1.249;lr=on&gt;</a><br>
&nbsp;DBG:core:print_rr_body: out rr [<a class="moz-txt-link-rfc2396E" href="sip:192.168.1.249;lr=on">&lt;sip:192.168.1.249;lr=on&gt;</a>]<br>
&nbsp;DBG:core:print_rr_body: we have 1 records<br>
&nbsp;DBG:b2b_entities:b2b_tm_cback: Created new dialog structure 0xb61618c0<br>
&nbsp;DBG:core:print_rr_body: current rr is <a class="moz-txt-link-rfc2396E" href="sip:192.168.1.249;lr=on">&lt;sip:192.168.1.249;lr=on&gt;</a><br>
&nbsp;DBG:core:print_rr_body: out rr [<a class="moz-txt-link-rfc2396E" href="sip:192.168.1.249;lr=on">&lt;sip:192.168.1.249;lr=on&gt;</a>]<br>
&nbsp;DBG:core:print_rr_body: we have 1 records<br>
&nbsp;DBG:b2b_logic:b2bl_parse_key: hash_index = [623]&nbsp; - local_index= [0]<br>
&nbsp;DBG:core:parse_headers: flags=ffffffffffffffff<br>
&nbsp;DBG:b2b_entities:b2b_parse_key: hash_index = [346]&nbsp; - local_index= [0]<br>
&nbsp;DBG:core:parse_headers: flags=ffffffffffffffff<br>
&nbsp;DBG:core:check_ip_address: params 192.168.1.4, 192.168.1.4, 0<br>
&nbsp;DBG:tm:t_reply_with_body: buffer computed<br>
&nbsp;DBG:tm:_reply_light: reply sent out. buf=0x81c70b8: SIP/2.0 1...,
shmem=0xb615e534: SIP/2.0 1<br>
&nbsp;DBG:tm:_reply_light: finished<br>
&nbsp;b2b_reply cucku (B2B.111.0.1262765386)<br>
&nbsp;DBG:core:parse_headers: flags=ffffffffffffffff<br>
&nbsp;DBG:core:parse_headers: flags=1000<br>
&nbsp;DBG:core:parse_content_type_hdr: missing Content-Type header<br>
&nbsp;ERROR:nathelper:force_rtp_proxy: Unable to parse body<br>
        <br>
Thank you<br>
Ha`<br>
--- On <b>Mon, 1/4/10, Anca Vamanu <i><a class="moz-txt-link-rfc2396E" href="mailto:anca@opensips.org">&lt;anca@opensips.org&gt;</a></i></b>
wrote:<br>
        <blockquote
 style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>
From: Anca Vamanu <a class="moz-txt-link-rfc2396E" href="mailto:anca@opensips.org">&lt;anca@opensips.org&gt;</a><br>
Subject: Re: [OpenSIPS-Users] need advice on B2b<br>
To: "OpenSIPS users mailling list" <a class="moz-txt-link-rfc2396E" href="mailto:users@lists.opensips.org">&lt;users@lists.opensips.org&gt;</a><br>
Date: Monday, January 4, 2010, 3:04 AM<br>
          <br>
          <div class="plainMail">Hi Ha`,<br>
          <br>
There is a very simple example in the documentation:<br>
          <br>
route[b2b_request] {<br>
&nbsp; xlog("b2b_request ($ci)\n");<br>
}<br>
          <br>
          <br>
route[b2b_reply] {<br>
&nbsp; xlog("b2b_reply ($ci)\n");<br>
}<br>
          <br>
          <br>
You can call in these routes any function that you call in a request
route.<br>
          <br>
Regards,<br>
          <br>
-- <br>
Anca Vamanu<br>
<a class="moz-txt-link-abbreviated" href="http://www.voice-system.ro">www.voice-system.ro</a><br>
          </div>
        </blockquote>
        </td>
      </tr>
    </tbody>
  </table>
  <br>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
  </pre>
</blockquote>
</body>
</html>