Skip to content

Commit

Permalink
Merge pull request #1939 from peternewman/e1.33-cherry-pick
Browse files Browse the repository at this point in the history
E1.33 cherry pick
  • Loading branch information
peternewman committed Mar 16, 2024
2 parents ff8bf86 + cb1d8f7 commit e7b4039
Show file tree
Hide file tree
Showing 19 changed files with 828 additions and 35 deletions.
70 changes: 70 additions & 0 deletions include/ola/acn/ACNFlags.h
@@ -0,0 +1,70 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* ACNFlags.h
* Flags used in ACN PDUs
* Copyright (C) 2020 Peter Newman
*/

#ifndef INCLUDE_OLA_ACN_ACNFLAGS_H_
#define INCLUDE_OLA_ACN_ACNFLAGS_H_

/**
* @addtogroup acn
* @{
* @file ACNFlags.h
* @brief ACN flag values.
* @}
*/

#include <stdint.h>

namespace ola {
namespace acn {

/**
* @addtogroup acn
* @{
*/

// masks for the flag fields
/**
* @brief This indicates a 20 bit length field (default is 12 bits)
*/
static const uint8_t LFLAG_MASK = 0x80;

/**
* @brief This indicates a vector is present
*/
static const uint8_t VFLAG_MASK = 0x40;

/**
* @brief This indicates a header field is present
*/
static const uint8_t HFLAG_MASK = 0x20;

/**
* @brief This indicates a data field is present
*/
static const uint8_t DFLAG_MASK = 0x10;

/**
* @}
*/

} // namespace acn
} // namespace ola

#endif // INCLUDE_OLA_ACN_ACNFLAGS_H_
14 changes: 13 additions & 1 deletion include/ola/acn/ACNVectors.h
Expand Up @@ -45,8 +45,11 @@ namespace acn {
enum RootVector {
VECTOR_ROOT_E131_REV2 = 3, /**< Draft E1.31, used by some old gear. */
VECTOR_ROOT_E131 = 4, /**< E1.31 (sACN) */
VECTOR_ROOT_E133 = 5, /**< E1.33 (RDNNet) */
VECTOR_ROOT_RPT = 5, /**< E1.33 (RPT) */
VECTOR_ROOT_NULL = 6, /**< NULL (empty) root */
VECTOR_ROOT_BROKER = 9, /**< E1.33 (Broker) */
VECTOR_ROOT_LLRP = 0x0A, /**< E1.33 (LLRP) */
VECTOR_ROOT_EPT = 0x0B, /**< E1.33 (EPT) */
};

/**
Expand Down Expand Up @@ -87,6 +90,15 @@ enum E133ControllerVector {
VECTOR_CONTROLLER_EXPECT_MASTER = 5, /**< Expect master message */
};

/**
* @brief Vectors used at the E1.33 LLRP layer.
*/
enum LLRPVector {
VECTOR_LLRP_PROBE_REQUEST = 1, /**< LLRP Probe Request */
VECTOR_LLRP_PROBE_REPLY = 1, /**< LLRP Probe Reply */
VECTOR_LLRP_RDM_CMD = 1, /**< LLRP RDM Command */
};

/**
* @}
*/
Expand Down
1 change: 1 addition & 0 deletions include/ola/acn/Makefile.mk
Expand Up @@ -3,6 +3,7 @@ olaacninclude_HEADERS =

