add a field to Packet to track unicast reply destination
This commit is contained in:
parent
f92bed2a8a
commit
f49250a610
|
@ -50,16 +50,22 @@ Device::Device(Style style)
|
|||
/**
|
||||
* @brief Device::receive
|
||||
* @param buffer
|
||||
* @param origin
|
||||
*/
|
||||
void Device::receive(ACN::PDU::Stream buffer)
|
||||
void Device::receive(ACN::PDU::Stream buffer, ipAddress &origin)
|
||||
{
|
||||
if (origin.port != UDP_PORT || origin.type != 1) // ACN::SDT::SDT_ADDR_IPV4
|
||||
return buffer->setstate(std::ios_base::badbit);
|
||||
|
||||
auto packet = std::make_shared<Packet>();
|
||||
packet->iStream(buffer);
|
||||
if (buffer->fail() || buffer->bad())
|
||||
{
|
||||
_report_code = RcParseFail;
|
||||
_report_text = "unable to read packet";
|
||||
return;
|
||||
}
|
||||
packet->originAddress = origin.address.ipv4.value;
|
||||
receive(packet);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
const Style styleCode; //!< \cite ARTNET The Style code defines the equipment style of the device.
|
||||
|
||||
void receive(ACN::PDU::Stream);
|
||||
void receive(ACN::PDU::Stream, ipAddress&);
|
||||
void receive(std::shared_ptr<Packet>);
|
||||
|
||||
std::shared_ptr<void> setSender(const std::function<void(std::shared_ptr<bufferstream>,
|
||||
|
|
|
@ -534,31 +534,28 @@ struct rdmsub_data
|
|||
struct Packet
|
||||
: public streamable
|
||||
{
|
||||
/**
|
||||
* @brief Packet
|
||||
* @param opcode
|
||||
* @param data
|
||||
*/
|
||||
/// @brief Packet
|
||||
/// @param opcode
|
||||
/// @param data
|
||||
Packet(OpCode opcode = OpNull, std::shared_ptr<packet_data> data = nullptr)
|
||||
: _opcode(opcode)
|
||||
, _data(data)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief opcode
|
||||
* @return
|
||||
*/
|
||||
/// @brief opcode
|
||||
/// @return
|
||||
OpCode opcode() const { return _opcode; }
|
||||
|
||||
/**
|
||||
* @brief data
|
||||
* @return
|
||||
*/
|
||||
/// @brief IP address where unicast replies will be sent.
|
||||
uint32_t originAddress;
|
||||
|
||||
/// @brief data
|
||||
/// @return
|
||||
template<class T>
|
||||
auto data() const
|
||||
{
|
||||
static_assert(std::is_base_of<packet_data, T>::value,
|
||||
"type parameter of data must derive from ARTNET::packet_data");
|
||||
"type must inherit ARTNET::packet_data");
|
||||
return _data ? std::optional<std::shared_ptr<T>>{std::static_pointer_cast<T>(_data)}
|
||||
: std::nullopt;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue