File rtps_types.hpp
File List > astutedds > rtps > rtps_types.hpp
Go to the documentation of this file
#ifndef ASTUTEDDS_RTPS_TYPES_HPP
#define ASTUTEDDS_RTPS_TYPES_HPP
#include <array>
#include <cstdint>
#include <cstring>
#include <string>
#include <vector>
namespace astutedds::rtps {
// RTPS Protocol Version (9.3.1)
struct ProtocolVersion_t {
uint8_t major{2};
uint8_t minor{5}; // RTPS 2.5
};
// RTPS Vendor ID (9.3.2)
//
// OMG-assigned RTPS vendor IDs (https://www.dds-foundation.org/dds-rtps-vendor-and-product-ids/):
//
// | Vendor ID | DDS / RTPS Product Name | Company |
// | -------------- | ----------------------------- | ----------------------------------------- |
// | {0x01, 0x01} | RTI Connext DDS | Real-Time Innovations, Inc. (RTI) |
// | {0x01, 0x02} | OpenSplice DDS | ADLink Ltd. |
// | {0x01, 0x03} | OpenDDS | Object Computing Inc. (OCI) |
// | {0x01, 0x04} | Mil-DDS | MilSoft |
// | {0x01, 0x05} | InterCOM DDS | Kongsberg |
// | {0x01, 0x06} | CoreDX DDS | Twin Oaks Computing |
// | {0x01, 0x07} | Not Active | Lakota Technical Solutions, Inc. |
// | {0x01, 0x08} | Not Active | ICOUP Consulting |
// | {0x01, 0x09} | Diamond DDS | ETRI |
// | {0x01, 0x0A} | RTI Connext DDS Micro | Real-Time Innovations, Inc. (RTI) |
// | {0x01, 0x0B} | Vortex Cafe | ADLink Ltd. |
// | {0x01, 0x0C} | Not Active | PrismTech Ltd. |
// | {0x01, 0x0D} | Vortex Lite | ADLink Ltd. |
// | {0x01, 0x0E} | Qeo (Not active) | Technicolor |
// | {0x01, 0x0F} | FastRTPS, FastDDS | eProsima |
// | {0x01, 0x10} | Eclipse Cyclone DDS | Eclipse Foundation |
// | {0x01, 0x11} | GurumDDS | Gurum Networks, Inc. |
// | {0x01, 0x12} | RustDDS | Atostek |
// | {0x01, 0x13} | ZRDDS | Nanjing Zhenrong Software Technology Co. |
// | {0x01, 0x14} | Dust DDS | S2E Software Systems B.V. |
// | {0x01, 0x15} | Safe DDS | eProsima |
// | {0x01, 0x16} | Federated Designs DDS Tools | Federated Designs |
// | {0x01, 0x17} | Rocket Edge Connect for DDS | Rocket Software |
// | {0x01, 0x18} | Bell Digital Backbone RTPS | Bell Textron, Inc. |
// | {0x01, 0x19} | int2DDS | Intellectus Corporation |
// | {0x01, 0x1A} | HDDS (High Performance DDS) | Naskel |
// | {0x01, 0x1B} | Zenzen DDS | Zenzen IoT |
// | {0x01, 0x1C} | AstuteDDS | Astute Systems PTY LTD |
struct VendorId_t {
std::array<uint8_t, 2> vendorId{{0x01, 0x1C}}; // AstuteDDS OMG-assigned vendor ID
};
// RTPS GUID (9.3.3)
struct GuidPrefix_t {
std::array<uint8_t, 12> value{};
};
struct EntityId_t {
std::array<uint8_t, 3> entityKey{};
uint8_t entityKind{0};
// Predefined Entity IDs (9.3.3.1)
static constexpr EntityId_t ENTITYID_UNKNOWN() {
return EntityId_t{{0x00, 0x00, 0x00}, 0x00};
}
static constexpr EntityId_t ENTITYID_PARTICIPANT() {
return EntityId_t{{0x00, 0x00, 0x01}, 0xc1};
}
static constexpr EntityId_t ENTITYID_SEDP_BUILTIN_TOPICS_ANNOUNCER() {
return EntityId_t{{0x00, 0x00, 0x02}, 0xc2};
}
static constexpr EntityId_t ENTITYID_SEDP_BUILTIN_TOPICS_DETECTOR() {
return EntityId_t{{0x00, 0x00, 0x02}, 0xc7};
}
static constexpr EntityId_t ENTITYID_SEDP_BUILTIN_PUBLICATIONS_ANNOUNCER() {
return EntityId_t{{0x00, 0x00, 0x03}, 0xc2};
}
static constexpr EntityId_t ENTITYID_SEDP_BUILTIN_PUBLICATIONS_DETECTOR() {
return EntityId_t{{0x00, 0x00, 0x03}, 0xc7};
}
static constexpr EntityId_t ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_ANNOUNCER() {
return EntityId_t{{0x00, 0x00, 0x04}, 0xc2};
}
static constexpr EntityId_t ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_DETECTOR() {
return EntityId_t{{0x00, 0x00, 0x04}, 0xc7};
}
static constexpr EntityId_t ENTITYID_SPDP_BUILTIN_PARTICIPANT_ANNOUNCER() {
return EntityId_t{{0x00, 0x01, 0x00}, 0xc2};
}
static constexpr EntityId_t ENTITYID_SPDP_BUILTIN_PARTICIPANT_DETECTOR() {
return EntityId_t{{0x00, 0x01, 0x00}, 0xc7};
}
static constexpr EntityId_t ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER() {
return EntityId_t{{0x00, 0x02, 0x00}, 0xc2};
}
static constexpr EntityId_t ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_READER() {
return EntityId_t{{0x00, 0x02, 0x00}, 0xc7};
}
};
struct GUID_t {
GuidPrefix_t guidPrefix{};
EntityId_t entityId{};
// Comparison operator for use in maps
bool operator<(const GUID_t& other) const {
int prefix_cmp = std::memcmp(guidPrefix.value.data(),
other.guidPrefix.value.data(), 12);
if (prefix_cmp != 0) return prefix_cmp < 0;
int key_cmp = std::memcmp(entityId.entityKey.data(),
other.entityId.entityKey.data(), 3);
if (key_cmp != 0) return key_cmp < 0;
return entityId.entityKind < other.entityId.entityKind;
}
};
// Sequence Number (9.3.4)
struct SequenceNumber_t {
int32_t high{0};
uint32_t low{0};
static constexpr SequenceNumber_t SEQUENCENUMBER_UNKNOWN() {
return SequenceNumber_t{-1, 0};
}
};
// Locator (9.3.5)
enum class LocatorKind_t : int32_t {
LOCATOR_KIND_INVALID = -1,
LOCATOR_KIND_RESERVED = 0,
LOCATOR_KIND_UDPv4 = 1,
LOCATOR_KIND_UDPv6 = 2
};
struct Locator_t {
LocatorKind_t kind{LocatorKind_t::LOCATOR_KIND_INVALID};
uint32_t port{0};
std::array<uint8_t, 16> address{};
};
using LocatorList_t = std::vector<Locator_t>;
// Timestamp (9.3.6)
struct Time_t {
constexpr Time_t() = default;
constexpr Time_t(int32_t s, uint32_t f) : seconds(s), fraction(f) {}
int32_t seconds{0};
uint32_t fraction{0}; // Fraction of a second in (1/2^32) units
uint32_t nanosec{0}; // DDS PSM API: nanosecond representation
bool operator==(const Time_t&) const = default;
bool operator!=(const Time_t&) const = default;
static constexpr Time_t TIME_INVALID() {
return Time_t{-1, 0xffffffff};
}
static constexpr Time_t TIME_ZERO() {
return Time_t{0, 0};
}
static constexpr Time_t TIME_INFINITE() {
return Time_t{0x7fffffff, 0xffffffff};
}
};
// Duration (similar to Time_t but used for durations)
using Duration_t = Time_t;
// Count (9.3.7)
using Count_t = int32_t;
// Parameter List (9.4.2.11)
struct ParameterId_t {
uint16_t value{0};
// Standard Parameter IDs
static constexpr uint16_t PID_PAD = 0x0000;
static constexpr uint16_t PID_SENTINEL = 0x0001;
static constexpr uint16_t PID_PROTOCOL_VERSION = 0x0015;
static constexpr uint16_t PID_VENDOR_ID = 0x0016;
static constexpr uint16_t PID_PARTICIPANT_GUID = 0x0050;
static constexpr uint16_t PID_ENDPOINT_GUID = 0x005a;
static constexpr uint16_t PID_TOPIC_NAME = 0x0005;
static constexpr uint16_t PID_TYPE_NAME = 0x0007;
static constexpr uint16_t PID_UNICAST_LOCATOR = 0x002f;
static constexpr uint16_t PID_MULTICAST_LOCATOR = 0x0030;
static constexpr uint16_t PID_DEFAULT_UNICAST_LOCATOR = 0x0031;
static constexpr uint16_t PID_DEFAULT_MULTICAST_LOCATOR = 0x0048;
static constexpr uint16_t PID_METATRAFFIC_UNICAST_LOCATOR = 0x0032;
static constexpr uint16_t PID_METATRAFFIC_MULTICAST_LOCATOR = 0x0033;
};
struct Parameter {
ParameterId_t parameterId{};
uint16_t length{0};
std::vector<uint8_t> value;
};
using ParameterList = std::vector<Parameter>;
// Submessage Kinds (9.4.5.1.1)
enum class SubmessageKind : uint8_t {
PAD = 0x01,
ACKNACK = 0x06,
HEARTBEAT = 0x07,
GAP = 0x08,
INFO_TS = 0x09,
INFO_SRC = 0x0c,
INFO_REPLY_IP4 = 0x0d,
INFO_DST = 0x0e,
INFO_REPLY = 0x0f,
NACK_FRAG = 0x12,
HEARTBEAT_FRAG = 0x13,
DATA = 0x15,
DATA_FRAG = 0x16
};
// Submessage Header (9.4.5.1)
struct SubmessageHeader {
SubmessageKind submessageId{};
uint8_t flags{0};
uint16_t submessageLength{0};
};
// Change Kind (for cache changes)
enum class ChangeKind_t : uint32_t {
ALIVE = 0,
ALIVE_FILTERED = 1,
NOT_ALIVE_DISPOSED = 2,
NOT_ALIVE_UNREGISTERED = 3
};
} // namespace astutedds::rtps
#endif // ASTUTEDDS_RTPS_TYPES_HPP