Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E1.33 controller #1841

Draft
wants to merge 148 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
23a00bb
First attempt at LLRP header and PDU
peternewman Jan 29, 2020
d53a8ee
Merge branch 'master' into e1.33
peternewman Jan 30, 2020
8524079
Fix a Doxygen typo
peternewman Feb 3, 2020
674ea51
Update some E1.33 Vectors
peternewman Feb 3, 2020
bd619c2
Add the ability to pack UIDSets
peternewman Feb 4, 2020
a89f3db
Fix the Doxygen
peternewman Feb 4, 2020
063de3d
Fix a Doxygen typo
peternewman Feb 4, 2020
0204d59
Add the initial LLRPProbeRequestPDU
peternewman Feb 4, 2020
910e9c4
Merge branch 'e1.33' of https://github.com/peternewman/ola into e1.33
peternewman Feb 4, 2020
f1cc481
Tidy some Doxygen
peternewman Feb 4, 2020
27c1cb5
Add the ability to easily write a CID to an ostream
peternewman Feb 4, 2020
e9dd374
Add LLRP Probe Request PDU, fix the length flags bug
peternewman Feb 4, 2020
2d0ed43
Fix the lint issues
peternewman Feb 4, 2020
38d893d
Add the LLRPProbeReplyPDU
peternewman Feb 6, 2020
956c0fb
Fix the LLRP vector values
peternewman Feb 6, 2020
d72c6aa
Add the ability to force the length flag on a Root PDU
peternewman Feb 6, 2020
d972695
Allow an LLRPProbeReplyPDU to be sent
peternewman Feb 6, 2020
3eb8518
Tidying and TODO
peternewman Feb 6, 2020
f3b7511
Initial handling of LLRPProbeRequest PDUs
peternewman Feb 6, 2020
e445c32
Initial LLRP discoverable device
peternewman Feb 6, 2020
f743476
Use the correct MAC address in the responses
peternewman Feb 9, 2020
7e5f935
Fix a typo
peternewman Feb 9, 2020
4983aa9
Switch to our flags module and set the UID from the command line
peternewman Feb 9, 2020
dc06b8a
Add the ability to make a UID set from binary data
peternewman Feb 9, 2020
f2343ce
Pass all the LLRPProbeRequest info across in the callback and act on …
peternewman Feb 9, 2020
9583793
Fix a typo
peternewman Feb 10, 2020
1955638
Allow the RDMInflator to be used with both native E1.33 and LLRP RDM …
peternewman Feb 11, 2020
32ecc52
Add the ability to pack an RDMPDU
peternewman Feb 11, 2020
0469724
Initial version of an LLRP RDM responder
peternewman Feb 11, 2020
a150d7e
Add the LLRP Broadcast CID
peternewman Feb 11, 2020
b0662a0
Fix some lint issues and follow more of the standard
peternewman Feb 11, 2020
280d3f6
Ensure we work on the same host as the manager
peternewman Feb 17, 2020
324b4ec
Add a helper method to convert an RDMResponse to a NACKing RDMResponse
peternewman Feb 17, 2020
ccba9fa
Don't send back ACK_OVERFLOW or ACK_TIMER responses
peternewman Feb 17, 2020
52e8913
NACK if an invalid subdevice is targetted
peternewman Feb 17, 2020
46a08ac
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Feb 18, 2020
bc2099b
Rename the target code to a more standardised name
peternewman Feb 18, 2020
ed113e1
Update some missed docs
peternewman Feb 18, 2020
8db5131
Add the ability to inflate an LLRP Probe Reply and build a Probe Request
peternewman Feb 18, 2020
bd0a09c
Minor tweak to some logging
peternewman Feb 19, 2020
fc83330
Initial basic attempt at an LLRP manager
peternewman Feb 19, 2020
ac119e8
Support sending set commands
peternewman Feb 25, 2020
9845e37
Update some RDM comments
peternewman Feb 25, 2020
e6b8f99
Update PIDs from rdm-app repo
peternewman Feb 25, 2020
2aeaac8
Add initial negative E1.33/E1.37-7 tests. Need to add categories still
peternewman Feb 26, 2020
6870361
Add the ability to override the expected NACK for GetZeroMixin
peternewman Feb 26, 2020
f67491f
Correct the expected NACK for some endpoint number checks
peternewman Feb 26, 2020
e59b028
Support loopback and selecting an interface
peternewman Feb 26, 2020
fd26efa
Add some detail on how DMX-TRI error codes are done from its developer
peternewman Mar 4, 2023
9d60884
Improve some size calculations, only output SetWithNoData when actual…
peternewman Mar 4, 2023
966a9fa
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Mar 4, 2023
067bc03
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Mar 5, 2023
c2126d1
First attempt at the E1.33 Broker PDU
peternewman Mar 7, 2023
2a43710
First attempt at BrokerClientEntryPDU
peternewman Mar 7, 2023
19eca6f
First go at BrokerConnectPDU, could do with more tests
peternewman Mar 7, 2023
d01494b
Fix a typo in the DeviceManager stuff
peternewman Mar 8, 2023
f49c1f8
Add the BrokerNullPDU and tests
peternewman Mar 8, 2023
5b36363
Correct the byte order for the E1.33 version field
peternewman Mar 9, 2023
eb609f3
Correct the size of the BrokerPDU's vector
peternewman Mar 9, 2023
e99ec91
Correct a broker endian check for the E1.33 version in our tests
peternewman Mar 9, 2023
d40a36a
Add a testPrepend test for the BrokerClientEntryPDU base class
peternewman Mar 9, 2023
ad9ac0d
Allow the timeout interval of the HealthCheckedConnection to be custo…
peternewman Mar 10, 2023
910b0b0
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Mar 11, 2023
5c56490
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Mar 11, 2023
9fab749
Add some more new simple E1.33 inflators
peternewman Jul 3, 2023
6d4d923
More E1.33 vectors
peternewman Jul 3, 2023
81b8e38
Fix a minor typo
peternewman Jul 3, 2023
66e7f10
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Jul 3, 2023
b23bc6b
A few more E1.33 enums
peternewman Jul 3, 2023
bdb40db
Add the ability to build BrokerNullTCP packets
peternewman Jul 3, 2023
847734f
Correctly commit only a partial change for now
peternewman Jul 3, 2023
4d7049c
Update E133HealthCheckedConnection to work with the new standardised …
peternewman Jul 3, 2023
0271789
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Jul 3, 2023
a577535
Fix a lint issue
peternewman Jul 3, 2023
7686be6
Temporarily remove the the PIDs with IPV6 type in them until we suppo…
peternewman Jul 3, 2023
064e2f5
Merge branch 'e1.33' of https://github.com/peternewman/ola into e1.33…
peternewman Jul 3, 2023
1a027ac
Add some more enums
peternewman Jul 8, 2023
d1eb7b8
Update the RDM Inflator to the standardised E1.33
peternewman Jul 8, 2023
669e2e5
Add support inflator for a lot of E1.33 RPT PDUs
peternewman Jul 8, 2023
ec58616
Add tests for the LLRP and RPT headers in the HeaderSet
peternewman Jul 8, 2023
c73d3b3
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Dec 25, 2023
7c44c8b
Add some ConnectStatusCode helpers
peternewman Dec 27, 2023
eb97fb4
Add some E1.33 helpers
peternewman Jan 2, 2024
40ff84c
Update the RDM PDU to the released standard version
peternewman Feb 24, 2024
b3942cf
Add the RPT and RPT Request PDU classes
peternewman Feb 24, 2024
218c4c7
Tidy the whitespace on RPTPDU.h
peternewman Feb 24, 2024
ec6ba37
Remove some unnecessary usings from BrokerNullPDU
peternewman Feb 28, 2024
e00322d
Add the BrokerFetchClientListPDU class
peternewman Feb 28, 2024
16455b1
Add message builders for RDMCommand and BrokerFetchClientList packets
peternewman Feb 28, 2024
77859eb
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Feb 28, 2024
b176ba1
Update the TCP header for ACN to match the released standards
peternewman Mar 3, 2024
356decf
Handle some conversion errors
peternewman Mar 10, 2024
e96154c
Migrate the E1.33 code into a separate lib in libs/acn
peternewman Mar 10, 2024
5961212
Fix a header guard after moving a file
peternewman Mar 10, 2024
e41fd88
Fix the tests after making a new library
peternewman Mar 10, 2024
35e4ed1
Be more consistent with the representation of enums to match the stan…
peternewman Mar 16, 2024
7026e60
Remove redundant duplicate copies of some libraries since they've moved
peternewman Mar 16, 2024
33ea03f
Update the TCP header for ACN to match the released standards in TCPT…
peternewman Mar 16, 2024
0ea80e1
Work towards a new E1.33 plugin
peternewman Mar 16, 2024
1a036f9
Some of the basics of the E1.33 plugin
peternewman Mar 16, 2024
58a6cc2
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Mar 16, 2024
2350e26
Add the BrokerConnectReplyInflator class and tests
peternewman Mar 17, 2024
7feb4c3
Add the BrokerClientEntryRPTPDU class and tests
peternewman Mar 17, 2024
93253cd
Fix a minor typo
peternewman Mar 17, 2024
998475d
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Mar 21, 2024
1054c29
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Mar 27, 2024
773a4ad
Fix a broken merge
peternewman Mar 28, 2024
6ea9f01
Add more logging to a test and remove unnecessary includes
peternewman Mar 28, 2024
d294042
Add some RPT Status handling helpers
peternewman Mar 30, 2024
d1cbab9
Move more stuff to the E1.33 lib and fix the LLRP build
peternewman Mar 30, 2024
d4378b9
Fix a typo
peternewman Mar 30, 2024
e1e94e3
Add more E1.33 Enums
peternewman Mar 30, 2024
d976466
Add some RPT UID functionality and more tests
peternewman Mar 30, 2024
a5ddef0
Add a first version of the RPTStatusInflator.
peternewman Mar 31, 2024
2bfeb55
Fix some comments
peternewman Apr 5, 2024
14d56c9
Fix some null pointer exceptions
peternewman Apr 5, 2024
91e014f
Fix more null pointer exceptions
peternewman Apr 6, 2024
4bdfdbd
RPTPDU test PrependPDU and fix a NPE error in that
peternewman Apr 11, 2024
b1dbef0
RPTRequestPDU fix a NPE error in PrependPDU
peternewman Apr 11, 2024
9e113f0
Handle vendorcast/broadcast when sending RDM commands via E1.33
peternewman Apr 11, 2024
49d4e2c
Add a TODO for future tidying up
peternewman Apr 11, 2024
af117de
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Apr 11, 2024
1c8e4ed
Fix a lint error
peternewman Apr 12, 2024
31c6af0
Add BrokerClientEntryRPT Inflator
peternewman Apr 12, 2024
0dc3e4a
Fix a licence
peternewman Apr 12, 2024
157e7d0
Sort some sources for the lib
peternewman Apr 12, 2024
f302dfc
Add another basic inflator
peternewman Apr 12, 2024
af12b76
Initial BrokerNullInflator test
peternewman Apr 13, 2024
d6ff723
Fix a typo in a header guard
peternewman Apr 13, 2024
5b8e4d7
Fix NPE and add tests for E133StatusHelper functions
peternewman Apr 13, 2024
3a02f31
Fix some lint errors
peternewman Apr 13, 2024
14d84e5
Fix a comment
peternewman Apr 13, 2024
ebe7f20
Expose the default UID via the PluginAdaptor
peternewman Apr 14, 2024
356ae17
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Apr 14, 2024
44ad498
Fix the missed rename
peternewman Apr 14, 2024
3d752e7
Fix some cpplint issues
peternewman Apr 14, 2024
71378c9
Update the E1.33/E1.37-7 PIDs within RDMEnums.h
peternewman Apr 16, 2024
1eec20a
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Apr 21, 2024
05404c7
Fix a presumed broken merge and a lint issue
peternewman Apr 21, 2024
2c2fdc7
Tidy a header file
peternewman Apr 21, 2024
ed8d532
Fix a comment
peternewman Apr 21, 2024
2d5280c
Fix a typo
peternewman Apr 21, 2024
720bb24
Fix a comment typo
peternewman Apr 21, 2024
672ca47
Update to the standardised PID names for E1.37-7
peternewman Apr 21, 2024
3d070a6
Fix the formatting of some PID values in some Python exceptions
peternewman Apr 21, 2024
bc81275
Fix some lint issues
peternewman Apr 21, 2024
54d2743
Ensure we don't get an NPE if the Stack is missing
peternewman Apr 21, 2024
c382d1c
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
First attempt at BrokerClientEntryPDU
  • Loading branch information
peternewman committed Mar 7, 2023
commit 2a43710c8e595911c2981ce08bf0dc47d5888f27
63 changes: 63 additions & 0 deletions libs/acn/BrokerClientEntryHeader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.
*
* BrokerClientEntryHeader.h
* The E1.33 Broker Client Entry Header
* Copyright (C) 2023 Peter Newman
*/

#ifndef LIBS_ACN_BROKERCLIENTENTRYHEADER_H_
#define LIBS_ACN_BROKERCLIENTENTRYHEADER_H_

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

#include <stdint.h>

namespace ola {
namespace acn {

// TODO(Peter): I think technically this probably shouldn't be a header and
// instead is just data at this level!
/*
* Header for the Broker Client Entry level
*/
class BrokerClientEntryHeader {
public:
BrokerClientEntryHeader() {}

BrokerClientEntryHeader(const ola::acn::CID &client_cid)
: m_client_cid(client_cid) {
}
~BrokerClientEntryHeader() {}

const ola::acn::CID ClientCid() const { return m_client_cid; }

bool operator==(const BrokerClientEntryHeader &other) const {
return m_client_cid == other.m_client_cid;
}

PACK(
struct broker_client_entry_pdu_header_s {
uint8_t client_cid[CID::CID_LENGTH];
});
typedef struct broker_client_entry_pdu_header_s broker_client_entry_pdu_header;

private:
ola::acn::CID m_client_cid;
};
} // namespace acn
} // namespace ola
#endif // LIBS_ACN_BROKERCLIENTENTRYHEADER_H_
114 changes: 114 additions & 0 deletions libs/acn/BrokerClientEntryPDU.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* 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.
*
* BrokerClientEntryPDU.cpp
* The BrokerClientEntryPDU
* Copyright (C) 2023 Peter Newman
*/


#include "ola/Logging.h"
#include "ola/base/Array.h"
#include "ola/network/NetworkUtils.h"
#include "libs/acn/BrokerClientEntryPDU.h"

namespace ola {
namespace acn {

using ola::io::OutputStream;
using ola::network::HostToNetwork;

/*
* Size of the header portion.
*/
unsigned int BrokerClientEntryPDU::HeaderSize() const {
return sizeof(BrokerClientEntryHeader::broker_client_entry_pdu_header);
}


/*
* Size of the data portion
*/
unsigned int BrokerClientEntryPDU::DataSize() const {
return m_pdu ? m_pdu->Size() : 0;
}


/*
* Pack the header portion.
*/
bool BrokerClientEntryPDU::PackHeader(uint8_t *data, unsigned int *length) const {
unsigned int header_size = HeaderSize();

if (*length < header_size) {
OLA_WARN << "BrokerClientEntryPDU::PackHeader: buffer too small, got " << *length
<< " required " << header_size;
*length = 0;
return false;
}

BrokerClientEntryHeader::broker_client_entry_pdu_header header;
m_header.ClientCid().Pack(header.client_cid);
*length = sizeof(BrokerClientEntryHeader::broker_client_entry_pdu_header);
memcpy(data, &header, *length);
return true;
}


/*
* Pack the data portion.
*/
bool BrokerClientEntryPDU::PackData(uint8_t *data, unsigned int *length) const {
if (m_pdu)
return m_pdu->Pack(data, length);
*length = 0;
return true;
}


/*
* Pack the header into a buffer.
*/
void BrokerClientEntryPDU::PackHeader(OutputStream *stream) const {
BrokerClientEntryHeader::broker_client_entry_pdu_header header;
m_header.ClientCid().Pack(header.client_cid);
stream->Write(reinterpret_cast<uint8_t*>(&header),
sizeof(BrokerClientEntryHeader::broker_client_entry_pdu_header));
}


/*
* Pack the data into a buffer
*/
void BrokerClientEntryPDU::PackData(OutputStream *stream) const {
if (m_pdu)
m_pdu->Write(stream);
}


void BrokerClientEntryPDU::PrependPDU(ola::io::IOStack *stack,
uint32_t vector,
const ola::acn::CID &client_cid) {
BrokerClientEntryHeader::broker_client_entry_pdu_header header;
client_cid.Pack(header.client_cid);
stack->Write(reinterpret_cast<uint8_t*>(&header),
sizeof(BrokerClientEntryHeader::broker_client_entry_pdu_header));

vector = HostToNetwork(vector);
stack->Write(reinterpret_cast<uint8_t*>(&vector), sizeof(vector));
PrependFlagsAndLength(stack, VFLAG_MASK | HFLAG_MASK | DFLAG_MASK, true);
}
} // namespace acn
} // namespace ola
61 changes: 61 additions & 0 deletions libs/acn/BrokerClientEntryPDU.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.
*
* BrokerClientEntryPDU.h
* Interface for the BrokerClientEntryPDU class
* Copyright (C) 2023 Peter Newman
*/

#ifndef LIBS_ACN_BROKERCLIENTENTRYPDU_H_
#define LIBS_ACN_BROKERCLIENTENTRYPDU_H_

#include <ola/acn/CID.h>
#include <ola/io/IOStack.h>

#include "libs/acn/PDU.h"
#include "libs/acn/BrokerClientEntryHeader.h"

namespace ola {
namespace acn {

class BrokerClientEntryPDU: public PDU {
public:
BrokerClientEntryPDU(unsigned int vector,
const BrokerClientEntryHeader &header,
const PDU *pdu):
PDU(vector, FOUR_BYTES, true),
m_header(header),
m_pdu(pdu) {}
~BrokerClientEntryPDU() {}

unsigned int HeaderSize() const;
unsigned int DataSize() const;
bool PackHeader(uint8_t *data, unsigned int *length) const;
bool PackData(uint8_t *data, unsigned int *length) const;

void PackHeader(ola::io::OutputStream *stream) const;
void PackData(ola::io::OutputStream *stream) const;

static void PrependPDU(ola::io::IOStack *stack,
uint32_t vector,
const ola::acn::CID &client_cid);

private:
BrokerClientEntryHeader m_header;
const PDU *m_pdu;
};
} // namespace acn
} // namespace ola
#endif // LIBS_ACN_BROKERCLIENTENTRYPDU_H_
141 changes: 141 additions & 0 deletions libs/acn/BrokerClientEntryPDUTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* 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.
*
* BrokerClientEntryPDUTest.cpp
* Test fixture for the BrokerClientEntryPDU class
* Copyright (C) 2023 Peter Newman
*/

