-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2191 from elBoberido/iox-2185-use-prefix-for-iceo…
…ryx-resources iox-#2185 Use prefix for iceoryx resources
- Loading branch information
Showing
28 changed files
with
310 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) 2019 - 2020 by Robert Bosch GmbH. All rights reserved. | ||
// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved. | ||
// Copyright (c) 2022 by NXP. All rights reserved. | ||
// Copyright (c) 2024 by Mathias Kraus <[email protected]>. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -20,6 +21,7 @@ | |
|
||
#include "iceoryx_platform/platform_settings.hpp" | ||
#include "iceoryx_posh/iceoryx_posh_deployment.hpp" | ||
#include "iox/detail/convert.hpp" | ||
#include "iox/duration.hpp" | ||
#include "iox/function.hpp" | ||
#include "iox/log/logstream.hpp" | ||
|
@@ -196,6 +198,22 @@ struct DefaultChunkQueueConfig | |
static constexpr uint64_t MAX_QUEUE_CAPACITY = MAX_SUBSCRIBER_QUEUE_CAPACITY; | ||
}; | ||
|
||
constexpr const char ICEORYX_RESOURCE_PREFIX[] = "iox1"; | ||
|
||
/// @brief The resource type is used to customize the resource prefix by adding an 'i' or 'u' depending whether the | ||
/// resource is defined by iceoryx, e.g. the roudi IPC channel, or by the user, e.g. the runtime name. This shall | ||
/// prevent the system from being affected by users defining resource names which are intended to be used by iceoryx. | ||
enum class ResourceType | ||
{ | ||
ICEORYX_DEFINED, | ||
USER_DEFINED, | ||
}; | ||
|
||
using ResourcePrefix_t = string<13>; // 'iox1_' + MAX_UINT16_SIZE + '_' + optional 'x_' | ||
/// @brief Returns the prefix string used for resources | ||
/// @param[in] uniqueRouDiID to use for the prefix string | ||
inline ResourcePrefix_t iceoryxResourcePrefix(uint16_t uniqueRouDiID, ResourceType resourceType); | ||
|
||
// alias for string | ||
using RuntimeName_t = string<MAX_RUNTIME_NAME_LENGTH>; | ||
using NodeName_t = string<build::IOX_MAX_NODE_NAME_LENGTH>; | ||
|
@@ -214,11 +232,11 @@ namespace roudi | |
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) | ||
using ConfigFilePathString_t = string<1024>; | ||
|
||
constexpr const char ROUDI_LOCK_NAME[] = "iox-unique-roudi"; | ||
constexpr const char ROUDI_LOCK_NAME[] = "unique_roudi"; | ||
constexpr const char IPC_CHANNEL_ROUDI_NAME[] = "roudi"; | ||
|
||
/// shared memory segment for the iceoryx management data | ||
constexpr const char SHM_NAME[] = "iceoryx_mgmt"; | ||
constexpr const char SHM_NAME[] = "management"; | ||
|
||
// this is used by the UniquePortId | ||
constexpr uint16_t DEFAULT_UNIQUE_ROUDI_ID{0U}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// Copyright (c) 2020 - 2021 by Apex.AI Inc. All rights reserved. | ||
// Copyright (c) 2024 by Mathias Kraus <[email protected]>. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -49,6 +50,19 @@ log::LogStream& operator<<(log::LogStream& stream, ConnectionState value) noexce | |
return stream; | ||
} | ||
|
||
ResourcePrefix_t iceoryxResourcePrefix(uint16_t uniqueRouDiID, ResourceType resourceType) | ||
{ | ||
static_assert(std::is_same_v<uint16_t, std::remove_const_t<decltype(uniqueRouDiID)>>, | ||
"Please adjust 'MAX_UINT16_WIDTH' to the new fixed width type to have enough space for the " | ||
"stringified unique RouDi ID"); | ||
constexpr auto MAX_UINT16_WIDTH{5}; | ||
iox::string<MAX_UINT16_WIDTH> uniqueRoudiIdString{TruncateToCapacity, | ||
iox::convert::toString(uniqueRouDiID).c_str()}; | ||
|
||
auto resourceTypeString{resourceType == ResourceType::ICEORYX_DEFINED ? iox::string<1>{"i"} : iox::string<1>{"u"}}; | ||
return concatenate(ICEORYX_RESOURCE_PREFIX, "_", uniqueRoudiIdString, "_", resourceTypeString, "_"); | ||
} | ||
|
||
namespace roudi | ||
{ | ||
inline iox::log::LogStream& operator<<(iox::log::LogStream& logstream, const MonitoringMode& mode) noexcept | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. | ||
// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. | ||
// Copyright (c) 2023 by Mathias Kraus <[email protected]>. All rights reserved. | ||
// Copyright (c) 2023 - 2024 by Mathias Kraus <[email protected]>. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -23,6 +23,7 @@ | |
#include "iceoryx_posh/mepoo/memory_info.hpp" | ||
#include "iceoryx_posh/mepoo/mepoo_config.hpp" | ||
#include "iox/bump_allocator.hpp" | ||
#include "iox/detail/convert.hpp" | ||
#include "iox/logging.hpp" | ||
#include "iox/relative_pointer.hpp" | ||
|
||
|
@@ -72,7 +73,21 @@ inline SharedMemoryObjectType MePooSegment<SharedMemoryObjectType, MemoryManager | |
{ | ||
return std::move( | ||
typename SharedMemoryObjectType::Builder() | ||
.name(writerGroup.getName()) | ||
.name([&writerGroup] { | ||
using ShmName_t = detail::PosixSharedMemory::Name_t; | ||
ShmName_t shmName = iceoryxResourcePrefix(roudi::DEFAULT_UNIQUE_ROUDI_ID, ResourceType::USER_DEFINED); | ||
if (shmName.size() + writerGroup.getName().size() > ShmName_t::capacity()) | ||
{ | ||
IOX_LOG(FATAL, | ||
"The payload segment with the name '" | ||
<< writerGroup.getName().size() | ||
<< "' would exceed the maximum allowed size when used with the '" << shmName | ||
<< "' prefix!"); | ||
IOX_PANIC(""); | ||
} | ||
shmName.append(TruncateToCapacity, writerGroup.getName()); | ||
return shmName; | ||
}()) | ||
.memorySizeInBytes(MemoryManager::requiredChunkMemorySize(mempoolConfig)) | ||
.accessMode(AccessMode::READ_WRITE) | ||
.openMode(OpenMode::PURGE_AND_CREATE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright (c) 2019, 2021 by Robert Bosch GmbH. All rights reserved. | ||
// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. | ||
// Copyright (c) 2023 by Mathias Kraus <[email protected]>. All rights reserved. | ||
// Copyright (c) 2023 - 2024 by Mathias Kraus <[email protected]>. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
@@ -248,7 +248,7 @@ void RouDi::processRuntimeMessages() noexcept | |
{ | ||
setThreadName("IPC-msg-process"); | ||
|
||
runtime::IpcInterfaceCreator roudiIpcInterface{IPC_CHANNEL_ROUDI_NAME}; | ||
runtime::IpcInterfaceCreator roudiIpcInterface{IPC_CHANNEL_ROUDI_NAME, ResourceType::ICEORYX_DEFINED}; | ||
|
||
IOX_LOG(INFO, "RouDi is ready for clients"); | ||
fflush(stdout); // explicitly flush 'stdout' for 'launch_testing' | ||
|
@@ -289,6 +289,23 @@ void RouDi::processMessage(const runtime::IpcMessage& message, | |
const iox::runtime::IpcMessageType& cmd, | ||
const RuntimeName_t& runtimeName) noexcept | ||
{ | ||
if (runtimeName.empty()) | ||
{ | ||
IOX_LOG(ERROR, "Got message with empty runtime name!"); | ||
return; | ||
} | ||
|
||
|
||
for (const auto s : platform::IOX_PATH_SEPARATORS) | ||
{ | ||
const char separator[2]{s}; | ||
if (runtimeName.find(separator).has_value()) | ||
{ | ||
IOX_LOG(ERROR, "Got message with a runtime name with invalid characters: \"" << runtimeName << "\"!"); | ||
return; | ||
} | ||
} | ||
|
||
switch (cmd) | ||
{ | ||
case runtime::IpcMessageType::REG: | ||
|
Oops, something went wrong.