RtpsSampleHeader.h

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 #ifndef DCPS_RTPSSAMPLEHEADER_H
00009 #define DCPS_RTPSSAMPLEHEADER_H
00010 
00011 #include "Rtps_Udp_Export.h"
00012 
00013 #include "ace/Basic_Types.h"
00014 #include "dds/DCPS/RTPS/RtpsCoreC.h"
00015 #include "dds/DCPS/transport/framework/TransportSendControlElement.h"
00016 #include "dds/DCPS/transport/framework/TransportSendListener.h"
00017 
00018 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00019 class ACE_Message_Block;
00020 ACE_END_VERSIONED_NAMESPACE_DECL
00021 
00022 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00023 
00024 namespace OpenDDS {
00025 namespace DCPS {
00026 
00027 class ReceivedDataSample;
00028 class DataSampleElement;
00029 class DisjointSequence;
00030 
00031 /// Adapt the TransportReceiveStrategy for RTPS's "sample" (submessage) Header
00032 class OpenDDS_Rtps_Udp_Export RtpsSampleHeader {
00033 public:
00034 
00035   // This is not really the max_marshaled_size, but it's used for determining
00036   // how much of the submessage to show in debugging hexdumps.  Since we don't
00037   // know which kind of submessage we have, we can only count on the 4-byte
00038   // SubmessageHeader being present.
00039   static size_t max_marshaled_size() { return 4; }
00040 
00041   // We never have partial "sample" headers since this is UDP.
00042   // (The header could fail to parse in init(), but unlike the TCP case we
00043   // never want to go back to the reactor and wait for more bytes to arrive.)
00044   static bool partial(const ACE_Message_Block&) { return false; }
00045 
00046   /// Create two new serialized headers (owned by caller), the "head" having at
00047   /// most "size" bytes (header + data) and the "tail" having the rest.
00048   /// Returns a pair containing the largest fragment number in each new header.
00049   static SequenceRange split(const ACE_Message_Block& orig, size_t size,
00050                              Message_Block_Ptr& head,
00051                              Message_Block_Ptr& tail);
00052 
00053   RtpsSampleHeader();
00054   explicit RtpsSampleHeader(ACE_Message_Block& mb);
00055   RtpsSampleHeader& operator=(ACE_Message_Block& mn);
00056 
00057   void pdu_remaining(size_t size);
00058   size_t marshaled_size();
00059   ACE_UINT32 message_length();
00060 
00061   bool valid() const;
00062 
00063   bool into_received_data_sample(ReceivedDataSample& rds);
00064 
00065   static bool payload_byte_order(const ReceivedDataSample& rds);
00066 
00067   bool more_fragments() const;
00068 
00069   RTPS::Submessage submessage_;
00070 
00071 private:
00072   void init(ACE_Message_Block& mb);
00073 
00074   bool valid_, frag_;
00075   size_t marshaled_size_, message_length_;
00076 
00077 public:
00078   // Unlike the rest of this class, which is used with the
00079   // TransportReceiveStrategy, these functions do the inverse of
00080   // into_received_data_sample() so they are used on the sending side:
00081   // translating from an OpenDDS data structure to the RTPS format.
00082   static void populate_data_sample_submessages(RTPS::SubmessageSeq& subm,
00083                                                const DataSampleElement& dsle,
00084                                                bool requires_inline_qos);
00085   static void populate_data_control_submessages(RTPS::SubmessageSeq& subm,
00086                                                 const TransportSendControlElement& tsce,
00087                                                 bool requires_inline_qos);
00088   static void populate_inline_qos(const TransportSendListener::InlineQosData& qos_data,
00089                                   RTPS::ParameterList& plist);
00090   static bool control_message_supported(char message_id);
00091 
00092   // All of the fragments we generate will use the FRAG_SIZE of 1024, which may
00093   // be the smallest allowed by the spec (8.4.14.1.1).  There is no practical
00094   // advantage to increasing this constant, since any number of 1024-byte
00095   // fragments may appear in a single DATA_FRAG submessage.  The spec is
00096   // ambiguous in its use of KB to mean either 1000 or 1024, and uses < instead
00097   // of <= (see issue 16966).
00098   static const ACE_CDR::UShort FRAG_SIZE = 1024;
00099 
00100 private:
00101   static void process_iqos(DataSampleHeader& opendds,
00102                            const OpenDDS::RTPS::ParameterList& iqos);
00103 };
00104 
00105 }
00106 }
00107 
00108 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00109 
00110 #ifdef __ACE_INLINE__
00111 #include "RtpsSampleHeader.inl"
00112 #endif
00113 
00114 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1