1 // Copyright (c) 2011 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.
5 #include "net/base/net_util.h"
10 #include "base/memory/scoped_ptr.h"
13 #include "net/base/network_interfaces_posix.h"
15 #include <netinet/in.h>
16 #endif // !defined(OS_NACL)
23 // The application layer can pass |policy| defined in net_util.h to
24 // request filtering out certain type of interfaces.
25 bool ShouldIgnoreInterface(const std::string
& name
, int policy
) {
26 // Filter out VMware interfaces, typically named vmnet1 and vmnet8,
27 // which might not be useful for use cases like WebRTC.
28 if ((policy
& EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES
) &&
29 ((name
.find("vmnet") != std::string::npos
) ||
30 (name
.find("vnic") != std::string::npos
))) {
37 // Check if the address is unspecified (i.e. made of zeroes) or loopback.
38 bool IsLoopbackOrUnspecifiedAddress(const sockaddr
* addr
) {
39 if (addr
->sa_family
== AF_INET6
) {
40 const struct sockaddr_in6
* addr_in6
=
41 reinterpret_cast<const struct sockaddr_in6
*>(addr
);
42 const struct in6_addr
* sin6_addr
= &addr_in6
->sin6_addr
;
43 if (IN6_IS_ADDR_LOOPBACK(sin6_addr
) || IN6_IS_ADDR_UNSPECIFIED(sin6_addr
)) {
46 } else if (addr
->sa_family
== AF_INET
) {
47 const struct sockaddr_in
* addr_in
=
48 reinterpret_cast<const struct sockaddr_in
*>(addr
);
49 if (addr_in
->sin_addr
.s_addr
== INADDR_LOOPBACK
||
50 addr_in
->sin_addr
.s_addr
== 0) {
54 // Skip non-IP addresses.
60 } // namespace internal
62 bool GetNetworkList(NetworkInterfaceList
* networks
, int policy
) {
67 std::string
GetWifiSSID() {
73 WifiPHYLayerProtocol
GetWifiPHYLayerProtocol() {
74 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN
;
77 scoped_ptr
<ScopedWifiOptions
> SetWifiOptions(int options
) {
78 return scoped_ptr
<ScopedWifiOptions
>();