Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: net/base/net_util_posix.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/net_util_posix.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "net/base/net_util.h"
6
7 #include <set>
8 #include <sys/types.h>
9
10 #include "base/memory/scoped_ptr.h"
11
12 #if !defined(OS_NACL)
13 #include "net/base/net_util_posix.h"
14 #include <net/if.h>
15 #include <netinet/in.h>
16 #endif // !defined(OS_NACL)
17
18 namespace net {
19
20 #if !defined(OS_NACL)
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.
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))) {
31 return true;
32 }
33
34 return false;
35 }
36
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)) {
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 #else // OS_NACL
62 bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
63 NOTIMPLEMENTED();
64 return false;
65 }
66
67 std::string GetWifiSSID() {
68 NOTIMPLEMENTED();
69 return "";
70 }
71 #endif // OS_NACL
72
73 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() {
74 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN;
75 }
76
77 scoped_ptr<ScopedWifiOptions> SetWifiOptions(int options) {
78 return scoped_ptr<ScopedWifiOptions>();
79 }
80
81
82 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util_posix.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698