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 cherry pick part 4 #1950

Merged
merged 20 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8d1c563
Add the ability to build BrokerNullTCP packets
peternewman Jul 3, 2023
f56a071
Correctly commit only a partial change for now
peternewman Jul 3, 2023
d242ccb
Update E133HealthCheckedConnection to work with the new standardised …
peternewman Jul 3, 2023
b378b89
Update the RDM Inflator to the standardised E1.33
peternewman Jul 8, 2023
7f68a42
Add support inflator for a lot of E1.33 RPT PDUs
peternewman Jul 8, 2023
65d58c9
Add tests for the LLRP and RPT headers in the HeaderSet
peternewman Jul 8, 2023
a0df70a
Update the RDM PDU to the released standard version
peternewman Feb 24, 2024
262dc37
Add the RPT and RPT Request PDU classes
peternewman Feb 24, 2024
5dabc8b
Tidy the whitespace on RPTPDU.h
peternewman Feb 24, 2024
8af9777
Add the BrokerFetchClientListPDU class
peternewman Feb 28, 2024
eab5997
Add message builders for RDMCommand and BrokerFetchClientList packets
peternewman Feb 28, 2024
58ae321
Try and fix the clearing an object of non-trivial type error
peternewman Mar 28, 2024
3345540
Merge branch 'master' into e1.33-cherry-pick
kripton Mar 28, 2024
ac11a22
Merge branch 'master' into e1.33-cherry-pick
peternewman Apr 5, 2024
da414b9
Fix some comments
peternewman Apr 5, 2024
2c91e70
Merge branch 'e1.33-cherry-pick' of https://github.com/peternewman/ol…
peternewman Apr 5, 2024
d6a13dd
Fix some null pointer exceptions
peternewman Apr 5, 2024
9b385f6
Fix more null pointer exceptions
peternewman Apr 6, 2024
564dcb6
RPTPDU test PrependPDU and fix a NPE error in that
peternewman Apr 11, 2024
10d264a
RPTRequestPDU fix a NPE error in PrependPDU
peternewman Apr 11, 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
11 changes: 11 additions & 0 deletions include/ola/e133/MessageBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <ola/e133/E133Enums.h>
#include <ola/io/IOStack.h>
#include <ola/io/MemoryBlockPool.h>
#include <ola/rdm/RDMCommand.h>
#include <string>

