OpenDDS  Snapshot(2023/04/28-20:55)
TransportHeader.cpp
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 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
9 #include "TransportHeader.h"
10 #include "dds/DCPS/Serializer.h"
11 #include "EntryExit.h"
12 
13 const ACE_CDR::Octet
15  { 0x44, 0x43, 0x50, 0x53, 0x02, 0x00 };
16 // D C P S | |__ minor version
17 // |________ major version
18 
19 #if !defined (__ACE_INLINE__)
20 # include "TransportHeader.inl"
21 #endif /* !__ACE_INLINE__ */
22 
24 
25 namespace OpenDDS {
26 namespace DCPS {
27 
29 {
31 
32  if (!writer.write_octet_array(value.protocol_, sizeof(value.protocol_)))
33  return false;
34 
35  const ACE_CDR::Octet flags =
39 
40  return (writer << ACE_OutputCDR::from_octet(flags)) &&
41  (writer << ACE_OutputCDR::from_octet(value.reserved_)) &&
42  (writer << value.length_) &&
43  (writer << value.sequence_) &&
44  (writer << value.source_);
45 }
46 
47 /*static*/
48 ACE_UINT32
49 TransportHeader::get_length(const char* marshaled_header)
50 {
51  const TransportHeader* hdr = 0;
52  static const unsigned int OFFSET = sizeof(hdr->protocol_) +
53  1 /*flags*/ +
54  sizeof(hdr->reserved_);
55  return *reinterpret_cast<const ACE_UINT32*>(marshaled_header + OFFSET);
56 }
57 
58 }
59 }
60 
ACE_Byte Octet
const LogLevel::Value value
Definition: debug.cpp:61
static ACE_UINT32 get_length(const char *marshaled_transport_header)
static const ACE_CDR::Octet DCPS_PROTOCOL[6]
ACE_CDR::Octet reserved_
Reserved for future use (provides padding for preamble).
bool write_octet_array(const ACE_CDR::Octet *x, ACE_CDR::ULong length)
Definition: Serializer.inl:697
Class to serialize and deserialize data for DDS.
Definition: Serializer.h:369
ACE_CDR::Boolean operator<<(Serializer &serializer, CoherentChangeControl &value)
Marshal/Insertion into a buffer.
ACE_CDR::Octet protocol_[6]
The protocol of the packet being transmitted.
Defines class that represents a transport packet header.
bool byte_order_
Flags: marshaled as a single byte (ACE_CDR::Octet)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28