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

Changes to allow build on FreeBSD #1460

Merged
merged 9 commits into from
Aug 13, 2018
6 changes: 3 additions & 3 deletions common/network/PosixInterfacePicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#endif // HAVE_SYS_SOCKET_H
#include <arpa/inet.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> // Required by FreeBSD
#include <netinet/in.h> // Required by FreeBSD
#endif // HAVE_NETINET_IN_H
#include <errno.h>
#include <net/if.h>
Expand Down Expand Up @@ -226,7 +226,7 @@ vector<Interface> PosixInterfacePicker::GetInterfaces(
interface.index = ifrcopy.ifr_index;
#else
interface.index = ifrcopy.ifr_ifindex;
#endif // SIOCGIFINDEX
#endif // __FreeBSD__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot!

}
}
#elif defined(HAVE_IF_NAMETOINDEX)
Expand All @@ -235,7 +235,7 @@ vector<Interface> PosixInterfacePicker::GetInterfaces(
if (index != 0) {
interface.index = index;
}
#endif // defined(HAVE_IF_NAMETOINDEX)
#endif // SIOCGIFINDEX

/* ok, if that all failed we should prob try and use sysctl to work out the
* broadcast and hardware addresses
Expand Down
26 changes: 26 additions & 0 deletions common/web/JsonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,12 @@ void JsonTest::testLookups() {
JsonString string1("foo");
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(&string1),
string1.LookupElement(empty_pointer));

#ifdef __FreeBSD__
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
#else
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
#endif // __FreeBSD__
string1.LookupElement(invalid_pointer));

// Now try an object
Expand All @@ -571,7 +576,12 @@ void JsonTest::testLookups() {
object.LookupElement(empty_pointer));
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(name_value),
object.LookupElement(name_pointer));

#ifdef __FreeBSD__
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
#else
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
#endif // __FreeBSD__
object.LookupElement(invalid_pointer));

// Now try an array
Expand All @@ -591,17 +601,33 @@ void JsonTest::testLookups() {

OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(array),
array->LookupElement(empty_pointer));

#ifdef __FreeBSD__
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
#else
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
#endif // __FreeBSD__
array->LookupElement(invalid_pointer));

OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(string2),
array->LookupElement(first));
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(string3),
array->LookupElement(middle));
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(string4),
array->LookupElement(last));

#ifdef __FreeBSD__
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
#else
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
#endif // __FreeBSD__
array->LookupElement(one_past_last));

#ifdef __FreeBSD__
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(0),
#else
OLA_ASSERT_EQ(reinterpret_cast<JsonValue*>(NULL),
#endif // __FreeBSD__
array->LookupElement(invalid));

// now a nested case
Expand Down
2 changes: 1 addition & 1 deletion config/resolv.m4
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ AC_CHECK_HEADERS([resolv.h])
am_save_LDFLAGS="$LDFLAGS"
RESOLV_LIBS=""

acx_resolv_libs="-lresolv -resolv"
acx_resolv_libs="-lresolv -resolv -lc"
for lib in $acx_resolv_libs; do
acx_resolv_ok=no
LDFLAGS="$am_save_LDFLAGS $lib"
Expand Down
4 changes: 4 additions & 0 deletions ola/AutoStart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ TCPSocket *ConnectToServer(unsigned short port) {
// Try to start the server, we pass --daemon (fork into background) and
// --syslog (log to syslog).
execlp("olad", "olad", "--daemon", "--syslog",
#ifdef __FreeBSD__
reinterpret_cast<char*>(0));
#else
reinterpret_cast<char*>(NULL));
#endif // __FreeBSD__
OLA_WARN << "Failed to exec: " << strerror(errno);
_exit(1);
}
Expand Down
36 changes: 36 additions & 0 deletions olad/plugin_api/UniverseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,11 @@ void UniverseTest::testRDMSend() {
&UniverseTest::ConfirmRDM,
__LINE__,
ola::rdm::RDM_UNKNOWN_UID,
#ifdef __FreeBSD__
reinterpret_cast<const RDMResponse*>(0)));
#else
reinterpret_cast<const RDMResponse*>(NULL)));
#endif // __FreeBSD__

// ok, now try something that returns a response from the port
request = new ola::rdm::RDMGetRequest(
Expand All @@ -654,7 +658,11 @@ void UniverseTest::testRDMSend() {
&UniverseTest::ConfirmRDM,
__LINE__,
ola::rdm::RDM_TIMEOUT,
#ifdef __FreeBSD__
reinterpret_cast<const RDMResponse*>(0)));
#else
reinterpret_cast<const RDMResponse*>(NULL)));
#endif // __FreeBSD__

// now try a broadcast fan out
UID vendorcast_uid = UID::VendorcastAddress(0x7a70);
Expand Down Expand Up @@ -683,7 +691,11 @@ void UniverseTest::testRDMSend() {
&UniverseTest::ConfirmRDM,
__LINE__,
ola::rdm::RDM_WAS_BROADCAST,
#ifdef __FreeBSD__
reinterpret_cast<const RDMResponse*>(0)));
#else
reinterpret_cast<const RDMResponse*>(NULL)));
#endif // __FreeBSD__

// now confirm that if one of the ports fails to send, we see this response
request = new ola::rdm::RDMGetRequest(
Expand All @@ -707,7 +719,11 @@ void UniverseTest::testRDMSend() {
&UniverseTest::ConfirmRDM,
__LINE__,
ola::rdm::RDM_FAILED_TO_SEND,
#ifdef __FreeBSD__
reinterpret_cast<const RDMResponse*>(0)));
#else
reinterpret_cast<const RDMResponse*>(NULL)));
#endif // __FreeBSD__

// DUB responses are slightly different
request = NewDiscoveryUniqueBranchRequest(source_uid, uid1, uid2, 0);
Expand All @@ -727,7 +743,11 @@ void UniverseTest::testRDMSend() {
&UniverseTest::ConfirmRDM,
__LINE__,
ola::rdm::RDM_DUB_RESPONSE,
#ifdef __FreeBSD__
reinterpret_cast<const RDMResponse*>(0)));
#else
reinterpret_cast<const RDMResponse*>(NULL)));
#endif // __FreeBSD__

// now check that we still get a RDM_DUB_RESPONSE even if one port returns an
// RDM_TIMEOUT
Expand All @@ -744,7 +764,11 @@ void UniverseTest::testRDMSend() {
&UniverseTest::ConfirmRDM,
__LINE__,
ola::rdm::RDM_DUB_RESPONSE,
#ifdef __FreeBSD__
reinterpret_cast<const RDMResponse*>(0)));
#else
reinterpret_cast<const RDMResponse*>(NULL)));
#endif // __FreeBSD__

// and the same again but the second port returns
// RDM_PLUGIN_DISCOVERY_NOT_SUPPORTED
Expand All @@ -761,7 +785,11 @@ void UniverseTest::testRDMSend() {
&UniverseTest::ConfirmRDM,
__LINE__,
ola::rdm::RDM_DUB_RESPONSE,
#ifdef __FreeBSD__
reinterpret_cast<const RDMResponse*>(0)));
#else
reinterpret_cast<const RDMResponse*>(NULL)));
#endif // __FreeBSD__

// now the first port returns a RDM_TIMEOUT
request = NewDiscoveryUniqueBranchRequest(source_uid, uid1, uid2, 0);
Expand All @@ -777,7 +805,11 @@ void UniverseTest::testRDMSend() {
&UniverseTest::ConfirmRDM,
__LINE__,
ola::rdm::RDM_TIMEOUT,
#ifdef __FreeBSD__
reinterpret_cast<const RDMResponse*>(0)));
#else
reinterpret_cast<const RDMResponse*>(NULL)));
#endif // __FreeBSD__

// finally if neither ports support the DUB, we should return that
request = NewDiscoveryUniqueBranchRequest(source_uid, uid1, uid2, 0);
Expand All @@ -793,7 +825,11 @@ void UniverseTest::testRDMSend() {
&UniverseTest::ConfirmRDM,
__LINE__,
ola::rdm::RDM_PLUGIN_DISCOVERY_NOT_SUPPORTED,
#ifdef __FreeBSD__
reinterpret_cast<const RDMResponse*>(0)));
#else
reinterpret_cast<const RDMResponse*>(NULL)));
#endif // __FreeBSD__

universe->RemovePort(&port1);
universe->RemovePort(&port2);
Expand Down