<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>sip registration is kept for the duration of expires value and
      "older one" is relative and might be something that results in
      unwanted behaviour. For example, if you have 2 end points for the
      same user, one fixed phone registering every hour and one mobile
      app registering every 5min, when the mobile app changes mobile
      network/wifi and registers again with a new contact, you may end
      up removing the contact corresponding to the fixed phone, instead
      of the previous contact for mobile app (which has an invalid IP
      due to migration to another network). So I would rather be very
      careful with removing the older contacts.</p>
    <p>That being said, you can fetch all the contacts for a user using
      reg_fetch_contacts(), loop with a while through them and keep the
      ruid attribute for the contact you want to remove and then use
      unregister() for it. Here are relevant examples that can help
      implementing it:</p>
    <p>  * <a
href="https://www.kamailio.org/docs/modules/stable/modules/registrar.html#idm909">https://www.kamailio.org/docs/modules/stable/modules/registrar.html#idm909</a></p>
    <p>  * <a
href="https://www.kamailio.org/docs/modules/stable/modules/registrar.html#registrar.f.unregister">https://www.kamailio.org/docs/modules/stable/modules/registrar.html#registrar.f.unregister</a></p>
    <p>If you ensure the same expires value for registrations,
      practically the oldest contact has the lowest value for
      $ulc(caller=>expires). If devices use different expires values,
      then you end up in the case described by my remark above. You can
      also test the last_modified field to decide what is the oldest
      contact.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 19.08.20 16:35, Duarte Rocha wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAAJJHZhw8+shigbOrUJdt5OZWU=DezaXnAZ4nS96k+tTYOL3ng@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="auto">
        <div dir="auto">Greetings, </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">I'm currently creating a Kamailio with
          registrations and i'm unsure how to use the save() function.</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">I want to limit the number of contacts for the
          AOR to 2. I also want to force the registration of new
          contacts even if the maximum number is reached, removing the
          older ones.</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">I saw that on opensips i could use the flags
          "fc2" for this but they aren't available on Kamailio's save().
          I'm using the max_contacts parameter but in the docs it states
          the once the limit is reached, it will reject new Registers.</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">How can i implement the force registration
          behaviour here?</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">Best Regards,</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">Duarte Rocha</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
  </body>
</html>