Qingsi Wang | 0961933 | 2018-09-12 22:51:55 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2018 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef RTC_BASE_MDNS_RESPONDER_INTERFACE_H_ |
| 12 | #define RTC_BASE_MDNS_RESPONDER_INTERFACE_H_ |
| 13 | |
| 14 | #include <functional> |
| 15 | #include <map> |
| 16 | #include <memory> |
| 17 | #include <set> |
| 18 | #include <string> |
| 19 | |
| 20 | #include "rtc_base/ipaddress.h" |
| 21 | #include "rtc_base/socketaddress.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | // Defines an mDNS responder that can be used in ICE candidate gathering, where |
| 26 | // the local IP addresses of host candidates are obfuscated by mDNS hostnames. |
| 27 | class MDnsResponderInterface { |
| 28 | public: |
| 29 | using NameCreatedCallback = |
| 30 | std::function<void(const rtc::IPAddress&, const std::string&)>; |
| 31 | using NameRemovedCallback = std::function<void(bool)>; |
| 32 | |
| 33 | MDnsResponderInterface() = default; |
| 34 | virtual ~MDnsResponderInterface() = default; |
| 35 | |
| 36 | // Asynchronously creates a type-4 UUID hostname for an IP address. The |
| 37 | // created name should be given to |callback| with the address that it |
| 38 | // represents. |
| 39 | virtual void CreateNameForAddress(const rtc::IPAddress& addr, |
| 40 | NameCreatedCallback callback) = 0; |
| 41 | // Removes the name mapped to the given address if there is such an |
| 42 | // name-address mapping previously created via CreateNameForAddress. The |
| 43 | // result of whether an associated name-address mapping is removed should be |
| 44 | // given to |callback|. |
| 45 | virtual void RemoveNameForAddress(const rtc::IPAddress& addr, |
| 46 | NameRemovedCallback callback) = 0; |
| 47 | }; |
| 48 | |
| 49 | } // namespace webrtc |
| 50 | |
| 51 | #endif // RTC_BASE_MDNS_RESPONDER_INTERFACE_H_ |