xref: /aosp_15_r20/external/webrtc/rtc_base/network.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2004 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_NETWORK_H_
12 #define RTC_BASE_NETWORK_H_
13 
14 #include <stdint.h>
15 
16 #include <deque>
17 #include <map>
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "absl/base/attributes.h"
23 #include "absl/strings/string_view.h"
24 #include "api/array_view.h"
25 #include "api/field_trials_view.h"
26 #include "api/sequence_checker.h"
27 #include "api/task_queue/pending_task_safety_flag.h"
28 #include "api/transport/field_trial_based_config.h"
29 #include "rtc_base/ip_address.h"
30 #include "rtc_base/mdns_responder_interface.h"
31 #include "rtc_base/memory/always_valid_pointer.h"
32 #include "rtc_base/network_monitor.h"
33 #include "rtc_base/network_monitor_factory.h"
34 #include "rtc_base/socket_factory.h"
35 #include "rtc_base/system/rtc_export.h"
36 #include "rtc_base/third_party/sigslot/sigslot.h"
37 #include "rtc_base/thread_annotations.h"
38 
39 #if defined(WEBRTC_POSIX)
40 struct ifaddrs;
41 #endif  // defined(WEBRTC_POSIX)
42 
43 namespace rtc {
44 
45 extern const char kPublicIPv4Host[];
46 extern const char kPublicIPv6Host[];
47 
48 class IfAddrsConverter;
49 class Network;
50 class NetworkMonitorInterface;
51 class Thread;
52 
53 // By default, ignore loopback interfaces on the host.
54 const int kDefaultNetworkIgnoreMask = ADAPTER_TYPE_LOOPBACK;
55 
56 namespace webrtc_network_internal {
57 bool CompareNetworks(const std::unique_ptr<Network>& a,
58                      const std::unique_ptr<Network>& b);
59 }  // namespace webrtc_network_internal
60 
61 // Makes a string key for this network. Used in the network manager's maps.
62 // Network objects are keyed on interface name, network prefix and the
63 // length of that prefix.
64 std::string MakeNetworkKey(absl::string_view name,
65                            const IPAddress& prefix,
66                            int prefix_length);
67 
68 // Utility function that attempts to determine an adapter type by an interface
69 // name (e.g., "wlan0"). Can be used by NetworkManager subclasses when other
70 // mechanisms fail to determine the type.
71 RTC_EXPORT AdapterType GetAdapterTypeFromName(absl::string_view network_name);
72 
73 class DefaultLocalAddressProvider {
74  public:
75   virtual ~DefaultLocalAddressProvider() = default;
76 
77   // The default local address is the local address used in multi-homed endpoint
78   // when the any address (0.0.0.0 or ::) is used as the local address. It's
79   // important to check the return value as a IP family may not be enabled.
80   virtual bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const = 0;
81 };
82 
83 class MdnsResponderProvider {
84  public:
85   virtual ~MdnsResponderProvider() = default;
86 
87   // Returns the mDNS responder that can be used to obfuscate the local IP
88   // addresses of ICE host candidates by mDNS hostnames.
89   //
90   // The provider MUST outlive the mDNS responder.
91   virtual webrtc::MdnsResponderInterface* GetMdnsResponder() const = 0;
92 };
93 
94 // Network/mask in CIDR representation.
95 class NetworkMask {
96  public:
NetworkMask(const IPAddress & addr,int prefix_length)97   NetworkMask(const IPAddress& addr, int prefix_length)
98       : address_(addr), prefix_length_(prefix_length) {}
99 
address()100   const IPAddress& address() const { return address_; }
prefix_length()101   int prefix_length() const { return prefix_length_; }
102 
103   bool operator==(const NetworkMask& o) const {
104     return address_ == o.address_ && prefix_length_ == o.prefix_length_;
105   }
106 
107  private:
108   IPAddress address_;
109   // Length of valid bits in address_ (for ipv4 valid range is 0-32)
110   int prefix_length_;
111 };
112 
113 // Generic network manager interface. It provides list of local
114 // networks.
115 //
116 // Every method of NetworkManager (including the destructor) must be called on
117 // the same thread, except for the constructor which may be called on any
118 // thread.
119 //
120 // This allows constructing a NetworkManager subclass on one thread and
121 // passing it into an object that uses it on a different thread.
122 class RTC_EXPORT NetworkManager : public DefaultLocalAddressProvider,
123                                   public MdnsResponderProvider {
124  public:
125   // This enum indicates whether adapter enumeration is allowed.
126   enum EnumerationPermission {
127     ENUMERATION_ALLOWED,  // Adapter enumeration is allowed. Getting 0 network
128                           // from GetNetworks means that there is no network
129                           // available.
130     ENUMERATION_BLOCKED,  // Adapter enumeration is disabled.
131                           // GetAnyAddressNetworks() should be used instead.
132   };
133 
134   // Called when network list is updated.
135   sigslot::signal0<> SignalNetworksChanged;
136 
137   // Indicates a failure when getting list of network interfaces.
138   sigslot::signal0<> SignalError;
139 
140   // This should be called on the NetworkManager's thread before the
141   // NetworkManager is used. Subclasses may override this if necessary.
Initialize()142   virtual void Initialize() {}
143 
144   // Start/Stop monitoring of network interfaces
145   // list. SignalNetworksChanged or SignalError is emitted immediately
146   // after StartUpdating() is called. After that SignalNetworksChanged
147   // is emitted whenever list of networks changes.
148   virtual void StartUpdating() = 0;
149   virtual void StopUpdating() = 0;
150 
151   // Returns the current list of networks available on this machine.
152   // StartUpdating() must be called before this method is called.
153   // It makes sure that repeated calls return the same object for a
154   // given network, so that quality is tracked appropriately. Does not
155   // include ignored networks.
156   // The returned vector of Network* is valid as long as the NetworkManager is
157   // alive.
158   virtual std::vector<const Network*> GetNetworks() const = 0;
159 
160   // Returns the current permission state of GetNetworks().
161   virtual EnumerationPermission enumeration_permission() const;
162 
163   // "AnyAddressNetwork" is a network which only contains single "any address"
164   // IP address.  (i.e. INADDR_ANY for IPv4 or in6addr_any for IPv6). This is
165   // useful as binding to such interfaces allow default routing behavior like
166   // http traffic.
167   //
168   // This method appends the "any address" networks to the list, such that this
169   // can optionally be called after GetNetworks.
170   virtual std::vector<const Network*> GetAnyAddressNetworks() = 0;
171 
172   // Dumps the current list of networks in the network manager.
DumpNetworks()173   virtual void DumpNetworks() {}
174   bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const override;
175 
176   struct Stats {
177     int ipv4_network_count;
178     int ipv6_network_count;
StatsStats179     Stats() {
180       ipv4_network_count = 0;
181       ipv6_network_count = 0;
182     }
183   };
184 
185   // MdnsResponderProvider interface.
186   webrtc::MdnsResponderInterface* GetMdnsResponder() const override;
187 
set_vpn_list(const std::vector<NetworkMask> & vpn)188   virtual void set_vpn_list(const std::vector<NetworkMask>& vpn) {}
189 };
190 
191 // Base class for NetworkManager implementations.
192 class RTC_EXPORT NetworkManagerBase : public NetworkManager {
193  public:
194   NetworkManagerBase(const webrtc::FieldTrialsView* field_trials = nullptr);
195 
196   std::vector<const Network*> GetNetworks() const override;
197   std::vector<const Network*> GetAnyAddressNetworks() override;
198 
199   EnumerationPermission enumeration_permission() const override;
200 
201   bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const override;
202 
203   // Check if MAC address in |bytes| is one of the pre-defined
204   // MAC addresses for know VPNs.
205   static bool IsVpnMacAddress(rtc::ArrayView<const uint8_t> address);
206 
207  protected:
208   // Updates `networks_` with the networks listed in `list`. If
209   // `networks_map_` already has a Network object for a network listed
210   // in the `list` then it is reused. Accept ownership of the Network
211   // objects in the `list`. `changed` will be set to true if there is
212   // any change in the network list.
213   void MergeNetworkList(std::vector<std::unique_ptr<Network>> list,
214                         bool* changed);
215 
216   // `stats` will be populated even if |*changed| is false.
217   void MergeNetworkList(std::vector<std::unique_ptr<Network>> list,
218                         bool* changed,
219                         NetworkManager::Stats* stats);
220 
set_enumeration_permission(EnumerationPermission state)221   void set_enumeration_permission(EnumerationPermission state) {
222     enumeration_permission_ = state;
223   }
224 
225   void set_default_local_addresses(const IPAddress& ipv4,
226                                    const IPAddress& ipv6);
227 
228   Network* GetNetworkFromAddress(const rtc::IPAddress& ip) const;
229 
230   // To enable subclasses to get the networks list, without interfering with
231   // refactoring of the interface GetNetworks method.
GetNetworksInternal()232   const std::vector<Network*>& GetNetworksInternal() const { return networks_; }
233 
234   std::unique_ptr<Network> CreateNetwork(absl::string_view name,
235                                          absl::string_view description,
236                                          const IPAddress& prefix,
237                                          int prefix_length,
238                                          AdapterType type) const;
239 
field_trials()240   const webrtc::FieldTrialsView* field_trials() const {
241     return field_trials_.get();
242   }
243 
244  private:
245   friend class NetworkTest;
246   webrtc::AlwaysValidPointer<const webrtc::FieldTrialsView,
247                              webrtc::FieldTrialBasedConfig>
248       field_trials_;
249   EnumerationPermission enumeration_permission_;
250 
251   std::vector<Network*> networks_;
252 
253   std::map<std::string, std::unique_ptr<Network>> networks_map_;
254 
255   std::unique_ptr<rtc::Network> ipv4_any_address_network_;
256   std::unique_ptr<rtc::Network> ipv6_any_address_network_;
257 
258   IPAddress default_local_ipv4_address_;
259   IPAddress default_local_ipv6_address_;
260   // We use 16 bits to save the bandwidth consumption when sending the network
261   // id over the Internet. It is OK that the 16-bit integer overflows to get a
262   // network id 0 because we only compare the network ids in the old and the new
263   // best connections in the transport channel.
264   uint16_t next_available_network_id_ = 1;
265 
266   // True if calling network_preference() with a changed value
267   // should result in firing the SignalNetworkChanged signal.
268   bool signal_network_preference_change_ = false;
269 };
270 
271 // Basic implementation of the NetworkManager interface that gets list
272 // of networks using OS APIs.
273 class RTC_EXPORT BasicNetworkManager : public NetworkManagerBase,
274                                        public NetworkBinderInterface,
275                                        public sigslot::has_slots<> {
276  public:
277   // This is used by lots of downstream code.
278   BasicNetworkManager(SocketFactory* socket_factory,
279                       const webrtc::FieldTrialsView* field_trials = nullptr)
BasicNetworkManager(nullptr,socket_factory,field_trials)280       : BasicNetworkManager(/* network_monitor_factory= */ nullptr,
281                             socket_factory,
282                             field_trials) {}
283 
284   BasicNetworkManager(NetworkMonitorFactory* network_monitor_factory,
285                       SocketFactory* socket_factory,
286                       const webrtc::FieldTrialsView* field_trials = nullptr);
287   ~BasicNetworkManager() override;
288 
289   void StartUpdating() override;
290   void StopUpdating() override;
291 
292   void DumpNetworks() override;
293 
started()294   bool started() { return start_count_ > 0; }
295 
296   // Sets the network ignore list, which is empty by default. Any network on the
297   // ignore list will be filtered from network enumeration results.
298   // Should be called only before initialization.
set_network_ignore_list(const std::vector<std::string> & list)299   void set_network_ignore_list(const std::vector<std::string>& list) {
300     RTC_DCHECK(thread_ == nullptr);
301     network_ignore_list_ = list;
302   }
303 
304   // Set a list of manually configured VPN's.
305   void set_vpn_list(const std::vector<NetworkMask>& vpn) override;
306 
307   // Check if |prefix| is configured as VPN.
308   bool IsConfiguredVpn(IPAddress prefix, int prefix_length) const;
309 
310   // Bind a socket to interface that ip address belong to.
311   // Implementation look up interface name and calls
312   // BindSocketToNetwork on NetworkMonitor.
313   // The interface name is needed as e.g ipv4 over ipv6 addresses
314   // are not exposed using Android functions, but it is possible
315   // bind an ipv4 address to the interface.
316   NetworkBindingResult BindSocketToNetwork(int socket_fd,
317                                            const IPAddress& address) override;
318 
319  protected:
320 #if defined(WEBRTC_POSIX)
321   // Separated from CreateNetworks for tests.
322   void ConvertIfAddrs(ifaddrs* interfaces,
323                       IfAddrsConverter* converter,
324                       bool include_ignored,
325                       std::vector<std::unique_ptr<Network>>* networks) const
326       RTC_RUN_ON(thread_);
327   NetworkMonitorInterface::InterfaceInfo GetInterfaceInfo(
328       struct ifaddrs* cursor) const RTC_RUN_ON(thread_);
329 #endif  // defined(WEBRTC_POSIX)
330 
331   // Creates a network object for each network available on the machine.
332   bool CreateNetworks(bool include_ignored,
333                       std::vector<std::unique_ptr<Network>>* networks) const
334       RTC_RUN_ON(thread_);
335 
336   // Determines if a network should be ignored. This should only be determined
337   // based on the network's property instead of any individual IP.
338   bool IsIgnoredNetwork(const Network& network) const RTC_RUN_ON(thread_);
339 
340   // This function connects a UDP socket to a public address and returns the
341   // local address associated it. Since it binds to the "any" address
342   // internally, it returns the default local address on a multi-homed endpoint.
343   IPAddress QueryDefaultLocalAddress(int family) const RTC_RUN_ON(thread_);
344 
345  private:
346   friend class NetworkTest;
347 
348   // Creates a network monitor and listens for network updates.
349   void StartNetworkMonitor() RTC_RUN_ON(thread_);
350   // Stops and removes the network monitor.
351   void StopNetworkMonitor() RTC_RUN_ON(thread_);
352   // Called when it receives updates from the network monitor.
353   void OnNetworksChanged();
354 
355   // Updates the networks and reschedules the next update.
356   void UpdateNetworksContinually() RTC_RUN_ON(thread_);
357   // Only updates the networks; does not reschedule the next update.
358   void UpdateNetworksOnce() RTC_RUN_ON(thread_);
359 
360   Thread* thread_ = nullptr;
361   bool sent_first_update_ = true;
362   int start_count_ = 0;
363 
364   std::vector<std::string> network_ignore_list_;
365   NetworkMonitorFactory* const network_monitor_factory_;
366   SocketFactory* const socket_factory_;
367   std::unique_ptr<NetworkMonitorInterface> network_monitor_
368       RTC_GUARDED_BY(thread_);
369   bool allow_mac_based_ipv6_ RTC_GUARDED_BY(thread_) = false;
370   bool bind_using_ifname_ RTC_GUARDED_BY(thread_) = false;
371 
372   std::vector<NetworkMask> vpn_;
373   rtc::scoped_refptr<webrtc::PendingTaskSafetyFlag> task_safety_flag_;
374 };
375 
376 // Represents a Unix-type network interface, with a name and single address.
377 class RTC_EXPORT Network {
378  public:
379   Network(absl::string_view name,
380           absl::string_view description,
381           const IPAddress& prefix,
382           int prefix_length,
383           const webrtc::FieldTrialsView* field_trials = nullptr)
Network(name,description,prefix,prefix_length,rtc::ADAPTER_TYPE_UNKNOWN,field_trials)384       : Network(name,
385                 description,
386                 prefix,
387                 prefix_length,
388                 rtc::ADAPTER_TYPE_UNKNOWN,
389                 field_trials) {}
390 
391   Network(absl::string_view name,
392           absl::string_view description,
393           const IPAddress& prefix,
394           int prefix_length,
395           AdapterType type,
396           const webrtc::FieldTrialsView* field_trials = nullptr);
397 
398   Network(const Network&);
399   ~Network();
400 
401   // This signal is fired whenever type() or underlying_type_for_vpn() changes.
402   // Mutable, to support connecting on the const Network passed to cricket::Port
403   // constructor.
404   mutable sigslot::signal1<const Network*> SignalTypeChanged;
405 
406   // This signal is fired whenever network preference changes.
407   sigslot::signal1<const Network*> SignalNetworkPreferenceChanged;
408 
default_local_address_provider()409   const DefaultLocalAddressProvider* default_local_address_provider() const {
410     return default_local_address_provider_;
411   }
set_default_local_address_provider(const DefaultLocalAddressProvider * provider)412   void set_default_local_address_provider(
413       const DefaultLocalAddressProvider* provider) {
414     default_local_address_provider_ = provider;
415   }
416 
set_mdns_responder_provider(const MdnsResponderProvider * provider)417   void set_mdns_responder_provider(const MdnsResponderProvider* provider) {
418     mdns_responder_provider_ = provider;
419   }
420 
421   // Returns the name of the interface this network is associated with.
name()422   const std::string& name() const { return name_; }
423 
424   // Returns the OS-assigned name for this network. This is useful for
425   // debugging but should not be sent over the wire (for privacy reasons).
description()426   const std::string& description() const { return description_; }
427 
428   // Returns the prefix for this network.
prefix()429   const IPAddress& prefix() const { return prefix_; }
430   // Returns the length, in bits, of this network's prefix.
prefix_length()431   int prefix_length() const { return prefix_length_; }
432 
433   // Returns the family for the network prefix.
family()434   int family() const { return prefix_.family(); }
435 
436   // `key_` has unique value per network interface. Used in sorting network
437   // interfaces. Key is derived from interface name and it's prefix.
key()438   std::string key() const { return key_; }
439 
440   // Returns the Network's current idea of the 'best' IP it has.
441   // Or return an unset IP if this network has no active addresses.
442   // Here is the rule on how we mark the IPv6 address as ignorable for WebRTC.
443   // 1) return all global temporary dynamic and non-deprecated ones.
444   // 2) if #1 not available, return global ones.
445   // 3) if #2 not available and WebRTC-IPv6NetworkResolutionFixes enabled,
446   // return local link ones.
447   // 4) if #3 not available, use ULA ipv6 as last resort. (ULA stands for
448   // unique local address, which is not route-able in open internet but might
449   // be useful for a close WebRTC deployment.
450 
451   // TODO(guoweis): rule #3 actually won't happen at current
452   // implementation. The reason being that ULA address starting with
453   // 0xfc 0r 0xfd will be grouped into its own Network. The result of
454   // that is WebRTC will have one extra Network to generate candidates
455   // but the lack of rule #3 shouldn't prevent turning on IPv6 since
456   // ULA should only be tried in a close deployment anyway.
457 
458   // Note that when not specifying any flag, it's treated as case global
459   // IPv6 address
460   IPAddress GetBestIP() const;
461 
462   // Adds an active IP address to this network. Does not check for duplicates.
AddIP(const InterfaceAddress & ip)463   void AddIP(const InterfaceAddress& ip) { ips_.push_back(ip); }
AddIP(const IPAddress & ip)464   void AddIP(const IPAddress& ip) { ips_.push_back(rtc::InterfaceAddress(ip)); }
465 
466   // Sets the network's IP address list. Returns true if new IP addresses were
467   // detected. Passing true to already_changed skips this check.
468   bool SetIPs(const std::vector<InterfaceAddress>& ips, bool already_changed);
469   // Get the list of IP Addresses associated with this network.
GetIPs()470   const std::vector<InterfaceAddress>& GetIPs() const { return ips_; }
471   // Clear the network's list of addresses.
ClearIPs()472   void ClearIPs() { ips_.clear(); }
473   // Returns the mDNS responder that can be used to obfuscate the local IP
474   // addresses of host candidates by mDNS names in ICE gathering. After a
475   // name-address mapping is created by the mDNS responder, queries for the
476   // created name will be resolved by the responder.
477   webrtc::MdnsResponderInterface* GetMdnsResponder() const;
478 
479   // Returns the scope-id of the network's address.
480   // Should only be relevant for link-local IPv6 addresses.
scope_id()481   int scope_id() const { return scope_id_; }
set_scope_id(int id)482   void set_scope_id(int id) { scope_id_ = id; }
483 
484   // Indicates whether this network should be ignored, perhaps because
485   // the IP is 0, or the interface is one we know is invalid.
ignored()486   bool ignored() const { return ignored_; }
set_ignored(bool ignored)487   void set_ignored(bool ignored) { ignored_ = ignored; }
488 
type()489   AdapterType type() const { return type_; }
490   // When type() is ADAPTER_TYPE_VPN, this returns the type of the underlying
491   // network interface used by the VPN, typically the preferred network type
492   // (see for example, the method setUnderlyingNetworks(android.net.Network[])
493   // on https://developer.android.com/reference/android/net/VpnService.html).
494   // When this information is unavailable from the OS, ADAPTER_TYPE_UNKNOWN is
495   // returned.
underlying_type_for_vpn()496   AdapterType underlying_type_for_vpn() const {
497     return underlying_type_for_vpn_;
498   }
set_type(AdapterType type)499   void set_type(AdapterType type) {
500     if (type_ == type) {
501       return;
502     }
503     type_ = type;
504     if (type != ADAPTER_TYPE_VPN) {
505       underlying_type_for_vpn_ = ADAPTER_TYPE_UNKNOWN;
506     }
507     SignalTypeChanged(this);
508   }
509 
set_underlying_type_for_vpn(AdapterType type)510   void set_underlying_type_for_vpn(AdapterType type) {
511     if (underlying_type_for_vpn_ == type) {
512       return;
513     }
514     underlying_type_for_vpn_ = type;
515     SignalTypeChanged(this);
516   }
517 
IsVpn()518   bool IsVpn() const { return type_ == ADAPTER_TYPE_VPN; }
519 
IsCellular()520   bool IsCellular() const { return IsCellular(type_); }
521 
IsCellular(AdapterType type)522   static bool IsCellular(AdapterType type) {
523     switch (type) {
524       case ADAPTER_TYPE_CELLULAR:
525       case ADAPTER_TYPE_CELLULAR_2G:
526       case ADAPTER_TYPE_CELLULAR_3G:
527       case ADAPTER_TYPE_CELLULAR_4G:
528       case ADAPTER_TYPE_CELLULAR_5G:
529         return true;
530       default:
531         return false;
532     }
533   }
534 
535   // Note: This function is called "rarely".
536   // Twice per Network in BasicPortAllocator if
537   // PORTALLOCATOR_DISABLE_COSTLY_NETWORKS. Once in Port::Construct() (and when
538   // Port::OnNetworkTypeChanged is called).
539   ABSL_DEPRECATED(
540       "Use the version with field trials, see bugs.webrtc.org/webrtc:10335")
541   uint16_t GetCost(const webrtc::FieldTrialsView* field_trials = nullptr) const;
542   uint16_t GetCost(const webrtc::FieldTrialsView& field_trials) const;
543 
544   // A unique id assigned by the network manager, which may be signaled
545   // to the remote side in the candidate.
id()546   uint16_t id() const { return id_; }
set_id(uint16_t id)547   void set_id(uint16_t id) { id_ = id; }
548 
preference()549   int preference() const { return preference_; }
set_preference(int preference)550   void set_preference(int preference) { preference_ = preference; }
551 
552   // When we enumerate networks and find a previously-seen network is missing,
553   // we do not remove it (because it may be used elsewhere). Instead, we mark
554   // it inactive, so that we can detect network changes properly.
active()555   bool active() const { return active_; }
set_active(bool active)556   void set_active(bool active) {
557     if (active_ != active) {
558       active_ = active;
559     }
560   }
561 
562   // Property set by operating system/firmware that has information
563   // about connection strength to e.g WIFI router or CELL base towers.
network_preference()564   NetworkPreference network_preference() const { return network_preference_; }
set_network_preference(NetworkPreference val)565   void set_network_preference(NetworkPreference val) {
566     if (network_preference_ == val) {
567       return;
568     }
569     network_preference_ = val;
570     SignalNetworkPreferenceChanged(this);
571   }
572 
573   static std::pair<rtc::AdapterType, bool /* vpn */>
574   GuessAdapterFromNetworkCost(int network_cost);
575 
576   // Debugging description of this network
577   std::string ToString() const;
578 
579  private:
580   const webrtc::FieldTrialsView* field_trials_ = nullptr;
581   const DefaultLocalAddressProvider* default_local_address_provider_ = nullptr;
582   const MdnsResponderProvider* mdns_responder_provider_ = nullptr;
583   std::string name_;
584   std::string description_;
585   IPAddress prefix_;
586   int prefix_length_;
587   std::string key_;
588   std::vector<InterfaceAddress> ips_;
589   int scope_id_;
590   bool ignored_;
591   AdapterType type_;
592   AdapterType underlying_type_for_vpn_ = ADAPTER_TYPE_UNKNOWN;
593   int preference_;
594   bool active_ = true;
595   uint16_t id_ = 0;
596   NetworkPreference network_preference_ = NetworkPreference::NEUTRAL;
597 
598   friend class NetworkManager;
599 };
600 
601 }  // namespace rtc
602 
603 #endif  // RTC_BASE_NETWORK_H_
604