Klaus, Inaki, Daniel,<br><br>    Thanks!  Sorry I did not see this email come through, I&#39;m going to go ahead and give this method a go, and I&#39;ll update with the results, I have optimistic views.<br><br>As for the reason I was rewriting $ru and setting $du to null, is because originally when I just changed $du to the &#39;destination proxy&#39; it did not seem to work at all (I do not even recall what exactly what was happening) however I decided to just change $ru, and have the other proxy just &quot;lookup&quot; the usrloc information again.  Again, this method looks interesting and I&#39;ll let you guys know how it goes, thanks for all the input and help!<br>
<br>Sincerely,<br>Brandon.<br><br><div class="gmail_quote">On Fri, Apr 24, 2009 at 1:18 AM, Klaus Darilion <span dir="ltr">&lt;<a href="mailto:klaus.mailinglists@pernau.at">klaus.mailinglists@pernau.at</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
Brandon Armstead schrieb:<div class="im"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Klaus,<br>
<br>
    So I took you and Inaki&#39;s input and essentially constructed a setup like so after the lookup(&quot;location&quot;) call:<br>
<br>
if(isbflagset(1)){<br>
    $du = null;<br>
    $rd = &quot;P1&quot;;<br>
} else if(isbflagset(2)){<br>
    $du = null;<br>
    $rd = &quot;P2&quot;;<br>
} else if(isbflagset(3)){<br>
    $du = null;<br>
    $rd = &quot;P3&quot;;<br>
} else if(isbflagset(4)){<br>
    $du = null;<br>
    $rd = &quot;P4&quot;;<br>
}<br>
</blockquote>
<br></div>
1. The above code has to be in the branch_route block - otherwise multiple registrations of a single user are not handled correctly.<br>
<br>
2. you are rewriting the RURI. You should not do that as some clients wants to the in the RURI the Contact provided during REGISTER.<br>
<br>
3. probably you use fix_nated_register() to store the public IP:port of the client too. After lookup, this information is written to DURI. Thus, by setting $du you overwrite this info. You should put it into a special header so that you can restore it in the other proxy.<br>

<br>
Here a snippet how it should work (untested, no warranty): ( I use the term &quot;originating&quot; proxy for the proxy which received the INVITE and the term &quot;serving&quot; proxy for the proxy which handles the connection/registration of a certain SIP client).<br>

<br>
e.g:<br>
Alice -----INVITE-----&gt; P1-------&gt;P2-----&gt;Bob2<br>
                        /  \<br>
                       /    \<br>
                      /      V<br>
                     V       P3----&gt;Bob3<br>
                  Bob1<br>
