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 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00024 00025 namespace OpenDDS { 00026 namespace DCPS { 00027 00028 void 00029 RtpsTransportHeader::init(ACE_Message_Block& mb) 00030 { 00031 // Byte order doesn't matter for RTPS::Header, since it's 00032 // exclusively structs/arrays of octet. 00033 Serializer ser(&mb, false, Serializer::ALIGN_CDR); 00034 valid_ = (ser >> header_); 00035 00036 if (valid_) { 00037 00038 // length_ started as the total number of bytes in the datagram's payload. 00039 // When we return to the TransportReceiveStrategy it must be the number 00040 // of bytes remaining after processing this RTPS::Header. 00041 length_ -= max_marshaled_size(); 00042 00043 // RTPS spec v2.1 section 8.3.6.3 00044 valid_ = std::equal(header_.prefix, header_.prefix + sizeof(header_.prefix), 00045 PROTOCOL_RTPS); 00046 valid_ &= (header_.version.major == OpenDDS::RTPS::PROTOCOLVERSION.major); 00047 } 00048 } 00049 00050 const SequenceNumber& 00051 RtpsTransportHeader::sequence() 00052 { 00053 return dummy; 00054 } 00055 00056 } 00057 } 00058 00059 OPENDDS_END_VERSIONED_NAMESPACE_DECL