#include <cppunit/extensions/HelperMacros.h>

#include "ola/Logging.h"
#include "ola/io/IOQueue.h"
#include "ola/io/OutputStream.h"
#include "ola/network/NetworkUtils.h"
#include "ola/testing/TestUtils.h"
#include "libs/acn/BrokerClientEntryPDU.h"
#include "libs/acn/PDUTestCommon.h"


namespace ola {
namespace acn {

using ola::io::IOQueue;
using ola::io::OutputStream;
using ola::network::HostToNetwork;

class BrokerClientEntryPDUTest: public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(BrokerClientEntryPDUTest);
CPPUNIT_TEST(testSimpleBrokerClientEntryPDU);
CPPUNIT_TEST(testSimpleBrokerClientEntryPDUToOutputStream);
CPPUNIT_TEST_SUITE_END();

public:
void testSimpleBrokerClientEntryPDU();
void testSimpleBrokerClientEntryPDUToOutputStream();

void setUp() {
ola::InitLogging(ola::OLA_LOG_DEBUG, ola::OLA_LOG_STDERR);
}

private:
static const unsigned int TEST_VECTOR;
static const uint8_t TEST_DATA[];
};

const uint8_t BrokerClientEntryPDUTest::TEST_DATA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15};

CPPUNIT_TEST_SUITE_REGISTRATION(BrokerClientEntryPDUTest);