<br>
Bob&#39;s client Bob1 is connected to P1.<br>
Bob&#39;s client Bob2 is connected to P2.<br>
Bob&#39;s client Bob3 is connected to P3.<br>
<br>
So, P1 is the originating proxy. P2 is the serving proxy of Bob2. ....<br>
<br>
We do NAT traversal (note: we must not call fix_nated_contact() for messages sent between the proxies!): the originating proxy for the call-leg to the caller, the serving proxy for the call-leg to the callee.<br>
The RTP proxy will be managed by the originating proxy only.<br>
<br>
<br>
<br>
route{<br>
if (loose_route()) {<br>
  ... additional loose route processing...<br>
  if (check_route_param(&quot;rtpproxy=yes&quot;)) {<br>
    force_rtp_proxy();<br>
    setbflag(7);<br>
  }<br>
<br>
  # downstream: in-dialog request is in the same direction as the<br>
  # initial request<br>
  if ( (check_route_param(&quot;nat=caller&quot;) &amp;&amp; is_direction(&quot;downstream&quot;))<br>
    || (check_route_param(&quot;nat=callee&quot;) &amp;&amp; is_direction(&quot;upstream&quot;))) {<br>
    fix_nated_contact();<br>
  } else if (check_route_param(&quot;nat=both&quot;) {<br>
    fix_nated_contact();<br>
    setbflag(8);<br>
  } else {<br>
    setbflag(8);<br>
  }<br>
<br>
  t_on_reply(&quot;1&quot;);<br>
  t_relay();<br>
  exit();<br>
}<br>
...<br>
<br>
# I am proxy 1<br>
if ((src_ip=ip.of.proxy.2) || (src_ip=ip.of.proxy.3)...) {<br>
  # request comes from other proxy, that means I am the<br>
  # serving proxy<br>
  # do not lookup(), RURI is already set and<br>
  # DURI is provided in our X-DURI header<br>
  $du = $header(X-DURI);<br>
  # we do not care about an RTP proxy because that&#39;s the task of the<br>
  # proxy which performed the lookup() (the originating proxy)<br>
  # add some record-route cookie to mark that we should perform<br>
  # SIP NAT traversal for the callee<br>
  add_rr_param(&quot;;nat=callee&quot;);<br>
  # activate reply_route to fix_nated_contact of callee<br>
  setbflag(8); # flag 8 = fix contact<br>
  t_on_reply(&quot;1&quot;);<br>
  record_route();<br>
  t_relay();<br>
  exit;<br>
}<br>
<br>
...<br>
# a new request - thus I am the originating proxy<br>
<br>
if ($dU looks like phone number) {<br>
   ... route to Gateway....<br>
  exit;<br>
}<br>
<br>
if (!lookup(&quot;location&quot;)) {<br>
  sl_send_reply(&quot;404&quot;,&quot;not found&quot;);<br>
  exit;<br>
}<br>
# activate branch route to have dedicated routing per branch<br>
t_on_branch(&quot;1&quot;);<br>
<br>
# activate reply route to activate RTP proxy<br>
t_on_reply(&quot;1&quot;);<br>
<br>
# NAT traversal<br>
fix_nated_contact();<br>
<br>
record_route();<br>
t_relay();<br>
exit;<br>
}<br>
<br>
branch_route[1]{<br>
 if(isbflagset(1)){<br>
   # oh, that&#39;s me<br>
<br>
   # add some record-route cookie to mark that we should perform<br>
   # SIP NAT traversal for the callee and caller<br>
   add_rr_param(&quot;;nat=both&quot;);<br>
<br>
   # add some record-route cookie to mark that we are<br>
   # in charge for the RTP proxy<br>
   add_rr_param(&quot;;rtpproxy=yes&quot;);<br>
<br>
   force_rtp_proxy();<br>
   setbflag(7); # flag 7 = RTP proxy<br>
 } else {<br>
   # add some record-route cookie to mark that we should perform<br>
   # SIP NAT traversal for the caller<br>
   add_rr_param(&quot;;nat=caller&quot;);<br>
<br>
   # we have to route the request to the serving proxy<br>
   # write DURI in the header<br>
   append_hf(&quot;X-DURI: $du&quot;);<br>
   if(isbflagset(2)){<br>
       $du = sip:ip.of.proxy.2;transport=udp;<br>
   } else if(isbflagset(3)){<br>
       $du = sip:ip.of.proxy.3;transport=udp;<br>
   } else if(isbflagset(4)){<br>
       $du = sip:ip.of.proxy.4;transport=udp;<br>
   }<br>
 }<br>
}<br>
<br>
reply_route[1]{<br>
  if (isbflagset(7) &amp;&amp; has_body(&quot;application/sdp&quot;)) {<br>
    force_rtp_proxy()<br>
  }<br>
  if (isbflagset(8)) {<br>
    fix_nated_contact()<br>
  }<br>
}<br>
<br>
<br>
<br>
Note: this code does not care about the received socket of the proxy. Thus it works if the proxy listens only on one port.<br>
<br>
regards<br>
klaus<br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
On each Proxy, I changed the code appropriately excluding the Proxy from itself (so it does not forward to itself).  I&#39;m noticing weird behavior however as it seems as if what is happening is it created other issues such as:<br>

<br>
[INCOMING SERVER] -&gt; P1 -&gt; P2 -&gt; P1 -&gt; (loop?)<br>
<br>
Also I setup this test amongst two development servers (in which case it worked without issues).  Once I included in more development instances into the ring it seemed as if the flags were being set when they should not be?<br>

<br>
I.e. I placed a call FROM UA1 (with bflag 5 SET) From the above example configuration ^ code.  If you notice (flag 5) is missing.  To UA2 (Flag 3), again this looked to be doing some strange things such as acting as if another flag was set when it should not have been, thus forwarding to the wrong proxy or the wrong proxy order.  Do you guys have any further thoughts or input on this?  Thanks!<br>

<br></div><div><div></div><div class="h5">
On Thu, Apr 23, 2009 at 12:31 AM, Klaus Darilion &lt;<a href="mailto:klaus.mailinglists@pernau.at" target="_blank">klaus.mailinglists@pernau.at</a> &lt;mailto:<a href="mailto:klaus.mailinglists@pernau.at" target="_blank">klaus.mailinglists@pernau.at</a>&gt;&gt; wrote:<br>

<br>
    Hi Brandon!<br>
<br>
    Back to the original email ....<br>
<br>
    Brandon Armstead schrieb:<br>
<br>
        Hello guys,<br>
<br>
           Is there a method upon using lookup(&quot;location&quot;) to also pull<br>
        out the &quot;socket&quot; information for the original location the UAC<br>
        registered to, for scenarios of this example:<br>
<br>
        P1 &amp; P2 share same usrloc database.<br>
<br>
        UA1 registers to P1<br>
        UA2 registers to P2<br>
<br>
        UA1 calls UA2<br>
<br>
        UA1 invites -&gt; P1 -&gt; INVITES -&gt; UA2 (bypassing P2 -- where the<br>
        actual nat binding is).<br>
<br>
        Now upon P1 looking up usrloc for UA2, I would like to recognize<br>
        that P1 is not the Proxy to deliver the call, and forward the<br>
        request to P2 to send to UA2.<br>
<br>
        So currently I have:<br>
<br>
        UA1 INVITE -&gt; P1 INVITE -&gt; UA2<br>
<br>
        I wish to have:<br>
<br>
        UA1 INVITE -&gt; P1 INVITE -&gt; P2 INVITE -&gt; UA2<br>
<br>
        Is there an easy method to do this?  I have been looking at the<br>
        new nat traversal module it looks like it is doable with this<br>
        (any further input as far as that?).  Also is it possible with<br>
        the classic Nat Helper module?  Any input is appreciated, thanks!<br>
<br>
<br>
    I think the nat_traversal module can not help you in this case, nor<br>
    nathelper.<br>
<br>
    One possibility would be to spoof at P1 the IP address of P2 -<br>
    nevertheless this would cause the reply sent back to P2, but the<br>
    transaction is created in P1. (and you need to hack Kamailio for IP<br>
    spoofing).<br>
<br>
    Another easy solution would be: In P1 set a certain branch-flag when<br>
    the client registers, e.g. bflag 1. In P2 set a certain branch-flag<br>
    when the client registers, e.g. bflag 2.<br>
<br>
    Now, if a user is called, just make a lookup() and t_relay. Further<br>
    in the branch_route check if:<br>
     in P1: isbflagset(2) --&gt; forward to P2<br>
     in P2: isbflagset(1) --&gt; forward to P1<br>
<br>
    klaus<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
        ------------------------------------------------------------------------<br>
<br>
        _______________________________________________<br>
        Kamailio (OpenSER) - Users mailing list<br></div></div>
        <a href="mailto:Users@lists.kamailio.org" target="_blank">Users@lists.kamailio.org</a> &lt;mailto:<a href="mailto:Users@lists.kamailio.org" target="_blank">Users@lists.kamailio.org</a>&gt;<div class="im"><br>
        <a href="http://lists.kamailio.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.kamailio.org/cgi-bin/mailman/listinfo/users</a><br>
        <a href="http://lists.openser-project.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.openser-project.org/cgi-bin/mailman/listinfo/users</a><br>
<br>
<br>
</div></blockquote>
</blockquote></div><br>