Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/openlightingproject/ola i…
Browse files Browse the repository at this point in the history
…nto e1.33-controller
  • Loading branch information
peternewman committed Dec 25, 2023
2 parents ec58616 + 1a68747 commit c73d3b3
Show file tree
Hide file tree
Showing 40 changed files with 930 additions and 175 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
pkg: "gcc g++"
- id: "distcheck-debian-stable-amd64-gcc"
task: "distcheck"
configure-args: "--enable-ja-rule --enable-e133 --enable-rdm-tests --enable-java-libs"
configure-args: "--enable-ja-rule --enable-e133 --enable-rdm-tests"
# TODO(Perry): Fix Debian 12 OOM issue on GitHub Actions
container: "debian:stable"
compiler:
Expand All @@ -30,7 +30,7 @@ jobs:
pkg: "gcc g++"
- id: "distcheck-debian-stable-amd64-clang"
task: "distcheck"
configure-args: "--enable-ja-rule --enable-e133 --enable-rdm-tests --enable-java-libs"
configure-args: "--enable-ja-rule --enable-e133 --enable-rdm-tests"
# TODO(Perry): Fix Debian 12 OOM issue on GitHub Actions
container: "debian:stable"
compiler:
Expand All @@ -50,13 +50,13 @@ jobs:
run: apt-get update -y
# See comments beginning at
# https://github.com/actions/runner/issues/763#issuecomment-1435474884
# Without Git, actions/checkout@v3 will resort to REST and will not
# Without Git, actions/checkout@v4 will resort to REST and will not
# create a .git folder or .git.config. The Problem Matcher looks for
# .git/config to find where the root of the repo is, so it must be
# present.
- name: Install Git
run: apt-get -y install git
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install build tools
shell: bash
run: |
Expand Down Expand Up @@ -90,17 +90,18 @@ jobs:
- name: Autoreconf
run: sudo --preserve-env -u builduser env "PATH=$PATH" autoreconf -i
- name: Set configure arguments
# Env var name DISTCHECK_CONFIGURE_FLAGS must be used, see #1881 and #1883
run: |
echo "GH_OLA_CONFIGURE_ARGS=${{ matrix.configure-args }}" >> $GITHUB_ENV
echo "DISTCHECK_CONFIGURE_FLAGS=${{ matrix.configure-args }}" >> $GITHUB_ENV
- name: Set additional Linux configure arguments
if: runner.os == 'Linux'
# Silence all deprecated declarations on Linux due to auto_ptr making the build log too long
run: |
echo "GH_OLA_CONFIGURE_ARGS=$GH_OLA_CONFIGURE_ARGS CPPFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV
echo "DISTCHECK_CONFIGURE_FLAGS=$DISTCHECK_CONFIGURE_FLAGS CPPFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV
- name: Print configure command
run: echo "./configure $GH_OLA_CONFIGURE_ARGS"
run: echo "./configure $DISTCHECK_CONFIGURE_FLAGS"
- name: Configure
run: sudo --preserve-env -u builduser env "PATH=$PATH" ./configure $GH_OLA_CONFIGURE_ARGS
run: sudo --preserve-env -u builduser env "PATH=$PATH" ./configure $DISTCHECK_CONFIGURE_FLAGS
- name: ${{ matrix.task }}
run: sudo --preserve-env -u builduser env "PATH=$PATH" make ${{ matrix.task }} -j${{ steps.num-cpu-cores.outputs.NUM_CPU_CORES }} VERBOSE=1
- name: Display structure of the built files
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:
run: apt-get update -y
# See comments beginning at
# https://github.com/actions/runner/issues/763#issuecomment-1435474884
# Without Git, actions/checkout@v3 will resort to REST and will not
# Without Git, actions/checkout@v4 will resort to REST and will not
# create a .git folder or .git.config. The Problem Matcher looks for
# .git/config to find where the root of the repo is, so it must be
# present.
- name: Install Git
run: apt-get -y install git
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install build tools
run: apt-get -y install devscripts adduser fakeroot sudo
- name: Install build dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/isort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ jobs:
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: isort/isort-action@v1
6 changes: 3 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
run: apt-get update -y
# See comments beginning at
# https://github.com/actions/runner/issues/763#issuecomment-1435474884
# Without Git, actions/checkout@v3 will resort to REST and will not
# Without Git, actions/checkout@v4 will resort to REST and will not
# create a .git folder or .git.config. The Problem Matcher looks for
# .git/config to find where the root of the repo is, so it must be
# present.
- name: Install Git
run: apt-get -y install git
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install build tools
shell: bash
run: |
Expand Down Expand Up @@ -260,7 +260,7 @@ jobs:
name: weblint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js v18
uses: actions/setup-node@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ elif [[ $TASK = 'pychecker-wip' ]]; then
pychecker --quiet --limit 500 --blacklist $PYCHECKER_BLACKLIST $(find ./ -name "*.py" -and ! \( -name "*_pb2.py" -or -name "OlaClient.py" -or -name "ola_candidate_ports.py" \) | xargs)
else
# Otherwise compile and check as normal
# Env var name DISTCHECK_CONFIGURE_FLAGS must be used, see #1881 and #1883
if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then
# Silence all deprecated declarations on Linux due to auto_ptr making the build log too long
export DISTCHECK_CONFIGURE_FLAGS='--enable-rdm-tests --enable-java-libs --enable-ja-rule --enable-e133 CPPFLAGS=-Wno-deprecated-declarations'
Expand Down
2 changes: 1 addition & 1 deletion README.developer
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The release lifecycle is:
- New feature work occurs on the master branch.
- Once the new features are considered stable or enough time has passed, a new
minor release branch will be created, e.g. 0.10.
- The minor release branch will be stablized with bugfixes, these bug fixes
- The minor release branch will be stabilized with bugfixes, these bug fixes
will also be merged back into master.
- Once declared stable, a new patch branch 0 will be created e.g. 0.10.0
- Release specific changes like the version number, debian files etc. will be
Expand Down
2 changes: 1 addition & 1 deletion common/io/IOStackTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void IOStackTest::testAppendToQueue() {
}

