Question: generating v4 UUIDs
Version
The version of ACE and/or TAO you are using ACE 6.5.6
Host machine and operating system
Centos 7.7
Target machine and operating system (if different from host)
Linux
Compiler name and version (including patch level)
gcc 9.2.0
The $ACE_ROOT/ace/config.h file
If you use a link to a platform-specific file, simply state which one
The $ACE_ROOT/include/makeinclude/platform_macros.GNU file
if you use a link to a platform-specific file, simply state which one (unless this isn't used in this case, e.g., with Microsoft Visual C++)
Contents of $ACE_ROOT/bin/MakeProjectCreator/config/default.features
Used by MPC when you generate your own makefiles
AREA/CLASS/EXAMPLE AFFECTED:
What example failed? What module failed to compile?
The problem effects:
Does it affect compilation, linking, or execution. Please indicate whether ACE/TAO, your application, or both are affected. NO
Synopsis
Brief description of the problem I have given the description in the comment.
Description
Detailed description of problem. Don't just say "
Repeat by
What you did to get the error; include test program or session transcript if at all possible. I am not facing any errors. I have a generic question about UUIDs.
Sample fix/ workaround
If available
This is not applicable in my case. I have a question.
Hello,
I was playing around with uuid generators and observed that regardless of given version whether 1 or 4 or any other - the uuid is different only in the middle as shown below in 'Item A'.
But one uses uuidgen (which is available on linux as a binary) it produces uuids which are totally different than the previous one, as seen in 'Item B'.
Question: How can I achieve the same with ACE, any hints would be very useful. I want to generate consecutive UUIDs which are totally different compared to the last one.
Item A
(20200403-00:28:25) $:random> ./generate_uuid.exe
LM_INFO@00:28:27.187761@(11638|11638)@(25:main)@@ 445df0c8-76a6-41ea-8000-54e1add327e9
LM_INFO@00:28:27.187796@(11638|11638)@(25:main)@@ 445df30c-76a6-41ea-8000-54e1add327e9
LM_INFO@00:28:27.187818@(11638|11638)@(25:main)@@ 445df410-76a6-41ea-8000-54e1add327e9
(20200403-00:28:27) $:random>
Item B
(20200403-00:30:20) $:random> uuidgen
d1c36c2a-81c5-4c77-8927-16706e316bc7
(20200403-00:32:08) $:random> uuidgen
6f29c915-867c-4977-a587-8e066ff44a76
(20200403-00:32:10) $:random> uuidgen
bfb4d974-b3e2-4bd0-8c4d-44de6f016b9d
(20200403-00:32:11) $:random> uuidgen
f32b348e-5eb7-48d4-8815-39189d058993
(20200403-00:32:12) $:random> uuidgen
fb5e93e1-cffe-47b8-8990-217a169f35cb
So I now know why the uuid "node" is always the same as it is controlled by the init function, as seen below in "ace/UUID.cpp" file in ace version 6.5.6.
Why is it not random each time? Is there a specific reason for binding it to the macaddress?
337 void
338 UUID_Generator::init (void)
339 {
340 if (this->is_init_)
341 return;
342
343 ACE_OS::macaddr_node_t macaddress;
344 int const result = ACE_OS::getmacaddress (&macaddress);
345
346 UUID_Node::Node_ID node_id;
347
348 if (-1 == result)
349 {
350 ACE_OS::memcpy (node_id,
351 macaddress.node,
352 UUID_Node::NODE_ID_SIZE);
353 }
354 else
355 {
356 node_id [0] = static_cast<u_char> (ACE_OS::rand ());
357 node_id [1] = static_cast<u_char> (ACE_OS::rand ());
358 node_id [2] = static_cast<u_char> (ACE_OS::rand ());
359 node_id [3] = static_cast<u_char> (ACE_OS::rand ());
360 node_id [4] = static_cast<u_char> (ACE_OS::rand ());
361 node_id [5] = static_cast<u_char> (ACE_OS::rand ());
362 }
363