Coverage Report

Created: 2025-06-13 06:46

/src/Fast-DDS/include/fastdds/rtps/messages/RTPS_messages.hpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
/**
16
 * @file RTPS_messages.hpp
17
 */
18
19
#ifndef FASTDDS_RTPS_MESSAGES__RTPS_MESSAGES_HPP
20
#define FASTDDS_RTPS_MESSAGES__RTPS_MESSAGES_HPP
21
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
22
23
#include <iostream>
24
#include <bitset>
25
26
#include <fastdds/rtps/common/Guid.hpp>
27
#include <fastdds/rtps/common/Types.hpp>
28
#include <fastdds/rtps/common/VendorId_t.hpp>
29
30
namespace eprosima {
31
namespace fastdds {
32
namespace rtps {
33
34
// //!@brief Enumeration of the different Submessages types
35
enum SubmessageId : uint8_t
36
{
37
    PAD             = 0x01,
38
    ACKNACK         = 0x06,
39
    HEARTBEAT       = 0x07,
40
    GAP             = 0x08,
41
    INFO_TS         = 0x09,
42
    INFO_SRC        = 0x0c,
43
    INFO_REPLY_IP4  = 0x0d,
44
    INFO_DST        = 0x0e,
45
    INFO_REPLY      = 0x0f,
46
    NACK_FRAG       = 0x12,
47
    HEARTBEAT_FRAG  = 0x13,
48
    DATA            = 0x15,
49
    DATA_FRAG       = 0x16
50
};
51
52
//!@brief Structure Header_t, RTPS Message Header Structure.
53
//!@ingroup COMMON_MODULE
54
struct Header_t
55
{
56
    //!Protocol version
57
    ProtocolVersion_t version;
58
    //!Vendor ID
59
    fastdds::rtps::VendorId_t vendorId;
60
    //!GUID prefix
61
    GuidPrefix_t guidPrefix;
62
    Header_t()
63
        : version(c_ProtocolVersion)
64
        , vendorId(c_VendorId_eProsima)
65
0
    {
66
0
    }
67
68
    ~Header_t()
69
0
    {
70
0
    }
71
72
};
73
74
/**
75
 * @param output
76
 * @param h
77
 * @return
78
 */
79
inline std::ostream& operator <<(
80
        std::ostream& output,
81
        const Header_t& h)
82
0
{
83
0
    output << "RTPS HEADER of Version: " << (int)h.version.m_major << "." << (int)h.version.m_minor;
84
0
    output << "  || VendorId: " << std::hex << (int)h.vendorId[0] << "." << (int)h.vendorId[1] << std::dec;
85
0
    output << "GuidPrefix: " << h.guidPrefix;
86
0
    return output;
87
0
}
88
89
//!@brief Structure SubmessageHeader_t, used to contain the header information of a submessage.
90
struct SubmessageHeader_t
91
{
92
    octet submessageId;
93
    uint32_t submessageLength;
94
    SubmessageFlag flags;
95
    bool is_last;
96
97
    SubmessageHeader_t()
98
7.85k
        : submessageId(0)
99
7.85k
        , submessageLength(0)
100
7.85k
        , flags(0)
101
7.85k
        , is_last(false)
102
7.85k
    {
103
7.85k
    }
104
105
};
106
107
using std::cout;
108
using std::endl;
109
using std::bitset;
110
111
/**
112
 * @param output
113
 * @param sh
114
 * @return
115
 */
116
inline std::ostream& operator <<(
117
        std::ostream& output,
118
        const SubmessageHeader_t& sh)
119
0
{
120
0
    output << "Submessage Header, ID: " << std::hex << (int)sh.submessageId << std::dec;
121
0
    output << " length: " << (int)sh.submessageLength << " flags " << (bitset<8>)sh.flags;
122
0
    return output;
123
0
}
124
125
} // namespace rtps
126
} // namespace fastdds
127
} // namespace eprosima
128
129
130
#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
131
#endif // FASTDDS_RTPS_MESSAGES__RTPS_MESSAGES_HPP