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 #ifdef UNSAFE_BUFFERS_BUILD 6 // TODO(crbug.com/40284755): Remove this and spanify to fix the errors. 7 #pragma allow_unsafe_buffers 8 #endif 9 10 #include "net/base/network_interfaces_posix.h" 11 12 #include <netinet/in.h> 13 #include <sys/types.h> 14 15 #include <memory> 16 #include <set> 17 18 #include "net/base/network_interfaces.h" 19 20 namespace net { 21 namespace internal { 22 23 // The application layer can pass |policy| defined in net_util.h to 24 // request filtering out certain type of interfaces. ShouldIgnoreInterface(const std::string & name,int policy)25bool 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))) { 31 return true; 32 } 33 34 return false; 35 } 36 37 // Check if the address is unspecified (i.e. made of zeroes) or loopback. IsLoopbackOrUnspecifiedAddress(const sockaddr * addr)38bool 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)) { 44 return true; 45 } 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) { 51 return true; 52 } 53 } else { 54 // Skip non-IP addresses. 55 return true; 56 } 57 return false; 58 } 59 60 } // namespace internal 61 SetWifiOptions(int options)62std::unique_ptr<ScopedWifiOptions> SetWifiOptions(int options) { 63 return nullptr; 64 } 65 66 } // namespace net 67