OpenDDS::DCPS::TransportHeader Struct Reference

Defines class that represents a transport packet header. More...

#include <TransportHeader.h>

Collaboration diagram for OpenDDS::DCPS::TransportHeader:
Collaboration graph
[legend]

List of all members.

Classes

struct  no_init_t

Public Types

enum  { BYTE_ORDER_FLAG, FIRST_FRAGMENT_FLAG, LAST_FRAGMENT_FLAG }

Public Member Functions

 TransportHeader ()
 Default constructor.
 TransportHeader (ACE_Message_Block &buffer)
 Construct with values extracted from a buffer.
TransportHeaderoperator= (ACE_Message_Block &buffer)
 Assignment from an ACE_Message_Block.
void incomplete (ACE_Message_Block &)
bool swap_bytes () const
 Determine if the serializer should swap bytes.
bool valid () const
 Determine if this is a valid packet header.
bool init (ACE_Message_Block *buffer)
 Demarshal transport packet from ACE_Message_Block.
bool first_fragment ()
bool last_fragment ()
void last_fragment (bool frag)
const SequenceNumbersequence ()

Static Public Member Functions

static size_t max_marshaled_size ()
 Similar to IDL compiler generated methods.
static ACE_UINT32 get_length (const char *marshaled_transport_header)

Public Attributes

ACE_CDR::Octet protocol_ [6]
 The protocol of the packet being transmitted.
bool byte_order_
 Flags: marshaled as a single byte (ACE_CDR::Octet).
bool first_fragment_
bool last_fragment_
ACE_CDR::Octet reserved_
 Reserved for future use (provides padding for preamble).
ACE_UINT32 length_
SequenceNumber sequence_
ACE_INT64 source_

Static Public Attributes

static const ACE_CDR::Octet DCPS_PROTOCOL [6]

Private Member Functions

 TransportHeader (const no_init_t &)

Static Private Attributes

static const no_init_t no_init = {}

Detailed Description

Defines class that represents a transport packet header.

The TransportHeader is the transport packet header. Each packet sent by the transport will always start with a transport packet header, followed by one or more data samples (all belonging to the same transport packet).

Definition at line 36 of file TransportHeader.h.


Member Enumeration Documentation

anonymous enum

Constants for bit masking the marshaled flags byte. This needs to match the 'Flags' above.

Enumerator:
BYTE_ORDER_FLAG 
FIRST_FRAGMENT_FLAG 
LAST_FRAGMENT_FLAG 

Definition at line 66 of file TransportHeader.h.


Constructor & Destructor Documentation

ACE_INLINE OpenDDS::DCPS::TransportHeader::TransportHeader (  ) 

Default constructor.

Definition at line 19 of file TransportHeader.inl.

References DBG_ENTRY_LVL, DCPS_PROTOCOL, and protocol_.

00020   : byte_order_(ACE_CDR_BYTE_ORDER),
00021     first_fragment_(false),
00022     last_fragment_(false),
00023     reserved_(0),
00024     length_(0),
00025     sequence_(),
00026     source_(0)
00027 {
00028   DBG_ENTRY_LVL("TransportHeader","TransportHeader",6);
00029 
00030   std::copy(&DCPS_PROTOCOL[0], &DCPS_PROTOCOL[6], this->protocol_);
00031 }

ACE_INLINE OpenDDS::DCPS::TransportHeader::TransportHeader ( ACE_Message_Block buffer  )  [explicit]

Construct with values extracted from a buffer.

Definition at line 39 of file TransportHeader.inl.

References DBG_ENTRY_LVL, and init().

00040 {
00041   DBG_ENTRY_LVL("TransportHeader","TransportHeader",6);
00042   this->init(&buffer);
00043 }

Here is the call graph for this function:

ACE_INLINE OpenDDS::DCPS::TransportHeader::TransportHeader ( const no_init_t  )  [explicit, private]

Definition at line 34 of file TransportHeader.inl.

00035 {
00036 }


Member Function Documentation

bool OpenDDS::DCPS::TransportHeader::first_fragment (  )  [inline]

Definition at line 90 of file TransportHeader.h.

00090 { return this->first_fragment_; }

ACE_UINT32 OpenDDS::DCPS::TransportHeader::get_length ( const char *  marshaled_transport_header  )  [static]

Definition at line 51 of file TransportHeader.cpp.

References no_init, protocol_, and reserved_.

Referenced by OpenDDS::DCPS::ShmemReceiveStrategy::receive_bytes().

00052 {
00053   static const TransportHeader hdr(no_init);
00054   static const unsigned int OFFSET = sizeof(hdr.protocol_) +
00055                                      1 /*flags*/ +
00056                                      sizeof(hdr.reserved_);
00057   return *reinterpret_cast<const ACE_UINT32*>(marshaled_header + OFFSET);
00058 }

Here is the caller graph for this function:

void OpenDDS::DCPS::TransportHeader::incomplete ( ACE_Message_Block  )  [inline]

Definition at line 48 of file TransportHeader.h.

00048 {}

ACE_INLINE bool OpenDDS::DCPS::TransportHeader::init ( ACE_Message_Block buffer  ) 

Demarshal transport packet from ACE_Message_Block.

Definition at line 90 of file TransportHeader.inl.

References byte_order_, BYTE_ORDER_FLAG, DBG_ENTRY_LVL, first_fragment_, FIRST_FRAGMENT_FLAG, last_fragment_, LAST_FRAGMENT_FLAG, length_, OpenDDS::DCPS::Serializer::read_octet_array(), reserved_, sequence_, source_, swap_bytes(), and OpenDDS::DCPS::Serializer::swap_bytes().

