Skip to content

Commit e7b4039

Browse files
authored
Merge pull request #1939 from peternewman/e1.33-cherry-pick
E1.33 cherry pick
2 parents ff8bf86 + cb1d8f7 commit e7b4039

19 files changed

+828
-35
lines changed

include/ola/acn/ACNFlags.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation; either version 2 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU Library General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program; if not, write to the Free Software
14+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15+
*
16+
* ACNFlags.h
17+
* Flags used in ACN PDUs
18+
* Copyright (C) 2020 Peter Newman
19+
*/
20+
21+
#ifndef INCLUDE_OLA_ACN_ACNFLAGS_H_
22+
#define INCLUDE_OLA_ACN_ACNFLAGS_H_
23+
24+
/**
25+
* @addtogroup acn
26+
* @{
27+
* @file ACNFlags.h
28+
* @brief ACN flag values.
29+
* @}
30+
*/
31+
32+
#include <stdint.h>
33+
34+
namespace ola {
35+
namespace acn {
36+
37+
/**
38+
* @addtogroup acn
39+
* @{
40+
*/
41+
42+
// masks for the flag fields
43+
/**
44+
* @brief This indicates a 20 bit length field (default is 12 bits)
45+
*/
46+
static const uint8_t LFLAG_MASK = 0x80;
47+
48+
/**
49+
* @brief This indicates a vector is present
50+
*/
51+
static const uint8_t VFLAG_MASK = 0x40;
52+
53+
/**
54+
* @brief This indicates a header field is present
55+
*/
56+
static const uint8_t HFLAG_MASK = 0x20;
57+
58+
/**
59+
* @brief This indicates a data field is present
60+
*/
61+
static const uint8_t DFLAG_MASK = 0x10;
62+
63+
/**
64+
* @}
65+
*/
66+
67+
} // namespace acn
68+
} // namespace ola
69+
70+
#endif // INCLUDE_OLA_ACN_ACNFLAGS_H_

include/ola/acn/ACNVectors.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ namespace acn {
4545
enum RootVector {
4646
VECTOR_ROOT_E131_REV2 = 3, /**< Draft E1.31, used by some old gear. */
4747
VECTOR_ROOT_E131 = 4, /**< E1.31 (sACN) */
48-
VECTOR_ROOT_E133 = 5, /**< E1.33 (RDNNet) */
48+
VECTOR_ROOT_RPT = 5, /**< E1.33 (RPT) */
4949
VECTOR_ROOT_NULL = 6, /**< NULL (empty) root */
50+
VECTOR_ROOT_BROKER = 9, /**< E1.33 (Broker) */
51+
VECTOR_ROOT_LLRP = 0x0A, /**< E1.33 (LLRP) */
52+
VECTOR_ROOT_EPT = 0x0B, /**< E1.33 (EPT) */
5053
};
5154

5255
/**
@@ -87,6 +90,15 @@ enum E133ControllerVector {
8790
VECTOR_CONTROLLER_EXPECT_MASTER = 5, /**< Expect master message */
8891
};
8992

93+
/**
94+
* @brief Vectors used at the E1.33 LLRP layer.
95+
*/
96+
enum LLRPVector {
97+
VECTOR_LLRP_PROBE_REQUEST = 1, /**< LLRP Probe Request */
98+
VECTOR_LLRP_PROBE_REPLY = 1, /**< LLRP Probe Reply */
99+
VECTOR_LLRP_RDM_CMD = 1, /**< LLRP RDM Command */
100+
};
101+
90102
/**
91103
* @}
92104
*/

include/ola/acn/Makefile.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ olaacninclude_HEADERS =
33

44
if INSTALL_ACN
55
olaacninclude_HEADERS += \
6+
include/ola/acn/ACNFlags.h \
67
include/ola/acn/ACNPort.h \
78
include/ola/acn/ACNVectors.h \
89
include/ola/acn/CID.h

