00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/ 00009 #include "TransportHeader.h" 00010 #include "dds/DCPS/Serializer.h" 00011 #include "EntryExit.h" 00012 00013 const ACE_CDR::Octet 00014 OpenDDS::DCPS::TransportHeader::DCPS_PROTOCOL[] = 00015 { 0x44, 0x43, 0x50, 0x53, 0x02, 0x00 }; 00016 // D C P S | |__ minor version 00017 // |________ major version 00018 00019 #if !defined (__ACE_INLINE__) 00020 # include "TransportHeader.inl" 00021 #endif /* !__ACE_INLINE__ */ 00022 00023 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00024 00025 namespace OpenDDS { 00026 namespace DCPS { 00027 00028 const TransportHeader::no_init_t TransportHeader::no_init = {}; 00029 00030 bool operator<<(ACE_Message_Block& buffer, const TransportHeader& value) 00031 { 00032 Serializer writer(&buffer); 00033 00034 if (!writer.write_octet_array(value.protocol_, sizeof(value.protocol_))) 00035 return false; 00036 00037 const ACE_CDR::Octet flags = 00038 (value.byte_order_ << TransportHeader::BYTE_ORDER_FLAG) | 00039 (value.first_fragment_ << TransportHeader::FIRST_FRAGMENT_FLAG) | 00040 (value.last_fragment_ << TransportHeader::LAST_FRAGMENT_FLAG); 00041 00042 return (writer << ACE_OutputCDR::from_octet(flags)) && 00043 (writer << ACE_OutputCDR::from_octet(value.reserved_)) && 00044 (writer << value.length_) && 00045 (writer << value.sequence_) && 00046 (writer << value.source_); 00047 } 00048 00049 /*static*/ 00050 ACE_UINT32 00051 TransportHeader::get_length(const char* marshaled_header) 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 } 00059 00060 } 00061 } 00062 00063 OPENDDS_END_VERSIONED_NAMESPACE_DECL