#include <TransportHeader.h>
Collaboration diagram for OpenDDS::DCPS::TransportHeader:
Public Types | |
BYTE_ORDER_FLAG | |
FIRST_FRAGMENT_FLAG | |
LAST_FRAGMENT_FLAG | |
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. | |
TransportHeader & | operator= (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. | |
void | init (ACE_Message_Block *buffer) |
Demarshal transport packet from ACE_Message_Block. | |
bool | first_fragment () |
bool | last_fragment () |
void | last_fragment (bool frag) |
const SequenceNumber & | sequence () |
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 = {} |
Classes | |
struct | no_init_t |
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 33 of file TransportHeader.h.
anonymous enum |
Constants for bit masking the marshaled flags byte. This needs to match the 'Flags' above.
Definition at line 63 of file TransportHeader.h.
00063 { BYTE_ORDER_FLAG, FIRST_FRAGMENT_FLAG, LAST_FRAGMENT_FLAG };
ACE_INLINE OpenDDS::DCPS::TransportHeader::TransportHeader | ( | ) |
Default constructor.
Definition at line 17 of file TransportHeader.inl.
References DBG_ENTRY_LVL, and DCPS_PROTOCOL.
00018 : byte_order_(ACE_CDR_BYTE_ORDER), 00019 first_fragment_(false), 00020 last_fragment_(false), 00021 reserved_(0), 00022 length_(0), 00023 sequence_(), 00024 source_(0) 00025 { 00026 DBG_ENTRY_LVL("TransportHeader","TransportHeader",6); 00027 00028 std::copy(&DCPS_PROTOCOL[0], &DCPS_PROTOCOL[6], this->protocol_); 00029 }
ACE_INLINE OpenDDS::DCPS::TransportHeader::TransportHeader | ( | ACE_Message_Block & | buffer | ) | [explicit] |
Construct with values extracted from a buffer.
Definition at line 37 of file TransportHeader.inl.
References DBG_ENTRY_LVL, and init().
00038 { 00039 DBG_ENTRY_LVL("TransportHeader","TransportHeader",6); 00040 this->init(&buffer); 00041 }
ACE_INLINE OpenDDS::DCPS::TransportHeader::TransportHeader | ( | const no_init_t & | ) | [explicit, private] |
bool OpenDDS::DCPS::TransportHeader::first_fragment | ( | ) | [inline] |
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 }
void OpenDDS::DCPS::TransportHeader::incomplete | ( | ACE_Message_Block & | ) | [inline] |
ACE_INLINE void OpenDDS::DCPS::TransportHeader::init | ( | ACE_Message_Block * | buffer | ) |
Demarshal transport packet from ACE_Message_Block.
Definition at line 88 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(), sequence_, source_, swap_bytes(), and OpenDDS::DCPS::Serializer::swap_bytes().
Referenced by operator=(), and TransportHeader().
00089 { 00090 DBG_ENTRY_LVL("TransportHeader","init",6); 00091 00092 Serializer reader(buffer); 00093 00094 reader.read_octet_array(this->protocol_, sizeof(this->protocol_)); 00095 00096 ACE_CDR::Octet flags; 00097 reader >> ACE_InputCDR::to_octet(flags); 00098 this->byte_order_= flags & (1 << BYTE_ORDER_FLAG); 00099 this->first_fragment_ = flags & (1 << FIRST_FRAGMENT_FLAG); 00100 this->last_fragment_ = flags & (1 << LAST_FRAGMENT_FLAG); 00101 00102 reader >> ACE_InputCDR::to_octet(this->reserved_); 00103 00104 reader.swap_bytes(swap_bytes()); 00105 00106 reader >> this->length_; 00107 00108 reader >> this->sequence_; 00109 00110 reader >> this->source_; 00111 }
void OpenDDS::DCPS::TransportHeader::last_fragment | ( | bool | frag | ) | [inline] |
bool OpenDDS::DCPS::TransportHeader::last_fragment | ( | ) | [inline] |
ACE_INLINE size_t OpenDDS::DCPS::TransportHeader::max_marshaled_size | ( | ) | [static] |
Similar to IDL compiler generated methods.
Definition at line 54 of file TransportHeader.inl.
References length_, no_init, protocol_, reserved_, sequence_, and source_.
Referenced by OpenDDS::DCPS::UdpDataLink::open().
00055 { 00056 // Representation takes no extra space for encoding. 00057 TransportHeader hdr(no_init); 00058 return sizeof(hdr.protocol_) + 00059 1 /*flags*/ + 00060 sizeof(hdr.reserved_) + 00061 sizeof(hdr.length_) + 00062 sizeof(hdr.sequence_) + 00063 sizeof(hdr.source_); 00064 }
ACE_INLINE TransportHeader & OpenDDS::DCPS::TransportHeader::operator= | ( | ACE_Message_Block & | buffer | ) |
Assignment from an ACE_Message_Block.
Definition at line 45 of file TransportHeader.inl.
References DBG_ENTRY_LVL, and init().
00046 { 00047 DBG_ENTRY_LVL("TransportHeader","operator=",6); 00048 this->init(&buffer); 00049 return *this; 00050 }
const SequenceNumber& OpenDDS::DCPS::TransportHeader::sequence | ( | ) | [inline] |
ACE_INLINE bool OpenDDS::DCPS::TransportHeader::swap_bytes | ( | ) | const |
Determine if the serializer should swap bytes.
Definition at line 68 of file TransportHeader.inl.
References byte_order_, and DBG_ENTRY_LVL.
Referenced by init(), and OpenDDS::DCPS::MulticastDataLink::sample_received().
00069 { 00070 DBG_ENTRY_LVL("TransportHeader","swap_bytes",6); 00071 00072 return this->byte_order_ != ACE_CDR_BYTE_ORDER; 00073 }
ACE_INLINE bool OpenDDS::DCPS::TransportHeader::valid | ( | ) | const |
Determine if this is a valid packet header.
Definition at line 77 of file TransportHeader.inl.
References DBG_ENTRY_LVL, and DCPS_PROTOCOL.
00078 { 00079 DBG_ENTRY_LVL("TransportHeader","valid",6); 00080 00081 // Currently we do not support compatibility with other 00082 // versions of the protocol: 00083 return std::equal(&DCPS_PROTOCOL[0], &DCPS_PROTOCOL[6], this->protocol_); 00084 }
Flags: marshaled as a single byte (ACE_CDR::Octet).
Definition at line 57 of file TransportHeader.h.
Referenced by init(), OpenDDS::DCPS::operator<<(), and swap_bytes().
const ACE_CDR::Octet OpenDDS::DCPS::TransportHeader::DCPS_PROTOCOL [static] |
Initial value:
{ 0x44, 0x43, 0x50, 0x53, 0x02, 0x00 }
Definition at line 34 of file TransportHeader.h.
Referenced by OpenDDS::DCPS::ShmemSendStrategy::send_bytes_i(), TransportHeader(), and valid().
Definition at line 58 of file TransportHeader.h.
Referenced by init(), OpenDDS::DCPS::operator<<(), and OpenDDS::DCPS::TransportSendStrategy::send().
Definition at line 59 of file TransportHeader.h.
Referenced by OpenDDS::DCPS::TransportSendStrategy::get_packet_elems_from_queue(), init(), OpenDDS::DCPS::operator<<(), and OpenDDS::DCPS::TransportSendStrategy::send().
ACE_UINT32 OpenDDS::DCPS::TransportHeader::length_ |
The size of the message following this header, not including the bytes used by this TransportHeader.
Definition at line 70 of file TransportHeader.h.
Referenced by OpenDDS::DCPS::TransportSendStrategy::adjust_packet_after_send(), OpenDDS::DCPS::TransportSendStrategy::clear(), OpenDDS::DCPS::TransportSendStrategy::do_remove_sample(), OpenDDS::DCPS::TransportSendStrategy::get_packet_elems_from_queue(), init(), max_marshaled_size(), OpenDDS::DCPS::UdpDataLink::open(), OpenDDS::DCPS::operator<<(), OpenDDS::DCPS::TransportSendStrategy::perform_work(), OpenDDS::DCPS::TransportSendStrategy::resume_send(), OpenDDS::DCPS::TransportSendStrategy::send(), OpenDDS::DCPS::TransportSendStrategy::send_stop(), and OpenDDS::DCPS::TransportSendStrategy::space_available().
const TransportHeader::no_init_t OpenDDS::DCPS::TransportHeader::no_init = {} [static, private] |
Definition at line 96 of file TransportHeader.h.
Referenced by get_length(), and max_marshaled_size().
ACE_CDR::Octet OpenDDS::DCPS::TransportHeader::protocol_[6] |
The protocol of the packet being transmitted.
Definition at line 54 of file TransportHeader.h.
Referenced by get_length(), max_marshaled_size(), and OpenDDS::DCPS::operator<<().
ACE_CDR::Octet OpenDDS::DCPS::TransportHeader::reserved_ |
Reserved for future use (provides padding for preamble).
Definition at line 66 of file TransportHeader.h.
Referenced by get_length(), max_marshaled_size(), and OpenDDS::DCPS::operator<<().
The sequence number of the packet identified by this header; this value is guaranteed to be a monotonically increasing number per transport instance.
Definition at line 75 of file TransportHeader.h.
Referenced by init(), max_marshaled_size(), OpenDDS::DCPS::operator<<(), and OpenDDS::DCPS::TransportSendStrategy::prepare_header().
ACE_INT64 OpenDDS::DCPS::TransportHeader::source_ |
A transport-specific identification number which uniquely identifies the source of the packet.
Definition at line 79 of file TransportHeader.h.
Referenced by init(), max_marshaled_size(), OpenDDS::DCPS::operator<<(), OpenDDS::DCPS::MulticastSendStrategy::prepare_header_i(), OpenDDS::DCPS::MulticastDataLink::ready_to_deliver(), and OpenDDS::DCPS::MulticastDataLink::sample_received().