TransportHeader.cpp

Go to the documentation of this file.
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 namespace OpenDDS {
00024 namespace DCPS {
00025 
00026 const TransportHeader::no_init_t TransportHeader::no_init = {};
00027 
00028 bool operator<<(ACE_Message_Block& buffer, const TransportHeader& value)
00029 {
00030   Serializer writer(&buffer);
00031 
00032   writer.write_octet_array(value.protocol_, sizeof(value.protocol_));
00033 
00034   const ACE_CDR::Octet flags =
00035     (value.byte_order_ << TransportHeader::BYTE_ORDER_FLAG) |
00036     (value.first_fragment_ << TransportHeader::FIRST_FRAGMENT_FLAG) |
00037     (value.last_fragment_ << TransportHeader::LAST_FRAGMENT_FLAG);
00038   writer << ACE_OutputCDR::from_octet(flags);
00039 
00040   writer << ACE_OutputCDR::from_octet(value.reserved_);
00041 
00042   writer << value.length_;
00043   writer << value.sequence_;
00044   writer << value.source_;
00045 
00046   return writer.good_bit();
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 }

Generated on Fri Feb 12 20:05:28 2016 for OpenDDS by  doxygen 1.4.7