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 3// found in the LICENSE file. 4 5#ifndef NET_BASE_NET_UTIL_H_ 6#define NET_BASE_NET_UTIL_H_ 7 8#include "build/build_config.h" 9 10#if defined(OS_WIN) 11#include <windows.h> 12#include <ws2tcpip.h> 13#elif defined(OS_POSIX) 14#include <sys/types.h> 15#include <sys/socket.h> 16#endif 17 18#include <string> 19#include <vector> 20 21#include "base/basictypes.h" 22#include "base/strings/string16.h" 23#include "base/strings/utf_offset_string_conversions.h" 24#include "net/base/address_family.h" 25#include "net/base/escape.h" 26#include "net/base/net_export.h" 27#include "net/base/network_change_notifier.h" 28 29class GURL; 30 31namespace base { 32class Time; 33} 34 35namespace url { 36struct CanonHostInfo; 37struct Parsed; 38} 39 40namespace net { 41 42// Used by FormatUrl to specify handling of certain parts of the url. 43typedef uint32 FormatUrlType; 44typedef uint32 FormatUrlTypes; 45 46// IPAddressNumber is used to represent an IP address's numeric value as an 47// array of bytes, from most significant to least significant. This is the 48// network byte ordering. 49// 50// IPv4 addresses will have length 4, whereas IPv6 address will have length 16. 51typedef std::vector<unsigned char> IPAddressNumber; 52typedef std::vector<IPAddressNumber> IPAddressList; 53 54static const size_t kIPv4AddressSize = 4; 55static const size_t kIPv6AddressSize = 16; 56#if defined(OS_WIN) 57// Bluetooth address size. Windows Bluetooth is supported via winsock. 58static const size_t kBluetoothAddressSize = 6; 59#endif 60 61// Nothing is ommitted. 62NET_EXPORT extern const FormatUrlType kFormatUrlOmitNothing; 63 64// If set, any username and password are removed. 65NET_EXPORT extern const FormatUrlType kFormatUrlOmitUsernamePassword; 66 67// If the scheme is 'http://', it's removed. 68NET_EXPORT extern const FormatUrlType kFormatUrlOmitHTTP; 69 70// Omits the path if it is just a slash and there is no query or ref. This is 71// meaningful for non-file "standard" URLs. 72NET_EXPORT extern const FormatUrlType kFormatUrlOmitTrailingSlashOnBareHostname; 73 74// Convenience for omitting all unecessary types. 75NET_EXPORT extern const FormatUrlType kFormatUrlOmitAll; 76 77// Returns the number of explicitly allowed ports; for testing. 78NET_EXPORT_PRIVATE extern size_t GetCountOfExplicitlyAllowedPorts(); 79 80// Splits an input of the form <host>[":"<port>] into its consitituent parts. 81// Saves the result into |*host| and |*port|. If the input did not have 82// the optional port, sets |*port| to -1. 83// Returns true if the parsing was successful, false otherwise. 84// The returned host is NOT canonicalized, and may be invalid. 85// 86// IPv6 literals must be specified in a bracketed form, for instance: 87// [::1]:90 and [::1] 88// 89// The resultant |*host| in both cases will be "::1" (not bracketed). 90NET_EXPORT bool ParseHostAndPort( 91 std::string::const_iterator host_and_port_begin, 92 std::string::const_iterator host_and_port_end, 93 std::string* host, 94 int* port); 95NET_EXPORT bool ParseHostAndPort( 96 const std::string& host_and_port, 97 std::string* host, 98 int* port); 99 100// Returns a host:port string for the given URL. 101NET_EXPORT std::string GetHostAndPort(const GURL& url); 102 103// Returns a host[:port] string for the given URL, where the port is omitted 104// if it is the default for the URL's scheme. 105NET_EXPORT_PRIVATE std::string GetHostAndOptionalPort(const GURL& url); 106 107// Returns true if |hostname| contains a non-registerable or non-assignable 108// domain name (eg: a gTLD that has not been assigned by IANA) or an IP address 109// that falls in an IANA-reserved range. 110NET_EXPORT bool IsHostnameNonUnique(const std::string& hostname); 111 112// Returns true if an IP address hostname is in a range reserved by the IANA. 113// Works with both IPv4 and IPv6 addresses, and only compares against a given 114// protocols's reserved ranges. 115NET_EXPORT bool IsIPAddressReserved(const IPAddressNumber& address); 116 117// Convenience struct for when you need a |struct sockaddr|. 118struct SockaddrStorage { 119 SockaddrStorage() : addr_len(sizeof(addr_storage)), 120 addr(reinterpret_cast<struct sockaddr*>(&addr_storage)) {} 121 SockaddrStorage(const SockaddrStorage& other); 122 void operator=(const SockaddrStorage& other); 123 124 struct sockaddr_storage addr_storage; 125 socklen_t addr_len; 126 struct sockaddr* const addr; 127}; 128 129// Extracts the IP address and port portions of a sockaddr. |port| is optional, 130// and will not be filled in if NULL. 131bool GetIPAddressFromSockAddr(const struct sockaddr* sock_addr, 132 socklen_t sock_addr_len, 133 const unsigned char** address, 134 size_t* address_len, 135 uint16* port); 136 137// Returns the string representation of an IP address. 138// For example: "192.168.0.1" or "::1". 139NET_EXPORT std::string IPAddressToString(const uint8* address, 140 size_t address_len); 141 142// Returns the string representation of an IP address along with its port. 143// For example: "192.168.0.1:99" or "[::1]:80". 144NET_EXPORT std::string IPAddressToStringWithPort(const uint8* address, 145 size_t address_len, 146 uint16 port); 147 148// Same as IPAddressToString() but for a sockaddr. This output will not include 149// the IPv6 scope ID. 150NET_EXPORT std::string NetAddressToString(const struct sockaddr* sa, 151 socklen_t sock_addr_len); 152 153// Same as IPAddressToStringWithPort() but for a sockaddr. This output will not 154// include the IPv6 scope ID. 155NET_EXPORT std::string NetAddressToStringWithPort(const struct sockaddr* sa, 156 socklen_t sock_addr_len); 157 158// Same as IPAddressToString() but for an IPAddressNumber. 159NET_EXPORT std::string IPAddressToString(const IPAddressNumber& addr); 160 161// Same as IPAddressToStringWithPort() but for an IPAddressNumber. 162NET_EXPORT std::string IPAddressToStringWithPort( 163 const IPAddressNumber& addr, uint16 port); 164 165// Returns the address as a sequence of bytes in network-byte-order. 166NET_EXPORT std::string IPAddressToPackedString(const IPAddressNumber& addr); 167 168// Returns the hostname of the current system. Returns empty string on failure. 169NET_EXPORT std::string GetHostName(); 170 171// Extracts the unescaped username/password from |url|, saving the results 172// into |*username| and |*password|. 173NET_EXPORT_PRIVATE void GetIdentityFromURL(const GURL& url, 174 base::string16* username, 175 base::string16* password); 176 177// Returns either the host from |url|, or, if the host is empty, the full spec. 178NET_EXPORT std::string GetHostOrSpecFromURL(const GURL& url); 179 180// Return the value of the HTTP response header with name 'name'. 'headers' 181// should be in the format that URLRequest::GetResponseHeaders() returns. 182// Returns the empty string if the header is not found. 183NET_EXPORT std::string GetSpecificHeader(const std::string& headers, 184 const std::string& name); 185 186// Converts the given host name to unicode characters. This can be called for 187// any host name, if the input is not IDN or is invalid in some way, we'll just 188// return the ASCII source so it is still usable. 189// 190// The input should be the canonicalized ASCII host name from GURL. This 191// function does NOT accept UTF-8! 192// 193// |languages| is a comma separated list of ISO 639 language codes. It 194// is used to determine whether a hostname is 'comprehensible' to a user 195// who understands languages listed. |host| will be converted to a 196// human-readable form (Unicode) ONLY when each component of |host| is 197// regarded as 'comprehensible'. Scipt-mixing is not allowed except that 198// Latin letters in the ASCII range can be mixed with a limited set of 199// script-language pairs (currently Han, Kana and Hangul for zh,ja and ko). 200// When |languages| is empty, even that mixing is not allowed. 201NET_EXPORT base::string16 IDNToUnicode(const std::string& host, 202 const std::string& languages); 203 204// Canonicalizes |host| and returns it. Also fills |host_info| with 205// IP address information. |host_info| must not be NULL. 206NET_EXPORT std::string CanonicalizeHost(const std::string& host, 207 url::CanonHostInfo* host_info); 208 209// Returns true if |host| is not an IP address and is compliant with a set of 210// rules based on RFC 1738 and tweaked to be compatible with the real world. 211// The rules are: 212// * One or more components separated by '.' 213// * Each component begins with an alphanumeric character or '-' 214// * Each component contains only alphanumeric characters and '-' or '_' 215// * Each component ends with an alphanumeric character or '-' 216// * The last component begins with an alphanumeric character 217// * Optional trailing dot after last component (means "treat as FQDN") 218// If |desired_tld| is non-NULL, the host will only be considered invalid if 219// appending it as a trailing component still results in an invalid host. This 220// helps us avoid marking as "invalid" user attempts to open, say, "www.-9.com" 221// by typing -, 9, <ctrl>+<enter>. 222// 223// NOTE: You should only pass in hosts that have been returned from 224// CanonicalizeHost(), or you may not get accurate results. 225NET_EXPORT bool IsCanonicalizedHostCompliant(const std::string& host, 226 const std::string& desired_tld); 227 228// Call these functions to get the html snippet for a directory listing. 229// The return values of both functions are in UTF-8. 230NET_EXPORT std::string GetDirectoryListingHeader(const base::string16& title); 231 232// Given the name of a file in a directory (ftp or local) and 233// other information (is_dir, size, modification time), it returns 234// the html snippet to add the entry for the file to the directory listing. 235// Currently, it's a script tag containing a call to a Javascript function 236// |addRow|. 237// 238// |name| is the file name to be displayed. |raw_bytes| will be used 239// as the actual target of the link (so for example, ftp links should use 240// server's encoding). If |raw_bytes| is an empty string, UTF-8 encoded |name| 241// will be used. 242// 243// Both |name| and |raw_bytes| are escaped internally. 244NET_EXPORT std::string GetDirectoryListingEntry(const base::string16& name, 245 const std::string& raw_bytes, 246 bool is_dir, int64 size, 247 base::Time modified); 248 249// If text starts with "www." it is removed, otherwise text is returned 250// unmodified. 251NET_EXPORT base::string16 StripWWW(const base::string16& text); 252 253// Runs |url|'s host through StripWWW(). |url| must be valid. 254NET_EXPORT base::string16 StripWWWFromHost(const GURL& url); 255 256// Checks |port| against a list of ports which are restricted by default. 257// Returns true if |port| is allowed, false if it is restricted. 258NET_EXPORT bool IsPortAllowedByDefault(int port); 259 260// Checks |port| against a list of ports which are restricted by the FTP 261// protocol. Returns true if |port| is allowed, false if it is restricted. 262NET_EXPORT_PRIVATE bool IsPortAllowedByFtp(int port); 263 264// Check if banned |port| has been overriden by an entry in 265// |explicitly_allowed_ports_|. 266NET_EXPORT_PRIVATE bool IsPortAllowedByOverride(int port); 267 268// Set socket to non-blocking mode 269NET_EXPORT int SetNonBlocking(int fd); 270 271// Formats the host in |url| and appends it to |output|. The host formatter 272// takes the same accept languages component as ElideURL(). 273NET_EXPORT void AppendFormattedHost(const GURL& url, 274 const std::string& languages, 275 base::string16* output); 276 277// Creates a string representation of |url|. The IDN host name may be in Unicode 278// if |languages| accepts the Unicode representation. |format_type| is a bitmask 279// of FormatUrlTypes, see it for details. |unescape_rules| defines how to clean 280// the URL for human readability. You will generally want |UnescapeRule::SPACES| 281// for display to the user if you can handle spaces, or |UnescapeRule::NORMAL| 282// if not. If the path part and the query part seem to be encoded in %-encoded 283// UTF-8, decodes %-encoding and UTF-8. 284// 285// The last three parameters may be NULL. 286// 287// |new_parsed| will be set to the parsing parameters of the resultant URL. 288// 289// |prefix_end| will be the length before the hostname of the resultant URL. 290// 291// |offset[s]_for_adjustment| specifies one or more offsets into the original 292// URL, representing insertion or selection points between characters: if the 293// input is "http://foo.com/", offset 0 is before the entire URL, offset 7 is 294// between the scheme and the host, and offset 15 is after the end of the URL. 295// Valid input offsets range from 0 to the length of the input URL string. On 296// exit, each offset will have been modified to reflect any changes made to the 297// output string. For example, if |url| is "http://a:b@c.com/", 298// |omit_username_password| is true, and an offset is 12 (pointing between 'c' 299// and '.'), then on return the output string will be "http://c.com/" and the 300// offset will be 8. If an offset cannot be successfully adjusted (e.g. because 301// it points into the middle of a component that was entirely removed or into 302// the middle of an encoding sequence), it will be set to base::string16::npos. 303// For consistency, if an input offset points between the scheme and the 304// username/password, and both are removed, on output this offset will be 0 305// rather than npos; this means that offsets at the starts and ends of removed 306// components are always transformed the same way regardless of what other 307// components are adjacent. 308NET_EXPORT base::string16 FormatUrl(const GURL& url, 309 const std::string& languages, 310 FormatUrlTypes format_types, 311 UnescapeRule::Type unescape_rules, 312 url::Parsed* new_parsed, 313 size_t* prefix_end, 314 size_t* offset_for_adjustment); 315NET_EXPORT base::string16 FormatUrlWithOffsets( 316 const GURL& url, 317 const std::string& languages, 318 FormatUrlTypes format_types, 319 UnescapeRule::Type unescape_rules, 320 url::Parsed* new_parsed, 321 size_t* prefix_end, 322 std::vector<size_t>* offsets_for_adjustment); 323// This function is like those above except it takes |adjustments| rather 324// than |offset[s]_for_adjustment|. |adjustments| will be set to reflect all 325// the transformations that happened to |url| to convert it into the returned 326// value. 327NET_EXPORT base::string16 FormatUrlWithAdjustments( 328 const GURL& url, 329 const std::string& languages, 330 FormatUrlTypes format_types, 331 UnescapeRule::Type unescape_rules, 332 url::Parsed* new_parsed, 333 size_t* prefix_end, 334 base::OffsetAdjuster::Adjustments* adjustments); 335 336// This is a convenience function for FormatUrl() with 337// format_types = kFormatUrlOmitAll and unescape = SPACES. This is the typical 338// set of flags for "URLs to display to the user". You should be cautious about 339// using this for URLs which will be parsed or sent to other applications. 340inline base::string16 FormatUrl(const GURL& url, const std::string& languages) { 341 return FormatUrl(url, languages, kFormatUrlOmitAll, UnescapeRule::SPACES, 342 NULL, NULL, NULL); 343} 344 345// Returns whether FormatUrl() would strip a trailing slash from |url|, given a 346// format flag including kFormatUrlOmitTrailingSlashOnBareHostname. 347NET_EXPORT bool CanStripTrailingSlash(const GURL& url); 348 349// Strip the portions of |url| that aren't core to the network request. 350// - user name / password 351// - reference section 352NET_EXPORT_PRIVATE GURL SimplifyUrlForRequest(const GURL& url); 353 354NET_EXPORT void SetExplicitlyAllowedPorts(const std::string& allowed_ports); 355 356class NET_EXPORT ScopedPortException { 357 public: 358 explicit ScopedPortException(int port); 359 ~ScopedPortException(); 360 361 private: 362 int port_; 363 364 DISALLOW_COPY_AND_ASSIGN(ScopedPortException); 365}; 366 367// Returns true if it can determine that only loopback addresses are configured. 368// i.e. if only 127.0.0.1 and ::1 are routable. 369// Also returns false if it cannot determine this. 370bool HaveOnlyLoopbackAddresses(); 371 372// Returns AddressFamily of the address. 373NET_EXPORT_PRIVATE AddressFamily GetAddressFamily( 374 const IPAddressNumber& address); 375 376// Maps the given AddressFamily to either AF_INET, AF_INET6 or AF_UNSPEC. 377NET_EXPORT_PRIVATE int ConvertAddressFamily(AddressFamily address_family); 378 379// Parses a URL-safe IP literal (see RFC 3986, Sec 3.2.2) to its numeric value. 380// Returns true on success, and fills |ip_number| with the numeric value 381NET_EXPORT bool ParseURLHostnameToNumber(const std::string& hostname, 382 IPAddressNumber* ip_number); 383 384// Parses an IP address literal (either IPv4 or IPv6) to its numeric value. 385// Returns true on success and fills |ip_number| with the numeric value. 386NET_EXPORT bool ParseIPLiteralToNumber(const std::string& ip_literal, 387 IPAddressNumber* ip_number); 388 389// Converts an IPv4 address to an IPv4-mapped IPv6 address. 390// For example 192.168.0.1 would be converted to ::ffff:192.168.0.1. 391NET_EXPORT_PRIVATE IPAddressNumber ConvertIPv4NumberToIPv6Number( 392 const IPAddressNumber& ipv4_number); 393 394// Returns true iff |address| is an IPv4-mapped IPv6 address. 395NET_EXPORT_PRIVATE bool IsIPv4Mapped(const IPAddressNumber& address); 396 397// Converts an IPv4-mapped IPv6 address to IPv4 address. Should only be called 398// on IPv4-mapped IPv6 addresses. 399NET_EXPORT_PRIVATE IPAddressNumber ConvertIPv4MappedToIPv4( 400 const IPAddressNumber& address); 401 402// Parses an IP block specifier from CIDR notation to an 403// (IP address, prefix length) pair. Returns true on success and fills 404// |*ip_number| with the numeric value of the IP address and sets 405// |*prefix_length_in_bits| with the length of the prefix. 406// 407// CIDR notation literals can use either IPv4 or IPv6 literals. Some examples: 408// 409// 10.10.3.1/20 410// a:b:c::/46 411// ::1/128 412NET_EXPORT bool ParseCIDRBlock(const std::string& cidr_literal, 413 IPAddressNumber* ip_number, 414 size_t* prefix_length_in_bits); 415 416// Compares an IP address to see if it falls within the specified IP block. 417// Returns true if it does, false otherwise. 418// 419// The IP block is given by (|ip_prefix|, |prefix_length_in_bits|) -- any 420// IP address whose |prefix_length_in_bits| most significant bits match 421// |ip_prefix| will be matched. 422// 423// In cases when an IPv4 address is being compared to an IPv6 address prefix 424// and vice versa, the IPv4 addresses will be converted to IPv4-mapped 425// (IPv6) addresses. 426NET_EXPORT_PRIVATE bool IPNumberMatchesPrefix(const IPAddressNumber& ip_number, 427 const IPAddressNumber& ip_prefix, 428 size_t prefix_length_in_bits); 429 430// Retuns the port field of the |sockaddr|. 431const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address, 432 socklen_t address_len); 433// Returns the value of port in |sockaddr| (in host byte ordering). 434NET_EXPORT_PRIVATE int GetPortFromSockaddr(const struct sockaddr* address, 435 socklen_t address_len); 436 437// Returns true if |host| is one of the names (e.g. "localhost") or IP 438// addresses (IPv4 127.0.0.0/8 or IPv6 ::1) that indicate a loopback. 439// 440// Note that this function does not check for IP addresses other than 441// the above, although other IP addresses may point to the local 442// machine. 443NET_EXPORT_PRIVATE bool IsLocalhost(const std::string& host); 444 445// A subset of IP address attributes which are actionable by the 446// application layer. Currently unimplemented for all hosts; 447// IP_ADDRESS_ATTRIBUTE_NONE is always returned. 448enum IPAddressAttributes { 449 IP_ADDRESS_ATTRIBUTE_NONE = 0, 450 451 // A temporary address is dynamic by nature and will not contain MAC 452 // address. Presence of MAC address in IPv6 addresses can be used to 453 // track an endpoint and cause privacy concern. Please refer to 454 // RFC4941. 455 IP_ADDRESS_ATTRIBUTE_TEMPORARY = 1 << 0, 456 457 // A temporary address could become deprecated once the preferred 458 // lifetime is reached. It is still valid but shouldn't be used to 459 // create new connections. 460 IP_ADDRESS_ATTRIBUTE_DEPRECATED = 1 << 1, 461}; 462 463// struct that is used by GetNetworkList() to represent a network 464// interface. 465struct NET_EXPORT NetworkInterface { 466 NetworkInterface(); 467 NetworkInterface(const std::string& name, 468 const std::string& friendly_name, 469 uint32 interface_index, 470 NetworkChangeNotifier::ConnectionType type, 471 const IPAddressNumber& address, 472 uint32 network_prefix, 473 int ip_address_attributes); 474 ~NetworkInterface(); 475 476 std::string name; 477 std::string friendly_name; // Same as |name| on non-Windows. 478 uint32 interface_index; // Always 0 on Android. 479 NetworkChangeNotifier::ConnectionType type; 480 IPAddressNumber address; 481 uint32 network_prefix; 482 int ip_address_attributes; // Combination of |IPAddressAttributes|. 483}; 484 485typedef std::vector<NetworkInterface> NetworkInterfaceList; 486 487// Policy settings to include/exclude network interfaces. 488enum HostAddressSelectionPolicy { 489 INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES = 0x0, 490 EXCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES = 0x1, 491 // Include temp address only when interface has both permanent and 492 // temp addresses. 493 INCLUDE_ONLY_TEMP_IPV6_ADDRESS_IF_POSSIBLE = 0x2, 494}; 495 496// Returns list of network interfaces except loopback interface. If an 497// interface has more than one address, a separate entry is added to 498// the list for each address. 499// Can be called only on a thread that allows IO. 500NET_EXPORT bool GetNetworkList(NetworkInterfaceList* networks, 501 int policy); 502 503// General category of the IEEE 802.11 (wifi) physical layer operating mode. 504enum WifiPHYLayerProtocol { 505 // No wifi support or no associated AP. 506 WIFI_PHY_LAYER_PROTOCOL_NONE, 507 // An obsolete modes introduced by the original 802.11, e.g. IR, FHSS. 508 WIFI_PHY_LAYER_PROTOCOL_ANCIENT, 509 // 802.11a, OFDM-based rates. 510 WIFI_PHY_LAYER_PROTOCOL_A, 511 // 802.11b, DSSS or HR DSSS. 512 WIFI_PHY_LAYER_PROTOCOL_B, 513 // 802.11g, same rates as 802.11a but compatible with 802.11b. 514 WIFI_PHY_LAYER_PROTOCOL_G, 515 // 802.11n, HT rates. 516 WIFI_PHY_LAYER_PROTOCOL_N, 517 // Unclassified mode or failure to identify. 518 WIFI_PHY_LAYER_PROTOCOL_UNKNOWN 519}; 520 521// Characterize the PHY mode of the currently associated access point. 522// Currently only available on OS_WIN. 523NET_EXPORT WifiPHYLayerProtocol GetWifiPHYLayerProtocol(); 524 525enum WifiOptions { 526 // Disables background SSID scans. 527 WIFI_OPTIONS_DISABLE_SCAN = 1 << 0, 528 // Enables media streaming mode. 529 WIFI_OPTIONS_MEDIA_STREAMING_MODE = 1 << 1 530}; 531 532class NET_EXPORT ScopedWifiOptions { 533 public: 534 ScopedWifiOptions() {} 535 virtual ~ScopedWifiOptions(); 536 537 private: 538 DISALLOW_COPY_AND_ASSIGN(ScopedWifiOptions); 539}; 540 541// Set temporary options on all wifi interfaces. 542// |options| is an ORed bitfield of WifiOptions. 543// Options are automatically disabled when the scoped pointer 544// is freed. Currently only available on OS_WIN. 545NET_EXPORT scoped_ptr<ScopedWifiOptions> SetWifiOptions(int options); 546 547// Returns number of matching initial bits between the addresses |a1| and |a2|. 548unsigned CommonPrefixLength(const IPAddressNumber& a1, 549 const IPAddressNumber& a2); 550 551// Computes the number of leading 1-bits in |mask|. 552unsigned MaskPrefixLength(const IPAddressNumber& mask); 553 554// Differentiated Services Code Point. 555// See http://tools.ietf.org/html/rfc2474 for details. 556enum DiffServCodePoint { 557 DSCP_NO_CHANGE = -1, 558 DSCP_FIRST = DSCP_NO_CHANGE, 559 DSCP_DEFAULT = 0, // Same as DSCP_CS0 560 DSCP_CS0 = 0, // The default 561 DSCP_CS1 = 8, // Bulk/background traffic 562 DSCP_AF11 = 10, 563 DSCP_AF12 = 12, 564 DSCP_AF13 = 14, 565 DSCP_CS2 = 16, 566 DSCP_AF21 = 18, 567 DSCP_AF22 = 20, 568 DSCP_AF23 = 22, 569 DSCP_CS3 = 24, 570 DSCP_AF31 = 26, 571 DSCP_AF32 = 28, 572 DSCP_AF33 = 30, 573 DSCP_CS4 = 32, 574 DSCP_AF41 = 34, // Video 575 DSCP_AF42 = 36, // Video 576 DSCP_AF43 = 38, // Video 577 DSCP_CS5 = 40, // Video 578 DSCP_EF = 46, // Voice 579 DSCP_CS6 = 48, // Voice 580 DSCP_CS7 = 56, // Control messages 581 DSCP_LAST = DSCP_CS7 582}; 583 584} // namespace net 585 586#endif // NET_BASE_NET_UTIL_H_ 587