use uniform EPI 17 implimentation

This commit is contained in:
Kevin Matz 2021-02-03 13:49:53 -05:00
parent 9d1421b86b
commit 149f5b809d
4 changed files with 9 additions and 52 deletions

View File

@ -45,9 +45,17 @@ Appliance::Appliance(UUID::uuid cid)
void Appliance::UdpStreamHandler(PDU::Stream stream) {
// verify the UDP preamble
RLP::UDP::preamble_t preamble(stream);
// Implementations shall check the ACN Packet Identifier and preamble size.
if (!preamble)
stream->setstate(stream->rdstate() | std::ios_base::failbit);
// implementations shall compute the size and position of the PDU block from
// the preamble size and postamble size provided. ... ignoring any extra
// octets in the preamble or postamble.
for(int i = RLP::UDP::PREAMBLE_MINIMUM_SIZE; i < preamble.length; i++)
stream->read8();
if (!stream->good())
return;
auto block = PDU::readBlock<RLP::Pdu>(stream);

View File

@ -64,7 +64,7 @@ void EspReceiver::UdpStreamHandler(AsyncUDPPacket udp_packet) {
// wrap a PDU io stream around the AsyncUDPPacket data buffer
PDU::Stream stream(new PDU::pdu_stream(udp_packet.data(),
udp_packet.available()));
Receiver::UdpStreamHandler(stream);
Appliance::UdpStreamHandler(stream);
}
} // SACN

View File

@ -57,54 +57,6 @@ SACN::Universe * Receiver::universe(uint16_t universe) {
}
/**
Parse the received UDP data, overrideing base class implimentation of EPI17.
Layer 4 only. Verificiton of layer 3 (UDP port) must be handled prior to calling.
@param packet is a shared pointer to the UDP data buffer.
*/
void Receiver::UdpStreamHandler(PDU::Stream stream) {
// verify the UDP preamble
RLP::UDP::preamble_t preamble(stream);
// 5.1 Preamble Size
// Sources shall set the Preamble Size to 0x0010. Receivers of UDP-based
// E1.31 shall discard the packet if the Preamble Size is not 0x0010.
if (preamble.length != 0x0010)
stream->setstate(stream->rdstate() | std::ios_base::failbit);
// 5.2 Post-amble Size
// Receivers of UDP based E1.31 shall discard the packet if the
// Post-amble Size is not 0x0000.
if (preamble.postamble_size != 0x0000)
stream->setstate(stream->rdstate() | std::ios_base::failbit);
// 5.3 ACN Packet Identifier
// Receivers shall discard the packet if the ACN Packet Identifier is
// not valid.
if (!preamble)
stream->setstate(stream->rdstate() | std::ios_base::failbit);
if (!stream->good())
return;
auto block = PDU::readBlock<RLP::Pdu>(stream);
if (stream->fail())
return;
for(auto root : *block) {
// 5.5 Vector
// Receivers shall discard the packet if the received value is not
// VECTOR_ROOT_E131_DATA or VECTOR_ROOT_E131_EXTENDED.
if (root->vector() != VECTOR_ROOT_E131_DATA &&
root->vector() != VECTOR_ROOT_E131_EXTENDED)
return;
RlpReceiver(root);
}
}
/**
Receive VECTOR_ROOT_E131_DATA vector'd packets.

View File

@ -40,9 +40,6 @@ public:
SACN::Universe * universe(uint16_t universe);
protected:
// override base class implimentation of EPI 17
virtual void UdpStreamHandler(PDU::Stream);
// process data frames
void rootDataHandler(std::shared_ptr<RLP::Pdu>);
void dataPacketHandler(std::shared_ptr<DATA::Pdu>);