RtpsUdpSendStrategy.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef DCPS_RTPSUDPSENDSTRATEGY_H
00009 #define DCPS_RTPSUDPSENDSTRATEGY_H
00010
00011 #include "Rtps_Udp_Export.h"
00012
00013 #if defined(OPENDDS_SECURITY)
00014 #include "dds/DdsSecurityCoreC.h"
00015 #endif
00016
00017 #include "dds/DCPS/transport/framework/TransportSendStrategy.h"
00018
00019 #include "dds/DCPS/RTPS/MessageTypes.h"
00020
00021 #include "ace/INET_Addr.h"
00022
00023 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00024
00025 namespace OpenDDS {
00026 namespace DCPS {
00027
00028 class RtpsUdpDataLink;
00029 class RtpsUdpInst;
00030 typedef RcHandle<RtpsUdpDataLink> RtpsUdpDataLink_rch;
00031
00032 class OpenDDS_Rtps_Udp_Export RtpsUdpSendStrategy
00033 : public TransportSendStrategy {
00034 public:
00035 RtpsUdpSendStrategy(RtpsUdpDataLink* link,
00036 const GuidPrefix_t& local_prefix);
00037
00038 virtual void stop_i();
00039
00040 struct OverrideToken {
00041 explicit OverrideToken(RtpsUdpSendStrategy* outer) : outer_(outer) {}
00042 ~OverrideToken();
00043 RtpsUdpSendStrategy* outer_;
00044 };
00045 friend struct OverrideToken;
00046
00047 OverrideToken override_destinations(const ACE_INET_Addr& destination);
00048 OverrideToken override_destinations(
00049 const OPENDDS_SET(ACE_INET_Addr)& destinations);
00050
00051 void send_rtps_control(ACE_Message_Block& submessages,
00052 const ACE_INET_Addr& destination);
00053 void send_rtps_control(ACE_Message_Block& submessages,
00054 const OPENDDS_SET(ACE_INET_Addr)& destinations);
00055
00056 #if defined(OPENDDS_SECURITY)
00057 void encode_payload(const RepoId& pub_id, Message_Block_Ptr& payload,
00058 RTPS::SubmessageSeq& submessages);
00059 #endif
00060
00061 protected:
00062 virtual ssize_t send_bytes_i(const iovec iov[], int n);
00063 ssize_t send_bytes_i_helper(const iovec iov[], int n);
00064
00065 virtual size_t max_message_size() const
00066 {
00067 return UDP_MAX_MESSAGE_SIZE;
00068 }
00069 virtual void add_delayed_notification(TransportQueueElement* element);
00070 virtual RemoveResult do_remove_sample(const RepoId& pub_id,
00071 const TransportQueueElement::MatchCriteria& criteria,
00072 void* context);
00073
00074 private:
00075 bool marshal_transport_header(ACE_Message_Block* mb);
00076 ssize_t send_multi_i(const iovec iov[], int n,
00077 const OPENDDS_SET(ACE_INET_Addr)& addrs);
00078 ssize_t send_single_i(const iovec iov[], int n,
00079 const ACE_INET_Addr& addr);
00080
00081 #if defined(OPENDDS_SECURITY)
00082 ACE_Message_Block* pre_send_packet(const ACE_Message_Block* plain);
00083
00084 struct Chunk {
00085 char* start_;
00086 unsigned int length_;
00087 DDS::OctetSeq encoded_;
00088 };
00089
00090 bool encode_writer_submessage(const RepoId& receiver,
00091 OPENDDS_VECTOR(Chunk)& replacements,
00092 DDS::Security::CryptoTransform* crypto,
00093 const DDS::OctetSeq& plain,
00094 DDS::Security::DatawriterCryptoHandle sender_dwch,
00095 char* submessage_start, CORBA::Octet msgId);
00096
00097 bool encode_reader_submessage(const RepoId& receiver,
00098 OPENDDS_VECTOR(Chunk)& replacements,
00099 DDS::Security::CryptoTransform* crypto,
00100 const DDS::OctetSeq& plain,
00101 DDS::Security::DatareaderCryptoHandle sender_drch,
00102 char* submessage_start, CORBA::Octet msgId);
00103
00104 ACE_Message_Block* replace_chunks(const ACE_Message_Block* plain,
00105 const OPENDDS_VECTOR(Chunk)& replacements);
00106 #endif
00107
00108 RtpsUdpDataLink* link_;
00109 const OPENDDS_SET(ACE_INET_Addr)* override_dest_;
00110 const ACE_INET_Addr* override_single_dest_;
00111
00112 RTPS::Header rtps_header_;
00113 char rtps_header_data_[RTPS::RTPSHDR_SZ];
00114 ACE_Data_Block rtps_header_db_;
00115 ACE_Message_Block rtps_header_mb_;
00116 };
00117
00118 }
00119 }
00120
00121 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00122
00123 #endif