rlp writing
This commit is contained in:
parent
d9e42f5c2f
commit
7495897b4a
|
@ -56,6 +56,21 @@ void Component::UdpPayloadReceiver(PDU::Stream stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Component::rlpSendUdp
|
||||||
|
* @param vector
|
||||||
|
* @param data
|
||||||
|
* @param ip
|
||||||
|
*/
|
||||||
|
void Component::rlpSendUdp (const uint32_t vector,
|
||||||
|
const PDU::Message< PDU::pdu_data > data,
|
||||||
|
const SDT::UDP::ipAddress& ip) const
|
||||||
|
{
|
||||||
|
RLP::UDP::transport transport(true);
|
||||||
|
rlpSend(transport, vector, data, ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Component::TcpPacketReceiver
|
* @brief Component::TcpPacketReceiver
|
||||||
* @param stream
|
* @param stream
|
||||||
|
@ -73,6 +88,21 @@ void Component::TcpPacketReceiver(PDU::Stream stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Component::rlpSendTcp
|
||||||
|
* @param vector
|
||||||
|
* @param data
|
||||||
|
* @param ip
|
||||||
|
*/
|
||||||
|
void Component::rlpSendTcp (const uint32_t vector,
|
||||||
|
const PDU::Message<PDU::pdu_data> data,
|
||||||
|
const SDT::UDP::ipAddress& ip) const
|
||||||
|
{
|
||||||
|
RLP::TCP::transport transport(true);
|
||||||
|
rlpSend(transport, vector, data, ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Component::RlpReceiver
|
* @brief Component::RlpReceiver
|
||||||
* @param root
|
* @param root
|
||||||
|
@ -104,4 +134,59 @@ void Component::RlpRegisterVector(uint32_t vect, PDU::Handler<RLP::Pdu> handle)
|
||||||
rlp_vectors_[vect].push_back(handle);
|
rlp_vectors_[vect].push_back(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Component::rlpSend
|
||||||
|
* @param transport
|
||||||
|
* @param vector
|
||||||
|
* @param data
|
||||||
|
* @param ip
|
||||||
|
*/
|
||||||
|
void Component::rlpSend(ACN::RLP::message_transport& transport,
|
||||||
|
const uint32_t vector,
|
||||||
|
const PDU::Message<PDU::pdu_data> data,
|
||||||
|
const SDT::UDP::ipAddress& ip) const
|
||||||
|
{
|
||||||
|
// rlp header
|
||||||
|
RLP::rlp_header header;
|
||||||
|
header.cid = cid();
|
||||||
|
|
||||||
|
// rlp pdu
|
||||||
|
auto rlp = std::shared_ptr<RLP::Pdu>(new RLP::Pdu());
|
||||||
|
rlp->setVector(vector);
|
||||||
|
rlp->setHeader(&header);
|
||||||
|
rlp->setData(data.get());
|
||||||
|
|
||||||
|
// root block
|
||||||
|
PDU::Block<RLP::Pdu> block;
|
||||||
|
block.pdu->push_back(rlp);
|
||||||
|
transport.root = block;
|
||||||
|
|
||||||
|
// create an output stream
|
||||||
|
size_t length = transport.streamSize();
|
||||||
|
uint8_t buffer[length];
|
||||||
|
ACN::PDU::Stream stream(new ACN::PDU::pdu_stream(buffer, length));
|
||||||
|
|
||||||
|
// write message
|
||||||
|
*stream << transport;
|
||||||
|
rlpSend(stream, ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Component::rlpSend
|
||||||
|
* @param stream
|
||||||
|
* @param ip
|
||||||
|
*
|
||||||
|
* \attention Override this method in your derived class that can write
|
||||||
|
* to the network.
|
||||||
|
*/
|
||||||
|
void Component::rlpSend(const PDU::Stream stream,
|
||||||
|
const SDT::UDP::ipAddress& ip) const
|
||||||
|
{
|
||||||
|
(void)stream;
|
||||||
|
(void)ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // ACN::RLP
|
}; // ACN::RLP
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "acn/component.h"
|
#include "acn/component.h"
|
||||||
#include "acn/pdu.h"
|
#include "acn/pdu.h"
|
||||||
#include "rlp.h"
|
#include "rlp.h"
|
||||||
|
#include "sdt/udp.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -49,14 +50,24 @@ public:
|
||||||
|
|
||||||
// EPI 17 - ACN RLP on UDP
|
// EPI 17 - ACN RLP on UDP
|
||||||
virtual void UdpPayloadReceiver(PDU::Stream);
|
virtual void UdpPayloadReceiver(PDU::Stream);
|
||||||
|
void rlpSendUdp(const uint32_t vector, const PDU::Message<PDU::pdu_data> data,
|
||||||
|
const SDT::UDP::ipAddress&) const;
|
||||||
|
|
||||||
// EPI 33 - ACN RLP Operation on TCP
|
// EPI 33 - ACN RLP Operation on TCP
|
||||||
virtual void TcpPacketReceiver(PDU::Stream);
|
virtual void TcpPacketReceiver(PDU::Stream);
|
||||||
|
void rlpSendTcp(const uint32_t vector, const PDU::Message<PDU::pdu_data> data,
|
||||||
|
const SDT::UDP::ipAddress&) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void RlpReceiver(PDU::Message<RLP::Pdu>);
|
void RlpReceiver(PDU::Message<RLP::Pdu>);
|
||||||
void RlpRegisterVector(uint32_t, PDU::Handler<RLP::Pdu>);
|
void RlpRegisterVector(uint32_t, PDU::Handler<RLP::Pdu>);
|
||||||
|
|
||||||
|
void rlpSend(ACN::RLP::message_transport&, const uint32_t vector,
|
||||||
|
const PDU::Message<PDU::pdu_data> data,
|
||||||
|
const SDT::UDP::ipAddress&) const;
|
||||||
|
|
||||||
|
virtual void rlpSend(const PDU::Stream, const SDT::UDP::ipAddress&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<uint32_t, std::vector<PDU::Handler<RLP::Pdu>>> rlp_vectors_;
|
std::map<uint32_t, std::vector<PDU::Handler<RLP::Pdu>>> rlp_vectors_;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue