<div dir="ltr">Thanks Daniel,<div>I want to remove the htable entry after the register goes through, and I also want to check if the htable entry exists later.</div><div><br></div><div>I see</div><div><br></div><div>sht_rm_value_re("ha=>.*"); </div><div><br></div><div>to remove the htable entry but how do i later check if the key exists?</div><div><br></div><div>Thanks</div><div>/V</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 16, 2014 at 11:52 AM, Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    if you want to rely on kamailio to memorize where to send the
    following register, the hash table is the right tool.<br>
    <br>
    Cheers,<br>
    Daniel<div><div class="h5"><br>
    <br>
    <div>On 16/09/14 03:37, Vik Killa wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <div dir="ltr">Hello,
        <div>I'm learning Kamailio. My ultimate goal is to be able to
          route SIP messages from User Agents to specific FS boxes.</div>
        <div><br>
        </div>
        <div>I'm starting with routing REGISTER messages.</div>
        <div>I used app_perl to randomly lookup one of the FS box's IP
          Address from postgres database, then I stored the IP in avp
          and then in hash. It seemed like overkill but it was the only
          way I could keep the FS IP address in memory between the first
          REGISTER and REGISTER with Auth.</div>
        <div><br>
        </div>
        <div>my app_perl script sets the IP as follows:</div>
        <div><br>
        </div>
        <div>
          <div>my $sth = $dbh->prepare("SELECT ip_address FROM
            host_machine WHERE is_online = true ORDER BY random() LIMIT
            1");</div>
          <div>$sth->execute();</div>
          <div>my $host_ip_address = $sth->fetchrow();</div>
        </div>
        <div>Kamailio::AVP::add(10, <a>"sip:$host_ip_address:5060"</a>);<br>
        </div>
        <div><br>
        </div>
        <div>And here is my kamailio.cfg for REGISTERs</div>
        <div><br>
        </div>
        <div>
          <div>route[REGISTRAR]</div>
          <div>{</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap"> </span>if
            (!is_method("REGISTER|PUBLISH"))</div>
          <div><span style="white-space:pre-wrap"> </span>return;</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap"> </span>if
            (is_present_hf("Authorization")) {</div>
          <div><span style="white-space:pre-wrap"> </span>add_path_received();</div>
          <div><span style="white-space:pre-wrap"> </span>$avp(i:10)
            = $sht(a=>$ci::dest_server);</div>
          <div><span style="white-space:pre-wrap"> </span>avp_pushto("$du",
            "$avp(i:10)");</div>
          <div><span style="white-space:pre-wrap"> </span>} else {</div>
          <div><span style="white-space:pre-wrap"> </span>perl_exec("random_server");</div>
          <div><span style="white-space:pre-wrap"> </span></div>
          <div><span style="white-space:pre-wrap"> </span>avp_pushto("$du",
            "$avp(i:10)");</div>
          <div><span style="white-space:pre-wrap"> </span>$sht(a=>$ci::dest_server)
            = $avp(i:10);</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap"> </span>}</div>
          <div><span style="white-space:pre-wrap"> </span></div>
          <div><span style="white-space:pre-wrap"> </span>t_relay();<span style="white-space:pre-wrap"> </span></div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap"> </span>exit;<br>
          </div>
          <div>}</div>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>"random_server" is the perl script to get the FS IP
          address...</div>
        <div>Seems crude but works... </div>
        <div>I'm sure there is probably a more elegant way to do what im
          trying so any advice and criticism is appreciated, thank you!</div>
        <div><br>
        </div>
        <div>/V</div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
    </font></span></blockquote><span class="HOEnZb"><font color="#888888">
    <br>
    <pre cols="72">-- 
Daniel-Constantin Mierla
<a href="http://twitter.com/#!/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Next Kamailio Advanced Trainings 2014 - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
Sep 22-25, Berlin, Germany</pre>
  </font></span></div>

<br>_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br></div>