namespace ola {
Expand All @@ -46,8 +47,18 @@ class MessageBuilder {

void PrependRDMHeader(IOStack *packet);

void BuildTCPRDMCommandPDU(IOStack *packet,
ola::rdm::RDMRequest *request,
uint16_t source_endpoint_id,
uint16_t destination_endpoint_id,
uint32_t sequence_number);

void BuildNullTCPPacket(IOStack *packet);

void BuildBrokerFetchClientListTCPPacket(IOStack *packet);

void BuildBrokerNullTCPPacket(IOStack *packet);

void BuildTCPE133StatusPDU(IOStack *packet,
uint32_t sequence_number, uint16_t endpoint_id,
ola::e133::E133StatusCode status_code,
Expand Down
38 changes: 38 additions & 0 deletions libs/acn/BrokerFetchClientListPDU.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.
*
* BrokerFetchClientListPDU.cpp
* The BrokerFetchClientListPDU
* Copyright (C) 2023 Peter Newman
*/

#include "libs/acn/BrokerFetchClientListPDU.h"

#include <ola/network/NetworkUtils.h>
#include <ola/acn/ACNVectors.h>

namespace ola {
namespace acn {

using ola::network::HostToNetwork;

void BrokerFetchClientListPDU::PrependPDU(ola::io::IOStack *stack) {
uint16_t vector = HostToNetwork(static_cast<uint16_t>(
VECTOR_BROKER_FETCH_CLIENT_LIST));
stack->Write(reinterpret_cast<uint8_t*>(&vector), sizeof(vector));
PrependFlagsAndLength(stack, VFLAG_MASK | HFLAG_MASK | DFLAG_MASK, true);
}
} // namespace acn
} // namespace ola
56 changes: 56 additions & 0 deletions libs/acn/BrokerFetchClientListPDU.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.
*
* BrokerFetchClientListPDU.h
* The BrokerFetchClientListPDU class
* Copyright (C) 2023 Peter Newman
*/

#ifndef LIBS_ACN_BROKERFETCHCLIENTLISTPDU_H_
#define LIBS_ACN_BROKERFETCHCLIENTLISTPDU_H_

#include <ola/io/IOStack.h>

#include "libs/acn/PDU.h"

namespace ola {
namespace acn {

class BrokerFetchClientListPDU : public PDU {
public:
explicit BrokerFetchClientListPDU(unsigned int vector):
PDU(vector, TWO_BYTES, true) {}

unsigned int HeaderSize() const { return 0; }
bool PackHeader(OLA_UNUSED uint8_t *data,
unsigned int *length) const {
*length = 0;
return true;
}
void PackHeader(OLA_UNUSED ola::io::OutputStream *stream) const {}

unsigned int DataSize() const { return 0; }
bool PackData(OLA_UNUSED uint8_t *data,
unsigned int *length) const {
*length = 0;
return true;
}
void PackData(OLA_UNUSED ola::io::OutputStream *stream) const {}

static void PrependPDU(ola::io::IOStack *stack);
};
} // namespace acn
} // namespace ola
#endif // LIBS_ACN_BROKERFETCHCLIENTLISTPDU_H_
148 changes: 148 additions & 0 deletions libs/acn/BrokerFetchClientListPDUTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* 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.
*
* BrokerFetchClientListPDUTest.cpp
* Test fixture for the BrokerFetchClientListPDU class
* Copyright (C) 2023 Peter Newman
*/

#include <cppunit/extensions/HelperMacros.h>

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

namespace ola {
namespace acn {

using ola::acn::BrokerFetchClientListPDU;
using ola::io::IOQueue;
using ola::io::IOStack;
using ola::io::OutputStream;
using ola::network::HostToNetwork;

class BrokerFetchClientListPDUTest: public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(BrokerFetchClientListPDUTest);
CPPUNIT_TEST(testSimpleBrokerFetchClientListPDU);
CPPUNIT_TEST(testSimpleBrokerFetchClientListPDUToOutputStream);
CPPUNIT_TEST(testPrepend);
CPPUNIT_TEST_SUITE_END();

public:
void testSimpleBrokerFetchClientListPDU();
void testSimpleBrokerFetchClientListPDUToOutputStream();
void testPrepend();

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

private:
static const uint16_t TEST_VECTOR;
};

CPPUNIT_TEST_SUITE_REGISTRATION(BrokerFetchClientListPDUTest);

const uint16_t BrokerFetchClientListPDUTest::TEST_VECTOR = 39;


/*
* Test that packing a BrokerFetchClientListPDU works.
*/
void BrokerFetchClientListPDUTest::testSimpleBrokerFetchClientListPDU() {
BrokerFetchClientListPDU pdu(TEST_VECTOR);

OLA_ASSERT_EQ(0u, pdu.HeaderSize());
OLA_ASSERT_EQ(0u, pdu.DataSize());
OLA_ASSERT_EQ(5u, 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]);
uint16_t actual_value;
memcpy(&actual_value, data + 3, sizeof(actual_value));
OLA_ASSERT_EQ(HostToNetwork(TEST_VECTOR), actual_value);

// 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 BrokerFetchClientListPDUTest::
testSimpleBrokerFetchClientListPDUToOutputStream() {
BrokerFetchClientListPDU pdu(TEST_VECTOR);

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

IOQueue output;
OutputStream stream(&output);
pdu.Write(&stream);
OLA_ASSERT_EQ(5u, 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, 0x05,
0, 39
};
OLA_ASSERT_DATA_EQUALS(EXPECTED, sizeof(EXPECTED), pdu_data, pdu_size);
output.Pop(output.Size());
delete[] pdu_data;
}


void BrokerFetchClientListPDUTest::testPrepend() {
IOStack stack;
BrokerFetchClientListPDU::PrependPDU(&stack);

unsigned int length = stack.Size();
uint8_t *buffer = new uint8_t[length];
OLA_ASSERT(stack.Read(buffer, length));

const uint8_t expected_data[] = {
0xf0, 0x00, 0x05,
0, 0x06
};
OLA_ASSERT_DATA_EQUALS(expected_data, sizeof(expected_data), buffer, length);
delete[] buffer;
}
} // namespace acn
} // namespace ola
8 changes: 7 additions & 1 deletion libs/acn/HeaderSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "libs/acn/E133Header.h"
#include "libs/acn/LLRPHeader.h"
#include "libs/acn/RootHeader.h"
#include "libs/acn/RPTHeader.h"
#include "libs/acn/TransportHeader.h"

namespace ola {
Expand Down Expand Up @@ -60,14 +61,18 @@ class HeaderSet {
const LLRPHeader &GetLLRPHeader() const { return m_llrp_header; }
void SetLLRPHeader(const LLRPHeader &header) { m_llrp_header = header; }

const RPTHeader &GetRPTHeader() const { return m_rpt_header; }
void SetRPTHeader(const RPTHeader &header) { m_rpt_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_llrp_header == other.m_llrp_header);
m_llrp_header == other.m_llrp_header &&
m_rpt_header == other.m_rpt_header);
}

private:
Expand All @@ -77,6 +82,7 @@ class HeaderSet {
E133Header m_e133_header;
DMPHeader m_dmp_header;
LLRPHeader m_llrp_header;
RPTHeader m_rpt_header;
};
} // namespace acn
} // namespace ola
Expand Down
Loading
Loading