<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi guys, <br>
    <br>
    You are absolutely right, I will make the changes to go with the
    server_id.<br>
    <br>
    Thank you,<br>
    Lucian<br>
    <br>
    <div class="moz-cite-prefix">On 02.06.2016 15:31, Alekzander
      Spiridonov wrote:<br>
    </div>
    <blockquote
cite="mid:CA+=mPaoKo2c2-YOdOjpOA19nZ=cFZg1shrjW5EsnZgSenRf9UQ@mail.gmail.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>It looks like a re-invention of a uuid. Isn't it?<br>
        </div>
        I'd say that using server_id is better approach.<br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">2016-06-02 14:38 GMT+03:00
          Daniel-Constantin Mierla <span dir="ltr"><<a
              moz-do-not-send="true" href="mailto:miconda@gmail.com"
              target="_blank">miconda@gmail.com</a>></span>:<br>
          <blockquote class="gmail_quote">
            <div>
              <p>Hello,</p>
              <p>wondering if it wouldn't be better to get the hostname
                once at startup, rather than doing it each time a new
                cookie is needed.</p>
              <p>On the other hand, note that you can set server_id for
                each kamailio instance to make it uniquely identifiable,
                which is also important for sruid generator (although
                that uses random and startup timestamp as well).</p>
              <p>Also, sometime the local hostname overlaps, seen lots
                of servers using just 'www' or 'debian'. So ensuring the
                uniqueness was shifted to the sysadmins of the network
                nodes.</p>
              <p>Cheers,<br>
                Daniel<br>
              </p>
              <div>
                <div class="h5"> <br>
                  <div>On 02/06/16 12:54, Lucian Balaceanu wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <pre>Module: kamailio
Branch: master
Commit: 69e57b9260c6c09380fdb9cfd074ea67a459230a
URL: <a moz-do-not-send="true" href="https://github.com/kamailio/kamailio/commit/69e57b9260c6c09380fdb9cfd074ea67a459230a" target="_blank">https://github.com/kamailio/kamailio/commit/69e57b9260c6c09380fdb9cfd074ea67a459230a</a>

Author: Lucian Balaceanu <a moz-do-not-send="true" href="mailto:lucian.balaceanu@1and1.ro" target="_blank"><lucian.balaceanu@1and1.ro></a>
Committer: Lucian Balaceanu <a moz-do-not-send="true" href="mailto:lucian.balaceanu@1and1.ro" target="_blank"><lucian.balaceanu@1and1.ro></a>
Date: 2016-06-02T13:50:02+03:00

rtpengine: change cookie to hostname_pid_seqno

- pid_seqno in gencookie() is not a unique identifictor in a multi kamailio setup

---

Modified: modules/rtpengine/rtpengine.c

---

Diff:  <a moz-do-not-send="true" href="https://github.com/kamailio/kamailio/commit/69e57b9260c6c09380fdb9cfd074ea67a459230a.diff" target="_blank">https://github.com/kamailio/kamailio/commit/69e57b9260c6c09380fdb9cfd074ea67a459230a.diff</a>
Patch: <a moz-do-not-send="true" href="https://github.com/kamailio/kamailio/commit/69e57b9260c6c09380fdb9cfd074ea67a459230a.patch" target="_blank">https://github.com/kamailio/kamailio/commit/69e57b9260c6c09380fdb9cfd074ea67a459230a.patch</a>

---

diff --git a/modules/rtpengine/rtpengine.c b/modules/rtpengine/rtpengine.c
index 5481f49..a37ab6f 100644
--- a/modules/rtpengine/rtpengine.c
+++ b/modules/rtpengine/rtpengine.c
@@ -97,6 +97,8 @@ MODULE_VERSION
 #define        NAT_UAC_TEST_S_1918                     0x08
 #define        NAT_UAC_TEST_RPORT                      0x10
 
+#define COOKIE_SIZE                                    128
+#define HOSTNAME_SIZE                          100
 
 #define DEFAULT_RTPP_SET_ID                    0
 #define MAX_RTPP_TRIED_NODES                   50
@@ -2016,12 +2018,15 @@ static void mod_destroy(void)
 }
 
 
-
 static char * gencookie(void)
 {
-       static char cook[34];
+       static char cook[COOKIE_SIZE];
+       char hostname[HOSTNAME_SIZE];
+
+       if (gethostname(hostname, HOSTNAME_SIZE - 1) < 0)
+               strcpy(hostname, "host");
+       snprintf(cook, COOKIE_SIZE, "%s_%d_%u ", hostname, (int)mypid, myseqn);
 
-       sprintf(cook, "%d_%u ", (int)mypid, myseqn);
        myseqn++;
        return cook;
 }


_______________________________________________
sr-dev mailing list
<a moz-do-not-send="true" href="mailto:sr-dev@lists.sip-router.org" target="_blank">sr-dev@lists.sip-router.org</a>
<a moz-do-not-send="true" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
                  </blockquote>
                  <br>
                </div>
              </div>
              <span class="HOEnZb">
                <pre cols="72">-- 
Daniel-Constantin Mierla
<a moz-do-not-send="true" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a> - <a moz-do-not-send="true" href="http://www.kamailio.org" target="_blank">http://www.kamailio.org</a>
<a moz-do-not-send="true" href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a></pre>
              </span></div>
            <br>
            _______________________________________________<br>
            sr-dev mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev"
              rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br>
        <br>
        -- <br>
        <div class="gmail_signature" data-smartmail="gmail_signature">Best
          regards,<br>
          Alekzander Spiridonov</div>
      </div>
    </blockquote>
    <br>
  </body>
</html>