Index: pjproject/trunk/pjlib/include/pj/guid.h
===================================================================
--- pjproject/trunk/pjlib/include/pj/guid.h	(revision 1814)
+++ pjproject/trunk/pjlib/include/pj/guid.h	(revision 1815)
@@ -50,6 +50,5 @@
  * dependent on the algorithm used internally to generate the GUID string.
  * If real GUID generator is used, then the length will be between 32 and
- * 36 bytes. If shadow GUID generator is used, then the length
- * will be 20 bytes. Application should not assume which algorithm will
+ * 36 bytes. Application should not assume which algorithm will
  * be used by GUID generator.
  *
Index: pjproject/trunk/pjlib/src/pj/guid_simple.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/guid_simple.c	(revision 1814)
+++ pjproject/trunk/pjlib/src/pj/guid_simple.c	(revision 1815)
@@ -18,9 +18,12 @@
  */
 #include <pj/guid.h>
+#include <pj/assert.h>
+#include <pj/rand.h>
 #include <pj/os.h>
-#include <pj/rand.h>
 #include <pj/string.h>
 
-PJ_DEF_DATA(const unsigned) PJ_GUID_STRING_LENGTH=20;
+PJ_DEF_DATA(const unsigned) PJ_GUID_STRING_LENGTH=32;
+
+static char guid_chars[64];
 
 PJ_DEF(unsigned) pj_GUID_STRING_LENGTH()
@@ -29,42 +32,46 @@
 }
 
-static void init_mac_address(unsigned char mac_addr[16])
+static void init_guid_chars(void)
 {
-    unsigned long *ulval1 = (unsigned long*) &mac_addr[0];
-    unsigned short *usval1 = (unsigned short*) &mac_addr[4];
+    char *p = guid_chars;
+    unsigned i;
 
-    *ulval1 = pj_rand();
-    *usval1 = (unsigned short) pj_rand();
+    for (i=0; i<10; ++i)
+	*p++ = '0'+i;
+
+    for (i=0; i<26; ++i) {
+	*p++ = 'a'+i;
+	*p++ = 'A'+i;
+    }
+
+    *p++ = '-';
+    *p++ = '.';
 }
 
 PJ_DEF(pj_str_t*) pj_generate_unique_string(pj_str_t *str)
 {
-    static int guid_initialized;
-    static unsigned pid;
-    static char str_pid[32];
-    static unsigned char mac_addr[32];
-    static char str_mac_addr[32];
-    static unsigned clock_seq;
+    char *p, *end;
 
     PJ_CHECK_STACK();
 
-    if (guid_initialized == 0) {
-	pid = pj_getpid();
-	init_mac_address(mac_addr);
-	clock_seq = 0;
-
-	sprintf(str_pid, "%04x", pid);
-	sprintf(str_mac_addr, "%02x%02x%02x%02x%02x%02x",
-	    mac_addr[0], mac_addr[1], mac_addr[2],
-	    mac_addr[3], mac_addr[4], mac_addr[5]);
-
-	guid_initialized = 1;
+    if (guid_chars[0] == '\0') {
+	pj_enter_critical_section();
+	if (guid_chars[0] == '\0') {
+	    init_guid_chars();
+	}
+	pj_enter_critical_section();
     }
 
-    strcpy(str->ptr, str_pid);
-    sprintf(str->ptr+4, "%08x", clock_seq++);
-    pj_memcpy(str->ptr+12, str_mac_addr, 8);
-    str->slen = 20;
+    /* This would only work if PJ_GUID_STRING_LENGTH is multiple of 2 bytes */
+    pj_assert(PJ_GUID_STRING_LENGTH % 2 == 0);
 
+    for (p=str->ptr, end=p+PJ_GUID_STRING_LENGTH; p<end; ) {
+	/* Assumes rand() only has 16bit randomness */
+	unsigned short val = pj_rand();
+	*p++ = guid_chars[(val >> 8)   & 63];
+	*p++ = guid_chars[(val & 0xFF) & 63];
+    }
+
+    str->slen = PJ_GUID_STRING_LENGTH;
     return str;
 }
Index: pjproject/trunk/pjnath/build/Makefile
===================================================================
--- pjproject/trunk/pjnath/build/Makefile	(revision 1814)
+++ pjproject/trunk/pjnath/build/Makefile	(revision 1815)
@@ -72,5 +72,6 @@
 # $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
 #
-TARGETS := pjnath pjnath-test pjstun-client pjstun-srv-test
+TARGETS := pjnath pjnath-test 
+#pjstun-client pjstun-srv-test
 
 all: $(TARGETS)
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 1814)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 1815)
@@ -512,4 +512,33 @@
 
 
+/* Init random seed */
+static void init_random_seed(void)
+{
+    pj_sockaddr addr;
+    const pj_str_t *hostname;
+    pj_uint32_t pid;
+    pj_time_val t;
+    unsigned seed=0;
+
+    /* Add hostname */
+    hostname = pj_gethostname();
+    seed = pj_hash_calc(seed, hostname->ptr, (int)hostname->slen);
+
+    /* Add primary IP address */
+    if (pj_gethostip(pj_AF_INET(), &addr)==PJ_SUCCESS)
+	seed = pj_hash_calc(seed, &addr.ipv4.sin_addr, 4);
+
+    /* Get timeofday */
+    pj_gettimeofday(&t);
+    seed = pj_hash_calc(seed, &t, sizeof(t));
+
+    /* Add PID */
+    pid = pj_getpid();
+    seed = pj_hash_calc(seed, &pid, sizeof(pid));
+
+    /* Init random seed */
+    pj_srand(seed);
+}
+
 /*
  * Instantiate pjsua application.
@@ -529,4 +558,6 @@
     PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
 
+    /* Init random seed */
+    init_random_seed();
 
     /* Init PJLIB-UTIL: */
