header, namespace, and whitespace cleanup
This commit is contained in:
parent
db6a22f4a5
commit
abb5bf1466
|
@ -21,7 +21,6 @@ set(CMAKE_AUTOMOC OFF)
|
|||
set(CMAKE_AUTORCC OFF)
|
||||
|
||||
set(SOURCE_FILES
|
||||
acn/acn.h
|
||||
acn/appliance.cpp
|
||||
acn/appliance.h
|
||||
acn/component.h
|
||||
|
|
60
acn/acn.h
60
acn/acn.h
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
acn.h
|
||||
|
||||
Copyright (c) 2020 Kevin Matz (kevin.matz@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "appliance.h"
|
||||
#include "component.h"
|
||||
#include "dmp.h"
|
||||
#include "pdu.h"
|
||||
#include "rlp.h"
|
||||
#include "rlp-tcp.h"
|
||||
#include "rlp-udp.h"
|
||||
#include "sdt.h"
|
||||
#include "sdt-udp.h"
|
||||
|
||||
// ANSI E1.17- 2015, Architecture for Control Networks
|
||||
namespace ACN {
|
||||
|
||||
// EPI 16 Protocol Identifier Database
|
||||
// from https://tsp.esta.org/tsp/working_groups/CP/epi16ids.php
|
||||
// as of 1/14/21
|
||||
|
||||
/// @brief Session Data Transport Protocol
|
||||
static const uint32_t PLASA_SDT = 0x00000001;
|
||||
/// @brief Device Management Protocol
|
||||
static const uint32_t PLASA_DMP = 0x00000002;
|
||||
/// @brief Lightweight streaming protocol for transport of DMX512
|
||||
static const uint32_t PLASA_E1_31 = 0x00000004;
|
||||
/// @brief RDMnet
|
||||
static const uint32_t PLASA_E1_33 = 0x00000005;
|
||||
/// @brief Empty data used for health checking connections in E1.33
|
||||
static const uint32_t PLASA_NULL = 0x00000006;
|
||||
/// @brief Open Lighting Architecture
|
||||
static const uint32_t OpenLightingProject_OLA = 0x00000007;
|
||||
/// @brief Extended functionality for sACN
|
||||
static const uint32_t PLASA_E1_31_EXTENDED = 0x00000008;
|
||||
/// @brief E1.59 Object Transform Protocol (OTP)
|
||||
const static uint32_t ESTA_OTP = 0x00000009;
|
||||
|
||||
} // ACN
|
|
@ -24,10 +24,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "component.h"
|
||||
#include "pdu.h"
|
||||
#include "rlp.h"
|
||||
#include "sdt.h"
|
||||
#include "pdu.h"
|
||||
#include "../uuid/uuid.h"
|
||||
#include "uuid/uuid.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../uuid/uuid.h"
|
||||
#include "uuid/uuid.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ACN {
|
||||
|
@ -51,23 +52,25 @@ public:
|
|||
void assignUserName(const std::string s) { uacn_ = s; }
|
||||
|
||||
protected:
|
||||
// EPI 19: ACN Discovery on IP Networks
|
||||
// 3. Component Name Strings
|
||||
// Each component shall maintain two text identifier strings intended to
|
||||
// indicate the function of the component in human readable terms for browsing
|
||||
// purposes.
|
||||
/**
|
||||
* EPI 19: ACN Discovery on IP Networks
|
||||
* 3. Component Name Strings
|
||||
* Each component shall maintain two text identifier strings intended to
|
||||
* indicate the function of the component in human readable terms for
|
||||
* browsing purposes.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief 3.1. Fixed Component Type Name (FCTN)
|
||||
* shall be a UTF-8 string that is assigned during manufacture.
|
||||
*/
|
||||
std::string fctn_;
|
||||
/**
|
||||
* @brief 3.1. Fixed Component Type Name (FCTN)
|
||||
* shall be a UTF-8 string that is assigned during manufacture.
|
||||
*/
|
||||
std::string fctn_;
|
||||
|
||||
/**
|
||||
* @brief 3.2. User Assigned Component Name (UACN)
|
||||
* shall be a UTF-8 string that may be assigned by the user.
|
||||
*/
|
||||
std::string uacn_;
|
||||
/**
|
||||
* @brief 3.2. User Assigned Component Name (UACN)
|
||||
* shall be a UTF-8 string that may be assigned by the user.
|
||||
*/
|
||||
std::string uacn_;
|
||||
|
||||
private:
|
||||
const UUID::uuid cid_;
|
||||
|
|
|
@ -39,6 +39,7 @@ pdu_stream::pdu_stream(uint8_t * p, std::streamsize l)
|
|||
setp(p, p + l);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief pdu_stream::operator >>
|
||||
* @param val
|
||||
|
|
|
@ -46,19 +46,20 @@ public:
|
|||
pdu_stream& operator>> (uint16_t& val);
|
||||
pdu_stream& operator>> (uint32_t& val);
|
||||
pdu_stream& operator>> (uint64_t& val);
|
||||
|
||||
template<typename T> T readType()
|
||||
{
|
||||
if (in_avail() < sizeof(T)) {
|
||||
setstate(std::ios_base::failbit);
|
||||
return 0;
|
||||
}
|
||||
T ret = 0;
|
||||
auto data = reinterpret_cast<uint8_t*>(&ret);
|
||||
for (int i = sizeof(T); --i >= 0; )
|
||||
data[i] = get();
|
||||
if (!in_avail())
|
||||
setstate(std::ios_base::eofbit);
|
||||
return ret;
|
||||
if (in_avail() < sizeof(T))
|
||||
setstate(std::ios_base::failbit);
|
||||
if (fail())
|
||||
return 0;
|
||||
T ret = 0;
|
||||
auto data = reinterpret_cast<uint8_t*>(&ret);
|
||||
for (int i = sizeof(T); --i >= 0; )
|
||||
data[i] = get();
|
||||
if (!in_avail())
|
||||
setstate(std::ios_base::eofbit);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// output sequence
|
||||
|
@ -70,9 +71,9 @@ public:
|
|||
pdu_stream& operator<< (const uint64_t& val);
|
||||
template<typename T> void writeType (const T& val)
|
||||
{
|
||||
auto data = reinterpret_cast<const uint8_t*>(&val);
|
||||
for (int i = sizeof(T); --i >= 0; )
|
||||
put(data[i]);
|
||||
auto data = reinterpret_cast<const uint8_t*>(&val);
|
||||
for (int i = sizeof(T); --i >= 0; )
|
||||
put(data[i]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -85,10 +86,10 @@ using Stream = std::shared_ptr<pdu_stream>;
|
|||
*/
|
||||
struct pdu_stream_object
|
||||
{
|
||||
virtual ~pdu_stream_object() {};
|
||||
virtual size_t streamSize() const = 0;
|
||||
virtual void iStream(Stream) = 0;
|
||||
virtual void oStream(Stream) const = 0;
|
||||
virtual ~pdu_stream_object() {};
|
||||
virtual size_t streamSize() const = 0;
|
||||
virtual void iStream(Stream) = 0;
|
||||
virtual void oStream(Stream) const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
217
acn/pdu.cpp
217
acn/pdu.cpp
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "pdu.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace ACN {
|
||||
|
@ -99,42 +100,42 @@ pdu_data * Pdu::data()
|
|||
*/
|
||||
size_t Pdu::streamSize() const
|
||||
{
|
||||
size_t s = 2; // flength is at least 2 octets
|
||||
size_t s = 2; // flength is at least 2 octets
|
||||
|
||||
// plus the length of the vector
|
||||
if (flags_.hasVector) {
|
||||
if (inherit_) {
|
||||
if (vector_ != inherit_->vector())
|
||||
s += vector_size_;
|
||||
} else {
|
||||
// plus the length of the vector
|
||||
if (flags_.hasVector) {
|
||||
if (inherit_) {
|
||||
if (vector_ != inherit_->vector())
|
||||
s += vector_size_;
|
||||
} else {
|
||||
s += vector_size_;
|
||||
}
|
||||
}
|
||||
|
||||
// plus the length of the header
|
||||
if (header_) {
|
||||
if (inherit_) {
|
||||
if (header_ != inherit_->header())
|
||||
s += header_->streamSize();
|
||||
} else {
|
||||
// plus the length of the header
|
||||
if (header_) {
|
||||
if (inherit_) {
|
||||
if (header_ != inherit_->header())
|
||||
s += header_->streamSize();
|
||||
}
|
||||
}
|
||||
|
||||
// plus the lenth of the data
|
||||
if (data_) {
|
||||
if (inherit_) {
|
||||
if (data_ != inherit_->data())
|
||||
s += data_->streamSize();
|
||||
} else {
|
||||
s += data_->streamSize();
|
||||
s += header_->streamSize();
|
||||
}
|
||||
}
|
||||
|
||||
// and another bit if the length needs it
|
||||
if (s > 0x0fff)
|
||||
s++;
|
||||
return s;
|
||||
// plus the lenth of the data
|
||||
if (data_) {
|
||||
if (inherit_) {
|
||||
if (data_ != inherit_->data())
|
||||
s += data_->streamSize();
|
||||
} else {
|
||||
s += data_->streamSize();
|
||||
}
|
||||
}
|
||||
|
||||
// and another bit if the length needs it
|
||||
if (s > 0x0fff)
|
||||
s++;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
@ -144,54 +145,54 @@ size_t Pdu::streamSize() const
|
|||
*/
|
||||
void Pdu::iStream(Stream stream)
|
||||
{
|
||||
// get the flags
|
||||
flags_.set(stream->peek());
|
||||
// get the flags
|
||||
flags_.set(stream->peek());
|
||||
|
||||
// get the length
|
||||
size_t length;
|
||||
length = stream->readType<uint16_t>() & 0x0fff; // high 4 bits are flags
|
||||
if (flags_.hasLength)
|
||||
length = (length << 8 ) | stream->readType<uint8_t>();
|
||||
// get the length
|
||||
size_t length;
|
||||
length = stream->readType<uint16_t>() & 0x0fff; // high 4 bits are flags
|
||||
if (flags_.hasLength)
|
||||
length = (length << 8 ) | stream->readType<uint8_t>();
|
||||
|
||||
// get the vector
|
||||
if (flags_.hasVector)
|
||||
switch (vector_size_) {
|
||||
case 1:
|
||||
vector_ = stream->readType<uint8_t>();
|
||||
break;
|
||||
case 2:
|
||||
vector_ = stream->readType<uint16_t>();
|
||||
break;
|
||||
case 4:
|
||||
vector_ = stream->readType<uint32_t>();
|
||||
break;
|
||||
default:
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
// get the vector
|
||||
if (flags_.hasVector)
|
||||
switch (vector_size_) {
|
||||
case 1:
|
||||
vector_ = stream->readType<uint8_t>();
|
||||
break;
|
||||
case 2:
|
||||
vector_ = stream->readType<uint16_t>();
|
||||
break;
|
||||
case 4:
|
||||
vector_ = stream->readType<uint32_t>();
|
||||
break;
|
||||
default:
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
|
||||
// length includes the flags, length, and vector.
|
||||
// the remainder of the length of header and data
|
||||
uint hd_length = length - (flags_.hasLength ? 3 : 2) - vector_size_;
|
||||
// length includes the flags, length, and vector.
|
||||
// the remainder of the length of header and data
|
||||
uint hd_length = length - (flags_.hasLength ? 3 : 2) - vector_size_;
|
||||
|
||||
// abort if the remaining PDU length isn't available
|
||||
if (!stream->good() || stream->available() < hd_length) {
|
||||
// abort if the remaining PDU length isn't available
|
||||
if (!stream->good() || stream->available() < hd_length) {
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
|
||||
// create a stream buffer for the header and data
|
||||
stream_ = Stream(new pdu_stream(stream->data(), hd_length));
|
||||
if (stream_->available() != hd_length) {
|
||||
// create a stream buffer for the header and data
|
||||
stream_ = Stream(new pdu_stream(stream->data(), hd_length));
|
||||
if (stream_->available() != hd_length) {
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
|
||||
// fast-forward the input stream
|
||||
for (uint i = 0; i < hd_length; i++)
|
||||
stream->get();
|
||||
if (!stream->available())
|
||||
stream->setstate(std::ios_base::eofbit);
|
||||
// fast-forward the input stream
|
||||
for (uint i = 0; i < hd_length; i++)
|
||||
stream->get();
|
||||
if (!stream->available())
|
||||
stream->setstate(std::ios_base::eofbit);
|
||||
}
|
||||
|
||||
|
||||
|
@ -201,60 +202,60 @@ void Pdu::iStream(Stream stream)
|
|||
*/
|
||||
void Pdu::oStream(Stream stream) const
|
||||
{
|
||||
pdu_flags flags = flags_;
|
||||
size_t length = streamSize();
|
||||
pdu_flags flags = flags_;
|
||||
size_t length = streamSize();
|
||||
|
||||
// check if length flag need to be set
|
||||
if (length > 0x0fff)
|
||||
flags.hasLength = true;
|
||||
// check if length flag need to be set
|
||||
if (length > 0x0fff)
|
||||
flags.hasLength = true;
|
||||
|
||||
// see if we can inherit members
|
||||
if (inherit_) {
|
||||
if (flags.hasVector)
|
||||
if (vector_ == inherit_->vector())
|
||||
flags.hasVector = false;
|
||||
if (flags.hasHeader)
|
||||
if (header_ == inherit_->header())
|
||||
flags.hasHeader = false;
|
||||
if (flags.hasData)
|
||||
if (data_ == inherit_->data())
|
||||
flags.hasData = false;
|
||||
// see if we can inherit members
|
||||
if (inherit_) {
|
||||
if (flags.hasVector)
|
||||
if (vector_ == inherit_->vector())
|
||||
flags.hasVector = false;
|
||||
if (flags.hasHeader)
|
||||
if (header_ == inherit_->header())
|
||||
flags.hasHeader = false;
|
||||
if (flags.hasData)
|
||||
if (data_ == inherit_->data())
|
||||
flags.hasData = false;
|
||||
}
|
||||
|
||||
// inject flags onto the high 4 bits of the length
|
||||
auto flength = reinterpret_cast<uint8_t*>(length);
|
||||
if (flags.hasLength)
|
||||
flength[2] = (flength[2] & 0x0f) | (uint8_t)flags;
|
||||
else
|
||||
flength[1] = (flength[1] & 0x0f) | (uint8_t)flags;
|
||||
// inject flags onto the high 4 bits of the length
|
||||
auto flength = reinterpret_cast<uint8_t*>(length);
|
||||
if (flags.hasLength)
|
||||
flength[2] = (flength[2] & 0x0f) | (uint8_t)flags;
|
||||
else
|
||||
flength[1] = (flength[1] & 0x0f) | (uint8_t)flags;
|
||||
|
||||
// write the flength to stream
|
||||
stream->write(flength, (flags.hasLength ? 3 : 2));
|
||||
// write the flength to stream
|
||||
stream->write(flength, (flags.hasLength ? 3 : 2));
|
||||
|
||||
// write the vector to stream
|
||||
if (flags.hasVector)
|
||||
switch (vector_size_) {
|
||||
case 1:
|
||||
stream->writeType<uint8_t>(vector_);
|
||||
break;
|
||||
case 2:
|
||||
stream->writeType<uint16_t>(vector_);
|
||||
break;
|
||||
case 4:
|
||||
stream->writeType<uint32_t>(vector_);
|
||||
break;
|
||||
default:
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
// write the vector to stream
|
||||
if (flags.hasVector)
|
||||
switch (vector_size_) {
|
||||
case 1:
|
||||
stream->writeType<uint8_t>(vector_);
|
||||
break;
|
||||
case 2:
|
||||
stream->writeType<uint16_t>(vector_);
|
||||
break;
|
||||
case 4:
|
||||
stream->writeType<uint32_t>(vector_);
|
||||
break;
|
||||
default:
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
|
||||
// write the header to stream
|
||||
if (flags.hasHeader)
|
||||
header_->oStream(stream);
|
||||
// write the header to stream
|
||||
if (flags.hasHeader)
|
||||
header_->oStream(stream);
|
||||
|
||||
// write the data to steam
|
||||
if (flags.hasData)
|
||||
data_->oStream(stream);
|
||||
// write the data to steam
|
||||
if (flags.hasData)
|
||||
data_->oStream(stream);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "rlp-tcp.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace ACN {
|
||||
|
@ -48,17 +49,18 @@ transport::transport(bool filled)
|
|||
*/
|
||||
void transport::iStream(PDU::Stream stream)
|
||||
{
|
||||
// 2. Preamble Format: The ACN Packet Identifier shall be the text string
|
||||
// “ASC-E1.17\0\0\0” encoded in [ASCII].
|
||||
/**
|
||||
* 2. Preamble Format:
|
||||
* The ACN Packet Identifier shall be the text string “ASC-E1.17\0\0\0”
|
||||
* encoded in [ASCII].
|
||||
*/
|
||||
stream->read(acn_id, sizeof(acn_id));
|
||||
if (stream->gcount() != 12)
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
if (memcmp(acn_id, ACN_PACKET_IDENTIFIER, 12)) {
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
if (memcmp(acn_id, ACN_PACKET_IDENTIFIER, 12))
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
|
||||
length = stream->readType<decltype(length)>();
|
||||
*stream >> length;
|
||||
|
||||
root.iStream(stream);
|
||||
}
|
||||
|
@ -69,10 +71,8 @@ void transport::iStream(PDU::Stream stream)
|
|||
*/
|
||||
void transport::oStream(PDU::Stream) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // TCP
|
||||
} // RLP
|
||||
} // ACN
|
||||
|
|
|
@ -58,15 +58,14 @@ struct transport
|
|||
* The ACN Packet Identifier shall be the text string “ASC-E1.17\0\0\0”
|
||||
* encoded in [ASCII].
|
||||
*/
|
||||
static constexpr uint8_t ACN_PACKET_IDENTIFIER[] = { 0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 };
|
||||
|
||||
|
||||
static const uint8_t ACN_PACKET_IDENTIFIER[] = { 0x41, 0x53, 0x43, 0x2d,
|
||||
0x45, 0x31, 0x2e, 0x31,
|
||||
0x37, 0x00, 0x00, 0x00 };
|
||||
/**
|
||||
* @brief 3.2 PDU Block Size INDEFINITE
|
||||
*/
|
||||
static const uint32_t INDEFINITE = 0xffffffff;
|
||||
|
||||
|
||||
} // TCP
|
||||
} // RLP
|
||||
} // ACN
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "rlp-udp.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace ACN {
|
||||
|
@ -51,32 +52,38 @@ transport::transport(bool filled)
|
|||
*/
|
||||
void transport::iStream(PDU::Stream stream)
|
||||
{
|
||||
*stream >> length;
|
||||
// 2. Preamble Format: The preamble size includes both size fields so the
|
||||
// minimum value for preamble size is 16 (octets).
|
||||
if (length < PREAMBLE_MINIMUM_SIZE) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* 2. Preamble Format:
|
||||
* The preamble size includes both size fields so the
|
||||
* minimum value for preamble size is 16 (octets).
|
||||
*/
|
||||
*stream >> length;
|
||||
if (length < PREAMBLE_MINIMUM_SIZE)
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
|
||||
*stream >> postamble_size;
|
||||
*stream >> postamble_size;
|
||||
|
||||
// 2. Preamble Format: The ACN Packet Identifier shall be the text string
|
||||
// “ASC-E1.17\0\0\0” encoded in [ASCII].
|
||||
stream->read(acn_id, sizeof(acn_id));
|
||||
if (stream->gcount() != sizeof(acn_id))
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
if (memcmp(acn_id, ACN_PACKET_IDENTIFIER, 12) != 0) { // memcmp returns 0 if matched
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* 2. Preamble Format:
|
||||
* The ACN Packet Identifier shall be the text string “ASC-E1.17\0\0\0”
|
||||
* encoded in [ASCII].
|
||||
*/
|
||||
stream->read(acn_id, sizeof(acn_id));
|
||||
if (stream->gcount() != sizeof(acn_id))
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
if (memcmp(acn_id, ACN_PACKET_IDENTIFIER, 12) != 0) // memcmp returns 0 if matched
|
||||
return stream->setstate(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 = PREAMBLE_MINIMUM_SIZE; i < length; i++)
|
||||
stream->readType<uint8_t>();
|
||||
|
||||
root.iStream(stream);
|
||||
/**
|
||||
* 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 = PREAMBLE_MINIMUM_SIZE; i < length; i++)
|
||||
stream->readType<uint8_t>();
|
||||
|
||||
root.iStream(stream);
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,11 +93,11 @@ void transport::iStream(PDU::Stream stream)
|
|||
*/
|
||||
void transport::oStream(PDU::Stream stream) const
|
||||
{
|
||||
*stream << length;
|
||||
*stream << postamble_size;
|
||||
stream->write(acn_id, sizeof(acn_id));
|
||||
for ( auto& pdu : *root.pdu )
|
||||
pdu->oStream(stream);
|
||||
*stream << length;
|
||||
*stream << postamble_size;
|
||||
stream->write(acn_id, sizeof(acn_id));
|
||||
for ( auto& pdu : *root.pdu )
|
||||
pdu->oStream(stream);
|
||||
}
|
||||
|
||||
} // UDP
|
||||
|
|
|
@ -34,21 +34,20 @@ namespace UDP {
|
|||
|
||||
/**
|
||||
* @brief ACN_PACKET_IDENTIFIER
|
||||
*
|
||||
* The ACN Packet Identifier shall be the text string
|
||||
* “ASC-E1.17\0\0\0” encoded in [ASCII].
|
||||
* The ACN Packet Identifier shall be the text string “ASC-E1.17\0\0\0”
|
||||
* encoded in [ASCII].
|
||||
*/
|
||||
static constexpr uint8_t ACN_PACKET_IDENTIFIER[] = { 0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 };
|
||||
|
||||
|
||||
static const uint8_t ACN_PACKET_IDENTIFIER[] = { 0x41, 0x53, 0x43, 0x2d,
|
||||
0x45, 0x31, 0x2e, 0x31,
|
||||
0x37, 0x00, 0x00, 0x00 };
|
||||
/**
|
||||
* @brief PREAMBLE_MINIMUM_SIZE
|
||||
*
|
||||
* 2. Preamble Format: The preamble size includes both size fields so the
|
||||
* minimum value for preamble size is 16 (octets).
|
||||
* The preamble size includes both size fields so the minimum value for
|
||||
* preamble size is 16 (octets).
|
||||
*/
|
||||
static const uint8_t PREAMBLE_MINIMUM_SIZE = 16;
|
||||
|
||||
|
||||
/**
|
||||
* @brief 2. Preamble Format
|
||||
*/
|
||||
|
@ -62,10 +61,10 @@ struct transport
|
|||
|
||||
PDU::Block<RLP::Pdu> root;
|
||||
|
||||
size_t streamSize() const override { return PREAMBLE_MINIMUM_SIZE +
|
||||
root.streamSize(); }
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override;
|
||||
size_t streamSize() const override { return PREAMBLE_MINIMUM_SIZE
|
||||
+ root.streamSize(); }
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override;
|
||||
};
|
||||
|
||||
|
||||
|
|
12
acn/rlp.cpp
12
acn/rlp.cpp
|
@ -43,12 +43,11 @@ size_t rlp_header::streamSize() const
|
|||
*/
|
||||
void rlp_header::iStream(PDU::Stream stream)
|
||||
{
|
||||
uint8_t * buffer = new uint8_t[UUID_LENGTH];
|
||||
uint8_t buffer[UUID_LENGTH];
|
||||
stream->read(buffer, UUID_LENGTH);
|
||||
if (stream->gcount() != UUID_LENGTH)
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
cid = UUID::uuid(buffer);
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,13 +79,8 @@ void Pdu::iStream(PDU::Stream stream)
|
|||
{
|
||||
PDU::Pdu::iStream(stream); //! do base class first
|
||||
if (stream->fail()) return;
|
||||
if (!stream_->good()) return;
|
||||
|
||||
if (flags_.hasHeader)
|
||||
{
|
||||
header_ = new rlp_header();
|
||||
header_->iStream(stream_);
|
||||
}
|
||||
createHeader<rlp_header>();
|
||||
}
|
||||
|
||||
} // RLP
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include "pdu.h"
|
||||
#include "../uuid/uuid.h"
|
||||
#include "uuid/uuid.h"
|
||||
|
||||
namespace ACN {
|
||||
namespace RLP {
|
||||
|
|
87
acn/sdt.cpp
87
acn/sdt.cpp
|
@ -33,14 +33,14 @@ namespace SDT {
|
|||
*/
|
||||
void params_t::iStream(PDU::Stream stream)
|
||||
{
|
||||
*stream >> Expiry;
|
||||
uint8_t packed;
|
||||
*stream >> packed;
|
||||
NAK_Outbound = packed >> 7;
|
||||
reserved = packed & 0xef;
|
||||
*stream >> NAKholdoff;
|
||||
*stream >> NAKmodulus;
|
||||
*stream >> NAKmaxwait;
|
||||
*stream >> Expiry;
|
||||
uint8_t packed;
|
||||
*stream >> packed;
|
||||
NAK_Outbound = packed >> 7;
|
||||
reserved = packed & 0xef;
|
||||
*stream >> NAKholdoff;
|
||||
*stream >> NAKmodulus;
|
||||
*stream >> NAKmaxwait;
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,14 +50,14 @@ void params_t::iStream(PDU::Stream stream)
|
|||
*/
|
||||
void join_data_t::iStream(PDU::Stream stream)
|
||||
{
|
||||
*stream >> mid;
|
||||
*stream >> number;
|
||||
*stream >> reciprocal;
|
||||
*stream >> sequence;
|
||||
*stream >> reliable;
|
||||
destination.iStream(stream);
|
||||
parameters.iStream(stream);
|
||||
*stream >> expiry;
|
||||
*stream >> mid;
|
||||
*stream >> number;
|
||||
*stream >> reciprocal;
|
||||
*stream >> sequence;
|
||||
*stream >> reliable;
|
||||
destination.iStream(stream);
|
||||
parameters.iStream(stream);
|
||||
*stream >> expiry;
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,13 +67,13 @@ void join_data_t::iStream(PDU::Stream stream)
|
|||
*/
|
||||
void join_accept_data_t::iStream(PDU::Stream stream)
|
||||
{
|
||||
uint8_t buf[16];
|
||||
stream->read(buf, sizeof(buf));
|
||||
leader = UUID::uuid(buf);
|
||||
*stream >> number;
|
||||
*stream >> mid;
|
||||
*stream >> reliable;
|
||||
*stream >> reciprocal;
|
||||
uint8_t buf[16];
|
||||
stream->read(buf, sizeof(buf));
|
||||
leader = UUID::uuid(buf);
|
||||
*stream >> number;
|
||||
*stream >> mid;
|
||||
*stream >> reliable;
|
||||
*stream >> reciprocal;
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,14 +99,14 @@ void join_refuse_data_t::iStream(PDU::Stream stream)
|
|||
*/
|
||||
void nak_data_t::iStream(PDU::Stream stream)
|
||||
{
|
||||
uint8_t buf[16];
|
||||
stream->read(buf, sizeof(buf));
|
||||
leader = UUID::uuid(buf);
|
||||
*stream >> number;
|
||||
*stream >> mid;
|
||||
*stream >> reliable;
|
||||
*stream >> missed_first;
|
||||
*stream >> missed_last;
|
||||
uint8_t buf[16];
|
||||
stream->read(buf, sizeof(buf));
|
||||
leader = UUID::uuid(buf);
|
||||
*stream >> number;
|
||||
*stream >> mid;
|
||||
*stream >> reliable;
|
||||
*stream >> missed_first;
|
||||
*stream >> missed_last;
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +116,7 @@ void nak_data_t::iStream(PDU::Stream stream)
|
|||
*/
|
||||
void wrapper_data_t::iStream(PDU::Stream stream)
|
||||
{
|
||||
*stream >> number;
|
||||
*stream >> number;
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,19 +194,19 @@ Pdu::Pdu()
|
|||
*/
|
||||
void Pdu::iStream(PDU::Stream stream)
|
||||
{
|
||||
PDU::Pdu::iStream(stream); //! do base class first
|
||||
if (stream->fail()) return;
|
||||
if (!stream_->good()) return;
|
||||
PDU::Pdu::iStream(stream); //! do base class first
|
||||
if (stream->fail()) return;
|
||||
if (!stream_->good()) return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief client_pdu_header_t::iStream
|
||||
* @param stream
|
||||
*/
|
||||
void client_pdu_header_t::iStream(PDU::Stream stream)
|
||||
void client_pdu_header::iStream(PDU::Stream stream)
|
||||
{
|
||||
*stream >> protocol;
|
||||
*stream >> association;
|
||||
*stream >> protocol;
|
||||
*stream >> association;
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,15 +226,10 @@ ClientPdu::ClientPdu()
|
|||
*/
|
||||
void ClientPdu::iStream(PDU::Stream stream)
|
||||
{
|
||||
PDU::Pdu::iStream(stream); //! do base class first
|
||||
if (stream->fail()) return;
|
||||
if (!stream_->good()) return;
|
||||
PDU::Pdu::iStream(stream);
|
||||
if (stream->fail()) return;
|
||||
|
||||
if (flags_.hasHeader)
|
||||
{
|
||||
header_ = new client_pdu_header_t();
|
||||
header_->iStream(stream_);
|
||||
}
|
||||
createHeader<client_pdu_header>();
|
||||
}
|
||||
|
||||
}; // SDT
|
||||
|
|
66
acn/sdt.h
66
acn/sdt.h
|
@ -65,7 +65,8 @@ using MID = uint16_t;
|
|||
/**
|
||||
* @brief 4.4.1.2 Channel Parameter Block
|
||||
*/
|
||||
struct params_t {
|
||||
struct params_t
|
||||
{
|
||||
uint8_t Expiry; // number of seconds without traffic before leaving
|
||||
struct {
|
||||
uint8_t NAK_Outbound : 1; // NAK to channel (1) or destination address (0)
|
||||
|
@ -81,7 +82,9 @@ struct params_t {
|
|||
/**
|
||||
* @brief 4.4.1 Join
|
||||
*/
|
||||
struct join_data_t : PDU::pdu_data {
|
||||
struct join_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
MID mid;
|
||||
uint16_t number;
|
||||
uint16_t reciprocal;
|
||||
|
@ -90,6 +93,7 @@ struct join_data_t : PDU::pdu_data {
|
|||
UDP::address_t destination;
|
||||
params_t parameters;
|
||||
uint8_t expiry;
|
||||
|
||||
size_t streamSize() const override { return 0; }
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -99,12 +103,15 @@ struct join_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.4.2 Join Accept
|
||||
*/
|
||||
struct join_accept_data_t : PDU::pdu_data {
|
||||
struct join_accept_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
UUID::uuid leader;
|
||||
uint16_t number;
|
||||
MID mid;
|
||||
uint32_t reliable;
|
||||
uint16_t reciprocal;
|
||||
|
||||
size_t streamSize() const override { return 26; }
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -114,12 +121,15 @@ struct join_accept_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.4.3 Join Refuse & 4.4.4 Leaving
|
||||
*/
|
||||
struct join_refuse_data_t : PDU::pdu_data {
|
||||
struct join_refuse_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
UUID::uuid leader;
|
||||
uint16_t number;
|
||||
MID mid;
|
||||
uint32_t reliable;
|
||||
uint8_t code;
|
||||
|
||||
size_t streamSize() const override { return 25; }
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -129,13 +139,16 @@ struct join_refuse_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.4.5 NAK
|
||||
*/
|
||||
struct nak_data_t : PDU::pdu_data {
|
||||
struct nak_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
UUID::uuid leader;
|
||||
uint16_t number;
|
||||
MID mid;
|
||||
uint32_t reliable;
|
||||
uint32_t missed_first;
|
||||
uint32_t missed_last;
|
||||
|
||||
size_t streamSize() const override { return 32; }
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -145,7 +158,9 @@ struct nak_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.4.6 Reliable Wrapper and Unreliable Wrapper
|
||||
*/
|
||||
struct wrapper_data_t : PDU::pdu_data {
|
||||
struct wrapper_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
uint16_t number;
|
||||
uint32_t sequence;
|
||||
uint32_t reliable;
|
||||
|
@ -153,6 +168,7 @@ struct wrapper_data_t : PDU::pdu_data {
|
|||
MID ack_range_begin;
|
||||
MID ack_range_end;
|
||||
uint16_t MAK_threshold;
|
||||
|
||||
size_t streamSize() const override { return 20; }
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -162,9 +178,12 @@ struct wrapper_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.4.7 SDT Client Block
|
||||
*/
|
||||
struct client_pdu_header_t : PDU::pdu_header {
|
||||
struct client_pdu_header
|
||||
: PDU::pdu_header
|
||||
{
|
||||
uint32_t protocol;
|
||||
uint16_t association;
|
||||
|
||||
size_t streamSize() const override { return 6; };
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -186,8 +205,11 @@ public:
|
|||
/**
|
||||
* @brief 4.4.8 Get Sessions
|
||||
*/
|
||||
struct get_sessions_data_t : PDU::pdu_data {
|
||||
struct get_sessions_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
UUID::uuid cid;
|
||||
|
||||
size_t streamSize() const override { return 0; }
|
||||
void iStream(PDU::Stream) override {};
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -197,7 +219,8 @@ struct get_sessions_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.4.9.1 Channel Owner Info Block
|
||||
*/
|
||||
struct channel_info_block_t {
|
||||
struct channel_info_block_t
|
||||
{
|
||||
MID mid;
|
||||
UUID::uuid owner;
|
||||
uint16_t number;
|
||||
|
@ -212,8 +235,11 @@ struct channel_info_block_t {
|
|||
/**
|
||||
* @brief 4.4.9 Sessions
|
||||
*/
|
||||
struct sessions_data_t : PDU::pdu_data {
|
||||
struct sessions_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
std::list<channel_info_block_t> list;
|
||||
|
||||
size_t streamSize() const override { return 0; }
|
||||
void iStream(PDU::Stream) override {};
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -223,8 +249,11 @@ struct sessions_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.5.1 ACK
|
||||
*/
|
||||
struct ack_data_t : PDU::pdu_data {
|
||||
struct ack_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
uint32_t reliable;
|
||||
|
||||
size_t streamSize() const override { return 4; }
|
||||
void iStream(PDU::Stream) override {};
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -234,10 +263,13 @@ struct ack_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.5.2 Channel Params
|
||||
*/
|
||||
struct channel_params_data_t : PDU::pdu_data {
|
||||
struct channel_params_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
params_t parameters;
|
||||
UDP::address_t address;
|
||||
uint8_t expiry;
|
||||
|
||||
size_t streamSize() const override { return 0; }
|
||||
void iStream(PDU::Stream) override {};
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -247,8 +279,11 @@ struct channel_params_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.5.3 Connect, 4.5.4 Connect Accept, & 4.5.6 Disconnect
|
||||
*/
|
||||
struct connect_data_t : PDU::pdu_data {
|
||||
struct connect_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
uint32_t protocol;
|
||||
|
||||
size_t streamSize() const override { return 4; }
|
||||
void iStream(PDU::Stream) override {};
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
@ -258,9 +293,12 @@ struct connect_data_t : PDU::pdu_data {
|
|||
/**
|
||||
* @brief 4.5.5 Connect Refuse & 4.5.7 Disconnecting
|
||||
*/
|
||||
struct connect_refuse_data_t : PDU::pdu_data {
|
||||
struct connect_refuse_data_t
|
||||
: PDU::pdu_data
|
||||
{
|
||||
uint32_t protocol;
|
||||
uint8_t code;
|
||||
|
||||
size_t streamSize() const override { return 0; }
|
||||
void iStream(PDU::Stream) override {};
|
||||
void oStream(PDU::Stream) const override {};
|
||||
|
|
|
@ -33,7 +33,6 @@ Personality::Personality()
|
|||
: description("Null")
|
||||
, footprint_(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,7 +41,6 @@ Personality::Personality()
|
|||
*/
|
||||
Personality::~Personality()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // namespace DMX
|
||||
|
|
|
@ -52,9 +52,11 @@ Universe::~Universe()
|
|||
*/
|
||||
uint8_t Universe::slot(const uint16_t address)
|
||||
{
|
||||
if (address == 0) return 0;
|
||||
if (address > null_start_data_.size() - 1) return 0;
|
||||
return null_start_data_[address];
|
||||
if (address == 0)
|
||||
return 0;
|
||||
if (address > null_start_data_.size() - 1)
|
||||
return 0;
|
||||
return null_start_data_[address];
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,7 +82,8 @@ double Universe::rxRate()
|
|||
* The only setData method used to establish rx rate.
|
||||
*/
|
||||
void Universe::setData(std::vector<uint8_t> vect) {
|
||||
switch (vect.front()) { // start code
|
||||
switch (vect.front()) // start code
|
||||
{
|
||||
case E111_NULL_START:
|
||||
vect.resize(null_start_data_.size(), 0); // pad shorter, truncate larger
|
||||
std::copy(vect.begin(), vect.end(), null_start_data_.begin());
|
||||
|
@ -90,7 +93,7 @@ void Universe::setData(std::vector<uint8_t> vect) {
|
|||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,8 +105,10 @@ void Universe::setData(std::vector<uint8_t> vect) {
|
|||
*/
|
||||
void Universe::setValue(const uint16_t address, const uint8_t value)
|
||||
{
|
||||
if (address == 0) return;
|
||||
if (address > null_start_data_.size() - 1) return;
|
||||
if (address == 0)
|
||||
return;
|
||||
if (address > null_start_data_.size() - 1)
|
||||
return;
|
||||
null_start_data_[address] = value;
|
||||
}
|
||||
|
||||
|
@ -118,8 +123,10 @@ void Universe::setValue(const uint16_t address, const uint8_t value)
|
|||
void Universe::setValue(const uint16_t start, const uint16_t footprint,
|
||||
const uint8_t* profile)
|
||||
{
|
||||
if (start == 0) return;
|
||||
if (start + footprint > null_start_data_.size() - 1) return;
|
||||
if (start == 0)
|
||||
return;
|
||||
if (start + footprint > null_start_data_.size() - 1)
|
||||
return;
|
||||
for (int i = 0; i < footprint; i++)
|
||||
null_start_data_[start + i] = profile[i];
|
||||
}
|
||||
|
@ -142,17 +149,17 @@ void Universe::onData(const DataHandler callback)
|
|||
*/
|
||||
void Universe::rx_timeout_(bool add_now)
|
||||
{
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto elapsed = [](auto& a, auto& b) {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(a - b);
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto elapsed = [] (auto& a, auto& b) {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(a - b);
|
||||
};
|
||||
|
||||
if (add_now)
|
||||
rx_times_.push(now);
|
||||
if (add_now)
|
||||
rx_times_.push(now);
|
||||
|
||||
while (rx_times_.size() > 0 &&
|
||||
elapsed(now, rx_times_.front()).count() > rx_timeout_period_)
|
||||
rx_times_.pop();
|
||||
while (rx_times_.size() > 0 &&
|
||||
elapsed(now, rx_times_.front()).count() > rx_timeout_period_)
|
||||
rx_times_.pop();
|
||||
}
|
||||
|
||||
} // namespace DMX
|
||||
|
|
|
@ -96,7 +96,8 @@ struct Message
|
|||
template<typename T>
|
||||
static void writeType(std::vector<uint8_t>& data, T val)
|
||||
{
|
||||
if (val == 0) {
|
||||
if (val == 0)
|
||||
{
|
||||
for (int i = sizeof(T); --i >= 0; )
|
||||
data.push_back(0);
|
||||
return;
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace LLRP {
|
|||
*/
|
||||
Target::Target()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +40,6 @@ Target::Target()
|
|||
*/
|
||||
Target::~Target()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,9 +67,8 @@ void Target::receiveLLRP(std::shared_ptr<Pdu> frame)
|
|||
* @brief Target::receiveProbeRequest
|
||||
* @param pdu
|
||||
*/
|
||||
void Target::receiveProbeRequest(std::shared_ptr<LLRP::ProbeRequest::Pdu> pdu)
|
||||
void Target::receiveProbeRequest(std::shared_ptr<LLRP::ProbeRequest::Pdu>)
|
||||
{
|
||||
(void)pdu;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "acn/dmp.h"
|
||||
#include "data.h"
|
||||
|
||||
namespace SACN {
|
||||
|
@ -33,12 +34,12 @@ namespace DATA {
|
|||
*/
|
||||
size_t data_header::streamSize() const
|
||||
{
|
||||
return sizeof(source_name)
|
||||
+ sizeof(priority)
|
||||
+ sizeof(sync_address)
|
||||
+ sizeof(sequence_number)
|
||||
+ sizeof(options)
|
||||
+ sizeof(universe);
|
||||
return sizeof(source_name)
|
||||
+ sizeof(priority)
|
||||
+ sizeof(sync_address)
|
||||
+ sizeof(sequence_number)
|
||||
+ sizeof(options)
|
||||
+ sizeof(universe);
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,16 +47,16 @@ size_t data_header::streamSize() const
|
|||
* @brief frame_header::iStream
|
||||
* @param stream
|
||||
*/
|
||||
void data_header::iStream(PDU::Stream stream)
|
||||
void data_header::iStream(ACN::PDU::Stream stream)
|
||||
{
|
||||
stream->read(source_name, sizeof(source_name));
|
||||
if (stream->gcount() != sizeof(source_name))
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
*stream >> priority;
|
||||
*stream >> sync_address;
|
||||
*stream >> sequence_number;
|
||||
*stream >> options;
|
||||
*stream >> universe;
|
||||
stream->read(source_name, sizeof(source_name));
|
||||
if (stream->gcount() != sizeof(source_name))
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
*stream >> priority;
|
||||
*stream >> sync_address;
|
||||
*stream >> sequence_number;
|
||||
*stream >> options;
|
||||
*stream >> universe;
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,14 +64,14 @@ void data_header::iStream(PDU::Stream stream)
|
|||
* @brief frame_header::asStream
|
||||
* @return
|
||||
*/
|
||||
void data_header::oStream(PDU::Stream stream) const
|
||||
void data_header::oStream(ACN::PDU::Stream stream) const
|
||||
{
|
||||
stream->write(source_name, 64);
|
||||
*stream << priority;
|
||||
*stream << sync_address;
|
||||
*stream << sequence_number;
|
||||
*stream << options;
|
||||
*stream << universe;
|
||||
stream->write(source_name, 64);
|
||||
*stream << priority;
|
||||
*stream << sync_address;
|
||||
*stream << sequence_number;
|
||||
*stream << options;
|
||||
*stream << universe;
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,7 +80,7 @@ void data_header::oStream(PDU::Stream stream) const
|
|||
* @param stream
|
||||
*/
|
||||
Pdu::Pdu()
|
||||
: PDU::Pdu(4) // vectors are 4 octets
|
||||
: ACN::PDU::Pdu(4) // vectors are 4 octets
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -88,13 +89,13 @@ Pdu::Pdu()
|
|||
* @brief Pdu::iStream
|
||||
* @param stream
|
||||
*/
|
||||
void Pdu::iStream(PDU::Stream stream)
|
||||
void Pdu::iStream(ACN::PDU::Stream stream)
|
||||
{
|
||||
PDU::Pdu::iStream(stream);
|
||||
ACN::PDU::Pdu::iStream(stream);
|
||||
if (stream->fail()) return;
|
||||
|
||||
createHeader<data_header>();
|
||||
createDataBlock<DMP::Pdu>();
|
||||
createDataBlock<ACN::DMP::Pdu>();
|
||||
}
|
||||
|
||||
} // DATA
|
||||
|
|
21
sacn/data.h
21
sacn/data.h
|
@ -23,27 +23,26 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "acn/pdu.h"
|
||||
#include "sacn.h"
|
||||
|
||||
namespace SACN {
|
||||
namespace DATA {
|
||||
|
||||
using std::uint8_t;
|
||||
using std::uint16_t;
|
||||
|
||||
/**
|
||||
* @brief Table 6-1: E1.31 Data Packet Framing Layer
|
||||
*/
|
||||
struct data_header : PDU::pdu_header {
|
||||
struct data_header : ACN::PDU::pdu_header {
|
||||
uint8_t source_name[64];
|
||||
uint8_t priority;
|
||||
uint16_t sync_address;
|
||||
uint8_t sequence_number;
|
||||
uint8_t options;
|
||||
uint16_t universe;
|
||||
|
||||
size_t streamSize() const override;
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override;
|
||||
void iStream(ACN::PDU::Stream) override;
|
||||
void oStream(ACN::PDU::Stream) const override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -51,9 +50,9 @@ struct data_header : PDU::pdu_header {
|
|||
* @brief 6.2.6 E1.31 Data Packet: Options
|
||||
*/
|
||||
enum options_t : uint8_t {
|
||||
PREVIEW_DATA = 0b10000000, // Bit 7 = Preview_Data
|
||||
STREAM_TERMINATED = 0b01000000, // Bit 6 = Stream_Terminated
|
||||
FORCE_SYNCHRONIZATION = 0b00100000, // Bit 5 = Force_Synchronization
|
||||
PREVIEW_DATA = 0b10000000, //!< Bit 7 = Preview_Data
|
||||
STREAM_TERMINATED = 0b01000000, //!< Bit 6 = Stream_Terminated
|
||||
FORCE_SYNCHRONIZATION = 0b00100000, //!< Bit 5 = Force_Synchronization
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,11 +60,11 @@ enum options_t : uint8_t {
|
|||
* @brief The DATA::Pdu class
|
||||
*/
|
||||
class Pdu
|
||||
: public PDU::Pdu
|
||||
: public ACN::PDU::Pdu
|
||||
{
|
||||
public:
|
||||
Pdu();
|
||||
void iStream(PDU::Stream) override;
|
||||
void iStream(ACN::PDU::Stream) override;
|
||||
};
|
||||
|
||||
} // DATA
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "acn/rlp.h"
|
||||
#include "extended.h"
|
||||
#include "config.h"
|
||||
|
||||
|
@ -34,9 +35,9 @@ namespace EXTENDED {
|
|||
*/
|
||||
size_t sync_header::streamSize() const
|
||||
{
|
||||
return sizeof(sequence_number)
|
||||
+ sizeof(sync_address)
|
||||
+ sizeof(reserved);
|
||||
return sizeof(sequence_number)
|
||||
+ sizeof(sync_address)
|
||||
+ sizeof(reserved);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,13 +45,13 @@ size_t sync_header::streamSize() const
|
|||
* @brief frame_sync_header::iStream
|
||||
* @param stream
|
||||
*/
|
||||
void sync_header::iStream(PDU::Stream stream)
|
||||
void sync_header::iStream(ACN::PDU::Stream stream)
|
||||
{
|
||||
*stream >> sequence_number;
|
||||
*stream >> sync_address;
|
||||
stream->read(reserved, sizeof(reserved));
|
||||
if (stream->gcount() != sizeof(reserved))
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
*stream >> sequence_number;
|
||||
*stream >> sync_address;
|
||||
stream->read(reserved, sizeof(reserved));
|
||||
if (stream->gcount() != sizeof(reserved))
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,7 +59,7 @@ void sync_header::iStream(PDU::Stream stream)
|
|||
* @brief sync_header::oStream
|
||||
* @return
|
||||
*/
|
||||
void sync_header::oStream(__attribute__((unused)) PDU::Stream stream) const
|
||||
void sync_header::oStream(ACN::PDU::Stream) const
|
||||
{
|
||||
/// TODO: write header to stream
|
||||
}
|
||||
|
@ -70,8 +71,8 @@ void sync_header::oStream(__attribute__((unused)) PDU::Stream stream) const
|
|||
*/
|
||||
size_t discovery_header::streamSize() const
|
||||
{
|
||||
return sizeof(source_name)
|
||||
+ sizeof(reserved);
|
||||
return sizeof(source_name)
|
||||
+ sizeof(reserved);
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,14 +80,14 @@ size_t discovery_header::streamSize() const
|
|||
* @brief discovery_header::iStream
|
||||
* @param stream
|
||||
*/
|
||||
void discovery_header::iStream(PDU::Stream stream)
|
||||
void discovery_header::iStream(ACN::PDU::Stream stream)
|
||||
{
|
||||
stream->read(source_name, sizeof(source_name));
|
||||
if (stream->gcount() != sizeof(source_name))
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
stream->read(reserved, sizeof(reserved));
|
||||
if (stream->gcount() != sizeof(reserved))
|
||||
stream->setstate(std::ios_base::failbit);
|
||||
stream->read(source_name, sizeof(source_name));
|
||||
if (stream->gcount() != sizeof(source_name))
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
stream->read(reserved, sizeof(reserved));
|
||||
if (stream->gcount() != sizeof(reserved))
|
||||
return stream->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,7 +95,7 @@ void discovery_header::iStream(PDU::Stream stream)
|
|||
* @brief discovery_header::oStream
|
||||
* @return
|
||||
*/
|
||||
void discovery_header::oStream(__attribute__((unused)) PDU::Stream stream) const
|
||||
void discovery_header::oStream(ACN::PDU::Stream) const
|
||||
{
|
||||
/// TODO: write header to stream
|
||||
}
|
||||
|
@ -105,29 +106,27 @@ void discovery_header::oStream(__attribute__((unused)) PDU::Stream stream) const
|
|||
* @param stream
|
||||
*/
|
||||
Pdu::Pdu()
|
||||
: PDU::Pdu(4) // vectors are 4 octets
|
||||
: ACN::PDU::Pdu(4) // vectors are 4 octets
|
||||
{
|
||||
}
|
||||
|
||||
void Pdu::iStream(PDU::Stream stream)
|
||||
void Pdu::iStream(ACN::PDU::Stream stream)
|
||||
{
|
||||
PDU::Pdu::iStream(stream);
|
||||
if (stream->fail()) return;
|
||||
ACN::PDU::Pdu::iStream(stream);
|
||||
if (stream->fail()) return;
|
||||
|
||||
switch(vector_)
|
||||
{
|
||||
case VECTOR_E131_EXTENDED_SYNCHRONIZATION:
|
||||
createHeader<sync_header>();
|
||||
break;
|
||||
case VECTOR_E131_EXTENDED_DISCOVERY:
|
||||
{
|
||||
createHeader<discovery_header>();
|
||||
createDataBlock<DISCOVERY::Pdu>();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch(vector_)
|
||||
{
|
||||
case VECTOR_E131_EXTENDED_SYNCHRONIZATION:
|
||||
createHeader<sync_header>();
|
||||
break;
|
||||
case VECTOR_E131_EXTENDED_DISCOVERY:
|
||||
createHeader<discovery_header>();
|
||||
createDataBlock<DISCOVERY::Pdu>();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
namespace DISCOVERY {
|
||||
|
@ -138,8 +137,8 @@ namespace DISCOVERY {
|
|||
*/
|
||||
size_t discovery_list_header::streamSize() const
|
||||
{
|
||||
return sizeof(page)
|
||||
+ sizeof(last_page);
|
||||
return sizeof(page)
|
||||
+ sizeof(last_page);
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,10 +146,10 @@ size_t discovery_list_header::streamSize() const
|
|||
* @brief discovery_list_header::iStream
|
||||
* @param stream
|
||||
*/
|
||||
void discovery_list_header::iStream(PDU::Stream stream)
|
||||
void discovery_list_header::iStream(ACN::PDU::Stream stream)
|
||||
{
|
||||
*stream >> page;
|
||||
*stream >> last_page;
|
||||
*stream >> page;
|
||||
*stream >> last_page;
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,7 +157,7 @@ void discovery_list_header::iStream(PDU::Stream stream)
|
|||
* @brief discovery_list_header::oStream
|
||||
* @return
|
||||
*/
|
||||
void discovery_list_header::oStream(__attribute__((unused)) PDU::Stream stream) const
|
||||
void discovery_list_header::oStream(ACN::PDU::Stream) const
|
||||
{
|
||||
/// TODO: write header to stream
|
||||
}
|
||||
|
@ -168,9 +167,10 @@ void discovery_list_header::oStream(__attribute__((unused)) PDU::Stream stream)
|
|||
* @brief discovery_list_data::iStream
|
||||
* @param stream
|
||||
*/
|
||||
void discovery_list_data::iStream(PDU::Stream stream)
|
||||
void discovery_list_data::iStream(ACN::PDU::Stream stream)
|
||||
{
|
||||
while (stream->good()) {
|
||||
while (stream->good())
|
||||
{
|
||||
auto f = discoveredUniverse();
|
||||
*stream >> f.universe;
|
||||
found.push_back(f);
|
||||
|
@ -182,7 +182,7 @@ void discovery_list_data::iStream(PDU::Stream stream)
|
|||
* @brief discovery_list_data::oStream
|
||||
* @param stream
|
||||
*/
|
||||
void discovery_list_data::oStream(PDU::Stream stream) const
|
||||
void discovery_list_data::oStream(ACN::PDU::Stream stream) const
|
||||
{
|
||||
for (auto & d : found)
|
||||
*stream << d.universe;
|
||||
|
@ -194,7 +194,7 @@ void discovery_list_data::oStream(PDU::Stream stream) const
|
|||
* @param stream
|
||||
*/
|
||||
Pdu::Pdu()
|
||||
: PDU::Pdu(4) // vectors are 4 octets
|
||||
: ACN::PDU::Pdu(4) // vectors are 4 octets
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -203,9 +203,9 @@ Pdu::Pdu()
|
|||
* @brief Pdu::iStream
|
||||
* @param stream
|
||||
*/
|
||||
void Pdu::iStream(PDU::Stream stream)
|
||||
void Pdu::iStream(ACN::PDU::Stream stream)
|
||||
{
|
||||
PDU::Pdu::iStream(stream);
|
||||
ACN::PDU::Pdu::iStream(stream);
|
||||
if (stream->fail()) return;
|
||||
|
||||
createHeader<discovery_list_header>();
|
||||
|
@ -214,7 +214,7 @@ void Pdu::iStream(PDU::Stream stream)
|
|||
if (data_)
|
||||
{
|
||||
auto data = static_cast<discovery_list_data*>(data_);
|
||||
auto root_header = static_cast<RLP::rlp_header*>(parent_->parent()->header());
|
||||
auto root_header = static_cast<ACN::RLP::rlp_header*>(parent_->parent()->header());
|
||||
auto frame_header = static_cast<EXTENDED::discovery_header*>(parent_->header());
|
||||
for ( auto & f : data->found )
|
||||
{
|
||||
|
|
|
@ -23,26 +23,27 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "acn/pdu.h"
|
||||
#include "sacn.h"
|
||||
#include "uuid/uuid.h"
|
||||
#include <functional>
|
||||
|
||||
namespace SACN {
|
||||
using namespace ACN;
|
||||
|
||||
namespace EXTENDED {
|
||||
|
||||
/**
|
||||
* @brief 6.3 E1.31 Synchronization Packet Framing Layer
|
||||
*/
|
||||
struct sync_header
|
||||
: PDU::pdu_header
|
||||
: ACN::PDU::pdu_header
|
||||
{
|
||||
uint8_t sequence_number;
|
||||
uint16_t sync_address;
|
||||
uint8_t reserved[2];
|
||||
|
||||
size_t streamSize() const override;
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override;
|
||||
void iStream(ACN::PDU::Stream) override;
|
||||
void oStream(ACN::PDU::Stream) const override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -50,13 +51,14 @@ struct sync_header
|
|||
* @brief 6.4 E1.31 Universe Discovery Packet Framing Layer
|
||||
*/
|
||||
struct discovery_header
|
||||
: PDU::pdu_header
|
||||
: ACN::PDU::pdu_header
|
||||
{
|
||||
uint8_t source_name[64];
|
||||
uint8_t reserved[4];
|
||||
|
||||
size_t streamSize() const override;
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override;
|
||||
void iStream(ACN::PDU::Stream) override;
|
||||
void oStream(ACN::PDU::Stream) const override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -64,11 +66,11 @@ struct discovery_header
|
|||
* @brief The EXTENDED::Pdu class
|
||||
*/
|
||||
class Pdu
|
||||
: public PDU::Pdu
|
||||
: public ACN::PDU::Pdu
|
||||
{
|
||||
public:
|
||||
Pdu();
|
||||
void iStream(PDU::Stream) override;
|
||||
void iStream(ACN::PDU::Stream) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -78,13 +80,14 @@ namespace DISCOVERY {
|
|||
* @brief Table 8-9: E1.31 Universe Discovery Packet Universe Discovery Layer
|
||||
*/
|
||||
struct discovery_list_header
|
||||
: PDU::pdu_header
|
||||
: ACN::PDU::pdu_header
|
||||
{
|
||||
uint8_t page;
|
||||
uint8_t last_page;
|
||||
|
||||
size_t streamSize() const override;
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override;
|
||||
void iStream(ACN::PDU::Stream) override;
|
||||
void oStream(ACN::PDU::Stream) const override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -105,12 +108,13 @@ using Watcher = std::function<void(std::shared_ptr<discoveredUniverse>)>;
|
|||
* @brief The discovery_list_data struct
|
||||
*/
|
||||
struct discovery_list_data
|
||||
: PDU::pdu_data
|
||||
: ACN::PDU::pdu_data
|
||||
{
|
||||
std::vector<discoveredUniverse> found;
|
||||
size_t streamSize() const override { return found.size(); }
|
||||
void iStream(PDU::Stream) override;
|
||||
void oStream(PDU::Stream) const override;
|
||||
|
||||
size_t streamSize() const override { return found.size(); }
|
||||
void iStream(ACN::PDU::Stream) override;
|
||||
void oStream(ACN::PDU::Stream) const override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -118,11 +122,11 @@ struct discovery_list_data
|
|||
* @brief The EXTENDED::DISCOVERY::Pdu class
|
||||
*/
|
||||
class Pdu
|
||||
: public PDU::Pdu
|
||||
: public ACN::PDU::Pdu
|
||||
{
|
||||
public:
|
||||
Pdu();
|
||||
void iStream(PDU::Stream) override;
|
||||
void iStream(ACN::PDU::Stream) override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace SACN {
|
|||
Node::Node(UUID::uuid cid)
|
||||
: Appliance(cid)
|
||||
{
|
||||
fctn_ = "libESTA sACN Node";
|
||||
fctn_ = "libESTA sACN Node";
|
||||
}
|
||||
|
||||
} // SACN
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "acn/pdu.h"
|
||||
#include "receiver.h"
|
||||
#include "config.h"
|
||||
|
||||
|
@ -51,7 +52,7 @@ Receiver::Receiver(UUID::uuid cid)
|
|||
Receiver::~Receiver()
|
||||
{
|
||||
for (auto& [_, universe] : universes_)
|
||||
delete universe;
|
||||
delete universe;
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,11 +72,11 @@ void Receiver::subscribe(const uint16_t num) {
|
|||
* @param num
|
||||
*/
|
||||
void Receiver::unsubscribe(const uint16_t num) {
|
||||
// delete merging universe proxy
|
||||
if (universes_.count(num)) {
|
||||
delete universes_.at(num);
|
||||
universes_.erase(num);
|
||||
}
|
||||
if (universes_.count(num))
|
||||
{
|
||||
delete universes_.at(num);
|
||||
universes_.erase(num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,7 +96,7 @@ Universe * Receiver::universe(const uint16_t num) {
|
|||
* @brief Receiver::discoveryStart
|
||||
*/
|
||||
void Receiver::discoveryStart() {
|
||||
subscribe(SACN::E131_DISCOVERY_UNIVERSE);
|
||||
subscribe(SACN::E131_DISCOVERY_UNIVERSE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,7 +104,7 @@ void Receiver::discoveryStart() {
|
|||
* @brief Receiver::discoveryStop
|
||||
*/
|
||||
void Receiver::discoveryStop() {
|
||||
unsubscribe(SACN::E131_DISCOVERY_UNIVERSE);
|
||||
unsubscribe(SACN::E131_DISCOVERY_UNIVERSE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,17 +123,17 @@ 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)
|
||||
void Receiver::dataReceiver(std::shared_ptr<ACN::RLP::Pdu> root)
|
||||
{
|
||||
root->createDataBlock<DATA::Pdu>();
|
||||
auto block = static_cast<PDU::Block<DATA::Pdu>*>(root->data());
|
||||
auto block = static_cast<ACN::PDU::Block<DATA::Pdu>*>(root->data());
|
||||
|
||||
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.
|
||||
/// 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);
|
||||
|
@ -150,19 +151,19 @@ 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)
|
||||
void Receiver::extendedReceiver(std::shared_ptr<ACN::RLP::Pdu> root)
|
||||
{
|
||||
root->createDataBlock<EXTENDED::Pdu>();
|
||||
auto block = static_cast<PDU::Block<EXTENDED::Pdu>*>(root->data());
|
||||
auto block = static_cast<ACN::PDU::Block<EXTENDED::Pdu>*>(root->data());
|
||||
|
||||
for(auto const &frame : *block->pdu)
|
||||
{
|
||||
switch(frame->vector()) {
|
||||
// 6.3 E1.31 Synchronization Packet Framing Layer
|
||||
/// 6.3 E1.31 Synchronization Packet Framing Layer
|
||||
case VECTOR_E131_EXTENDED_SYNCHRONIZATION:
|
||||
syncFrameHandler(frame);
|
||||
break;
|
||||
// 6.4 E1.31 Universe Discovery Packet Framing Layer
|
||||
/// 6.4 E1.31 Universe Discovery Packet Framing Layer
|
||||
case VECTOR_E131_EXTENDED_DISCOVERY:
|
||||
discoveryFrameHandler(frame);
|
||||
break;
|
||||
|
@ -190,47 +191,48 @@ void Receiver::dataFrameHandler(std::shared_ptr<DATA::Pdu> frame) {
|
|||
return;
|
||||
auto universe = universes_.at(source->universe())->sourceUniverse(*source);
|
||||
|
||||
// 6.2.3 E1.31 Data Packet: Priority
|
||||
// No priority outside the range of 0 to 200 shall be transmitted on
|
||||
// the network.
|
||||
/// 6.2.3 E1.31 Data Packet: Priority
|
||||
/// No priority outside the range of 0 to 200 shall be transmitted on
|
||||
/// the network.
|
||||
if (source->priority() > 200)
|
||||
frame->stream()->setstate(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.
|
||||
/// 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 (source->isPreview())
|
||||
return;
|
||||
|
||||
// 6.2.6 E1.31 Data Packet: Options
|
||||
// Stream_Terminated: Bit 6
|
||||
// allow E1.31 sources to terminate transmission of a stream or of
|
||||
// universe synchronization without waiting for a timeout to occur.
|
||||
// Any property values in an E1.31 Data Packet containing this bit
|
||||
// shall be ignored.
|
||||
/// 6.2.6 E1.31 Data Packet: Options
|
||||
/// Stream_Terminated: Bit 6
|
||||
/// allow E1.31 sources to terminate transmission of a stream or of
|
||||
/// universe synchronization without waiting for a timeout to occur.
|
||||
/// Any property values in an E1.31 Data Packet containing this bit
|
||||
/// shall be ignored.
|
||||
if (source->isTerminated()) {
|
||||
universes_[source->universe()]->deleteSourceUniverse(*source);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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.
|
||||
/// 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 (source->syncAddress() != 0)
|
||||
subscribe(source->syncAddress());
|
||||
|
||||
// PDU data will be a block of DMP
|
||||
auto block = static_cast<PDU::Block<DMP::Pdu>*>(frame->data());
|
||||
auto block = static_cast<ACN::PDU::Block<ACN::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.
|
||||
/// 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:
|
||||
case ACN::DMP::SET_PROPERTY:
|
||||
universe->set(dmp, source);
|
||||
break;
|
||||
default:
|
||||
|
@ -246,11 +248,7 @@ void Receiver::dataFrameHandler(std::shared_ptr<DATA::Pdu> frame) {
|
|||
*/
|
||||
void Receiver::syncFrameHandler(std::shared_ptr<EXTENDED::Pdu> frame)
|
||||
{
|
||||
#if defined(RTTI_ENABLED)
|
||||
auto header = dynamic_cast<EXTENDED::frame_sync_header*>(frame->header());
|
||||
#else
|
||||
auto header = static_cast<EXTENDED::sync_header*>(frame->header());
|
||||
#endif
|
||||
universes_.at(header->sync_address)->synchronize();
|
||||
}
|
||||
|
||||
|
@ -260,14 +258,13 @@ void Receiver::syncFrameHandler(std::shared_ptr<EXTENDED::Pdu> frame)
|
|||
* @param frame
|
||||
*/
|
||||
void Receiver::discoveryFrameHandler(std::shared_ptr<EXTENDED::Pdu> frame) {
|
||||
// PDU data will be a block of Discovery List PDU
|
||||
auto block = static_cast<PDU::Block<EXTENDED::DISCOVERY::Pdu>*>(frame->data());
|
||||
auto block = static_cast<ACN::PDU::Block<EXTENDED::DISCOVERY::Pdu>*>(frame->data());
|
||||
for(auto const &pdu : *block->pdu)
|
||||
{
|
||||
// 8 Universe Discovery Layer
|
||||
// Universe Discovery data only appears in E1.31 Universe Discovery
|
||||
// Packets and shall not be included in E1.31 Data Packets or E1.31
|
||||
// Synchronization Packets.
|
||||
/// 8 Universe Discovery Layer
|
||||
/// Universe Discovery data only appears in E1.31 Universe Discovery
|
||||
/// Packets and shall not be included in E1.31 Data Packets or E1.31
|
||||
/// Synchronization Packets.
|
||||
switch(pdu->vector()) {
|
||||
case VECTOR_UNIVERSE_DISCOVERY_UNIVERSE_LIST:
|
||||
discoveryListHanlder(pdu);
|
||||
|
|
|
@ -23,17 +23,19 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "acn/appliance.h"
|
||||
#include "data.h"
|
||||
#include "extended.h"
|
||||
#include "sacn.h"
|
||||
#include "universe.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace SACN {
|
||||
|
||||
class Receiver
|
||||
: public virtual Appliance
|
||||
: public virtual ACN::Appliance
|
||||
{
|
||||
public:
|
||||
Receiver(UUID::uuid = UUID::uuid());
|
||||
|
@ -49,8 +51,8 @@ public:
|
|||
|
||||
protected:
|
||||
// 5 - E1.31 use of the ACN Root Layer Protocol
|
||||
void dataReceiver(std::shared_ptr<RLP::Pdu>);
|
||||
void extendedReceiver(std::shared_ptr<RLP::Pdu>);
|
||||
void dataReceiver(std::shared_ptr<ACN::RLP::Pdu>);
|
||||
void extendedReceiver(std::shared_ptr<ACN::RLP::Pdu>);
|
||||
|
||||
// 6.2 E1.31 Data Packet Framing Layer
|
||||
void dataFrameHandler(std::shared_ptr<DATA::Pdu>);
|
||||
|
|
|
@ -24,11 +24,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "../acn/acn.h"
|
||||
|
||||
// E1.31 Lightweight streaming protocol for transport of DMX512 using ACN
|
||||
namespace SACN {
|
||||
using namespace ACN;
|
||||
|
||||
// Appendix A: Defined Parameters (Normative)
|
||||
static const uint32_t VECTOR_ROOT_E131_DATA = 0x00000004;
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace SACN {
|
|||
Source::Source(UUID::uuid cid)
|
||||
: Appliance(cid)
|
||||
{
|
||||
fctn_ = "libESTA sACN Source";
|
||||
fctn_ = "libESTA sACN Source";
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,15 +42,15 @@ Source::Source(UUID::uuid cid)
|
|||
*/
|
||||
void Source::create(const uint16_t num)
|
||||
{
|
||||
if (universes_.count(num))
|
||||
return;
|
||||
universes_.emplace(num, new Universe());
|
||||
if (universes_.count(num))
|
||||
return;
|
||||
universes_.emplace(num, new Universe());
|
||||
|
||||
auto source = std::shared_ptr<UniverseSource>(new UniverseSource());
|
||||
source->setCID(this->cid());
|
||||
source->setDescription(this->name());
|
||||
source->setUniverse(num);
|
||||
universes_[num]->setSource(source);
|
||||
auto source = std::shared_ptr<UniverseSource>(new UniverseSource());
|
||||
source->setCID(this->cid());
|
||||
source->setDescription(this->name());
|
||||
source->setUniverse(num);
|
||||
universes_[num]->setSource(source);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,13 +60,13 @@ void Source::create(const uint16_t num)
|
|||
*/
|
||||
void Source::terminate(const uint16_t num)
|
||||
{
|
||||
if (!universes_.count(num))
|
||||
return;
|
||||
if (!universes_.count(num))
|
||||
return;
|
||||
|
||||
auto source = universes_[num]->source();
|
||||
source->setOptions(0 | source->isForced()
|
||||
| source->isPreview()
|
||||
| DATA::STREAM_TERMINATED);
|
||||
auto source = universes_[num]->source();
|
||||
source->setOptions(0 | source->isForced()
|
||||
| source->isPreview()
|
||||
| DATA::STREAM_TERMINATED);
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,10 +76,10 @@ void Source::terminate(const uint16_t num)
|
|||
*/
|
||||
void Source::end(const uint16_t num)
|
||||
{
|
||||
if (!universes_.count(num))
|
||||
return;
|
||||
if (!universes_.count(num))
|
||||
return;
|
||||
|
||||
universes_.erase(num);
|
||||
universes_.erase(num);
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,10 +90,10 @@ void Source::end(const uint16_t num)
|
|||
*/
|
||||
Universe * Source::universe(const uint16_t num)
|
||||
{
|
||||
if (!universes_.count(num))
|
||||
return 0;
|
||||
if (!universes_.count(num))
|
||||
return 0;
|
||||
|
||||
return universes_.at(num);
|
||||
return universes_.at(num);
|
||||
}
|
||||
|
||||
} // SACN
|
||||
|
|
|
@ -23,15 +23,17 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "acn/appliance.h"
|
||||
#include "sacn.h"
|
||||
#include "universe.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace SACN {
|
||||
|
||||
|
||||
class Source
|
||||
: public virtual Appliance
|
||||
: public virtual ACN::Appliance
|
||||
{
|
||||
public:
|
||||
Source(UUID::uuid = UUID::uuid());
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "acn/rlp.h"
|
||||
#include "universe.h"
|
||||
#include "config.h"
|
||||
|
||||
|
@ -48,13 +49,8 @@ UniverseSource::UniverseSource()
|
|||
*/
|
||||
UniverseSource::UniverseSource(std::shared_ptr<DATA::Pdu> pdu)
|
||||
{
|
||||
#if defined(RTTI_ENABLED)
|
||||
auto root_header = dynamic_cast<RLP::rlp_header*>(pdu->parent()->header());
|
||||
auto frame_header = dynamic_cast<DATA::data_header*>(pdu->header());
|
||||
#else
|
||||
auto root_header = static_cast<RLP::rlp_header*>(pdu->parent()->header());
|
||||
auto root_header = static_cast<ACN::RLP::rlp_header*>(pdu->parent()->header());
|
||||
auto frame_header = static_cast<DATA::data_header*>(pdu->header());
|
||||
#endif
|
||||
|
||||
cid_ = root_header->cid;
|
||||
description_ = std::string((char*)frame_header->source_name);
|
||||
|
@ -73,7 +69,7 @@ UniverseSource::UniverseSource(std::shared_ptr<DATA::Pdu> pdu)
|
|||
*/
|
||||
bool operator== (const UniverseSource& a, const UniverseSource& b)
|
||||
{
|
||||
return (std::hash<UniverseSource>{}(a) == std::hash<UniverseSource>{}(b));
|
||||
return (std::hash<UniverseSource>{}(a) == std::hash<UniverseSource>{}(b));
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,7 +80,7 @@ Universe::Universe()
|
|||
: DMX::Universe(E131_NETWORK_DATA_LOSS_TIMEOUT)
|
||||
{
|
||||
sync_data_.clear();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -98,11 +94,12 @@ Universe::~Universe()
|
|||
/**
|
||||
Set universe data from a DMP PDU from a UniverseSource.
|
||||
*/
|
||||
void Universe::set(std::shared_ptr<DMP::Pdu> dmp,
|
||||
std::shared_ptr<UniverseSource> source) {
|
||||
// 7.3 Address Type and Data Type
|
||||
// Sources shall set the DMP Layer's Address Type and Data Type to 0xa1.
|
||||
// Receivers shall discard the packet if the received value is not 0xa1.
|
||||
void Universe::set(std::shared_ptr<ACN::DMP::Pdu> dmp,
|
||||
std::shared_ptr<UniverseSource> source)
|
||||
{
|
||||
/// 7.3 Address Type and Data Type
|
||||
/// Sources shall set the DMP Layer's Address Type and Data Type to 0xa1.
|
||||
/// Receivers shall discard the packet if the received value is not 0xa1.
|
||||
if (!dmp->header())
|
||||
return;
|
||||
auto type = static_cast<ACN::DMP::address_type*>(dmp->header());
|
||||
|
@ -116,34 +113,35 @@ void Universe::set(std::shared_ptr<DMP::Pdu> dmp,
|
|||
auto set_data = static_cast<ACN::DMP::address_pair_list*>(dmp->data());
|
||||
const auto& [range, data] = set_data->properties.front();
|
||||
|
||||
// 7.4 First Property Address
|
||||
// Sources shall set the DMP Layer's First Property Address to 0x0000.
|
||||
// Receivers shall discard the packet if the received value is not 0x0000.
|
||||
/// 7.4 First Property Address
|
||||
/// Sources shall set the DMP Layer's First Property Address to 0x0000.
|
||||
/// Receivers shall discard the packet if the received value is not 0x0000.
|
||||
if (range.address != 0)
|
||||
return;
|
||||
|
||||
// 7.5 Address Increment
|
||||
// Sources shall set the DMP Layer's Address Increment to 0x0001.
|
||||
// Receivers shall discard the packet if the received value is not 0x0001.
|
||||
/// 7.5 Address Increment
|
||||
/// Sources shall set the DMP Layer's Address Increment to 0x0001.
|
||||
/// Receivers shall discard the packet if the received value is not 0x0001.
|
||||
if (range.incriment != 1)
|
||||
return;
|
||||
|
||||
// 7.6 Property Value Count
|
||||
// The DMP Layer's Property Value Count is used to encode the number of
|
||||
// DMX512-A [DMX] Slots (including the START Code slot).
|
||||
/// 7.6 Property Value Count
|
||||
/// The DMP Layer's Property Value Count is used to encode the number of
|
||||
/// DMX512-A [DMX] Slots (including the START Code slot).
|
||||
if (range.count < 1 || range.count > 513)
|
||||
return;
|
||||
|
||||
setSource(source);
|
||||
|
||||
// 7.7 Property Values (DMX512-A Data)
|
||||
// The DMP Layer's Property values field is used to encode the
|
||||
// DMX512-A [DMX] START Code and data.
|
||||
/// 7.7 Property Values (DMX512-A Data)
|
||||
/// The DMP Layer's Property values field is used to encode the
|
||||
/// DMX512-A [DMX] START Code and data.
|
||||
|
||||
// 6.2.4.1 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 (source->syncAddress() == 0) {
|
||||
/// 6.2.4.1 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 (source->syncAddress() == 0)
|
||||
{
|
||||
sync_data_.clear();
|
||||
DMX::Universe::setData(data);
|
||||
}
|
||||
|
@ -164,15 +162,15 @@ void Universe::setSource(std::shared_ptr<UniverseSource> source)
|
|||
|
||||
uint8_t Universe::slot(const uint16_t addr)
|
||||
{
|
||||
// 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.
|
||||
/// 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 (isSyncronized() && source()->isForced() && rxRate() == 0)
|
||||
synchronize();
|
||||
|
||||
|
@ -267,10 +265,11 @@ bool MergeProxyUniverse::hasSources() const
|
|||
*/
|
||||
void MergeProxyUniverse::deleteSourceUniverse(const UniverseSource& src)
|
||||
{
|
||||
if (sources_.count(src)) {
|
||||
delete sources_.at(src);
|
||||
sources_.erase(src);
|
||||
}
|
||||
if (sources_.count(src))
|
||||
{
|
||||
delete sources_.at(src);
|
||||
sources_.erase(src);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -289,11 +288,7 @@ void MergeProxyUniverse::addSourceUniverse(Universe* universe)
|
|||
*/
|
||||
void MergeProxyUniverse::dataChangedNotifier(DMX::Universe* dmx)
|
||||
{
|
||||
#if defined(RTTI_ENABLED)
|
||||
auto sacn = static_cast<SACN::Universe*>(dmx);
|
||||
#else
|
||||
auto sacn = static_cast<SACN::Universe*>(dmx);
|
||||
#endif
|
||||
auto universe = dominant_();
|
||||
if (!universe)
|
||||
return;
|
||||
|
@ -310,7 +305,8 @@ void MergeProxyUniverse::dataChangedNotifier(DMX::Universe* dmx)
|
|||
bool MergeProxyUniverse::isSyncronized() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe) return false;
|
||||
if (!universe)
|
||||
return false;
|
||||
return universe->isSyncronized();
|
||||
}
|
||||
|
||||
|
@ -322,7 +318,8 @@ bool MergeProxyUniverse::isSyncronized() const
|
|||
std::shared_ptr<UniverseSource> MergeProxyUniverse::source() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe) return nullptr;
|
||||
if (!universe)
|
||||
return nullptr;
|
||||
return universe->source();
|
||||
}
|
||||
|
||||
|
@ -332,7 +329,7 @@ std::shared_ptr<UniverseSource> MergeProxyUniverse::source() const
|
|||
* @param pdu
|
||||
* @param source
|
||||
*/
|
||||
void MergeProxyUniverse::set(std::shared_ptr<DMP::Pdu> pdu,
|
||||
void MergeProxyUniverse::set(std::shared_ptr<ACN::DMP::Pdu> pdu,
|
||||
std::shared_ptr<UniverseSource> src)
|
||||
{
|
||||
if (!sources_.count(*src))
|
||||
|
@ -359,7 +356,8 @@ void MergeProxyUniverse::synchronize()
|
|||
const DMX::DimmerData * MergeProxyUniverse::data() const
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe) return nullptr;
|
||||
if (!universe)
|
||||
return nullptr;
|
||||
return universe->data();
|
||||
}
|
||||
|
||||
|
@ -372,7 +370,8 @@ const DMX::DimmerData * MergeProxyUniverse::data() const
|
|||
uint8_t MergeProxyUniverse::slot(const uint16_t s)
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe) return 0;
|
||||
if (!universe)
|
||||
return 0;
|
||||
return universe->slot(s);
|
||||
}
|
||||
|
||||
|
@ -384,7 +383,8 @@ uint8_t MergeProxyUniverse::slot(const uint16_t s)
|
|||
double MergeProxyUniverse::rxRate()
|
||||
{
|
||||
auto universe = dominant_();
|
||||
if (!universe) return 0.0;
|
||||
if (!universe)
|
||||
return 0.0;
|
||||
return universe->rxRate();
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,8 @@ double MergeProxyUniverse::rxRate()
|
|||
Universe* MergeProxyUniverse::dominant_() const
|
||||
{
|
||||
Universe* ret = nullptr;
|
||||
for (auto& [_, uni] : sources_) {
|
||||
for (auto& [_, uni] : sources_)
|
||||
{
|
||||
if (uni->rxRate() < 1) // stale universes cannot be dominant
|
||||
continue;
|
||||
if (!ret || uni->source()->priority() > ret->source()->priority())
|
||||
|
|
|
@ -23,10 +23,12 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "sacn.h"
|
||||
#include "acn/dmp.h"
|
||||
#include "data.h"
|
||||
#include "../dmx/universe.h"
|
||||
#include "../uuid/uuid.h"
|
||||
#include "dmx/universe.h"
|
||||
#include "sacn.h"
|
||||
#include "uuid/uuid.h"
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
@ -112,7 +114,7 @@ public:
|
|||
virtual std::shared_ptr<UniverseSource> source() const { return source_; }
|
||||
virtual uint8_t slot (const uint16_t) override;
|
||||
|
||||
virtual void set(std::shared_ptr<DMP::Pdu>, std::shared_ptr<UniverseSource>);
|
||||
virtual void set(std::shared_ptr<ACN::DMP::Pdu>, std::shared_ptr<UniverseSource>);
|
||||
virtual void setSource(std::shared_ptr<UniverseSource>);
|
||||
|
||||
virtual void synchronize();
|
||||
|
@ -149,7 +151,7 @@ public:
|
|||
// SACN::Universe overrides:
|
||||
bool isSyncronized() const override;
|
||||
std::shared_ptr<UniverseSource> source() const override;
|
||||
void set(std::shared_ptr<DMP::Pdu>, std::shared_ptr<UniverseSource>) override;
|
||||
void set(std::shared_ptr<ACN::DMP::Pdu>, std::shared_ptr<UniverseSource>) override;
|
||||
void setSource(std::shared_ptr<UniverseSource>) override {};
|
||||
void synchronize() override;
|
||||
|
||||
|
|
|
@ -78,7 +78,8 @@ uuid::~uuid()
|
|||
*
|
||||
* create this UUID from a byte array
|
||||
*/
|
||||
void uuid::fromArray_(const uint8_t * bytes) {
|
||||
void uuid::fromArray_(const uint8_t * bytes)
|
||||
{
|
||||
std::memcpy(raw_, bytes, 16);
|
||||
setFields_();
|
||||
}
|
||||
|
@ -90,7 +91,8 @@ void uuid::fromArray_(const uint8_t * bytes) {
|
|||
*
|
||||
* create this UUID from a C style char array
|
||||
*/
|
||||
void uuid::fromCstring_(const char * cstr) {
|
||||
void uuid::fromCstring_(const char * cstr)
|
||||
{
|
||||
fromString_(std::string(cstr));
|
||||
}
|
||||
|
||||
|
@ -101,7 +103,8 @@ void uuid::fromCstring_(const char * cstr) {
|
|||
*
|
||||
* create this UUID from a string representation
|
||||
*/
|
||||
void uuid::fromString_(std::string str) {
|
||||
void uuid::fromString_(std::string str)
|
||||
{
|
||||
// remove formating
|
||||
if (str.front() == '{' && str.back() == '}')
|
||||
str = str.substr(1, str.size() - 2);
|
||||
|
@ -122,7 +125,8 @@ void uuid::fromString_(std::string str) {
|
|||
*
|
||||
* output this UUID as a hex string
|
||||
*/
|
||||
std::string uuid::hex() const {
|
||||
std::string uuid::hex() const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::hex;
|
||||
for (int i = 0; i < 16; i++)
|
||||
|
@ -137,7 +141,8 @@ std::string uuid::hex() const {
|
|||
*
|
||||
* output this UUID as formated hex string
|
||||
*/
|
||||
std::string uuid::string() const {
|
||||
std::string uuid::string() const
|
||||
{
|
||||
std::string str = hex();
|
||||
str.reserve(str.length() + 6);
|
||||
for (int idx : {8, 13, 18, 23})
|
||||
|
@ -154,7 +159,8 @@ std::string uuid::string() const {
|
|||
*
|
||||
* output this UUID as a urn specified in RFC 4122
|
||||
*/
|
||||
std::string uuid::urn() const {
|
||||
std::string uuid::urn() const
|
||||
{
|
||||
return "urn:uuid:" + string();
|
||||
}
|
||||
|
||||
|
@ -302,16 +308,16 @@ void uuid::setRFC4122Fields_()
|
|||
*
|
||||
* exctract the type from the raw bytes
|
||||
*/
|
||||
void uuid::setType_() {
|
||||
if ((raw_[8] >> 7) == 0b0) {
|
||||
void uuid::setType_()
|
||||
{
|
||||
if ((raw_[8] >> 7) == 0b0)
|
||||
type_ = NCS;
|
||||
} else if ((raw_[8] >> 6) == 0b10) {
|
||||
else if ((raw_[8] >> 6) == 0b10)
|
||||
type_ = RFC4122;
|
||||
} else if ((raw_[8] >> 5) == 0b110) {
|
||||
else if ((raw_[8] >> 5) == 0b110)
|
||||
type_ = MS;
|
||||
} else {
|
||||
else
|
||||
type_ = RESVERED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -322,7 +328,8 @@ void uuid::setType_() {
|
|||
*/
|
||||
uuid& uuid::operator=(const uuid& other)
|
||||
{
|
||||
if (this != &other) { // protect against invalid self-assignment
|
||||
if (this != &other) // protect against invalid self-assignment
|
||||
{
|
||||
std::memcpy(raw_, other.raw_, 16);
|
||||
setFields_();
|
||||
}
|
||||
|
@ -401,9 +408,4 @@ uint64_t uuid::now_()
|
|||
return periods;
|
||||
}
|
||||
|
||||
// const std::string NAMESPACE_DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
||||
// const std::string NAMESPACE_URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
||||
// const std::string NAMESPACE_OID = "6ba7b812-9dad-11d1-80b4-00c04fd430c8";
|
||||
// const std::string NAMESPACE_X500 = "6ba7b814-9dad-11d1-80b4-00c04fd430c8";
|
||||
|
||||
}; // UUID
|
||||
|
|
10
uuid/uuid.h
10
uuid/uuid.h
|
@ -100,12 +100,10 @@ struct RFC4122Fields {
|
|||
*/
|
||||
static const uint64_t UUID_TICKS_BETWEEK_EPOCH = 122192928000000000;
|
||||
|
||||
|
||||
// extern const std::string NAMESPACE_DNS;
|
||||
// extern const std::string NAMESPACE_URL;
|
||||
// extern const std::string NAMESPACE_OID;
|
||||
// extern const std::string NAMESPACE_X500;
|
||||
|
||||
//static const char* NAMESPACE_DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
||||
//static const char* NAMESPACE_URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
||||
//static const char* NAMESPACE_OID = "6ba7b812-9dad-11d1-80b4-00c04fd430c8";
|
||||
//static const char* NAMESPACE_X500 = "6ba7b814-9dad-11d1-80b4-00c04fd430c8";
|
||||
|
||||
/**
|
||||
* @brief The uuid class
|
||||
|
|
Loading…
Reference in New Issue