const unsigned int BrokerClientEntryPDUTest::TEST_VECTOR = 39;


/*
* Test that packing a BrokerClientEntryPDU without data works.
*/
void BrokerClientEntryPDUTest::testSimpleBrokerClientEntryPDU() {
const CID client_cid = CID::FromData(TEST_DATA);
BrokerClientEntryHeader header(client_cid);
BrokerClientEntryPDU pdu(TEST_VECTOR, header, NULL);

OLA_ASSERT_EQ(16u, pdu.HeaderSize());
OLA_ASSERT_EQ(0u, pdu.DataSize());
OLA_ASSERT_EQ(23u, pdu.Size());

unsigned int size = pdu.Size();
uint8_t *data = new uint8_t[size];
unsigned int bytes_used = size;
OLA_ASSERT(pdu.Pack(data, &bytes_used));
OLA_ASSERT_EQ(size, bytes_used);

// spot check the data
OLA_ASSERT_EQ((uint8_t) 0xf0, data[0]);
// bytes_used is technically data[1] and data[2] if > 255
OLA_ASSERT_EQ((uint8_t) bytes_used, data[2]);
unsigned int actual_value;
memcpy(&actual_value, data + 3, sizeof(actual_value));
OLA_ASSERT_EQ(HostToNetwork(TEST_VECTOR), actual_value);

uint8_t buffer[CID::CID_LENGTH];
client_cid.Pack(buffer);
OLA_ASSERT_DATA_EQUALS(&data[7], CID::CID_LENGTH, buffer, sizeof(buffer));

// test undersized buffer
bytes_used = size - 1;
OLA_ASSERT_FALSE(pdu.Pack(data, &bytes_used));
OLA_ASSERT_EQ(0u, bytes_used);

// test oversized buffer
bytes_used = size + 1;
OLA_ASSERT(pdu.Pack(data, &bytes_used));
OLA_ASSERT_EQ(size, bytes_used);
delete[] data;
}


/*
* Test that writing to an output stream works.
*/
void BrokerClientEntryPDUTest::testSimpleBrokerClientEntryPDUToOutputStream() {
const ola::acn::CID client_cid = CID::FromData(TEST_DATA);
BrokerClientEntryHeader header(client_cid);
BrokerClientEntryPDU pdu(TEST_VECTOR, header, NULL);

OLA_ASSERT_EQ(16u, pdu.HeaderSize());
OLA_ASSERT_EQ(0u, pdu.DataSize());
OLA_ASSERT_EQ(23u, pdu.Size());

IOQueue output;
OutputStream stream(&output);
pdu.Write(&stream);
OLA_ASSERT_EQ(23u, output.Size());

uint8_t *pdu_data = new uint8_t[output.Size()];
unsigned int pdu_size = output.Peek(pdu_data, output.Size());
OLA_ASSERT_EQ(output.Size(), pdu_size);

uint8_t EXPECTED[] = {
0xf0, 0x00, 0x17,
0, 0, 0, 39,
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15
};
OLA_ASSERT_DATA_EQUALS(EXPECTED, sizeof(EXPECTED), pdu_data, pdu_size);
output.Pop(output.Size());
delete[] pdu_data;
}
} // namespace acn
} // namespace ola
1 change: 0 additions & 1 deletion libs/acn/BrokerPDU.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <ola/io/IOStack.h>

#include "libs/acn/PDU.h"
#include "libs/acn/BrokerHeader.h"

namespace ola {
namespace acn {
Expand Down
Loading