Permalink
Browse files

Merge pull request #1531 from OpenLightingProject/revert-1528-protobu…

…f-3.6

Revert "Make plugin interface selection track olad unless you've explicitly overridden them"
  • Loading branch information...
peternewman committed Jan 7, 2019
2 parents eff749e + 10d7661 commit cb021b41860ab63a5cb3add27e7fa91ac32511bb
Showing with 206 additions and 578 deletions.
  1. +2 −9 common/base/Flags.cpp
  2. +2 −2 common/network/AdvancedTCPConnectorTest.cpp
  3. +2 −19 common/network/Interface.cpp
  4. +10 −97 common/network/InterfacePicker.cpp
  5. +22 −116 common/network/InterfacePickerTest.cpp
  6. +1 −17 common/network/InterfaceTest.cpp
  7. +2 −2 common/network/SocketTest.cpp
  8. +1 −1 common/network/TCPConnectorTest.cpp
  9. +3 −3 include/ola/network/IPV4Address.h
  10. +1 −19 include/ola/network/Interface.h
  11. +0 −10 include/ola/network/InterfacePicker.h
  12. +1 −1 include/ola/testing/TestUtils.h
  13. +2 −12 include/olad/PluginAdaptor.h
  14. +11 −7 libs/acn/E131Node.cpp
  15. +4 −5 libs/acn/E131Node.h
  16. +3 −15 libs/acn/E131TestFramework.cpp
  17. +3 −17 libs/acn/e131_loadtest.cpp
  18. +1 −1 olad/OlaServer.cpp
  19. +2 −2 olad/PluginManagerTest.cpp
  20. +3 −10 olad/plugin_api/PluginAdaptor.cpp
  21. +1 −1 olad/plugin_api/PortTest.cpp
  22. +5 −5 olad/plugin_api/Preferences.cpp
  23. +3 −3 olad/plugin_api/UniverseTest.cpp
  24. +0 −1 plugins/artnet/ArtNetDevice.cpp
  25. +1 −1 plugins/artnet/ArtNetNode.h
  26. +1 −14 plugins/e131/E131Device.cpp
  27. +1 −14 plugins/espnet/EspNetDevice.cpp
  28. +19 −18 plugins/espnet/EspNetNode.cpp
  29. +1 −2 plugins/espnet/EspNetNode.h
  30. +2 −16 plugins/pathport/PathportDevice.cpp
  31. +23 −26 plugins/pathport/PathportNode.cpp
  32. +5 −6 plugins/pathport/PathportNode.h
  33. +1 −14 plugins/sandnet/SandNetDevice.cpp
  34. +29 −33 plugins/sandnet/SandNetNode.cpp
  35. +3 −3 plugins/sandnet/SandNetNode.h
  36. +1 −15 plugins/shownet/ShowNetDevice.cpp
  37. +25 −24 plugins/shownet/ShowNetNode.cpp
  38. +2 −3 plugins/shownet/ShowNetNode.h
  39. +1 −4 plugins/shownet/ShowNetNodeTest.cpp
  40. +2 −4 tools/e133/e133-monitor.cpp
  41. +4 −6 tools/e133/e133-receiver.cpp
