RtpsTransportHeader.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 "RtpsTransportHeader.h"
00009 
00010 #include "dds/DCPS/Serializer.h"
00011 #include "dds/DCPS/RTPS/BaseMessageTypes.h"
00012 #include "dds/DCPS/RTPS/RtpsCoreTypeSupportImpl.h"
00013 
00014 #ifndef __ACE_INLINE__
00015 #include "RtpsTransportHeader.inl"
00016 #endif
00017 
00018 namespace {
00019   const ACE_CDR::Octet PROTOCOL_RTPS[] = {'R', 'T', 'P', 'S'};
00020   const OpenDDS::DCPS::SequenceNumber dummy;
00021 }
00022 
00023 namespace OpenDDS {
00024 namespace DCPS {
00025 
00026 void
00027 RtpsTransportHeader::init(ACE_Message_Block& mb)
00028 {
00029   // Byte order doesn't matter for RTPS::Header, since it's
00030   // exclusively structs/arrays of octet.
00031   Serializer ser(&mb, false, Serializer::ALIGN_CDR);
00032   valid_ = (ser >> header_);
00033 
00034   if (valid_) {
00035 
00036     // length_ started as the total number of bytes in the datagram's payload.
00037     // When we return to the TransportReceiveStrategy it must be the number
00038     // of bytes remaining after processing this RTPS::Header.
00039     length_ -= max_marshaled_size();
00040 
00041     // RTPS spec v2.1 section 8.3.6.3
00042     valid_ = std::equal(header_.prefix, header_.prefix + sizeof(header_.prefix),
00043                         PROTOCOL_RTPS);
00044     valid_ &= (header_.version.major == OpenDDS::RTPS::PROTOCOLVERSION.major);
00045   }
00046 }
00047 
00048 const SequenceNumber&
00049 RtpsTransportHeader::sequence()
00050 {
00051   return dummy;
00052 }
00053 
00054 }
00055 }

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