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

Side by Side Diff: net/dns/address_sorter_posix.h

Issue 10442098: [net/dns] Resolve AF_UNSPEC on dual-stacked systems. Sort addresses according to RFC3484. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle ifa_netmnask == NULL and other errors after getifaddrs. Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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_DNS_ADDRESS_SORTER_POSIX_H_
6 #define NET_DNS_ADDRESS_SORTER_POSIX_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "net/base/address_list.h"
12 #include "net/base/net_errors.h"
13 #include "net/base/net_export.h"
14 #include "net/base/net_util.h"
15 #include "net/base/network_change_notifier.h"
16 #include "net/dns/address_sorter.h"
17
18 namespace net {
19
20 class ClientSocketFactory;
21
22 // Generic policy entry.
23 struct PolicyEntry {
24 // IPv4 addresses must be mapped to IPv6.
25 unsigned char prefix[kIPv6AddressSize];
26 unsigned prefix_length;
27 unsigned value;
28 };
29
30 typedef std::vector<PolicyEntry> PolicyTable;
31
32 enum AddressScope {
33 SCOPE_UNDEFINED = 0,
34 SCOPE_NODELOCAL = 1,
35 SCOPE_LINKLOCAL = 2,
36 SCOPE_SITELOCAL = 5,
37 SCOPE_ORGLOCAL = 8,
38 SCOPE_GLOBAL = 14,
39 };
40
41 struct SourceAddressInfo {
42 // Values read from policy tables.
43 AddressScope scope;
44 unsigned label;
mmenke 2012/08/07 18:30:27 nit: Suggest a blank line here, for legibility.
45 // Values from the OS, matter only if more than one source address is used.
46 unsigned prefix_length;
47 bool deprecated; // vs. preferred RFC4862
48 bool home; // vs. care-of RFC6275
49 bool native;
50 };
51
52 typedef std::map<IPAddressNumber, SourceAddressInfo> SourceAddressMap;
53
54 class NET_EXPORT_PRIVATE AddressSorterPosix
mmenke 2012/08/07 18:30:27 Suggest a comment that this is non-threadsafe and
55 : public AddressSorter,
56 public NetworkChangeNotifier::IPAddressObserver {
57 public:
58 explicit AddressSorterPosix(ClientSocketFactory* socket_factory);
59 virtual ~AddressSorterPosix();
60
61 virtual void Sort(const AddressList& list,
62 const CallbackType& callback) const OVERRIDE;
63
64 private:
65 friend class AddressSorterPosixTest;
66
67 // NetworkChangeNotifier::IPAddressObserver:
68 virtual void OnIPAddressChanged() OVERRIDE;
69
70 // Fills |info| with values for |address| from policy tables.
71 void FillPolicy(const IPAddressNumber& address,
72 SourceAddressInfo* info) const;
73
74 mutable SourceAddressMap source_map_;
mmenke 2012/08/07 18:30:27 Suggest a comment that this is mutable so unrecogn
75
76 ClientSocketFactory* socket_factory_;
77 PolicyTable precedence_table_;
78 PolicyTable label_table_;
79 PolicyTable ipv4_scope_table_;
80
81 DISALLOW_COPY_AND_ASSIGN(AddressSorterPosix);
82 };
83
84 } // namespace net
85
86 #endif // NET_DNS_ADDRESS_SORTER_POSIX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698