• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef DISCOVERY_DNSSD_IMPL_NETWORK_INTERFACE_CONFIG_H_
6 #define DISCOVERY_DNSSD_IMPL_NETWORK_INTERFACE_CONFIG_H_
7 
8 #include "platform/base/interface_info.h"
9 #include "platform/base/ip_address.h"
10 
11 namespace openscreen {
12 namespace discovery {
13 
14 class NetworkInterfaceConfig {
15  public:
16   NetworkInterfaceConfig(NetworkInterfaceIndex network_interface,
17                          IPAddress address_v4,
18                          IPAddress address_v6);
19   ~NetworkInterfaceConfig();
20 
network_interface()21   NetworkInterfaceIndex network_interface() const { return network_interface_; }
address_v4()22   const IPAddress& address_v4() const { return address_v4_; }
address_v6()23   const IPAddress& address_v6() const { return address_v6_; }
24 
25   bool HasAddressV4() const;
26   bool HasAddressV6() const;
27 
28   // Returns either the |address_v4_| or |address_v6_| depending which is
29   // present, or the empty IPAddress if neither is present.
30   const IPAddress& GetAddress() const;
31 
32  private:
33   friend class FakeNetworkInterfaceConfig;
34 
35   NetworkInterfaceConfig();
36 
37   NetworkInterfaceIndex network_interface_;
38   IPAddress address_v4_;
39   IPAddress address_v6_;
40 };
41 
42 }  // namespace discovery
43 }  // namespace openscreen
44 
45 #endif  // DISCOVERY_DNSSD_IMPL_NETWORK_INTERFACE_CONFIG_H_
46