1 // Copyright 2015 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/base/network_interfaces_posix.h" 6 7 #include <netinet/in.h> 8 #include <sys/types.h> 9 10 #include <memory> 11 #include <set> 12 13 #include "net/base/network_interfaces.h" 14 15 namespace net { 16 namespace internal { 17 18 // The application layer can pass |policy| defined in net_util.h to 19 // request filtering out certain type of interfaces. ShouldIgnoreInterface(const std::string & name,int policy)20bool ShouldIgnoreInterface(const std::string& name, int policy) { 21 // Filter out VMware interfaces, typically named vmnet1 and vmnet8, 22 // which might not be useful for use cases like WebRTC. 23 if ((policy & EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES) && 24 ((name.find("vmnet") != std::string::npos) || 25 (name.find("vnic") != std::string::npos))) { 26 return true; 27 } 28 29 return false; 30 } 31 32 // Check if the address is unspecified (i.e. made of zeroes) or loopback. IsLoopbackOrUnspecifiedAddress(const sockaddr * addr)33bool IsLoopbackOrUnspecifiedAddress(const sockaddr* addr) { 34 if (addr->sa_family == AF_INET6) { 35 const struct sockaddr_in6* addr_in6 = 36 reinterpret_cast<const struct sockaddr_in6*>(addr); 37 const struct in6_addr* sin6_addr = &addr_in6->sin6_addr; 38 if (IN6_IS_ADDR_LOOPBACK(sin6_addr) || IN6_IS_ADDR_UNSPECIFIED(sin6_addr)) { 39 return true; 40 } 41 } else if (addr->sa_family == AF_INET) { 42 const struct sockaddr_in* addr_in = 43 reinterpret_cast<const struct sockaddr_in*>(addr); 44 if (addr_in->sin_addr.s_addr == INADDR_LOOPBACK || 45 addr_in->sin_addr.s_addr == 0) { 46 return true; 47 } 48 } else { 49 // Skip non-IP addresses. 50 return true; 51 } 52 return false; 53 } 54 55 } // namespace internal 56 GetWifiPHYLayerProtocol()57WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { 58 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; 59 } 60 SetWifiOptions(int options)61std::unique_ptr<ScopedWifiOptions> SetWifiOptions(int options) { 62 return nullptr; 63 } 64 65 } // namespace net 66