if INSTALL_ACN
olaacninclude_HEADERS += \
include/ola/acn/ACNFlags.h \
include/ola/acn/ACNPort.h \
include/ola/acn/ACNVectors.h \
include/ola/acn/CID.h
Expand Down
4 changes: 2 additions & 2 deletions libs/acn/BaseInflator.cpp
Expand Up @@ -163,7 +163,7 @@ bool BaseInflator::DecodeLength(const uint8_t *data,
bool BaseInflator::DecodeVector(uint8_t flags, const uint8_t *data,
unsigned int length, uint32_t *vector,
unsigned int *bytes_used) {
if (flags & PDU::VFLAG_MASK) {
if (flags & ola::acn::VFLAG_MASK) {
if ((unsigned int) m_vector_size > length) {
*vector = 0;
*bytes_used = 0;
Expand Down Expand Up @@ -223,7 +223,7 @@ bool BaseInflator::InflatePDU(HeaderSet *headers,
return false;
}

if (flags & PDU::HFLAG_MASK) {
if (flags & ola::acn::HFLAG_MASK) {
result = DecodeHeader(headers, data + data_offset,
pdu_len - data_offset,
&header_bytes_used);
Expand Down
7 changes: 5 additions & 2 deletions libs/acn/BaseInflator.h
Expand Up @@ -87,8 +87,11 @@ class BaseInflator : public InflatorInterface {
unsigned int len);

// masks for the flag fields
// This indicates a 20 bit length field (default is 12 bits)
static const uint8_t LFLAG_MASK = 0x80;
/**
* @brief This indicates a 20 bit length field (default is 12 bits)
* @deprecated Use ola::acn::LFLAG_MASK instead (4 Feb 2020).
*/
static const uint8_t LFLAG_MASK = ola::acn::LFLAG_MASK;
// This masks the first 4 bits of the length field
static const uint8_t LENGTH_MASK = 0x0F;

Expand Down
18 changes: 9 additions & 9 deletions libs/acn/BaseInflatorTest.cpp
Expand Up @@ -204,7 +204,7 @@ void BaseInflatorTest::testDecodeVector() {
uint8_t data[] = {1, 2, 3, 4, 5, 6}; // the test data
unsigned int vector = 1;
unsigned int bytes_used = 0;
uint8_t flags = PDU::VFLAG_MASK;
uint8_t flags = VFLAG_MASK;

OLA_ASSERT_FALSE(inflator.DecodeVector(flags, data, 0, &vector, &bytes_used));
OLA_ASSERT_EQ((unsigned int) 0, vector);
Expand Down Expand Up @@ -235,7 +235,7 @@ void BaseInflatorTest::testDecodeVector() {
}

// now try with a vector size of 2
flags = PDU::VFLAG_MASK;
flags = VFLAG_MASK;
TestInflator inflator2(0, PDU::TWO_BYTES);
for (unsigned int i = 0; i < 2; i++) {
OLA_ASSERT_FALSE(
Expand Down Expand Up @@ -270,7 +270,7 @@ void BaseInflatorTest::testDecodeVector() {
}

// now try with a vector size of 4
flags = PDU::VFLAG_MASK;
flags = VFLAG_MASK;
TestInflator inflator4(0, PDU::FOUR_BYTES);
for (unsigned int i = 0; i < 4; i++) {
OLA_ASSERT_FALSE(
Expand All @@ -297,7 +297,7 @@ void BaseInflatorTest::testDecodeVector() {
void BaseInflatorTest::testInflatePDU() {
TestInflator inflator; // test with a vector size of 2
HeaderSet header_set;
uint8_t flags = PDU::VFLAG_MASK;
uint8_t flags = VFLAG_MASK;
unsigned int data_size = static_cast<unsigned int>(PDU::TWO_BYTES +
sizeof(PDU_DATA));
uint8_t *data = new uint8_t[data_size];
Expand All @@ -324,7 +324,7 @@ void BaseInflatorTest::testInflatePDUBlock() {
length_size + PDU::TWO_BYTES + sizeof(PDU_DATA));
uint8_t *data = new uint8_t[data_size];
// setup the vector
data[0] = PDU::VFLAG_MASK;
data[0] = VFLAG_MASK;
data[1] = static_cast<uint8_t>(data_size);
data[2] = 0x01;
data[3] = 0x21;
Expand All @@ -337,14 +337,14 @@ void BaseInflatorTest::testInflatePDUBlock() {

// inflate a multi-pdu block
data = new uint8_t[2 * data_size];
data[0] = PDU::VFLAG_MASK;
data[0] = VFLAG_MASK;
data[1] = static_cast<uint8_t>(data_size);
data[2] = 0x01;
data[3] = 0x21;
memcpy(data + length_size + PDU::TWO_BYTES,
PDU_DATA,
sizeof(PDU_DATA));
data[data_size] = PDU::VFLAG_MASK;
data[data_size] = VFLAG_MASK;
data[data_size + 1] = static_cast<uint8_t>(data_size);
data[data_size + 2] = 0x01;
data[data_size + 3] = 0x21;
Expand All @@ -362,11 +362,11 @@ void BaseInflatorTest::testInflatePDUBlock() {
unsigned int pdu_size = data_size + length_size + PDU::TWO_BYTES;
data = new uint8_t[pdu_size];

data[0] = PDU::VFLAG_MASK;
data[0] = VFLAG_MASK;
data[1] = static_cast<uint8_t>(pdu_size);
data[2] = 0x01;
data[3] = 0x21;
data[4] = PDU::VFLAG_MASK;
data[4] = VFLAG_MASK;
data[5] = static_cast<uint8_t>(data_size);
data[6] = 0x01;
data[7] = 0x21;
Expand Down
2 changes: 1 addition & 1 deletion libs/acn/E133Inflator.h
Expand Up @@ -38,7 +38,7 @@ class E133Inflator: public BaseInflator {
}
~E133Inflator() {}

uint32_t Id() const { return ola::acn::VECTOR_ROOT_E133; }
uint32_t Id() const { return ola::acn::VECTOR_ROOT_RPT; }

protected:
bool DecodeHeader(HeaderSet *headers,
Expand Down
8 changes: 7 additions & 1 deletion libs/acn/HeaderSet.h
Expand Up @@ -26,6 +26,7 @@
#include "libs/acn/DMPHeader.h"
#include "libs/acn/E131Header.h"
#include "libs/acn/E133Header.h"
#include "libs/acn/LLRPHeader.h"
#include "libs/acn/RootHeader.h"
#include "libs/acn/TransportHeader.h"

Expand Down Expand Up @@ -56,13 +57,17 @@ class HeaderSet {
const DMPHeader &GetDMPHeader() const { return m_dmp_header; }
void SetDMPHeader(const DMPHeader &header) { m_dmp_header = header; }

const LLRPHeader &GetLLRPHeader() const { return m_llrp_header; }
void SetLLRPHeader(const LLRPHeader &header) { m_llrp_header = header; }

bool operator==(const HeaderSet &other) const {
return (
m_transport_header == other.m_transport_header &&
m_root_header == other.m_root_header &&
m_e131_header == other.m_e131_header &&
m_e133_header == other.m_e133_header &&
m_dmp_header == other.m_dmp_header);
m_dmp_header == other.m_dmp_header &&
m_llrp_header == other.m_llrp_header);
}

private:
Expand All @@ -71,6 +76,7 @@ class HeaderSet {
E131Header m_e131_header;
E133Header m_e133_header;
DMPHeader m_dmp_header;
LLRPHeader m_llrp_header;
};
} // namespace acn
} // namespace ola
Expand Down
69 changes: 69 additions & 0 deletions libs/acn/LLRPHeader.h
@@ -0,0 +1,69 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* LLRPHeader.h
* The E1.33 LLRP Header
* Copyright (C) 2020 Peter Newman
*/

#ifndef LIBS_ACN_LLRPHEADER_H_
#define LIBS_ACN_LLRPHEADER_H_

#include <ola/acn/CID.h>
#include <ola/base/Macro.h>

#include <stdint.h>

namespace ola {
namespace acn {

/*
* Header for the LLRP layer
*/
class LLRPHeader {
public:
LLRPHeader()
: m_transaction_number(0) {
}

LLRPHeader(const ola::acn::CID &destination_cid,
uint32_t transaction_number)
: m_destination_cid(destination_cid),
m_transaction_number(transaction_number) {
}
~LLRPHeader() {}

const ola::acn::CID DestinationCid() const { return m_destination_cid; }
uint32_t TransactionNumber() const { return m_transaction_number; }

bool operator==(const LLRPHeader &other) const {
return ((m_destination_cid == other.m_destination_cid) &&
(m_transaction_number == other.m_transaction_number));
}

PACK(
struct llrp_pdu_header_s {
uint8_t destination_cid[CID::CID_LENGTH];
uint32_t transaction_number;
});
typedef struct llrp_pdu_header_s llrp_pdu_header;

private:
ola::acn::CID m_destination_cid;
uint32_t m_transaction_number;
};
} // namespace acn
} // namespace ola
#endif // LIBS_ACN_LLRPHEADER_H_

0 comments on commit e7b4039

Please sign in to comment.