Line data Source code
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 14 : OpenDDS::DCPS::TransportHeader::DCPS_PROTOCOL[] = 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 : 23 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 24 : 25 : namespace OpenDDS { 26 : namespace DCPS { 27 : 28 0 : bool operator<<(ACE_Message_Block& buffer, const TransportHeader& value) 29 : { 30 0 : Serializer writer(&buffer, Encoding::KIND_UNALIGNED_CDR); 31 : 32 0 : if (!writer.write_octet_array(value.protocol_, sizeof(value.protocol_))) 33 0 : return false; 34 : 35 0 : const ACE_CDR::Octet flags = 36 0 : (value.byte_order_ << TransportHeader::BYTE_ORDER_FLAG) | 37 0 : (value.first_fragment_ << TransportHeader::FIRST_FRAGMENT_FLAG) | 38 0 : (value.last_fragment_ << TransportHeader::LAST_FRAGMENT_FLAG); 39 : 40 0 : return (writer << ACE_OutputCDR::from_octet(flags)) && 41 0 : (writer << ACE_OutputCDR::from_octet(value.reserved_)) && 42 0 : (writer << value.length_) && 43 0 : (writer << value.sequence_) && 44 0 : (writer << value.source_); 45 0 : } 46 : 47 : /*static*/ 48 : ACE_UINT32 49 0 : TransportHeader::get_length(const char* marshaled_header) 50 : { 51 0 : const TransportHeader* hdr = 0; 52 : static const unsigned int OFFSET = sizeof(hdr->protocol_) + 53 : 1 /*flags*/ + 54 : sizeof(hdr->reserved_); 55 0 : return *reinterpret_cast<const ACE_UINT32*>(marshaled_header + OFFSET); 56 : } 57 : 58 : } 59 : } 60 : 61 : OPENDDS_END_VERSIONED_NAMESPACE_DECL