aboutsummaryrefslogtreecommitdiff
path: root/discovery/mdns
diff options
context:
space:
mode:
authorRyan Keane <rwkeane@google.com>2020-04-06 08:28:41 -0700
committerCommit Bot <commit-bot@chromium.org>2020-04-06 16:15:26 +0000
commit59b20e348f4dff95941dae02a0dfdd47c8faec5b (patch)
tree8edcf6f27bb8467f575f81187aa44e4b98568444 /discovery/mdns
parent14215fbea0c8139796893b8062ab444d5b0df4b3 (diff)
downloadopenscreen-59b20e348f4dff95941dae02a0dfdd47c8faec5b.tar.gz
Discovery: Multiple Network Interfaces Part 1
This CL is the first part of supporting multiple network interfaces. It makes necessary change for duplicate instances of DNS-SD to exist, each responsible for a single Network Interface. Additionally, as the endpoint is no longer published as part of the DnsSdInstanceRecord, these parameters are removed and use of this class is split into 2 parts - one containing the endpoints and one not. Future CLs will be responsible for: - Updating E2E tests. - Adding support for initiating multiple instances of discovery/dnssd/impl/service_impl.h (and renaming it). For full context, see CL: https://chromium-review.googlesource.com/c/openscreen/+/2076164 Bug: openscreen:105 Change-Id: I52168f03513d1a605ae3feda50a221f9f505cd79 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2093012 Commit-Queue: Ryan Keane <rwkeane@google.com> Reviewed-by: mark a. foltz <mfoltz@chromium.org> Reviewed-by: Max Yakimakha <yakimakha@chromium.org>
Diffstat (limited to 'discovery/mdns')
-rw-r--r--discovery/mdns/mdns_service_impl.cc9
-rw-r--r--discovery/mdns/mdns_service_impl.h4
-rw-r--r--discovery/mdns/public/mdns_service.h24
3 files changed, 8 insertions, 29 deletions
diff --git a/discovery/mdns/mdns_service_impl.cc b/discovery/mdns/mdns_service_impl.cc
index 61762510..ba4eb038 100644
--- a/discovery/mdns/mdns_service_impl.cc
+++ b/discovery/mdns/mdns_service_impl.cc
@@ -6,7 +6,6 @@
#include <memory>
-#include "discovery/common/config.h"
#include "discovery/common/reporting_client.h"
#include "discovery/mdns/mdns_records.h"
#include "discovery/mdns/public/mdns_constants.h"
@@ -20,7 +19,7 @@ std::unique_ptr<MdnsService> MdnsService::Create(
ReportingClient* reporting_client,
const Config& config,
NetworkInterfaceIndex network_interface,
- SupportedNetworkAddressFamily supported_address_types) {
+ Config::NetworkInfo::AddressFamilies supported_address_types) {
return std::make_unique<MdnsServiceImpl>(
task_runner, Clock::now, reporting_client, config, network_interface,
supported_address_types);
@@ -32,7 +31,7 @@ MdnsServiceImpl::MdnsServiceImpl(
ReportingClient* reporting_client,
const Config& config,
NetworkInterfaceIndex network_interface,
- SupportedNetworkAddressFamily supported_address_types)
+ Config::NetworkInfo::AddressFamilies supported_address_types)
: task_runner_(task_runner),
now_function_(now_function),
reporting_client_(reporting_client) {
@@ -43,7 +42,7 @@ MdnsServiceImpl::MdnsServiceImpl(
// Create all UDP sockets needed for this object. They should not yet be bound
// so that they do not send or receive data until the objects on which their
// callback depends is initialized.
- if (supported_address_types & kUseIpV4Multicast) {
+ if (supported_address_types & Config::NetworkInfo::kUseIpV4) {
ErrorOr<std::unique_ptr<UdpSocket>> socket = UdpSocket::Create(
task_runner, this, kDefaultMulticastGroupIPv4Endpoint);
OSP_DCHECK(!socket.is_error());
@@ -58,7 +57,7 @@ MdnsServiceImpl::MdnsServiceImpl(
network_interface);
}
- if (supported_address_types & kUseIpV6Multicast) {
+ if (supported_address_types & Config::NetworkInfo::kUseIpV6) {
ErrorOr<std::unique_ptr<UdpSocket>> socket = UdpSocket::Create(
task_runner, this, kDefaultMulticastGroupIPv6Endpoint);
OSP_DCHECK(!socket.is_error());
diff --git a/discovery/mdns/mdns_service_impl.h b/discovery/mdns/mdns_service_impl.h
index 7da1c1a9..e87d84a2 100644
--- a/discovery/mdns/mdns_service_impl.h
+++ b/discovery/mdns/mdns_service_impl.h
@@ -5,6 +5,7 @@
#ifndef DISCOVERY_MDNS_MDNS_SERVICE_IMPL_H_
#define DISCOVERY_MDNS_MDNS_SERVICE_IMPL_H_
+#include "discovery/common/config.h"
#include "discovery/mdns/mdns_domain_confirmed_provider.h"
#include "discovery/mdns/mdns_probe_manager.h"
#include "discovery/mdns/mdns_publisher.h"
@@ -26,7 +27,6 @@ class TaskRunner;
namespace discovery {
-struct Config;
class NetworkConfig;
class ReportingClient;
@@ -39,7 +39,7 @@ class MdnsServiceImpl : public MdnsService, public UdpSocket::Client {
ReportingClient* reporting_client,
const Config& config,
NetworkInterfaceIndex network_interface,
- SupportedNetworkAddressFamily supported_address_types);
+ Config::NetworkInfo::AddressFamilies supported_address_types);
~MdnsServiceImpl() override;
// MdnsService Overrides.
diff --git a/discovery/mdns/public/mdns_service.h b/discovery/mdns/public/mdns_service.h
index b32deb78..346213cd 100644
--- a/discovery/mdns/public/mdns_service.h
+++ b/discovery/mdns/public/mdns_service.h
@@ -8,6 +8,7 @@
#include <functional>
#include <memory>
+#include "discovery/common/config.h"
#include "discovery/mdns/public/mdns_constants.h"
#include "platform/base/error.h"
#include "platform/base/interface_info.h"
@@ -19,7 +20,6 @@ class TaskRunner;
namespace discovery {
-struct Config;
class DomainName;
class MdnsDomainConfirmedProvider;
class MdnsRecord;
@@ -28,12 +28,6 @@ class ReportingClient;
class MdnsService {
public:
- enum SupportedNetworkAddressFamily : uint8_t {
- kNoAddressFamily = 0,
- kUseIpV4Multicast = 0x01 << 0,
- kUseIpV6Multicast = 0x01 << 1
- };
-
MdnsService();
virtual ~MdnsService();
@@ -45,7 +39,7 @@ class MdnsService {
ReportingClient* reporting_client,
const Config& config,
NetworkInterfaceIndex network_interface,
- SupportedNetworkAddressFamily supported_address_types);
+ Config::NetworkInfo::AddressFamilies supported_address_types);
// Starts an mDNS query with the given properties. Updated records are passed
// to |callback|. The caller must ensure |callback| remains alive while it is
@@ -92,20 +86,6 @@ class MdnsService {
virtual Error UnregisterRecord(const MdnsRecord& record) = 0;
};
-inline MdnsService::SupportedNetworkAddressFamily operator&(
- MdnsService::SupportedNetworkAddressFamily lhs,
- MdnsService::SupportedNetworkAddressFamily rhs) {
- return static_cast<MdnsService::SupportedNetworkAddressFamily>(
- static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
-}
-
-inline MdnsService::SupportedNetworkAddressFamily operator|(
- MdnsService::SupportedNetworkAddressFamily lhs,
- MdnsService::SupportedNetworkAddressFamily rhs) {
- return static_cast<MdnsService::SupportedNetworkAddressFamily>(
- static_cast<uint8_t>(lhs) | static_cast<uint8_t>(rhs));
-}
-
} // namespace discovery
} // namespace openscreen