<div dir="ltr">Hi Daniel, Olle,<br><div class="gmail_extra"><br><br><div class="gmail_quote">On 16 September 2013 21:30, 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">you can call save() for 200ok received from downstream. In case you
    deal with nat or multiple local sockets, you need to call the
    functions for fixing the registration as well as storing the local
    socket.<br>
    <br>
    The processing can be like:<br>
    - forward register<br>
    - if getting 200ok, call save() for it<br>
    - if local timeout, call save in failure route -- you will have to
    call it via a sub-route, because save() is only allowed in request
    route and reply route, although failure_route should be safe for it<br>
    - if other reply from downstram, let it go to the phone<br></div></blockquote><div><br></div><div><br></div><div>I've made a start with this but need a little more help.</div><div><br></div><div>In route block [SIPOUT], in the case of a request going to a foreign domain I added:</div>
<div><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"># we need to track the reply to the REGISTER since we need to also save locally<br>
if ( is_method("REGISTER") ) {<br><span class="" style="white-space:pre">     </span>t_on_reply("REGISTER_REPLY");<br><span class="" style="white-space:pre"> </span>t_on_failure("REGISTER_FAILURE");<br>
}</blockquote></div><div><br></div><div>So this "captures" the reply or failure.</div><div><br></div><div>Then:</div><div><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">
onreply_route[REGISTER_REPLY] {<br><span class="" style="white-space:pre">      </span># Got a reply to a register from upstream.  Save locally if its an OK<br><span class="" style="white-space:pre">   </span>if (t_check_status("200")) {<br>
<span class="" style="white-space:pre">               </span>save("location", "0x02", "sip:$<a href="mailto:tU@local.domain.com">tU@local.domain.com</a>");<br><span class="" style="white-space:pre">              </span>append_hf("X-Runway-Trace: Runway saved registration as $<a href="mailto:tU@local.domain.com">tU@local.domain.com</a>\r\n");<br>
<span class="" style="white-space:pre">       </span>}<br>}</blockquote></div><div><br></div><div>The problem I have is that the save operates based on the content of the 200 OK reply.</div><div><br></div><div>So what goes into my DB for a register is like so:</div>
<div><br></div><div><div><font face="courier new, monospace">           id: 31</font></div><div><font face="courier new, monospace">         ruid: uloc-52383743-20e9-2</font></div><div><font face="courier new, monospace">     username: 2686959</font></div>
<div><font face="courier new, monospace">       domain: NULL</font></div><div><font face="courier new, monospace">      contact: sip:2686959@172.16.230.1:36574;rinstance=212220b8566c4337;transport=udp</font></div><div><font face="courier new, monospace">     received: sip:<a href="http://10.64.5.16:5060">10.64.5.16:5060</a></font></div>
<div><font face="courier new, monospace">         path: NULL</font></div><div><font face="courier new, monospace">      expires: 2013-09-17 14:32:24</font></div><div><font face="courier new, monospace">            q: -1.00</font></div>
<div><font face="courier new, monospace">       callid: MDA1MzRmZDQzZmMxNzhlNWUwMGUzNmYwNGYwZTM1YTc</font></div><div><font face="courier new, monospace">         cseq: 2</font></div><div><font face="courier new, monospace">last_modified: 2013-09-17 13:32:24</font></div>
<div><font face="courier new, monospace">        flags: 0</font></div><div><font face="courier new, monospace">       cflags: 0</font></div><div><font face="courier new, monospace">   user_agent: n/a</font></div><div><font face="courier new, monospace">       socket: udp:<a href="http://10.64.5.16:5060">10.64.5.16:5060</a></font></div>
<div><font face="courier new, monospace">      methods: NULL</font></div><div><font face="courier new, monospace">     instance: NULL</font></div><div><font face="courier new, monospace">       reg_id: 0</font></div></div>
<div><br></div><div>So this is OK, but the received and socket are both wrong (they are the "outside" interface of my proxy, where the reply came in.  The registering phone actually talks to Kamailio on the 172.16.230.128 interface).</div>
<div><br></div><div>More of a problem is what happens for an "unregister".</div><div><br></div><div>Here's the REGISTER as forwarded by Kamailio and the reply that comes back and is processed in the onreply_route:</div>
<div><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">U 2013/09/17 13:22:58.004730 <a href="http://10.64.5.16:5060">10.64.5.16:5060</a> -> x.x.x.60:5060<br>
REGISTER sip:<a href="http://vc2.connection-telecom.com">vc2.connection-telecom.com</a> SIP/2.0.<br>Via: SIP/2.0/UDP 10.64.5.16;branch=z9hG4bK66a6.f18d2a5.0.<br>Via: SIP/2.0/UDP 172.16.230.1:50108;branch=z9hG4bK-d8754z-f3d2c8070cecc90e-1---d8754z-;rport=50108.<br>
Max-Forwards: 16.<br>Contact: <sip:2686959@172.16.230.1:50108;rinstance=36d56481f191d185;transport=udp>;expires=0.<br>To: "vc2 2686959"<<a href="mailto:sip%3A2686959@xxxx.connection-telecom.com">sip:2686959@xxxx.connection-telecom.com</a>>.<br>
From: "vc2 2686959"<<a href="mailto:sip%3A2686959@xxxx.connection-telecom.com">sip:2686959@xxxx.connection-telecom.com</a>>;tag=114bde0a.<br>Call-ID: ZmUyY2JiOWQzMWE3OTM3YTNjNTM1OGUxOTE5Njc2ZTk.<br>CSeq: 4 REGISTER.<br>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO.<br>User-Agent: Bria 3 release 3.5.4 stamp 70878.<br>Authorization: Digest username="2686959",realm="<a href="http://xxxx.connection-telecom.com">xxxx.connection-telecom.com</a>",nonce="52383baf2e3b9efcb10180e2ad059ff0ae7fa675",uri="sip:<a href="http://vc2.connection-telecom.com">vc2.connection-telecom.com</a>",response="bad296f5041c869c330f015c4dcb6351",algorithm=MD5.<br>
Content-Length: 0.<br>P-hint: outbound.</blockquote><div>.</div><div><br></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">
U 2013/09/17 13:22:58.226378 x.x.x.60:5060 -> <a href="http://10.64.5.16:5060">10.64.5.16:5060</a><br>SIP/2.0 200 OK.<br>Via: SIP/2.0/UDP 10.64.5.16;branch=z9hG4bK66a6.f18d2a5.0;rport=5060.<br>Via: SIP/2.0/UDP 172.16.230.1:50108;branch=z9hG4bK-d8754z-f3d2c8070cecc90e-1---d8754z-;rport=50108.<br>
To: "vc2 2686959"<<a href="mailto:sip%3A2686959@xxxx.connection-telecom.com">sip:2686959@xxxx.connection-telecom.com</a>>;tag=4bb452afea88ea368a51bf5f3eee867d.8da4.<br>From: "vc2 2686959"<<a href="mailto:sip%3A2686959@xxxx.connection-telecom.com">sip:2686959@xxxx.connection-telecom.com</a>>;tag=114bde0a.<br>
Call-ID: ZmUyY2JiOWQzMWE3OTM3YTNjNTM1OGUxOTE5Njc2ZTk.<br>CSeq: 4 REGISTER.<br>Server: Telviva SIP proxy.<br>Content-Length: 0.</blockquote><div><br></div></div><div>So the 200 OK does not have the Contact header.</div><div>
<br></div><div>On the save Kamailio does not remove the existing registration from the location table, so the unregister isn't effective for the local location table.</div><div><br></div><div>Is there a way to get the save to find the original request?  Can I pull the original request back via tm module somehow?  Other ideas on getting this right?</div>
<div><br></div><div>Thanks,</div><div>Steve</div><div><br></div><div><br></div><div> </div></div></div></div>