From 304150a521b95654a0568536d2f8c7696dbbb333 Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Tue, 23 Aug 2016 14:48:28 -0700 Subject: [PATCH] Enable mDNS on Darwin We have to disable IPv6 to get this going, but nobody was yet using IPv6, so that should be fine for now. Test: Verified mDNS discovery on a MacBook Bug: 31042497 (cherry picked from 9ae65de087171072f3890a81b074ae27db319508) Change-Id: I628f0a1e9c4784db42fa56f5faf2904b6e1cf548 --- adb/Android.mk | 2 +- adb/transport_mdns.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/adb/Android.mk b/adb/Android.mk index 233a21f23..b12a9f8a7 100644 --- a/adb/Android.mk +++ b/adb/Android.mk @@ -151,7 +151,7 @@ LOCAL_SRC_FILES_linux := $(LIBADB_linux_SRC_FILES) LOCAL_SRC_FILES_windows := $(LIBADB_windows_SRC_FILES) LOCAL_SRC_FILES_linux += transport_mdns.cpp -LOCAL_SRC_FILES_darwin += transport_mdns_unsupported.cpp +LOCAL_SRC_FILES_darwin += transport_mdns.cpp LOCAL_SRC_FILES_windows += transport_mdns_unsupported.cpp LOCAL_SANITIZE := $(adb_host_sanitize) diff --git a/adb/transport_mdns.cpp b/adb/transport_mdns.cpp index b63fc83b4..384845252 100644 --- a/adb/transport_mdns.cpp +++ b/adb/transport_mdns.cpp @@ -85,10 +85,17 @@ class ResolvedService : public AsyncServiceRef { const char* hosttarget, uint16_t port) : name_(name), port_(port) { + + /* TODO: We should be able to get IPv6 support by adding + * kDNSServiceProtocol_IPv6 to the flags below. However, when we do + * this, we get served link-local addresses that are usually useless to + * connect to. What's more, we seem to /only/ get those and nothing else. + * If we want IPv6 in the future we'll have to figure out why. + */ DNSServiceErrorType ret = DNSServiceGetAddrInfo( &sdRef_, 0, interfaceIndex, - kDNSServiceProtocol_IPv6|kDNSServiceProtocol_IPv4, hosttarget, + kDNSServiceProtocol_IPv4, hosttarget, register_service_ip, reinterpret_cast(this)); if (ret != kDNSServiceErr_NoError) {