/**
* Confirm we re-use blocks
* Confirm we reuse blocks
*/
void IOStackTest::testBlockReuse() {
MemoryBlockPool pool(4);
Expand Down
2 changes: 1 addition & 1 deletion common/io/PollerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace io {
* reentrant. Calling any of the read / write / close actions may in turn add /
* remove descriptors, including the descriptor the method was itself called
* on. There are tests in SelectServerTest.cpp to exercise some of these cases
* but implementors need to be careful.
* but implementers need to be careful.
*
* @warning
* For example, if Poll() iterates over a set of Descriptors and calls
Expand Down
8 changes: 8 additions & 0 deletions common/messaging/DescriptorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using ola::messaging::BoolFieldDescriptor;
using ola::messaging::FieldDescriptor;
using ola::messaging::FieldDescriptorGroup;
using ola::messaging::IPV4FieldDescriptor;
using ola::messaging::MACFieldDescriptor;
using ola::messaging::StringFieldDescriptor;
using ola::messaging::UIDFieldDescriptor;
using ola::messaging::UInt16FieldDescriptor;
Expand Down Expand Up @@ -76,6 +77,13 @@ void DescriptorTest::testFieldDescriptors() {
OLA_ASSERT_TRUE(ipv4_descriptor.LimitedSize());
OLA_ASSERT_EQ(4u, ipv4_descriptor.MaxSize());

// MAC address
MACFieldDescriptor mac_descriptor("mac");
OLA_ASSERT_EQ(string("mac"), mac_descriptor.Name());
OLA_ASSERT_TRUE(mac_descriptor.FixedSize());
OLA_ASSERT_TRUE(mac_descriptor.LimitedSize());
OLA_ASSERT_EQ(6u, mac_descriptor.MaxSize());

// UID
UIDFieldDescriptor uid_descriptor("uid");
OLA_ASSERT_EQ(string("uid"), uid_descriptor.Name());
Expand Down
18 changes: 13 additions & 5 deletions common/messaging/MessagePrinterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@
using std::string;
using std::vector;
using ola::rdm::UID;
using ola::network::MACAddress;


using ola::messaging::BoolFieldDescriptor;
using ola::messaging::BoolMessageField;
using ola::messaging::FieldDescriptor;
using ola::messaging::FieldDescriptorGroup;
using ola::messaging::GroupMessageField;
using ola::messaging::IPV4FieldDescriptor;
using ola::messaging::GenericMessagePrinter;
using ola::messaging::IPV4MessageField;
using ola::messaging::GroupMessageField;
using ola::messaging::Int16FieldDescriptor;
using ola::messaging::Int16MessageField;
using ola::messaging::Int8FieldDescriptor;
using ola::messaging::Int8MessageField;
using ola::messaging::IPV4FieldDescriptor;
using ola::messaging::IPV4MessageField;
using ola::messaging::MACFieldDescriptor;
using ola::messaging::MACMessageField;
using ola::messaging::Message;
using ola::messaging::MessageFieldInterface;
using ola::messaging::StringFieldDescriptor;
Expand Down Expand Up @@ -87,6 +90,7 @@ void GenericMessagePrinterTest::testSimplePrinter() {
// setup some fields
BoolFieldDescriptor bool_descriptor("On/Off");
IPV4FieldDescriptor ipv4_descriptor("ip");
MACFieldDescriptor mac_descriptor("mac");
UIDFieldDescriptor uid_descriptor("uid");
StringFieldDescriptor string_descriptor("Name", 0, 32);
UInt32FieldDescriptor uint32_descriptor("Id");
Expand All @@ -100,6 +104,9 @@ void GenericMessagePrinterTest::testSimplePrinter() {
fields.push_back(
new IPV4MessageField(&ipv4_descriptor,
ola::network::HostToNetwork(0x0a000001)));
fields.push_back(
new MACMessageField(&mac_descriptor,
MACAddress::FromStringOrDie("01:23:45:67:89:ab")));
fields.push_back(new UIDMessageField(&uid_descriptor, UID(0x7a70, 1)));
fields.push_back(new StringMessageField(&string_descriptor, "foobar"));
fields.push_back(new UInt32MessageField(&uint32_descriptor, 42));
Expand All @@ -109,8 +116,9 @@ void GenericMessagePrinterTest::testSimplePrinter() {

Message message(fields);
string expected = (
"On/Off: false\nip: 10.0.0.1\nuid: 7a70:00000001\nName: foobar\nId: 42\n"
"Count: 4 x 10 ^ -3\nDelta: 10 x 10 ^ 1\nRate: 10 x 10 ^ -1\n");
"On/Off: false\nip: 10.0.0.1\nmac: 01:23:45:67:89:ab\n"
"uid: 7a70:00000001\nName: foobar\nId: 42\nCount: 4 x 10 ^ -3\n"
"Delta: 10 x 10 ^ 1\nRate: 10 x 10 ^ -1\n");
OLA_ASSERT_EQ(expected, m_printer.AsString(&message));
}

Expand Down
2 changes: 1 addition & 1 deletion common/network/IPV4Address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* IPV4Address.cpp
* A IPV4 address
* An IPV4 address
* Copyright (C) 2011 Simon Newton
*/

Expand Down
170 changes: 170 additions & 0 deletions common/network/IPV6Address.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* IPV6Address.cpp
* An IPV6 address
* Copyright (C) 2023 Peter Newman
*/

#if HAVE_CONFIG_H
#include <config.h>
#endif // HAVE_CONFIG_H

#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> // Required by FreeBSD
#endif // HAVE_SYS_SOCKET_H
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif // HAVE_ARPA_INET_H
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> // Required by FreeBSD
#endif // HAVE_NETINET_IN_H

#include <assert.h>
#include <math.h>
#include <stdint.h>
#include <limits>
#include <string>

#include "common/network/NetworkUtilsInternal.h"
#include "ola/Logging.h"
#include "ola/network/IPV6Address.h"
#include "ola/network/NetworkUtils.h"

namespace ola {
namespace network {

using std::string;

IPV6Address::IPV6Address(const uint8_t *address) {
// TODO(Peter): Deal with any network byte order conversion?
memcpy(&m_address.s6_addr[0], address, sizeof (struct in6_addr));
}

bool IPV6Address::operator<(const IPV6Address &other) const {
// TODO(Peter): Deal with any network byte order conversion?
return (memcmp(&m_address.s6_addr[0],
&other.m_address.s6_addr[0],
sizeof (struct in6_addr)) < 0);
}

bool IPV6Address::operator>(const IPV6Address &other) const {
// TODO(Peter): Deal with any network byte order conversion?
return (memcmp(&m_address.s6_addr[0],
&other.m_address.s6_addr[0],
sizeof (struct in6_addr)) > 0);
}

bool IPV6StringToAddress(const string &address, struct in6_addr *addr) {
bool ok;
//// TODO(Peter): This currently allows some rather quirky values as per
//// inet_pton, we may want to restrict that in future to match IPV6Validator
//// if that deviates

if (address.empty()) {
// Don't bother trying to extract an address if we weren't given one
return false;
}

#ifdef HAVE_INET_PTON
ok = (1 == inet_pton(AF_INET6, address.data(), addr));
#else
OLA_FATAL << "Failed to convert string to address, inet_pton unavailable";
return false;
#endif // HAVE_INET_PTON

if (!ok) {
OLA_WARN << "Could not convert address " << address;
}
return ok;
}

bool IPV6Address::IsWildcard() const {
return IN6_IS_ADDR_UNSPECIFIED(&m_address);
}

string IPV6Address::ToString() const {
struct in6_addr addr;
addr = m_address;
#ifdef HAVE_INET_NTOP
char str[INET6_ADDRSTRLEN];
if (inet_ntop(AF_INET6, &addr, str, INET6_ADDRSTRLEN) == NULL) {
OLA_FATAL << "Failed to convert address to string using inet_ntop";
return NULL;
}
return str;
#else
OLA_FATAL << "Failed to convert address to string, inet_ntop unavailable";
return NULL;
#endif // HAVE_INET_NTOP
}

IPV6Address* IPV6Address::FromString(const string &address) {
struct in6_addr addr;
if (!IPV6StringToAddress(address, &addr)) {
return NULL;
}

return new IPV6Address(addr);
}

bool IPV6Address::FromString(const string &address, IPV6Address *target) {
struct in6_addr addr;
if (!IPV6StringToAddress(address, &addr)) {
return false;
}
*target = IPV6Address(addr);
return true;
}

IPV6Address IPV6Address::FromStringOrDie(const string &address) {
struct in6_addr addr;
assert(IPV6StringToAddress(address, &addr));
return IPV6Address(addr);
}

/*bool IPV6Address::ToCIDRMask(IPV6Address address, uint8_t *mask) {
uint32_t netmask = NetworkToHost(address.AsInt());
uint8_t bits = 0;
bool seen_one = false;
for (uint8_t i = 0; i < std::numeric_limits<uint32_t>::digits; i++) {
if (netmask & 1) {
bits++;
seen_one = true;
} else {
if (seen_one) {
return false;
}
}
netmask = netmask >> 1;
}
*mask = bits;
return true;
}*/

IPV6Address IPV6Address::WildCard() {
in6_addr wildCard = IN6ADDR_ANY_INIT;
// TODO(Peter): Deal with any host to network conversion...
return IPV6Address(wildCard);
}

IPV6Address IPV6Address::Loopback() {
in6_addr loopback = IN6ADDR_LOOPBACK_INIT;
// TODO(Peter): Deal with any host to network conversion...
// return IPV6Address(HostToNetwork(IN6ADDR_LOOPBACK_INIT));
return IPV6Address(loopback);
}
} // namespace network
} // namespace ola
Loading

0 comments on commit c73d3b3

Please sign in to comment.