blob: 4b9ba9e06814ee592ee4d74a0ee39106c0ebd192 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2014 The Chromium Authors
guoweis7eb7ab52014-11-14 17:42:562// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
eromanc69886a42015-06-03 18:19:525#ifndef NET_BASE_NETWORK_INTERFACES_LINUX_H_
6#define NET_BASE_NETWORK_INTERFACES_LINUX_H_
guoweis7eb7ab52014-11-14 17:42:567
8// This file is only used to expose some of the internals
eromanc69886a42015-06-03 18:19:529// of network_interfaces_linux.cc to address_tracker_linux and tests.
guoweis7eb7ab52014-11-14 17:42:5610
meacerbc462ea2015-02-17 19:32:5311#include <string>
davidben1e912ea2016-04-20 19:17:0712#include <unordered_set>
meacerbc462ea2015-02-17 19:32:5313
pauljensen7a0c9f82017-05-17 20:52:0014#include "base/files/scoped_file.h"
guoweis7eb7ab52014-11-14 17:42:5615#include "net/base/address_tracker_linux.h"
bnc81c46c1f2016-10-04 16:25:5916#include "net/base/net_export.h"
eromanc69886a42015-06-03 18:19:5217#include "net/base/network_interfaces.h"
guoweis7eb7ab52014-11-14 17:42:5618
Tsuyoshi Horo4f516be2022-06-14 11:53:1319namespace net::internal {
guoweis7eb7ab52014-11-14 17:42:5620
derekjchow5482d5e2015-01-31 01:04:5121typedef char* (*GetInterfaceNameFunction)(int interface_index, char* ifname);
guoweis7eb7ab52014-11-14 17:42:5622
meacerbc462ea2015-02-17 19:32:5323typedef std::string (*GetInterfaceSSIDFunction)(const std::string& ifname);
24
guoweis7eb7ab52014-11-14 17:42:5625NET_EXPORT bool GetNetworkListImpl(
26 NetworkInterfaceList* networks,
27 int policy,
davidben1e912ea2016-04-20 19:17:0728 const std::unordered_set<int>& online_links,
guoweis7eb7ab52014-11-14 17:42:5629 const internal::AddressTrackerLinux::AddressMap& address_map,
30 GetInterfaceNameFunction get_interface_name);
31
meacerbc462ea2015-02-17 19:32:5332// Gets the current Wi-Fi SSID based on |interfaces|. Returns
33// empty string if there are no interfaces or if two interfaces have different
34// connection types. Otherwise returns the SSID of all interfaces if they have
35// the same SSID. This is adapted from
36// NetworkChangeNotifier::ConnectionTypeFromInterfaceList.
37NET_EXPORT std::string GetWifiSSIDFromInterfaceListInternal(
38 const NetworkInterfaceList& interfaces,
39 internal::GetInterfaceSSIDFunction get_interface_ssid);
40
pauljensen7a0c9f82017-05-17 20:52:0041// Returns a socket useful for performing ioctl()s.
42base::ScopedFD GetSocketForIoctl();
43
Tsuyoshi Horo4f516be2022-06-14 11:53:1344} // namespace net::internal
guoweis7eb7ab52014-11-14 17:42:5645
eromanc69886a42015-06-03 18:19:5246#endif // NET_BASE_NETWORK_INTERFACES_LINUX_H_