@@ -358,15 +358,8 @@ void FlagRegistry::GenManPage() {
str << " <" << flag->arg_type() << ">";
}
if (flag->short_opt()) {
if (flag->name() == FLAGS_version.name()) {
std::ostringstream help_str;
help_str << "Print\n.B " << exe_name << "\nversion information.";
short_flag_lines.push_back(
OptionPair(str.str(), help_str.str()));
} else {
short_flag_lines.push_back(
OptionPair(str.str(), iter->second->help()));
}
short_flag_lines.push_back(
OptionPair(str.str(), iter->second->help()));
} else {
long_flag_lines.push_back(
OptionPair(str.str(), iter->second->help()));
@@ -399,7 +399,7 @@ uint16_t AdvancedTCPConnectorTest::ReservePort() {
void AdvancedTCPConnectorTest::AcceptedConnection(TCPSocket *new_socket) {
OLA_ASSERT_NOT_NULL(new_socket);
GenericSocketAddress address = new_socket->GetPeerAddress();
OLA_ASSERT_EQ(address.Family(), static_cast<uint16_t>(AF_INET));
OLA_ASSERT_TRUE(address.Family() == AF_INET);
OLA_INFO << "Connection from " << address;

// terminate the ss when this connection is closed
@@ -415,7 +415,7 @@ void AdvancedTCPConnectorTest::OnConnect(TCPSocket *socket) {
OLA_ASSERT_NOT_NULL(socket);

GenericSocketAddress address = socket->GetPeerAddress();
OLA_ASSERT_EQ(address.Family(), static_cast<uint16_t>(AF_INET));
OLA_ASSERT_TRUE(address.Family() == AF_INET);
OLA_ASSERT_EQ(m_localhost, address.V4Addr().Host());

m_connected_socket = socket;
@@ -117,32 +117,16 @@ Interface& Interface::operator=(const Interface &other) {
}


bool Interface::operator==(const Interface &other) const {
bool Interface::operator==(const Interface &other) {
return (name == other.name &&
ip_address == other.ip_address &&
bcast_address == other.bcast_address &&
subnet_mask == other.subnet_mask &&
hw_address == other.hw_address &&
loopback == other.loopback &&
index == other.index &&
type == other.type);
}


string Interface::ToString(const string &separator) const {
std::ostringstream str;
str << name << separator
<< "Index: " << index << separator
<< "IP: " << ip_address << separator
<< "Broadcast: " << bcast_address << separator
<< "Subnet: " << subnet_mask << separator
<< "Type: " << type << separator
<< "MAC: " << hw_address << separator
<< "Loopback: " << loopback;
return str.str();
}


/**
* Create a new interface builder
*/
@@ -244,9 +228,8 @@ Interface InterfaceBuilder::Construct() {
bool InterfaceBuilder::SetAddress(const string &str,
IPV4Address *target) {
IPV4Address tmp_address;
if (!IPV4Address::FromString(str, &tmp_address)) {
if (!IPV4Address::FromString(str, &tmp_address))
return false;
}
*target = tmp_address;
return true;
}
@@ -19,7 +19,6 @@
*/

#include <string.h>
#include <algorithm>
#include <string>
#include <vector>

@@ -45,7 +44,7 @@ using std::vector;
* @param iface, the interface to populate
* @param ip_or_name the IP address or interface name of the local interface
* we'd prefer to use.
* @param options an Options struct configuring ChooseInterface
* @param options a Options struct configuring ChooseInterface
* @return true if we found an interface, false otherwise
*/
// TODO(Simon): Change these to callback based code to reduce duplication.
@@ -85,106 +84,22 @@ bool InterfacePicker::ChooseInterface(
}
}

if (!found && options.specific_only) {
if (!found && options.specific_only)
return false; // No match and being fussy
}

if (!found) {
if (!found)
*iface = interfaces[0];
}
OLA_DEBUG << "Using interface " << iface->name << " ("
<< iface->ip_address << ")";
OLA_DEBUG << "Using interface " << iface->name << " (" <<
iface->ip_address << ")";
return true;
}


/*
* Select an interface to use
* @param iface, the interface to populate
* @param ip_or_name the IP address or interface name of the local interface
* we'd prefer to use.
* @param default_ip_or_name the IP address or interface name of the local
* interface we'd prefer to fall back to if ip_or_name isn't found.
* @param options an Options struct configuring ChooseInterface
* @return true if we found an interface, false otherwise
*/
// TODO(Simon): Change these to callback based code to reduce duplication.
bool InterfacePicker::ChooseInterface(
Interface *iface,
const string &ip_or_name,
const string &default_ip_or_name,
const Options &options) const {
Options restricted_options = options;
if (!default_ip_or_name.empty()) {
// Need to force strict mode in the options here, so we only get a real
// match
restricted_options.specific_only = true;
}
if (!ip_or_name.empty() &&
ChooseInterface(iface, ip_or_name, restricted_options)) {
return true;
} else {
return ChooseInterface(iface, default_ip_or_name, options);
}
}


/*
* Select an interface to use
* @param iface, the interface to populate
* @param ip_or_name the IP address or interface name of the local interface
* we'd prefer to use.
* @param default_iface the Interface we'd prefer to fall back to if
* ip_or_name isn't found.
* @param options an Options struct configuring ChooseInterface
* @return true if we found an interface, false otherwise
*/
// TODO(Simon): Change these to callback based code to reduce duplication.
bool InterfacePicker::ChooseInterface(
Interface *iface,
const string &ip_or_name,
const Interface default_iface,
const Options &options) const {
Options restricted_options = options;
// Need to force strict mode in the options here, so we only get a real match
restricted_options.specific_only = true;
if (!ip_or_name.empty() &&
ChooseInterface(iface, ip_or_name, restricted_options)) {
return true;
} else {
vector<Interface> interfaces = GetInterfaces(options.include_loopback);
if (interfaces.empty()) {
OLA_INFO << "No interfaces found";
return false;
}

// Check that default_iface is actually in the picker list
vector<Interface>::const_iterator iter = std::find(
interfaces.begin(), interfaces.end(), default_iface);
if (iter != interfaces.end()) {
*iface = *iter;
return true;
} else {
OLA_INFO << "Default interface " << default_iface << " does not exist in "
"the InterfacePicker list";
if (options.specific_only) {
return false;
} else {
*iface = interfaces[0];
OLA_DEBUG << "Falling back to interface " << iface->name << " ("
<< iface->ip_address << ")";
return true;
}
}
}
}


/*
* Select an interface to use by index
* @param iface, the interface to populate
* @param index the index of the local interface we'd prefer to use.
* @param options an Options struct configuring ChooseInterface
* @param options a Options struct configuring ChooseInterface
* @return true if we found an interface, false otherwise
*/
// TODO(Simon): Change these to callback based code to reduce duplication.
@@ -210,15 +125,13 @@ bool InterfacePicker::ChooseInterface(
}
}

if (!found && options.specific_only) {
if (!found && options.specific_only)
return false; // No match and being fussy
}

if (!found) {
if (!found)
*iface = interfaces[0];
}
OLA_DEBUG << "Using interface " << iface->name << " ("
<< iface->ip_address << ") with index " << iface->index;
OLA_DEBUG << "Using interface " << iface->name << " (" <<
iface->ip_address << ") with index " << iface->index;
return true;
}

Oops, something went wrong.

0 comments on commit cb021b4

Please sign in to comment.