• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2010 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 #ifndef NET_BASE_ADDRESS_FAMILY_H_
6 #define NET_BASE_ADDRESS_FAMILY_H_
7 
8 #include "net/base/net_export.h"
9 
10 namespace net {
11 
12 class IPAddress;
13 
14 // Enum wrapper around the address family types supported by host resolver
15 // procedures.
16 enum AddressFamily {
17   ADDRESS_FAMILY_UNSPECIFIED,   // AF_UNSPEC
18   ADDRESS_FAMILY_IPV4,          // AF_INET
19   ADDRESS_FAMILY_IPV6,          // AF_INET6
20   ADDRESS_FAMILY_LAST = ADDRESS_FAMILY_IPV6
21 };
22 
23 // HostResolverFlags is a bitflag enum used by host resolver procedures to
24 // determine the value of addrinfo.ai_flags and work around getaddrinfo
25 // peculiarities.
26 enum {
27   HOST_RESOLVER_CANONNAME = 1 << 0,  // AI_CANONNAME
28   // Hint to the resolver proc that only loopback addresses are configured.
29   HOST_RESOLVER_LOOPBACK_ONLY = 1 << 1,
30   // Indicate the address family was set because no IPv6 support was detected.
31   HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6 = 1 << 2,
32   // The resolver should avoid resolving using multicast protocols (LLMNR or
33   // mDNS).
34   HOST_RESOLVER_AVOID_MULTICAST = 1 << 3
35 };
36 typedef int HostResolverFlags;
37 
38 // Returns AddressFamily for |address|.
39 NET_EXPORT AddressFamily GetAddressFamily(const IPAddress& address);
40 
41 // Maps the given AddressFamily to either AF_INET, AF_INET6 or AF_UNSPEC.
42 NET_EXPORT int ConvertAddressFamily(AddressFamily address_family);
43 
44 // Maps AF_INET, AF_INET6 or AF_UNSPEC to an AddressFamily.
45 NET_EXPORT AddressFamily ToAddressFamily(int family);
46 
47 }  // namespace net
48 
49 #endif  // NET_BASE_ADDRESS_FAMILY_H_
50