Windows does not have the getppid(), getuid(), getgid() functions.
We do get a random seed from CryptGenRandom(). That seed along with
process id and current time hopefully is good enough.

Signed-off-by: Gurucharan Shetty <gshe...@nicira.com>
---
 include/windows/windefs.h |    4 ++++
 lib/uuid.c                |    6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/include/windows/windefs.h b/include/windows/windefs.h
index 6d36adc..6fde1ea 100644
--- a/include/windows/windefs.h
+++ b/include/windows/windefs.h
@@ -32,4 +32,8 @@
 #define u_int32_t uint32_t
 #define u_int64_t uint64_t
 
+typedef int pid_t;
+typedef int uid_t;
+typedef int gid_t;
+
 #endif /* windefs.h */
diff --git a/lib/uuid.c b/lib/uuid.c
index 315c851..9ac5b55 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -220,17 +220,23 @@ do_init(void)
     get_entropy_or_die(random_seed, sizeof random_seed);
     xgettimeofday(&now);
     pid = getpid();
+#ifndef _WIN32
     ppid = getppid();
     uid = getuid();
     gid = getgid();
+#endif
 
     /* Convert seed into key. */
     sha1_init(&sha1_ctx);
     sha1_update(&sha1_ctx, random_seed, sizeof random_seed);
     sha1_update(&sha1_ctx, &pid, sizeof pid);
+#ifndef _WIN32
     sha1_update(&sha1_ctx, &ppid, sizeof ppid);
     sha1_update(&sha1_ctx, &uid, sizeof uid);
     sha1_update(&sha1_ctx, &gid, sizeof gid);
+#else
+    sha1_update(&sha1_ctx, &now, sizeof now);
+#endif
     sha1_final(&sha1_ctx, sha1);
 
     /* Generate key. */
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to