File type_lookup_wire.hpp

File List > astutedds > rtps > type_lookup_wire.hpp

Go to the documentation of this file

//
// Copyright (c) 2026, Astute Systems PTY LTD
//
// This file is part of the Astute DDS developed by Astute Systems.
//
// See the commercial LICENSE file in the project root for full license details.
//
// @file type_lookup_wire.hpp
// @brief Wire-level helpers for DDS-XTypes TypeLookup Service payloads
//
// Decodes selected XTypes 1.3 TypeInformation and TypeLookup reply structures
// used by the RTPS transport/inspect integration.
//

#ifndef ASTUTEDDS_RTPS_TYPE_LOOKUP_WIRE_HPP
#define ASTUTEDDS_RTPS_TYPE_LOOKUP_WIRE_HPP

#include <array>
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>

namespace astutedds::rtps
{

struct ParsedTypeLookupReply
{
    uint64_t relatedRequestSeqNum{0};
    std::string typeName;
    std::vector<std::string> fieldNames;
    std::vector<uint8_t> fieldKinds;

    struct NestedFieldSchema
    {
        std::string fieldName;                
        std::vector<std::string> subNames;    
        std::vector<uint8_t>     subKinds;    
    };
    std::vector<NestedFieldSchema> nestedSchemas;
};

struct ParsedTypeLookupRequest
{
    std::array<uint8_t, 24> requestId{};  // SampleIdentity bytes
    std::array<uint8_t, 14> completeTypeIdHash{};
    bool hasCompleteTypeIdHash{false};
};

// DDS-XTypes 1.3 §7.6.2.1 TypeInformation helper.
// Extracts EK_COMPLETE EquivalenceHash (14 bytes) when present.
bool extract_complete_type_id_hash_from_type_information(
    const uint8_t* data,
    size_t len,
    std::array<uint8_t, 14>& outHash);

// DDS-XTypes 1.3 §7.6.3.3 TypeLookup_Reply helper.
// Parses XCDR2-MUTABLE reply payload (including 4-byte encapsulation header)
// and extracts request sequence number, type name, and field names.
bool parse_type_lookup_reply_payload(
    const uint8_t* data,
    size_t len,
    ParsedTypeLookupReply& out);

// DDS-XTypes 1.3 §7.6.3.3 TypeLookup_Request helper.
// Parses XCDR2-MUTABLE request payload (including 4-byte encapsulation header)
// and extracts RequestHeader.requestId and GET_TYPES requested EK_COMPLETE hash.
bool parse_type_lookup_request_payload(
    const uint8_t* data,
    size_t len,
    ParsedTypeLookupRequest& out);

}  // namespace astutedds::rtps

#endif  // ASTUTEDDS_RTPS_TYPE_LOOKUP_WIRE_HPP