OpenDDS  Snapshot(2023/04/28-20:55)
TransportHeader.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_FRAMEWORK_TRANSPORTHEADER_H
9 #define OPENDDS_DCPS_TRANSPORT_FRAMEWORK_TRANSPORTHEADER_H
10 
11 #include "ace/Basic_Types.h"
12 #include "ace/CDR_Base.h"
13 
14 #include "dds/DCPS/Definitions.h"
16 
18 
19 namespace OpenDDS {
20 namespace DCPS {
21 
22 // If TransportHeader changes size, must recalculate
23 // serialized size and update static variable here
24 static const ACE_UINT32 TRANSPORT_HDR_SERIALIZED_SZ(28);
25 
26 /**
27  * @struct TransportHeader
28  *
29  * @brief Defines class that represents a transport packet header.
30  *
31  * The TransportHeader is the transport packet header. Each packet
32  * sent by the transport will always start with a transport packet
33  * header, followed by one or more data samples (all belonging to the
34  * same transport packet).
35  */
37  static const ACE_CDR::Octet DCPS_PROTOCOL[6];
38 
39  /// Default constructor.
41 
42  /// Construct with values extracted from a buffer.
43  explicit TransportHeader(ACE_Message_Block& buffer);
44 
45  /// Assignment from an ACE_Message_Block.
46  TransportHeader& operator=(ACE_Message_Block& buffer);
47 
49 
50  /// Determine if the serializer should swap bytes.
51  bool swap_bytes() const;
52 
53  /// Determine if this is a valid packet header.
54  bool valid() const;
55 
56  /// The protocol of the packet being transmitted.
57  ACE_CDR::Octet protocol_[6];
58 
59  /// Flags: marshaled as a single byte (ACE_CDR::Octet)
63 
64  /// Constants for bit masking the marshaled flags byte.
65  /// This needs to match the 'Flags' above.
66  enum { BYTE_ORDER_FLAG, FIRST_FRAGMENT_FLAG, LAST_FRAGMENT_FLAG };
67 
68  /// Reserved for future use (provides padding for preamble).
70 
71  /// The size of the message following this header, not including the
72  /// bytes used by this TransportHeader.
73  ACE_UINT32 length_;
74 
75  /// The sequence number of the packet identified by this header; this
76  /// value is guaranteed to be a monotonically increasing number per
77  /// transport instance.
79 
80  /// A transport-specific identification number which uniquely
81  /// identifies the source of the packet.
83 
84  /// Similar to IDL compiler generated methods.
85  static size_t get_max_serialized_size();
86 
87  /// Demarshal transport packet from ACE_Message_Block.
88  bool init(ACE_Message_Block* buffer);
89 
90  bool first_fragment() { return this->first_fragment_; }
91  bool last_fragment() { return this->last_fragment_; }
92  void last_fragment(bool frag) { this->last_fragment_ = frag; }
93  const SequenceNumber& sequence() { return this->sequence_; }
94 
95  static ACE_UINT32 get_length(const char* marshaled_transport_header);
96 };
97 
100 
101 } // namespace DCPS
102 } // namespace OpenDDS
103 
105 
106 #if defined(__ACE_INLINE__)
107 #include "TransportHeader.inl"
108 #endif /* __ACE_INLINE__ */
109 
110 #endif /* OPENDDS_DCPS_TRANSPORTHEADER_H */
ACE_Byte Octet
const LogLevel::Value value
Definition: debug.cpp:61
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
ACE_CDR::Octet reserved_
Reserved for future use (provides padding for preamble).
static const ACE_UINT32 TRANSPORT_HDR_SERIALIZED_SZ(28)
ACE_CDR::Boolean operator<<(Serializer &serializer, CoherentChangeControl &value)
Marshal/Insertion into a buffer.
const SequenceNumber & sequence()
int init(void)
Defines class that represents a transport packet header.
void incomplete(ACE_Message_Block &)
bool byte_order_
Flags: marshaled as a single byte (ACE_CDR::Octet)
Sequence number abstraction. Only allows positive 64 bit values.
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
long long ACE_INT64
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28