Referenced by operator=(), and TransportHeader().

00091 {
00092   DBG_ENTRY_LVL("TransportHeader","init",6);
00093 
00094   Serializer reader(buffer);
00095 
00096   if (!reader.read_octet_array(this->protocol_, sizeof(this->protocol_)))
00097     return false;
00098 
00099   ACE_CDR::Octet flags;
00100   if (!(reader >> ACE_InputCDR::to_octet(flags)))
00101     return false;
00102 
00103   this->byte_order_= flags & (1 << BYTE_ORDER_FLAG);
00104   this->first_fragment_ = flags & (1 << FIRST_FRAGMENT_FLAG);
00105   this->last_fragment_ = flags & (1 << LAST_FRAGMENT_FLAG);
00106 
00107   if (!(reader >> ACE_InputCDR::to_octet(this->reserved_)))
00108     return false;
00109 
00110   reader.swap_bytes(swap_bytes());
00111 
00112   return (reader >> this->length_) &&
00113          (reader >> this->sequence_) &&
00114          (reader >> this->source_);
00115 }

Here is the call graph for this function:

Here is the caller graph for this function:

void OpenDDS::DCPS::TransportHeader::last_fragment ( bool  frag  )  [inline]

Definition at line 92 of file TransportHeader.h.

00092 { this->last_fragment_ = frag; }

bool OpenDDS::DCPS::TransportHeader::last_fragment (  )  [inline]

Definition at line 91 of file TransportHeader.h.

00091 { return this->last_fragment_; }

ACE_INLINE size_t OpenDDS::DCPS::TransportHeader::max_marshaled_size (  )  [static]

Similar to IDL compiler generated methods.

Definition at line 56 of file TransportHeader.inl.

References length_, no_init, protocol_, reserved_, sequence_, and source_.

Referenced by OpenDDS::DCPS::UdpDataLink::open(), and OpenDDS::DCPS::TransportSendStrategy::TransportSendStrategy().

00057 {
00058   // Representation takes no extra space for encoding.
00059   TransportHeader hdr(no_init);
00060   return sizeof(hdr.protocol_) +
00061          1 /*flags*/ +
00062          sizeof(hdr.reserved_) +
00063          sizeof(hdr.length_) +
00064          sizeof(hdr.sequence_) +
00065          sizeof(hdr.source_);
00066 }

Here is the caller graph for this function:

ACE_INLINE TransportHeader & OpenDDS::DCPS::TransportHeader::operator= ( ACE_Message_Block buffer  ) 

Assignment from an ACE_Message_Block.

Definition at line 47 of file TransportHeader.inl.

References DBG_ENTRY_LVL, and init().

00048 {
00049   DBG_ENTRY_LVL("TransportHeader","operator=",6);
00050   this->init(&buffer);
00051   return *this;
00052 }

Here is the call graph for this function:

const SequenceNumber& OpenDDS::DCPS::TransportHeader::sequence (  )  [inline]

Definition at line 93 of file TransportHeader.h.

00093 { return this->sequence_; }

ACE_INLINE bool OpenDDS::DCPS::TransportHeader::swap_bytes (  )  const

Determine if the serializer should swap bytes.

Definition at line 70 of file TransportHeader.inl.

References byte_order_, and DBG_ENTRY_LVL.

Referenced by init(), OpenDDS::DCPS::ReliableSession::nak_received(), OpenDDS::DCPS::ReliableSession::nakack_received(), OpenDDS::DCPS::MulticastDataLink::sample_received(), OpenDDS::DCPS::MulticastSession::syn_received(), and OpenDDS::DCPS::MulticastSession::synack_received().

00071 {
00072   DBG_ENTRY_LVL("TransportHeader","swap_bytes",6);
00073 
00074   return this->byte_order_ != ACE_CDR_BYTE_ORDER;
00075 }

Here is the caller graph for this function:

ACE_INLINE bool OpenDDS::DCPS::TransportHeader::valid ( void   )  const

Determine if this is a valid packet header.

Definition at line 79 of file TransportHeader.inl.

References DBG_ENTRY_LVL, DCPS_PROTOCOL, and protocol_.

00080 {
00081   DBG_ENTRY_LVL("TransportHeader","valid",6);
00082 
00083   // Currently we do not support compatibility with other
00084   // versions of the protocol:
00085   return std::equal(&DCPS_PROTOCOL[0], &DCPS_PROTOCOL[6], this->protocol_);
00086 }


Member Data Documentation

Flags: marshaled as a single byte (ACE_CDR::Octet).

Definition at line 60 of file TransportHeader.h.

Referenced by init(), and swap_bytes().

Initial value:
  { 0x44, 0x43, 0x50, 0x53, 0x02, 0x00 }

Definition at line 37 of file TransportHeader.h.

Referenced by OpenDDS::DCPS::ShmemSendStrategy::send_bytes_i(), TransportHeader(), and valid().

Definition at line 99 of file TransportHeader.h.

Referenced by get_length(), and max_marshaled_size().

The protocol of the packet being transmitted.

Definition at line 57 of file TransportHeader.h.

Referenced by get_length(), max_marshaled_size(), TransportHeader(), and valid().

Reserved for future use (provides padding for preamble).

Definition at line 69 of file TransportHeader.h.

Referenced by get_length(), init(), and max_marshaled_size().


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1