Add MDnsResponderInterface and obfuscate local IP addresses in gathering.

MDnsResponderInterface can be accessed by rtc::NetworkManager to
generate mDNS hostnames for local IP addresses, so that the addresses of
ICE host candidates are obfuscated in gathering whenever an mDNS
responder is present. The mDNS responder will handle incoming mDNS
queries about the generated mDNS hostnames, e.g. queries received from
the AsyncResolverInterface of the remote ICE endpoint.

Bug: webrtc:9605
Change-Id: Ib9e77427327b3d1fabdb1f3854d5e8457db40375
Reviewed-on: https://webrtc-review.googlesource.com/97881
Reviewed-by: Qingsi Wang <qingsi@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Qingsi Wang <qingsi@google.com>
Cr-Commit-Position: refs/heads/master@{#24714}
diff --git a/rtc_base/mdns_responder_interface.h b/rtc_base/mdns_responder_interface.h
new file mode 100644
index 0000000..9dbaf56
--- /dev/null
+++ b/rtc_base/mdns_responder_interface.h
@@ -0,0 +1,51 @@
+/*
+ *  Copyright 2018 The WebRTC Project Authors. All rights reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef RTC_BASE_MDNS_RESPONDER_INTERFACE_H_
+#define RTC_BASE_MDNS_RESPONDER_INTERFACE_H_
+
+#include <functional>
+#include <map>
+#include <memory>
+#include <set>
+#include <string>
+
+#include "rtc_base/ipaddress.h"
+#include "rtc_base/socketaddress.h"
+
+namespace webrtc {
+
+// Defines an mDNS responder that can be used in ICE candidate gathering, where
+// the local IP addresses of host candidates are obfuscated by mDNS hostnames.
+class MDnsResponderInterface {
+ public:
+  using NameCreatedCallback =
+      std::function<void(const rtc::IPAddress&, const std::string&)>;
+  using NameRemovedCallback = std::function<void(bool)>;
+
+  MDnsResponderInterface() = default;
+  virtual ~MDnsResponderInterface() = default;
+
+  // Asynchronously creates a type-4 UUID hostname for an IP address. The
+  // created name should be given to |callback| with the address that it
+  // represents.
+  virtual void CreateNameForAddress(const rtc::IPAddress& addr,
+                                    NameCreatedCallback callback) = 0;
+  // Removes the name mapped to the given address if there is such an
+  // name-address mapping previously created via CreateNameForAddress. The
+  // result of whether an associated name-address mapping is removed should be
+  // given to |callback|.
+  virtual void RemoveNameForAddress(const rtc::IPAddress& addr,
+                                    NameRemovedCallback callback) = 0;
+};
+
+}  // namespace webrtc
+
+#endif  // RTC_BASE_MDNS_RESPONDER_INTERFACE_H_