Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 221769e

Browse files
committed
add node name to user data
1 parent e31ed1b commit 221769e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

rmw_connext_shared_cpp/src/node.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ create_node(
5353
// This String_dup is not matched with a String_free because DDS appears to
5454
// free this automatically.
5555
participant_qos.participant_name.name = DDS::String_dup(name);
56+
// since the participant name is not part of the DDS spec
57+
// the node name is also set in the user_data
58+
DDS_Long name_length = strlen(name);
59+
const char prefix[6] = "name=";
60+
bool success = participant_qos.user_data.value.length(name_length + sizeof(prefix));
61+
if (!success) {
62+
RMW_SET_ERROR_MSG("failed to resize participant user_data");
63+
return NULL;
64+
}
65+
memcpy(participant_qos.user_data.value.get_contiguous_buffer(), prefix, sizeof(prefix) - 1);
66+
{
67+
for (DDS_Long i = 0; i < name_length; ++i) {
68+
participant_qos.user_data.value[sizeof(prefix) - 1 + i] = name[i];
69+
}
70+
participant_qos.user_data.value[sizeof(prefix) - 1 + name_length] = ';';
71+
}
72+
5673
// forces local traffic to be sent over loopback,
5774
// even if a more efficient transport (such as shared memory) is installed
5875
// (in which case traffic will be sent over both transports)

0 commit comments

Comments
 (0)