libs/acn/BaseInflator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ bool BaseInflator::DecodeLength(const uint8_t *data,
163163
bool BaseInflator::DecodeVector(uint8_t flags, const uint8_t *data,
164164
unsigned int length, uint32_t *vector,
165165
unsigned int *bytes_used) {
166-
if (flags & PDU::VFLAG_MASK) {
166+
if (flags & ola::acn::VFLAG_MASK) {
167167
if ((unsigned int) m_vector_size > length) {
168168
*vector = 0;
169169
*bytes_used = 0;
@@ -223,7 +223,7 @@ bool BaseInflator::InflatePDU(HeaderSet *headers,
223223
return false;
224224
}
225225

226-
if (flags & PDU::HFLAG_MASK) {
226+
if (flags & ola::acn::HFLAG_MASK) {
227227
result = DecodeHeader(headers, data + data_offset,
228228
pdu_len - data_offset,
229229
&header_bytes_used);

libs/acn/BaseInflator.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ class BaseInflator : public InflatorInterface {
8787
unsigned int len);
8888

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

libs/acn/BaseInflatorTest.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void BaseInflatorTest::testDecodeVector() {
204204
uint8_t data[] = {1, 2, 3, 4, 5, 6}; // the test data
205205
unsigned int vector = 1;
206206
unsigned int bytes_used = 0;
207-
uint8_t flags = PDU::VFLAG_MASK;
207+
uint8_t flags = VFLAG_MASK;
208208

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

237237
// now try with a vector size of 2
238-
flags = PDU::VFLAG_MASK;
238+
flags = VFLAG_MASK;
239239
TestInflator inflator2(0, PDU::TWO_BYTES);
240240
for (unsigned int i = 0; i < 2; i++) {
241241
OLA_ASSERT_FALSE(
@@ -270,7 +270,7 @@ void BaseInflatorTest::testDecodeVector() {
270270
}
271271

272272
// now try with a vector size of 4
273-
flags = PDU::VFLAG_MASK;
273+
flags = VFLAG_MASK;
274274
TestInflator inflator4(0, PDU::FOUR_BYTES);
275275
for (unsigned int i = 0; i < 4; i++) {
276276
OLA_ASSERT_FALSE(
@@ -297,7 +297,7 @@ void BaseInflatorTest::testDecodeVector() {
297297
void BaseInflatorTest::testInflatePDU() {
298298
TestInflator inflator; // test with a vector size of 2
299299
HeaderSet header_set;
300-
uint8_t flags = PDU::VFLAG_MASK;
300+
uint8_t flags = VFLAG_MASK;
301301
unsigned int data_size = static_cast<unsigned int>(PDU::TWO_BYTES +
302302
sizeof(PDU_DATA));
303303
uint8_t *data = new uint8_t[data_size];
@@ -324,7 +324,7 @@ void BaseInflatorTest::testInflatePDUBlock() {
324324
length_size + PDU::TWO_BYTES + sizeof(PDU_DATA));
325325
uint8_t *data = new uint8_t[data_size];
326326
// setup the vector
327-
data[0] = PDU::VFLAG_MASK;
327+
data[0] = VFLAG_MASK;
328328
data[1] = static_cast<uint8_t>(data_size);
329329
data[2] = 0x01;
330330
data[3] = 0x21;
@@ -337,14 +337,14 @@ void BaseInflatorTest::testInflatePDUBlock() {
337337

338338
// inflate a multi-pdu block
339339
data = new uint8_t[2 * data_size];
340-
data[0] = PDU::VFLAG_MASK;
340+
data[0] = VFLAG_MASK;
341341
data[1] = static_cast<uint8_t>(data_size);
342342
data[2] = 0x01;
343343
data[3] = 0x21;
344344
memcpy(data + length_size + PDU::TWO_BYTES,
345345
PDU_DATA,
346346
sizeof(PDU_DATA));
347-
data[data_size] = PDU::VFLAG_MASK;
347+
data[data_size] = VFLAG_MASK;
348348
data[data_size + 1] = static_cast<uint8_t>(data_size);
349349
data[data_size + 2] = 0x01;
350350
data[data_size + 3] = 0x21;
@@ -362,11 +362,11 @@ void BaseInflatorTest::testInflatePDUBlock() {
362362
unsigned int pdu_size = data_size + length_size + PDU::TWO_BYTES;
363363
data = new uint8_t[pdu_size];
364364

365-
data[0] = PDU::VFLAG_MASK;
365+
data[0] = VFLAG_MASK;
366366
data[1] = static_cast<uint8_t>(pdu_size);
367367
data[2] = 0x01;
368368
data[3] = 0x21;
369-
data[4] = PDU::VFLAG_MASK;
369+
data[4] = VFLAG_MASK;
370370
data[5] = static_cast<uint8_t>(data_size);
371371
data[6] = 0x01;
372372
data[7] = 0x21;

libs/acn/E133Inflator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class E133Inflator: public BaseInflator {
3838
}
3939
~E133Inflator() {}
4040

41-
uint32_t Id() const { return ola::acn::VECTOR_ROOT_E133; }
41+
uint32_t Id() const { return ola::acn::VECTOR_ROOT_RPT; }
4242

4343
protected:
4444
bool DecodeHeader(HeaderSet *headers,

libs/acn/HeaderSet.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "libs/acn/DMPHeader.h"
2727
#include "libs/acn/E131Header.h"
2828
#include "libs/acn/E133Header.h"
29+
#include "libs/acn/LLRPHeader.h"
2930
#include "libs/acn/RootHeader.h"
3031
#include "libs/acn/TransportHeader.h"
3132

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

60+
const LLRPHeader &GetLLRPHeader() const { return m_llrp_header; }
61+
void SetLLRPHeader(const LLRPHeader &header) { m_llrp_header = header; }
62+
5963
bool operator==(const HeaderSet &other) const {
6064
return (
6165
m_transport_header == other.m_transport_header &&
6266
m_root_header == other.m_root_header &&
6367
m_e131_header == other.m_e131_header &&
6468
m_e133_header == other.m_e133_header &&
65-
m_dmp_header == other.m_dmp_header);
69+
m_dmp_header == other.m_dmp_header &&
70+
m_llrp_header == other.m_llrp_header);
6671
}
6772

6873
private:
@@ -71,6 +76,7 @@ class HeaderSet {
7176
E131Header m_e131_header;
7277
E133Header m_e133_header;
7378
DMPHeader m_dmp_header;
79+
LLRPHeader m_llrp_header;
7480
};
7581
} // namespace acn
7682
} // namespace ola

libs/acn/LLRPHeader.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation; either version 2 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU Library General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program; if not, write to the Free Software
14+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15+
*
16+
* LLRPHeader.h
17+
* The E1.33 LLRP Header
18+
* Copyright (C) 2020 Peter Newman
19+
*/
20+
21+
#ifndef LIBS_ACN_LLRPHEADER_H_
22+
#define LIBS_ACN_LLRPHEADER_H_
23+
24+
#include <ola/acn/CID.h>
25+
#include <ola/base/Macro.h>
26+
27+
#include <stdint.h>
28+
29+
namespace ola {
30+
namespace acn {
31+
32+
/*
33+
* Header for the LLRP layer
34+
*/
35+
class LLRPHeader {
36+
public:
37+
LLRPHeader()
38+
: m_transaction_number(0) {
39+
}
40+
41+
LLRPHeader(const ola::acn::CID &destination_cid,
42+
uint32_t transaction_number)
43+
: m_destination_cid(destination_cid),
44+
m_transaction_number(transaction_number) {
45+
}
46+
~LLRPHeader() {}
47+
48+
const ola::acn::CID DestinationCid() const { return m_destination_cid; }
49+
uint32_t TransactionNumber() const { return m_transaction_number; }
50+
51+
bool operator==(const LLRPHeader &other) const {
52+
return ((m_destination_cid == other.m_destination_cid) &&
53+
(m_transaction_number == other.m_transaction_number));
54+
}
55+
56+
PACK(
57+
struct llrp_pdu_header_s {
58+
uint8_t destination_cid[CID::CID_LENGTH];
59+
uint32_t transaction_number;
60+
});
61+
typedef struct llrp_pdu_header_s llrp_pdu_header;
62+
63+
private:
64+
ola::acn::CID m_destination_cid;
65+
uint32_t m_transaction_number;
66+
};
67+
} // namespace acn
68+
} // namespace ola
69+
#endif // LIBS_ACN_LLRPHEADER_H_

0 commit comments

Comments
 (0)