additional standard enforcement

This commit is contained in:
Kevin Matz 2021-01-08 14:01:24 -05:00
parent b9977c7f9d
commit f1fe989d9a
1 changed files with 63 additions and 7 deletions

View File

@ -54,14 +54,27 @@ Layer 4 only. Verificiton of layer 3 (UDP port) must be handled prior to callin
void Receiver::packetHandler(PDU::stream_ptr packet) {
// verify the UDP preamble
RLP::UDP::preamble_t preamble(packet);
// 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)
packet->setstate(packet->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)
packet->setstate(packet->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)
packet->setstate(packet->rdstate() | std::ios_base::failbit);
if (!packet->good()) return;
// Preamble length has a standard min, but no max. Discard any extra.
int extra = preamble.length - RLP::UDP::PREAMBLE_MINIMUM_SIZE;
for (int i = 0; i < extra; i++)
packet->read8();
if (!packet->good())
return;
auto block = PDU::readBlock<RLP::Pdu>(packet);
if (packet->fail())
@ -126,7 +139,18 @@ void Receiver::dataPacketHandler(DATA::pdu_ptr frame) {
return;
Universe * universe = universes_.at(header->universe);
// TODO: do something with merging/priorty
// 6.2.3 E1.31 Data Packet: Priority
// No priority outside the range of 0 to 200 shall be transmitted on
// the network.
if (header->priority > 200)
frame->buffer()->setstate(frame->buffer()->rdstate() |
std::ios_base::failbit);
// 6.2.6 E1.31 Data Packet: Options
// Preview_Data: Bit 7 (most significant bit)
// This bit, when set to 1, indicates that the data in this packet is intended for use in visualization or media server preview applications and shall not be used to generate live output.
if (header->options & DATA::PREVIEW_DATA)
return;
// 6.2.6 E1.31 Data Packet: Options
@ -140,7 +164,39 @@ void Receiver::dataPacketHandler(DATA::pdu_ptr frame) {
return;
}
// PDU data will be a block of one DMP PDU
// 6.2.6 E1.31 Data Packet: Options
// Force_Synchronization: Bit 5
// This bit indicates whether to lock or revert to an unsynchronized state
// when synchronization is lost. When set to 0, components that had been
// operating in a synchronized state shall not update with any new packets
// until synchronization resumes. When set to 1, once synchronization has
// been lost, components that had been operating in a synchronized state need
// not wait for a new E1.31 Synchronization Packet in order to update to the
// next E1.31 Data Packet.
if (!(header->options & DATA::FORCE_SYNCHRONIZATION) &&
universe->isSyncronized()) {
return; // operate in synchronized state?
}
// 6.2.4.1 Synchronization Address Usage in an E1.31 Data Packet
// a value of 0 in the Synchronization Address indicates that the universe
// data is not synchronized.
if (header->sync_address != 0) {
// TODO: do somthing to engage synchronization
}
// If a receiver is presented with an E1.31 Data Packet containing a Synchronization Address of 0, it shall discard any data waiting to be processed and immediately act on that Data Packet.
if (header->sync_address == 0 && universe->isSyncronized()) {
// TODO:: do something to break synchronization
}
// 6.2.3.1 Multiple Sources at Highest Priority
// It is possible for there to be multiple sources, all transmitting data at
// the highest currently active priority for a given universe. When this
// occurs, receivers must handle these sources in some way.
// TODO: do something with merging and arbitration
// PDU data will be a block of DMP
auto block = PDU::readBlock<DMP::Pdu>(frame->buffer());
if (frame->buffer()->fail())
return;