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

Side by Side Diff: net/base/net_util.h

Issue 1154323007: Split network_interfaces.h off of net_utils.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ip_util
Patch Set: address matt's comments Created 5 years, 6 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/address_tracker_linux.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_BASE_NET_UTIL_H_ 5 #ifndef NET_BASE_NET_UTIL_H_
6 #define NET_BASE_NET_UTIL_H_ 6 #define NET_BASE_NET_UTIL_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
11 #include <windows.h> 11 #include <windows.h>
12 #include <ws2tcpip.h> 12 #include <ws2tcpip.h>
13 #elif defined(OS_POSIX) 13 #elif defined(OS_POSIX)
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <sys/socket.h> 15 #include <sys/socket.h>
16 #endif 16 #endif
17 17
18 #include <string> 18 #include <string>
19 #include <vector> 19 #include <vector>
20 20
21 #include "base/basictypes.h" 21 #include "base/basictypes.h"
22 #include "base/strings/string16.h" 22 #include "base/strings/string16.h"
23 #include "base/strings/utf_offset_string_conversions.h" 23 #include "base/strings/utf_offset_string_conversions.h"
24 #include "net/base/address_family.h" 24 #include "net/base/address_family.h"
25 #include "net/base/escape.h" 25 #include "net/base/escape.h"
26 #include "net/base/ip_address_number.h" 26 #include "net/base/ip_address_number.h"
27 #include "net/base/net_export.h" 27 #include "net/base/net_export.h"
28 #include "net/base/network_change_notifier.h" 28 #include "net/base/network_change_notifier.h"
29 // TODO(eroman): Remove this header and require consumers to include it
30 // directly.
31 #include "net/base/network_interfaces.h"
29 32
30 class GURL; 33 class GURL;
31 34
32 namespace base { 35 namespace base {
33 class Time; 36 class Time;
34 } 37 }
35 38
36 namespace url { 39 namespace url {
37 struct CanonHostInfo; 40 struct CanonHostInfo;
38 struct Parsed; 41 struct Parsed;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // track an endpoint and cause privacy concern. Please refer to 373 // track an endpoint and cause privacy concern. Please refer to
371 // RFC4941. 374 // RFC4941.
372 IP_ADDRESS_ATTRIBUTE_TEMPORARY = 1 << 0, 375 IP_ADDRESS_ATTRIBUTE_TEMPORARY = 1 << 0,
373 376
374 // A temporary address could become deprecated once the preferred 377 // A temporary address could become deprecated once the preferred
375 // lifetime is reached. It is still valid but shouldn't be used to 378 // lifetime is reached. It is still valid but shouldn't be used to
376 // create new connections. 379 // create new connections.
377 IP_ADDRESS_ATTRIBUTE_DEPRECATED = 1 << 1, 380 IP_ADDRESS_ATTRIBUTE_DEPRECATED = 1 << 1,
378 }; 381 };
379 382
380 // struct that is used by GetNetworkList() to represent a network
381 // interface.
382 struct NET_EXPORT NetworkInterface {
383 NetworkInterface();
384 NetworkInterface(const std::string& name,
385 const std::string& friendly_name,
386 uint32 interface_index,
387 NetworkChangeNotifier::ConnectionType type,
388 const IPAddressNumber& address,
389 uint32 prefix_length,
390 int ip_address_attributes);
391 ~NetworkInterface();
392
393 std::string name;
394 std::string friendly_name; // Same as |name| on non-Windows.
395 uint32 interface_index; // Always 0 on Android.
396 NetworkChangeNotifier::ConnectionType type;
397 IPAddressNumber address;
398 uint32 prefix_length;
399 int ip_address_attributes; // Combination of |IPAddressAttributes|.
400 };
401
402 typedef std::vector<NetworkInterface> NetworkInterfaceList;
403
404 // Policy settings to include/exclude network interfaces.
405 enum HostAddressSelectionPolicy {
406 INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES = 0x0,
407 EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES = 0x1,
408 };
409
410 // Returns list of network interfaces except loopback interface. If an
411 // interface has more than one address, a separate entry is added to
412 // the list for each address.
413 // Can be called only on a thread that allows IO.
414 NET_EXPORT bool GetNetworkList(NetworkInterfaceList* networks,
415 int policy);
416
417 // Gets the SSID of the currently associated WiFi access point if there is one.
418 // Otherwise, returns empty string.
419 // Currently only implemented on Linux, ChromeOS and Android.
420 NET_EXPORT std::string GetWifiSSID();
421
422 // General category of the IEEE 802.11 (wifi) physical layer operating mode.
423 enum WifiPHYLayerProtocol {
424 // No wifi support or no associated AP.
425 WIFI_PHY_LAYER_PROTOCOL_NONE,
426 // An obsolete modes introduced by the original 802.11, e.g. IR, FHSS.
427 WIFI_PHY_LAYER_PROTOCOL_ANCIENT,
428 // 802.11a, OFDM-based rates.
429 WIFI_PHY_LAYER_PROTOCOL_A,
430 // 802.11b, DSSS or HR DSSS.
431 WIFI_PHY_LAYER_PROTOCOL_B,
432 // 802.11g, same rates as 802.11a but compatible with 802.11b.
433 WIFI_PHY_LAYER_PROTOCOL_G,
434 // 802.11n, HT rates.
435 WIFI_PHY_LAYER_PROTOCOL_N,
436 // Unclassified mode or failure to identify.
437 WIFI_PHY_LAYER_PROTOCOL_UNKNOWN
438 };
439
440 // Characterize the PHY mode of the currently associated access point.
441 // Currently only available on OS_WIN.
442 NET_EXPORT WifiPHYLayerProtocol GetWifiPHYLayerProtocol();
443
444 enum WifiOptions {
445 // Disables background SSID scans.
446 WIFI_OPTIONS_DISABLE_SCAN = 1 << 0,
447 // Enables media streaming mode.
448 WIFI_OPTIONS_MEDIA_STREAMING_MODE = 1 << 1
449 };
450
451 class NET_EXPORT ScopedWifiOptions {
452 public:
453 ScopedWifiOptions() {}
454 virtual ~ScopedWifiOptions();
455
456 private:
457 DISALLOW_COPY_AND_ASSIGN(ScopedWifiOptions);
458 };
459
460 // Set temporary options on all wifi interfaces.
461 // |options| is an ORed bitfield of WifiOptions.
462 // Options are automatically disabled when the scoped pointer
463 // is freed. Currently only available on OS_WIN.
464 NET_EXPORT scoped_ptr<ScopedWifiOptions> SetWifiOptions(int options);
465
466 // Differentiated Services Code Point. 383 // Differentiated Services Code Point.
467 // See http://tools.ietf.org/html/rfc2474 for details. 384 // See http://tools.ietf.org/html/rfc2474 for details.
468 enum DiffServCodePoint { 385 enum DiffServCodePoint {
469 DSCP_NO_CHANGE = -1, 386 DSCP_NO_CHANGE = -1,
470 DSCP_FIRST = DSCP_NO_CHANGE, 387 DSCP_FIRST = DSCP_NO_CHANGE,
471 DSCP_DEFAULT = 0, // Same as DSCP_CS0 388 DSCP_DEFAULT = 0, // Same as DSCP_CS0
472 DSCP_CS0 = 0, // The default 389 DSCP_CS0 = 0, // The default
473 DSCP_CS1 = 8, // Bulk/background traffic 390 DSCP_CS1 = 8, // Bulk/background traffic
474 DSCP_AF11 = 10, 391 DSCP_AF11 = 10,
475 DSCP_AF12 = 12, 392 DSCP_AF12 = 12,
(...skipping 13 matching lines...) Expand all
489 DSCP_CS5 = 40, // Video 406 DSCP_CS5 = 40, // Video
490 DSCP_EF = 46, // Voice 407 DSCP_EF = 46, // Voice
491 DSCP_CS6 = 48, // Voice 408 DSCP_CS6 = 48, // Voice
492 DSCP_CS7 = 56, // Control messages 409 DSCP_CS7 = 56, // Control messages
493 DSCP_LAST = DSCP_CS7 410 DSCP_LAST = DSCP_CS7
494 }; 411 };
495 412
496 } // namespace net 413 } // namespace net
497 414
498 #endif // NET_BASE_NET_UTIL_H_ 415 #endif // NET_BASE_NET_UTIL_H_
OLDNEW
« no previous file with comments | « net/base/address_tracker_linux.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698