From d1c190f8a219541359dd93af828276404ed14558 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Sat, 2 Nov 2024 11:16:43 +0100 Subject: [PATCH 1/9] [#500] Expose UniquePublisherId UniqueSubscriberId UniqueNotifierId UniqueListenerId bytes in CXX API --- .../cxx/include/iox2/unique_port_id.hpp | 15 +++++++- iceoryx2-ffi/cxx/src/unique_port_id.cpp | 36 +++++++++++++++++++ .../cxx/tests/src/unique_port_id_tests.cpp | 22 ++++++++++++ .../ffi/src/api/unique_listener_id.rs | 18 ++++++++++ .../ffi/src/api/unique_notifier_id.rs | 18 ++++++++++ .../ffi/src/api/unique_publisher_id.rs | 18 ++++++++++ .../ffi/src/api/unique_subscriber_id.rs | 19 ++++++++++ iceoryx2/src/port/port_identifiers.rs | 5 +++ 8 files changed, 150 insertions(+), 1 deletion(-) diff --git a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp index f4ffa7146..2e9e03406 100644 --- a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp @@ -13,9 +13,15 @@ #ifndef IOX2_UNIQUE_PORT_ID_HPP #define IOX2_UNIQUE_PORT_ID_HPP +#include "iox/optional.hpp" #include "iox2/internal/iceoryx2.hpp" +#include + namespace iox2 { + +constexpr uint64_t UNIQUE_PORT_ID_LENGTH = 128; + /// The system-wide unique id of a [`Publisher`]. class UniquePublisherId { public: @@ -25,6 +31,8 @@ class UniquePublisherId { auto operator=(UniquePublisherId&& rhs) noexcept -> UniquePublisherId&; ~UniquePublisherId(); + auto bytes() -> iox::optional>; + private: template friend class Publisher; @@ -38,7 +46,6 @@ class UniquePublisherId { iox2_unique_publisher_id_h m_handle = nullptr; }; - /// The system-wide unique id of a [`Subscriber`]. class UniqueSubscriberId { public: @@ -48,6 +55,8 @@ class UniqueSubscriberId { auto operator=(UniqueSubscriberId&& rhs) noexcept -> UniqueSubscriberId&; ~UniqueSubscriberId(); + auto bytes() -> iox::optional>; + private: template friend class Subscriber; @@ -69,6 +78,8 @@ class UniqueNotifierId { auto operator=(UniqueNotifierId&& rhs) noexcept -> UniqueNotifierId&; ~UniqueNotifierId(); + auto bytes() -> iox::optional>; + private: template friend class Notifier; @@ -90,6 +101,8 @@ class UniqueListenerId { auto operator=(UniqueListenerId&& rhs) noexcept -> UniqueListenerId&; ~UniqueListenerId(); + auto bytes() -> iox::optional>; + private: template friend class Listener; diff --git a/iceoryx2-ffi/cxx/src/unique_port_id.cpp b/iceoryx2-ffi/cxx/src/unique_port_id.cpp index c8f8116f2..13a76c686 100644 --- a/iceoryx2-ffi/cxx/src/unique_port_id.cpp +++ b/iceoryx2-ffi/cxx/src/unique_port_id.cpp @@ -43,6 +43,15 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle) : m_handle { handle } { } +auto UniquePublisherId::bytes() -> iox::optional> { + if (m_handle != nullptr) { + std::array bytes {}; + iox2_unique_publisher_id_value(m_handle, bytes.data()); + return bytes; + } + return iox::nullopt; +}; + void UniquePublisherId::drop() { if (m_handle != nullptr) { iox2_unique_publisher_id_drop(m_handle); @@ -81,6 +90,15 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle) : m_handle { handle } { } +auto UniqueSubscriberId::bytes() -> iox::optional> { + if (m_handle != nullptr) { + std::array bytes {}; + iox2_unique_subscriber_id_value(m_handle, bytes.data()); + return bytes; + } + return iox::nullopt; +}; + void UniqueSubscriberId::drop() { if (m_handle != nullptr) { iox2_unique_subscriber_id_drop(m_handle); @@ -118,6 +136,15 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle) : m_handle { handle } { } +auto UniqueNotifierId::bytes() -> iox::optional> { + if (m_handle != nullptr) { + std::array bytes {}; + iox2_unique_notifier_id_value(m_handle, bytes.data()); + return bytes; + } + return iox::nullopt; +}; + void UniqueNotifierId::drop() { if (m_handle != nullptr) { iox2_unique_notifier_id_drop(m_handle); @@ -155,6 +182,15 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle) : m_handle { handle } { } +auto UniqueListenerId::bytes() -> iox::optional> { + if (m_handle != nullptr) { + std::array bytes {}; + iox2_unique_listener_id_value(m_handle, bytes.data()); + return bytes; + } + return iox::nullopt; +}; + void UniqueListenerId::drop() { if (m_handle != nullptr) { iox2_unique_listener_id_drop(m_handle); diff --git a/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp b/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp index 939e4ec34..89e86cd4c 100644 --- a/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp +++ b/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp @@ -17,10 +17,12 @@ #include "iox2/publisher.hpp" #include "iox2/service_name.hpp" #include "iox2/subscriber.hpp" +#include "iox2/unique_port_id.hpp" #include "test.hpp" #include +#include namespace { using namespace iox2; @@ -63,6 +65,26 @@ struct UniquePortIdTest : public ::testing::Test { TYPED_TEST_SUITE(UniquePortIdTest, iox2_testing::ServiceTypes); +TYPED_TEST(UniquePortIdTest, unique_port_id_value) { + auto null_id = std::array {}; + + auto unique_publisher_id = this->publisher_1.id(); + ASSERT_TRUE(unique_publisher_id.bytes().has_value()); + ASSERT_NE(unique_publisher_id.bytes().value(), null_id); + + auto unique_subscriber_id = this->publisher_1.id(); + ASSERT_TRUE(unique_subscriber_id.bytes().has_value()); + ASSERT_NE(unique_subscriber_id.bytes().value(), null_id); + + auto unique_notifier_id = this->notifier_1.id(); + ASSERT_TRUE(unique_notifier_id.bytes().has_value()); + ASSERT_NE(unique_notifier_id.bytes().value(), null_id); + + auto unique_listener_id = this->listener_1.id(); + ASSERT_TRUE(unique_listener_id.bytes().has_value()); + ASSERT_NE(unique_listener_id.bytes().value(), null_id); +} + TYPED_TEST(UniquePortIdTest, unique_port_id_from_same_port_is_equal) { ASSERT_TRUE(this->listener_1.id() == this->listener_1.id()); ASSERT_TRUE(this->notifier_1.id() == this->notifier_1.id()); diff --git a/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs b/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs index b286894fa..89530262c 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs @@ -86,6 +86,24 @@ impl HandleToType for iox2_unique_listener_id_h_ref { // BEGIN C API +#[no_mangle] +unsafe extern "C" fn iox2_unique_listener_id_value( + handle: iox2_unique_listener_id_h, + id_ptr: *mut u8, +) { + handle.assert_non_null(); + + let h = &mut *handle.as_type(); + + if let Some(Some(id)) = (h.value.internal.as_ptr() as *const Option).as_ref() + { + let bytes = id.value().to_ne_bytes(); + unsafe { + std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, bytes.len()); + } + } +} + /// This function needs to be called to destroy the unique listener id! /// /// # Arguments diff --git a/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs b/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs index 8b289bd8a..22e0950e0 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs @@ -86,6 +86,24 @@ impl HandleToType for iox2_unique_notifier_id_h_ref { // BEGIN C API +#[no_mangle] +unsafe extern "C" fn iox2_unique_notifier_id_value( + handle: iox2_unique_notifier_id_h, + id_ptr: *mut u8, +) { + handle.assert_non_null(); + + let h = &mut *handle.as_type(); + + if let Some(Some(id)) = (h.value.internal.as_ptr() as *const Option).as_ref() + { + let bytes = id.value().to_ne_bytes(); + unsafe { + std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, bytes.len()); + } + } +} + /// This function needs to be called to destroy the unique notifier id! /// /// # Arguments diff --git a/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs b/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs index 4f81be0a6..3c1804d95 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs @@ -86,6 +86,24 @@ impl HandleToType for iox2_unique_publisher_id_h_ref { // BEGIN C API +#[no_mangle] +unsafe extern "C" fn iox2_unique_publisher_id_value( + handle: iox2_unique_publisher_id_h, + id_ptr: *mut u8, +) { + handle.assert_non_null(); + + let h = &mut *handle.as_type(); + + if let Some(Some(id)) = (h.value.internal.as_ptr() as *const Option).as_ref() + { + let bytes = id.value().to_ne_bytes(); + unsafe { + std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, bytes.len()); + } + } +} + /// This function needs to be called to destroy the unique publisher id! /// /// # Arguments diff --git a/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs b/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs index 65c8effc2..64487e76c 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs @@ -86,6 +86,25 @@ impl HandleToType for iox2_unique_subscriber_id_h_ref { // BEGIN C API +#[no_mangle] +unsafe extern "C" fn iox2_unique_subscriber_id_value( + handle: iox2_unique_subscriber_id_h, + id_ptr: *mut u8, +) { + handle.assert_non_null(); + + let h = &mut *handle.as_type(); + + if let Some(Some(id)) = + (h.value.internal.as_ptr() as *const Option).as_ref() + { + let bytes = id.value().to_ne_bytes(); + unsafe { + std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, bytes.len()); + } + } +} + /// This function needs to be called to destroy the unique subscriber id! /// /// # Arguments diff --git a/iceoryx2/src/port/port_identifiers.rs b/iceoryx2/src/port/port_identifiers.rs index 1826057ec..415de10a3 100644 --- a/iceoryx2/src/port/port_identifiers.rs +++ b/iceoryx2/src/port/port_identifiers.rs @@ -35,6 +35,11 @@ macro_rules! generate_id { pub fn new() -> Self { Self::default() } + + /// Returns the underlying raw value of the ID + pub fn value(&self) -> u128 { + self.0.value() + } } }; } From bb80099042ee4769a3d9c29d2664fb34bcd1a88d Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Sat, 2 Nov 2024 14:25:19 +0100 Subject: [PATCH 2/9] [#500] Only copy ID from iceoryx2 into CXX one time --- .../cxx/include/iox2/unique_port_id.hpp | 13 ++++-- iceoryx2-ffi/cxx/src/unique_port_id.cpp | 40 +++++++++---------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp index 2e9e03406..865b4156f 100644 --- a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp @@ -21,6 +21,7 @@ namespace iox2 { constexpr uint64_t UNIQUE_PORT_ID_LENGTH = 128; +using RawIdType = std::array; /// The system-wide unique id of a [`Publisher`]. class UniquePublisherId { @@ -31,7 +32,7 @@ class UniquePublisherId { auto operator=(UniquePublisherId&& rhs) noexcept -> UniquePublisherId&; ~UniquePublisherId(); - auto bytes() -> iox::optional>; + auto bytes() -> iox::optional&; private: template @@ -44,6 +45,7 @@ class UniquePublisherId { void drop(); iox2_unique_publisher_id_h m_handle = nullptr; + iox::optional m_raw_id; }; /// The system-wide unique id of a [`Subscriber`]. @@ -55,7 +57,7 @@ class UniqueSubscriberId { auto operator=(UniqueSubscriberId&& rhs) noexcept -> UniqueSubscriberId&; ~UniqueSubscriberId(); - auto bytes() -> iox::optional>; + auto bytes() -> iox::optional&; private: template @@ -67,6 +69,7 @@ class UniqueSubscriberId { void drop(); iox2_unique_subscriber_id_h m_handle = nullptr; + iox::optional m_raw_id; }; /// The system-wide unique id of a [`Notifier`]. @@ -78,7 +81,7 @@ class UniqueNotifierId { auto operator=(UniqueNotifierId&& rhs) noexcept -> UniqueNotifierId&; ~UniqueNotifierId(); - auto bytes() -> iox::optional>; + auto bytes() -> iox::optional&; private: template @@ -90,6 +93,7 @@ class UniqueNotifierId { void drop(); iox2_unique_notifier_id_h m_handle = nullptr; + iox::optional m_raw_id; }; /// The system-wide unique id of a [`Listener`]. @@ -101,7 +105,7 @@ class UniqueListenerId { auto operator=(UniqueListenerId&& rhs) noexcept -> UniqueListenerId&; ~UniqueListenerId(); - auto bytes() -> iox::optional>; + auto bytes() -> iox::optional&; private: template @@ -113,6 +117,7 @@ class UniqueListenerId { void drop(); iox2_unique_listener_id_h m_handle = nullptr; + iox::optional m_raw_id; }; auto operator==(const UniquePublisherId& lhs, const UniquePublisherId& rhs) -> bool; diff --git a/iceoryx2-ffi/cxx/src/unique_port_id.cpp b/iceoryx2-ffi/cxx/src/unique_port_id.cpp index 13a76c686..4055f53f7 100644 --- a/iceoryx2-ffi/cxx/src/unique_port_id.cpp +++ b/iceoryx2-ffi/cxx/src/unique_port_id.cpp @@ -43,13 +43,13 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle) : m_handle { handle } { } -auto UniquePublisherId::bytes() -> iox::optional> { - if (m_handle != nullptr) { - std::array bytes {}; +auto UniquePublisherId::bytes() -> iox::optional& { + if (!m_raw_id.has_value() && m_handle != nullptr) { + RawIdType bytes {}; iox2_unique_publisher_id_value(m_handle, bytes.data()); - return bytes; + m_raw_id.emplace(std::move(bytes)); } - return iox::nullopt; + return m_raw_id; }; void UniquePublisherId::drop() { @@ -90,13 +90,13 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle) : m_handle { handle } { } -auto UniqueSubscriberId::bytes() -> iox::optional> { - if (m_handle != nullptr) { - std::array bytes {}; +auto UniqueSubscriberId::bytes() -> iox::optional& { + if (!m_raw_id.has_value() && m_handle != nullptr) { + RawIdType bytes {}; iox2_unique_subscriber_id_value(m_handle, bytes.data()); - return bytes; + m_raw_id.emplace(std::move(bytes)); } - return iox::nullopt; + return m_raw_id; }; void UniqueSubscriberId::drop() { @@ -136,13 +136,13 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle) : m_handle { handle } { } -auto UniqueNotifierId::bytes() -> iox::optional> { - if (m_handle != nullptr) { - std::array bytes {}; +auto UniqueNotifierId::bytes() -> iox::optional& { + if (!m_raw_id.has_value() && m_handle != nullptr) { + RawIdType bytes {}; iox2_unique_notifier_id_value(m_handle, bytes.data()); - return bytes; + m_raw_id.emplace(std::move(bytes)); } - return iox::nullopt; + return m_raw_id; }; void UniqueNotifierId::drop() { @@ -182,13 +182,13 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle) : m_handle { handle } { } -auto UniqueListenerId::bytes() -> iox::optional> { - if (m_handle != nullptr) { - std::array bytes {}; +auto UniqueListenerId::bytes() -> iox::optional& { + if (!m_raw_id.has_value() && m_handle != nullptr) { + RawIdType bytes {}; iox2_unique_listener_id_value(m_handle, bytes.data()); - return bytes; + m_raw_id.emplace(std::move(bytes)); } - return iox::nullopt; + return m_raw_id; }; void UniqueListenerId::drop() { From d6541f161be541f9c8224e41e132ab7252d07342 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 13 Nov 2024 15:05:04 +0100 Subject: [PATCH 3/9] [#500] Use iox::vector instead of std::array --- iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp | 5 ++--- iceoryx2-ffi/cxx/src/unique_port_id.cpp | 8 ++++---- iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp index 865b4156f..616bdfffe 100644 --- a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp @@ -14,14 +14,13 @@ #define IOX2_UNIQUE_PORT_ID_HPP #include "iox/optional.hpp" +#include "iox/vector.hpp" #include "iox2/internal/iceoryx2.hpp" -#include - namespace iox2 { constexpr uint64_t UNIQUE_PORT_ID_LENGTH = 128; -using RawIdType = std::array; +using RawIdType = iox::vector; /// The system-wide unique id of a [`Publisher`]. class UniquePublisherId { diff --git a/iceoryx2-ffi/cxx/src/unique_port_id.cpp b/iceoryx2-ffi/cxx/src/unique_port_id.cpp index 4055f53f7..25c3041a2 100644 --- a/iceoryx2-ffi/cxx/src/unique_port_id.cpp +++ b/iceoryx2-ffi/cxx/src/unique_port_id.cpp @@ -45,7 +45,7 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle) auto UniquePublisherId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { - RawIdType bytes {}; + RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_publisher_id_value(m_handle, bytes.data()); m_raw_id.emplace(std::move(bytes)); } @@ -92,7 +92,7 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle) auto UniqueSubscriberId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { - RawIdType bytes {}; + RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_subscriber_id_value(m_handle, bytes.data()); m_raw_id.emplace(std::move(bytes)); } @@ -138,7 +138,7 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle) auto UniqueNotifierId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { - RawIdType bytes {}; + RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_notifier_id_value(m_handle, bytes.data()); m_raw_id.emplace(std::move(bytes)); } @@ -184,7 +184,7 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle) auto UniqueListenerId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { - RawIdType bytes {}; + RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_listener_id_value(m_handle, bytes.data()); m_raw_id.emplace(std::move(bytes)); } diff --git a/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp b/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp index 89e86cd4c..8a318d8ff 100644 --- a/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp +++ b/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp @@ -66,13 +66,13 @@ struct UniquePortIdTest : public ::testing::Test { TYPED_TEST_SUITE(UniquePortIdTest, iox2_testing::ServiceTypes); TYPED_TEST(UniquePortIdTest, unique_port_id_value) { - auto null_id = std::array {}; + auto null_id = iox::vector { iox2::UNIQUE_PORT_ID_LENGTH, 0 }; auto unique_publisher_id = this->publisher_1.id(); ASSERT_TRUE(unique_publisher_id.bytes().has_value()); ASSERT_NE(unique_publisher_id.bytes().value(), null_id); - auto unique_subscriber_id = this->publisher_1.id(); + auto unique_subscriber_id = this->subscriber_1.id(); ASSERT_TRUE(unique_subscriber_id.bytes().has_value()); ASSERT_NE(unique_subscriber_id.bytes().value(), null_id); From efdf158746c49c0731109344c51f6b896c60c64e Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 13 Nov 2024 15:28:53 +0100 Subject: [PATCH 4/9] [#500] Pass destination buffer size when retrieving ids --- iceoryx2-ffi/cxx/src/unique_port_id.cpp | 8 ++++---- .../ffi/src/api/unique_listener_id.rs | 19 ++++++++++++++++++- .../ffi/src/api/unique_notifier_id.rs | 19 ++++++++++++++++++- .../ffi/src/api/unique_publisher_id.rs | 19 ++++++++++++++++++- .../ffi/src/api/unique_subscriber_id.rs | 19 ++++++++++++++++++- 5 files changed, 76 insertions(+), 8 deletions(-) diff --git a/iceoryx2-ffi/cxx/src/unique_port_id.cpp b/iceoryx2-ffi/cxx/src/unique_port_id.cpp index 25c3041a2..cb354703e 100644 --- a/iceoryx2-ffi/cxx/src/unique_port_id.cpp +++ b/iceoryx2-ffi/cxx/src/unique_port_id.cpp @@ -46,7 +46,7 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle) auto UniquePublisherId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; - iox2_unique_publisher_id_value(m_handle, bytes.data()); + iox2_unique_publisher_id_value(m_handle, bytes.data(), bytes.size()); m_raw_id.emplace(std::move(bytes)); } return m_raw_id; @@ -93,7 +93,7 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle) auto UniqueSubscriberId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; - iox2_unique_subscriber_id_value(m_handle, bytes.data()); + iox2_unique_subscriber_id_value(m_handle, bytes.data(), bytes.size()); m_raw_id.emplace(std::move(bytes)); } return m_raw_id; @@ -139,7 +139,7 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle) auto UniqueNotifierId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; - iox2_unique_notifier_id_value(m_handle, bytes.data()); + iox2_unique_notifier_id_value(m_handle, bytes.data(), bytes.size()); m_raw_id.emplace(std::move(bytes)); } return m_raw_id; @@ -185,7 +185,7 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle) auto UniqueListenerId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; - iox2_unique_listener_id_value(m_handle, bytes.data()); + iox2_unique_listener_id_value(m_handle, bytes.data(), bytes.size()); m_raw_id.emplace(std::move(bytes)); } return m_raw_id; diff --git a/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs b/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs index 89530262c..d0873d06d 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs @@ -86,11 +86,26 @@ impl HandleToType for iox2_unique_listener_id_h_ref { // BEGIN C API +/// Retrieves the value of a unique listener ID. +/// +/// # Arguments +/// +/// * `handle` - A valid [`iox2_unique_listener_id_h`] +/// * `id_ptr` - Pointer to a buffer where the ID value will be written +/// * `id_length` - The length of the buffer pointed to by `id_ptr` +/// +/// # Safety +/// +/// * `handle` must be a valid, non-null pointer +/// * `id_ptr` must be a valid, non-null pointer to a buffer of at least `id_length` bytes +/// * `id_length` must be large enough to hold the ID value #[no_mangle] unsafe extern "C" fn iox2_unique_listener_id_value( handle: iox2_unique_listener_id_h, id_ptr: *mut u8, + id_length: usize, ) { + debug_assert!(!id_ptr.is_null()); handle.assert_non_null(); let h = &mut *handle.as_type(); @@ -98,8 +113,10 @@ unsafe extern "C" fn iox2_unique_listener_id_value( if let Some(Some(id)) = (h.value.internal.as_ptr() as *const Option).as_ref() { let bytes = id.value().to_ne_bytes(); + debug_assert!(bytes.len() <= id_length, "id_length is too small"); + unsafe { - std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, bytes.len()); + std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, id_length); } } } diff --git a/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs b/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs index 22e0950e0..f208643f3 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs @@ -86,11 +86,26 @@ impl HandleToType for iox2_unique_notifier_id_h_ref { // BEGIN C API +/// Retrieves the value of a unique notifier ID. +/// +/// # Arguments +/// +/// * `handle` - A valid [`iox2_unique_notifier_id_h`] +/// * `id_ptr` - Pointer to a buffer where the ID value will be written +/// * `id_length` - The length of the buffer pointed to by `id_ptr` +/// +/// # Safety +/// +/// * `handle` must be a valid, non-null pointer +/// * `id_ptr` must be a valid, non-null pointer to a buffer of at least `id_length` bytes +/// * `id_length` must be large enough to hold the ID value #[no_mangle] unsafe extern "C" fn iox2_unique_notifier_id_value( handle: iox2_unique_notifier_id_h, id_ptr: *mut u8, + id_length: usize, ) { + debug_assert!(!id_ptr.is_null()); handle.assert_non_null(); let h = &mut *handle.as_type(); @@ -98,8 +113,10 @@ unsafe extern "C" fn iox2_unique_notifier_id_value( if let Some(Some(id)) = (h.value.internal.as_ptr() as *const Option).as_ref() { let bytes = id.value().to_ne_bytes(); + debug_assert!(bytes.len() <= id_length, "id_length is too small"); + unsafe { - std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, bytes.len()); + std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, id_length); } } } diff --git a/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs b/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs index 3c1804d95..5b5acb231 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs @@ -86,11 +86,26 @@ impl HandleToType for iox2_unique_publisher_id_h_ref { // BEGIN C API +/// Retrieves the value of a unique publisher ID. +/// +/// # Arguments +/// +/// * `handle` - A valid [`iox2_unique_publisher_id_h`] +/// * `id_ptr` - Pointer to a buffer where the ID value will be written +/// * `id_length` - The length of the buffer pointed to by `id_ptr` +/// +/// # Safety +/// +/// * `handle` must be a valid, non-null pointer +/// * `id_ptr` must be a valid, non-null pointer to a buffer of at least `id_length` bytes +/// * `id_length` must be large enough to hold the ID value #[no_mangle] unsafe extern "C" fn iox2_unique_publisher_id_value( handle: iox2_unique_publisher_id_h, id_ptr: *mut u8, + id_length: usize, ) { + debug_assert!(!id_ptr.is_null()); handle.assert_non_null(); let h = &mut *handle.as_type(); @@ -98,8 +113,10 @@ unsafe extern "C" fn iox2_unique_publisher_id_value( if let Some(Some(id)) = (h.value.internal.as_ptr() as *const Option).as_ref() { let bytes = id.value().to_ne_bytes(); + debug_assert!(bytes.len() <= id_length, "id_length is too small"); + unsafe { - std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, bytes.len()); + std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, id_length); } } } diff --git a/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs b/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs index 64487e76c..c6c1fa7b5 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs @@ -86,11 +86,26 @@ impl HandleToType for iox2_unique_subscriber_id_h_ref { // BEGIN C API +/// Retrieves the value of a unique subscriber ID. +/// +/// # Arguments +/// +/// * `handle` - A valid [`iox2_unique_subscriber_id_h`] +/// * `id_ptr` - Pointer to a buffer where the ID value will be written +/// * `id_length` - The length of the buffer pointed to by `id_ptr` +/// +/// # Safety +/// +/// * `handle` must be a valid, non-null pointer +/// * `id_ptr` must be a valid, non-null pointer to a buffer of at least `id_length` bytes +/// * `id_length` must be large enough to hold the ID value #[no_mangle] unsafe extern "C" fn iox2_unique_subscriber_id_value( handle: iox2_unique_subscriber_id_h, id_ptr: *mut u8, + id_length: usize, ) { + debug_assert!(!id_ptr.is_null()); handle.assert_non_null(); let h = &mut *handle.as_type(); @@ -99,8 +114,10 @@ unsafe extern "C" fn iox2_unique_subscriber_id_value( (h.value.internal.as_ptr() as *const Option).as_ref() { let bytes = id.value().to_ne_bytes(); + debug_assert!(bytes.len() <= id_length, "id_length is too small"); + unsafe { - std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, bytes.len()); + std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, id_length); } } } From 5703e94f326499535cc3a0025301013726dadd40 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 13 Nov 2024 15:34:50 +0100 Subject: [PATCH 5/9] [#500] Add release notes --- doc/release-notes/iceoryx2-unreleased.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/release-notes/iceoryx2-unreleased.md b/doc/release-notes/iceoryx2-unreleased.md index 7489f1ffa..6dd00bea8 100644 --- a/doc/release-notes/iceoryx2-unreleased.md +++ b/doc/release-notes/iceoryx2-unreleased.md @@ -62,6 +62,7 @@ * Rename `iox2_publisher_loan` to `iox2_publisher_loan_slice_uninit` [#490](https://github.com/eclipse-iceoryx/iceoryx2/issues/490) 1. C always loans slices, for a single element, specify the `number_of_elements` to be 1 +* APIs to retrieve the value of `UniquePortIds` from the C/C++ bindings [#500](https://github.com/eclipse-iceoryx/iceoryx2/issues/500) ### API Breaking Changes From 6737410e40dcc1fd4be1a00490618fae81e4b347 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Fri, 15 Nov 2024 16:08:24 +0100 Subject: [PATCH 6/9] [#500] UniquePortId::bytes() return const ref --- iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp | 8 ++++---- iceoryx2-ffi/cxx/src/unique_port_id.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp index 616bdfffe..cc423795f 100644 --- a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp @@ -31,7 +31,7 @@ class UniquePublisherId { auto operator=(UniquePublisherId&& rhs) noexcept -> UniquePublisherId&; ~UniquePublisherId(); - auto bytes() -> iox::optional&; + auto bytes() -> const iox::optional&; private: template @@ -56,7 +56,7 @@ class UniqueSubscriberId { auto operator=(UniqueSubscriberId&& rhs) noexcept -> UniqueSubscriberId&; ~UniqueSubscriberId(); - auto bytes() -> iox::optional&; + auto bytes() -> const iox::optional&; private: template @@ -80,7 +80,7 @@ class UniqueNotifierId { auto operator=(UniqueNotifierId&& rhs) noexcept -> UniqueNotifierId&; ~UniqueNotifierId(); - auto bytes() -> iox::optional&; + auto bytes() -> const iox::optional&; private: template @@ -104,7 +104,7 @@ class UniqueListenerId { auto operator=(UniqueListenerId&& rhs) noexcept -> UniqueListenerId&; ~UniqueListenerId(); - auto bytes() -> iox::optional&; + auto bytes() -> const iox::optional&; private: template diff --git a/iceoryx2-ffi/cxx/src/unique_port_id.cpp b/iceoryx2-ffi/cxx/src/unique_port_id.cpp index cb354703e..07b07409a 100644 --- a/iceoryx2-ffi/cxx/src/unique_port_id.cpp +++ b/iceoryx2-ffi/cxx/src/unique_port_id.cpp @@ -43,7 +43,7 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle) : m_handle { handle } { } -auto UniquePublisherId::bytes() -> iox::optional& { +auto UniquePublisherId::bytes() -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_publisher_id_value(m_handle, bytes.data(), bytes.size()); @@ -90,7 +90,7 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle) : m_handle { handle } { } -auto UniqueSubscriberId::bytes() -> iox::optional& { +auto UniqueSubscriberId::bytes() -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_subscriber_id_value(m_handle, bytes.data(), bytes.size()); @@ -136,7 +136,7 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle) : m_handle { handle } { } -auto UniqueNotifierId::bytes() -> iox::optional& { +auto UniqueNotifierId::bytes() -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_notifier_id_value(m_handle, bytes.data(), bytes.size()); @@ -182,7 +182,7 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle) : m_handle { handle } { } -auto UniqueListenerId::bytes() -> iox::optional& { +auto UniqueListenerId::bytes() -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_listener_id_value(m_handle, bytes.data(), bytes.size()); From 2b22f5e86f7c04df268b2c18acf8419b64406261 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Mon, 18 Nov 2024 15:05:17 +0100 Subject: [PATCH 7/9] [#500] Truncate ID if provided buffer too small --- iceoryx2-ffi/ffi/src/api/unique_listener_id.rs | 6 +++++- iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs | 6 +++++- iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs | 6 +++++- iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs b/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs index d0873d06d..db1b6ee5c 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_listener_id.rs @@ -116,7 +116,11 @@ unsafe extern "C" fn iox2_unique_listener_id_value( debug_assert!(bytes.len() <= id_length, "id_length is too small"); unsafe { - std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, id_length); + std::ptr::copy_nonoverlapping( + bytes.as_ptr(), + id_ptr, + std::cmp::min(bytes.len(), id_length), + ); } } } diff --git a/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs b/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs index f208643f3..6eb2a7600 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_notifier_id.rs @@ -116,7 +116,11 @@ unsafe extern "C" fn iox2_unique_notifier_id_value( debug_assert!(bytes.len() <= id_length, "id_length is too small"); unsafe { - std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, id_length); + std::ptr::copy_nonoverlapping( + bytes.as_ptr(), + id_ptr, + std::cmp::min(bytes.len(), id_length), + ); } } } diff --git a/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs b/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs index 5b5acb231..a2e4d8338 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_publisher_id.rs @@ -116,7 +116,11 @@ unsafe extern "C" fn iox2_unique_publisher_id_value( debug_assert!(bytes.len() <= id_length, "id_length is too small"); unsafe { - std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, id_length); + std::ptr::copy_nonoverlapping( + bytes.as_ptr(), + id_ptr, + std::cmp::min(bytes.len(), id_length), + ); } } } diff --git a/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs b/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs index c6c1fa7b5..521c2c8c3 100644 --- a/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs +++ b/iceoryx2-ffi/ffi/src/api/unique_subscriber_id.rs @@ -117,7 +117,11 @@ unsafe extern "C" fn iox2_unique_subscriber_id_value( debug_assert!(bytes.len() <= id_length, "id_length is too small"); unsafe { - std::ptr::copy_nonoverlapping(bytes.as_ptr(), id_ptr, id_length); + std::ptr::copy_nonoverlapping( + bytes.as_ptr(), + id_ptr, + std::cmp::min(bytes.len(), id_length), + ); } } } From 30f7d250cb05af469b03395c02fc21b7a8454a48 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Mon, 18 Nov 2024 16:44:34 +0100 Subject: [PATCH 8/9] [#500] Make bytes() method const --- iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp | 16 ++++++++-------- iceoryx2-ffi/cxx/src/unique_port_id.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp index cc423795f..d03d57b09 100644 --- a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp @@ -31,7 +31,7 @@ class UniquePublisherId { auto operator=(UniquePublisherId&& rhs) noexcept -> UniquePublisherId&; ~UniquePublisherId(); - auto bytes() -> const iox::optional&; + auto bytes() const -> const iox::optional&; private: template @@ -44,7 +44,7 @@ class UniquePublisherId { void drop(); iox2_unique_publisher_id_h m_handle = nullptr; - iox::optional m_raw_id; + mutable iox::optional m_raw_id; }; /// The system-wide unique id of a [`Subscriber`]. @@ -56,7 +56,7 @@ class UniqueSubscriberId { auto operator=(UniqueSubscriberId&& rhs) noexcept -> UniqueSubscriberId&; ~UniqueSubscriberId(); - auto bytes() -> const iox::optional&; + auto bytes() const -> const iox::optional&; private: template @@ -68,7 +68,7 @@ class UniqueSubscriberId { void drop(); iox2_unique_subscriber_id_h m_handle = nullptr; - iox::optional m_raw_id; + mutable iox::optional m_raw_id; }; /// The system-wide unique id of a [`Notifier`]. @@ -80,7 +80,7 @@ class UniqueNotifierId { auto operator=(UniqueNotifierId&& rhs) noexcept -> UniqueNotifierId&; ~UniqueNotifierId(); - auto bytes() -> const iox::optional&; + auto bytes() const -> const iox::optional&; private: template @@ -92,7 +92,7 @@ class UniqueNotifierId { void drop(); iox2_unique_notifier_id_h m_handle = nullptr; - iox::optional m_raw_id; + mutable iox::optional m_raw_id; }; /// The system-wide unique id of a [`Listener`]. @@ -104,7 +104,7 @@ class UniqueListenerId { auto operator=(UniqueListenerId&& rhs) noexcept -> UniqueListenerId&; ~UniqueListenerId(); - auto bytes() -> const iox::optional&; + auto bytes() const -> const iox::optional&; private: template @@ -116,7 +116,7 @@ class UniqueListenerId { void drop(); iox2_unique_listener_id_h m_handle = nullptr; - iox::optional m_raw_id; + mutable iox::optional m_raw_id; }; auto operator==(const UniquePublisherId& lhs, const UniquePublisherId& rhs) -> bool; diff --git a/iceoryx2-ffi/cxx/src/unique_port_id.cpp b/iceoryx2-ffi/cxx/src/unique_port_id.cpp index 07b07409a..533cc95d6 100644 --- a/iceoryx2-ffi/cxx/src/unique_port_id.cpp +++ b/iceoryx2-ffi/cxx/src/unique_port_id.cpp @@ -43,7 +43,7 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle) : m_handle { handle } { } -auto UniquePublisherId::bytes() -> const iox::optional& { +auto UniquePublisherId::bytes() const -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_publisher_id_value(m_handle, bytes.data(), bytes.size()); @@ -90,7 +90,7 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle) : m_handle { handle } { } -auto UniqueSubscriberId::bytes() -> const iox::optional& { +auto UniqueSubscriberId::bytes() const -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_subscriber_id_value(m_handle, bytes.data(), bytes.size()); @@ -136,7 +136,7 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle) : m_handle { handle } { } -auto UniqueNotifierId::bytes() -> const iox::optional& { +auto UniqueNotifierId::bytes() const -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_notifier_id_value(m_handle, bytes.data(), bytes.size()); @@ -182,7 +182,7 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle) : m_handle { handle } { } -auto UniqueListenerId::bytes() -> const iox::optional& { +auto UniqueListenerId::bytes() const -> const iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_listener_id_value(m_handle, bytes.data(), bytes.size()); From 55519ace3cc9bfdd7a5b6412aabc361ae8a7752b Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Tue, 19 Nov 2024 11:31:53 +0100 Subject: [PATCH 9/9] [#500] Fix max length of UniquePortId --- iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp index d03d57b09..e640b7087 100644 --- a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp @@ -19,7 +19,7 @@ namespace iox2 { -constexpr uint64_t UNIQUE_PORT_ID_LENGTH = 128; +constexpr uint64_t UNIQUE_PORT_ID_LENGTH = 16; using RawIdType = iox::vector; /// The system-wide unique id of a [`Publisher`].