OpenDDS  Snapshot(2023/04/28-20:55)
RtpsSampleHeader.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifndef OPENDDS_DCPS_TRANSPORT_RTPS_UDP_RTPSSAMPLEHEADER_H
9 #define OPENDDS_DCPS_TRANSPORT_RTPS_UDP_RTPSSAMPLEHEADER_H
10 
11 #include "Rtps_Udp_Export.h"
12 
13 #include "ace/Basic_Types.h"
14 #include "dds/DCPS/RTPS/RtpsCoreC.h"
17 
19 class ACE_Message_Block;
21 
23 
24 namespace OpenDDS {
25 namespace DCPS {
26 
27 class ReceivedDataSample;
28 class DataSampleElement;
29 class DisjointSequence;
30 
31 /// Adapt the TransportReceiveStrategy for RTPS's "sample" (submessage) Header
33 public:
34 
35  // This is not really the max_serialized_size, but it's used for determining
36  // how much of the submessage to show in debugging hexdumps. Since we don't
37  // know which kind of submessage we have, we can only count on the 4-byte
38  // SubmessageHeader being present.
39  static size_t get_max_serialized_size() { return 4; }
40 
41  // We never have partial "sample" headers since this is UDP.
42  // (The header could fail to parse in init(), but unlike the TCP case we
43  // never want to go back to the reactor and wait for more bytes to arrive.)
44  static bool partial(const ACE_Message_Block&) { return false; }
45 
46  /// Create two new serialized headers (owned by caller), the "head" having at
47  /// most "size" bytes (header + data) and the "tail" having the rest.
48  /// Returns a pair containing the largest fragment number in each new header.
49  static SequenceRange split(const ACE_Message_Block& orig, size_t size,
50  Message_Block_Ptr& head,
51  Message_Block_Ptr& tail);
52 
54  explicit RtpsSampleHeader(ACE_Message_Block& mb);
55  RtpsSampleHeader& operator=(ACE_Message_Block& mn);
56 
57  void pdu_remaining(size_t size);
58  size_t get_serialized_size();
59  ACE_UINT32 message_length();
60 
61  bool valid() const;
62 
63  bool into_received_data_sample(ReceivedDataSample& rds);
64 
65  static bool payload_byte_order(const ReceivedDataSample& rds);
66 
67  bool more_fragments() const;
68 
70 
71 private:
72  void init(ACE_Message_Block& mb);
73 
74  bool valid_, frag_, data_;
75  size_t serialized_size_, message_length_;
76 
77 public:
78  // Unlike the rest of this class, which is used with the
79  // TransportReceiveStrategy, these functions do the inverse of
80  // into_received_data_sample() so they are used on the sending side:
81  // translating from an OpenDDS data structure to the RTPS format.
82  static void populate_data_sample_submessages(RTPS::SubmessageSeq& subm,
83  const DataSampleElement& dsle,
84  bool requires_inline_qos);
85  static void populate_data_control_submessages(RTPS::SubmessageSeq& subm,
86  const TransportSendControlElement& tsce,
87  bool requires_inline_qos);
88  static void populate_inline_qos(const TransportSendListener::InlineQosData& qos_data,
89  RTPS::ParameterList& plist);
90  static bool control_message_supported(char message_id);
91 
92  // All of the fragments we generate will use the FRAG_SIZE of 1024, which may
93  // be the smallest allowed by the spec (8.4.14.1.1). There is no practical
94  // advantage to increasing this constant, since any number of 1024-byte
95  // fragments may appear in a single DATA_FRAG submessage. The spec is
96  // ambiguous in its use of KB to mean either 1000 or 1024, and uses < instead
97  // of <= (see issue 16966).
98  static const ACE_CDR::UShort FRAG_SIZE = 1024;
99 
100 private:
101  static void process_iqos(DataSampleHeader& opendds,
102  const OpenDDS::RTPS::ParameterList& iqos);
103 };
104 
105 }
106 }
107 
109 
110 #ifdef __ACE_INLINE__
111 #include "RtpsSampleHeader.inl"
112 #endif
113 
114 #endif
sequence< Submessage > SubmessageSeq
Definition: RtpsCore.idl:885
#define ACE_BEGIN_VERSIONED_NAMESPACE_DECL
OpenDDS::internal::special_serialization typedef sequence< Parameter > ParameterList
Definition: RtpsCore.idl:236
Holds a data sample received by the transport.
ACE_UINT16 UShort
#define ACE_END_VERSIONED_NAMESPACE_DECL
int init(void)
std::pair< SequenceNumber, SequenceNumber > SequenceRange
Adapt the TransportReceiveStrategy for RTPS&#39;s "sample" (submessage) Header.
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
static bool partial(const ACE_Message_Block &)
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
#define OpenDDS_Rtps_Udp_Export