<div dir="ltr"><div class="gmail_extra"><br><br><div class="gmail_quote">On 17 September 2013 14:23, Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
</div></div>
    For the received field, you should call fix_nated_register() when
    you get the REGISTER (not for the reply). Or build the value for
    received_avp
    (<a href="http://kamailio.org/docs/modules/stable/modules/registrar.html#idp84696" target="_blank">http://kamailio.org/docs/modules/stable/modules/registrar.html#idp84696</a>)
    manually in config from source ip, source port and transport.<br></div></blockquote><div><br></div><div><br></div><div>I already have and call this route block:  (WITH_NAT is defined)</div><div><br></div><div><div># Caller NAT detection route</div>
<div>route[NATDETECT] {</div><div>#!ifdef WITH_NAT</div><div><span class="" style="white-space:pre">    </span>force_rport();</div><div><span class="" style="white-space:pre">     </span>if (nat_uac_test("19")) {</div>
<div><span class="" style="white-space:pre">            </span>if (is_method("REGISTER")) {</div><div><span class="" style="white-space:pre">                     </span>fix_nated_register();</div><div><span class="" style="white-space:pre">              </span>} else {</div>
<div><span class="" style="white-space:pre">                    </span>add_contact_alias();</div><div><span class="" style="white-space:pre">               </span>}</div><div><span class="" style="white-space:pre">          </span>setflag(FLT_NATS);</div><div>
<span class="" style="white-space:pre">       </span>}</div><div>#!ifdef WITH_RTPBRIDGING</div><div><span class="" style="white-space:pre">   </span>if (!is_method("BYE")) {</div><div><span class="" style="white-space:pre">         </span>setflag(FLT_NATS);</div>
<div><span class="" style="white-space:pre">    </span>}</div><div>#!endif</div><div>#!endif</div><div><span class="" style="white-space:pre">      </span>return;</div><div>}</div></div><div><br></div><div><br></div><div>But there is no NAT between the phone and Kamailio, so fix_nated_register isn't called.  And there is nothing to fix about the incoming register.  </div>
<div><br></div><div>But the register goes out on a different interface with a different address.  And the reply comes back on that interface.</div><div><br></div><div>So I presume the issue with the received/socket is that save() derived them off the reply.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">

    <br>
    With the socket is a bit more complex in this case, with multiple
    network interfaces, it can be set via a header, but
    msg_apply_changes() works on reply only with development version.
    Practically is about using the two parameters of registrar module:<br>
    <br>
    -
    <a href="http://kamailio.org/docs/modules/stable/modules/registrar.html#idp115832" target="_blank">http://kamailio.org/docs/modules/stable/modules/registrar.html#idp115832</a><br>
    <br>
    It might me easier to make a patch to provide custom socket value
    via an avp (like for received value), instead of header (this with
    header was added long time ago for replicated registrations).<br>
    <br>
    Is the subscriber having more than one phone? Or is restricted to
    have only one device? IIRC, with some (old?) versions of asterisk,
    only one phone was used. If it is only for one phone, you can try a
    different approach:<br></div></blockquote><div><br></div><div>The subscriber is not restricted to only having one phone - they can register more than one.  The downstream service supports that fine.  Kamailio can support it and I don't want to introduce a restriction since customers often have a desk phone and also want to use a soft client on mobile phone or similar.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">- use save() with no reply flag for REGISTER<br>

    - forward the register downstream<br>
    - in failure route, if it is a reply received from downstream, use
    unregister()<br>
    <br>
    There will be a short time window that the phone is registered
    locally. You can optimize it to call save() only when Authorization
    header is present in REGISTER, as you know downstream is always
    authenticating.<br>
    <br></div></blockquote><div><br></div><div>So apart from dealing with the multiple registrations this seems like a promising approach.</div><div><br></div><div>Another idea: can I do "append_branch" for a register?  If so, can I turn a register to the downstream service into a register for both the downstream service and my local registrar?  </div>
<div><br></div><div>Thanks,</div><div>Steve</div><div><br></div></div></div></div>