PDU::Block will only ever contain valid PDU
This commit is contained in:
parent
52d57c282c
commit
c033be5b6e
|
@ -61,9 +61,6 @@ void Appliance::UdpPayloadReceiver(PDU::Stream stream)
|
|||
auto transport = RLP::UDP::transport();
|
||||
transport.iStream(stream);
|
||||
|
||||
if (stream->fail())
|
||||
return;
|
||||
|
||||
for(auto const &root : *transport.root.pdu) {
|
||||
RlpReceiver(root);
|
||||
}
|
||||
|
@ -81,9 +78,6 @@ void Appliance::TcpPacketReceiver(PDU::Stream stream)
|
|||
auto transport = RLP::TCP::transport();
|
||||
transport.iStream(stream);
|
||||
|
||||
if (stream->fail())
|
||||
return;
|
||||
|
||||
for(auto const &root : *transport.root.pdu) {
|
||||
RlpReceiver(root);
|
||||
}
|
||||
|
@ -155,8 +149,21 @@ void Appliance::SdtReceiver(__attribute__((unused)) std::shared_ptr<RLP::Pdu> rl
|
|||
* @brief Appliance::DmpReceiver
|
||||
* @param rlp
|
||||
*/
|
||||
void Appliance::DmpReceiver(__attribute__((unused)) std::shared_ptr<RLP::Pdu> rlp)
|
||||
void Appliance::DmpReceiver(std::shared_ptr<RLP::Pdu> root)
|
||||
{
|
||||
auto block = PDU::Block<DMP::Pdu>();
|
||||
block.iStream(root->stream());
|
||||
if (root->stream()->fail())
|
||||
return;
|
||||
block.setParent(std::shared_ptr<RLP::Pdu>(root));
|
||||
root->setData(&block);
|
||||
|
||||
for(auto const &dmp : *block.pdu) {
|
||||
switch(dmp->vector()) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// TODO: DMP in root
|
||||
}
|
||||
|
||||
|
|
|
@ -122,11 +122,8 @@ void Receiver::onDiscovered(const EXTENDED::DISCOVERY::Watcher cb) {
|
|||
*
|
||||
* Receive VECTOR_ROOT_E131_DATA vector'd packets.
|
||||
*/
|
||||
void Receiver::dataReceiver(std::shared_ptr<RLP::Pdu> root) {
|
||||
// check that PDU is valid
|
||||
if (root->stream()->fail())
|
||||
return;
|
||||
|
||||
void Receiver::dataReceiver(std::shared_ptr<RLP::Pdu> root)
|
||||
{
|
||||
auto block = PDU::Block<DATA::Pdu>();
|
||||
block.iStream(root->stream());
|
||||
if (root->stream()->fail())
|
||||
|
@ -134,19 +131,20 @@ void Receiver::dataReceiver(std::shared_ptr<RLP::Pdu> root) {
|
|||
block.setParent(std::shared_ptr<ACN::PDU::Pdu>(root));
|
||||
root->setData(&block);
|
||||
|
||||
for(auto const &frame : *block.pdu) {
|
||||
// 6.2.1 E1.31 Data Packet: Vector
|
||||
// Sources sending an E1.31 Data Packet shall set the E1.31 Layer's Vector
|
||||
// to VECTOR_E131_DATA_PACKET. This value indicates that the E1.31 framing
|
||||
// layer is wrapping a DMP PDU.
|
||||
switch(frame->vector()) {
|
||||
case VECTOR_E131_DATA_PACKET:
|
||||
dataFrameHandler(frame);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
for(auto const &frame : *block.pdu)
|
||||
{
|
||||
// 6.2.1 E1.31 Data Packet: Vector
|
||||
// Sources sending an E1.31 Data Packet shall set the E1.31 Layer's Vector
|
||||
// to VECTOR_E131_DATA_PACKET. This value indicates that the E1.31 framing
|
||||
// layer is wrapping a DMP PDU.
|
||||
switch(frame->vector()) {
|
||||
case VECTOR_E131_DATA_PACKET:
|
||||
dataFrameHandler(frame);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,11 +154,8 @@ void Receiver::dataReceiver(std::shared_ptr<RLP::Pdu> root) {
|
|||
*
|
||||
* Receive VECTOR_ROOT_E131_EXTENDED vector'd packets.
|
||||
*/
|
||||
void Receiver::extendedReceiver(std::shared_ptr<RLP::Pdu> root) {
|
||||
// check that PDU is valid
|
||||
if (root->stream()->fail())
|
||||
return;
|
||||
|
||||
void Receiver::extendedReceiver(std::shared_ptr<RLP::Pdu> root)
|
||||
{
|
||||
auto block = PDU::Block<EXTENDED::Pdu>();
|
||||
block.iStream(root->stream());
|
||||
if (root->stream()->fail())
|
||||
|
@ -168,7 +163,8 @@ void Receiver::extendedReceiver(std::shared_ptr<RLP::Pdu> root) {
|
|||
block.setParent(std::shared_ptr<ACN::PDU::Pdu>(root));
|
||||
root->setData(&block);
|
||||
|
||||
for(auto const &frame : *block.pdu) {
|
||||
for(auto const &frame : *block.pdu)
|
||||
{
|
||||
switch(frame->vector()) {
|
||||
// 6.3 E1.31 Synchronization Packet Framing Layer
|
||||
case VECTOR_E131_EXTENDED_SYNCHRONIZATION:
|
||||
|
@ -196,10 +192,6 @@ void Receiver::extendedReceiver(std::shared_ptr<RLP::Pdu> root) {
|
|||
*
|
||||
*/
|
||||
void Receiver::dataFrameHandler(std::shared_ptr<DATA::Pdu> frame) {
|
||||
// check that PDU is valid
|
||||
if (frame->stream()->fail())
|
||||
return;
|
||||
|
||||
auto source = std::shared_ptr<UniverseSource>(new UniverseSource(frame));
|
||||
|
||||
if (!universes_.count(source->universe()))
|
||||
|
@ -239,19 +231,20 @@ void Receiver::dataFrameHandler(std::shared_ptr<DATA::Pdu> frame) {
|
|||
|
||||
// PDU data will be a block of DMP
|
||||
auto block = static_cast<PDU::Block<DMP::Pdu>*>(frame->data());
|
||||
for (auto const &dmp : *block->pdu) {
|
||||
// 7.2 DMP Layer: Vector
|
||||
// The DMP Layer's Vector shall be set to VECTOR_DMP_SET_PROPERTY, which
|
||||
// indicates a DMP Set Property message by sources. Receivers shall discard
|
||||
// the packet if the received value is not VECTOR_DMP_SET_PROPERTY.
|
||||
switch(dmp->vector()) {
|
||||
case DMP::SET_PROPERTY:
|
||||
universe->set(dmp, source);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
for (auto const &dmp : *block->pdu)
|
||||
{
|
||||
// 7.2 DMP Layer: Vector
|
||||
// The DMP Layer's Vector shall be set to VECTOR_DMP_SET_PROPERTY, which
|
||||
// indicates a DMP Set Property message by sources. Receivers shall discard
|
||||
// the packet if the received value is not VECTOR_DMP_SET_PROPERTY.
|
||||
switch(dmp->vector()) {
|
||||
case DMP::SET_PROPERTY:
|
||||
universe->set(dmp, source);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -275,13 +268,8 @@ void Receiver::syncFrameHandler(std::shared_ptr<EXTENDED::Pdu> frame)
|
|||
* @param frame
|
||||
*/
|
||||
void Receiver::discoveryFrameHandler(std::shared_ptr<EXTENDED::Pdu> frame) {
|
||||
// check that PDU is valid
|
||||
if (frame->stream()->fail())
|
||||
return;
|
||||
|
||||
// PDU data will be a block of Discovery List PDU
|
||||
auto block = static_cast<PDU::Block<EXTENDED::DISCOVERY::Pdu>*>(frame->data());
|
||||
|
||||
for(auto const &pdu : *block->pdu)
|
||||
{
|
||||
// 8 Universe Discovery Layer
|
||||
|
@ -304,10 +292,6 @@ void Receiver::discoveryFrameHandler(std::shared_ptr<EXTENDED::Pdu> frame) {
|
|||
* @param pdu
|
||||
*/
|
||||
void Receiver::discoveryListHanlder(std::shared_ptr<EXTENDED::DISCOVERY::Pdu> pdu) {
|
||||
// check that PDU is valid
|
||||
if (pdu->stream()->fail())
|
||||
return;
|
||||
|
||||
auto data = static_cast<EXTENDED::DISCOVERY::discovery_list_data*>(pdu->data());
|
||||
for (auto& f : data->found)
|
||||
for (const auto &cb : discoveryCallbacks_)
|
||||
|
|
Loading…
Reference in New Issue