Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS 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 SHILL_RESOLVER_ |
| 6 | #define SHILL_RESOLVER_ |
| 7 | |
| 8 | #include <base/file_path.h> |
Paul Stewart | 0d2ada3 | 2011-08-09 17:01:57 -0700 | [diff] [blame] | 9 | #include <base/lazy_instance.h> |
Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame] | 10 | #include <base/memory/ref_counted.h> |
Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame] | 11 | |
| 12 | #include "shill/refptr_types.h" |
| 13 | |
| 14 | namespace shill { |
| 15 | |
| 16 | // This provides a static function for dumping the DNS information out |
| 17 | // of an ipconfig into a "resolv.conf" formatted file. |
| 18 | class Resolver { |
| 19 | public: |
Paul Stewart | 0d2ada3 | 2011-08-09 17:01:57 -0700 | [diff] [blame] | 20 | virtual ~Resolver(); |
| 21 | |
Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame] | 22 | // Since this is a singleton, use Resolver::GetInstance()->Foo() |
| 23 | static Resolver *GetInstance(); |
| 24 | |
Paul Stewart | dd60e45 | 2011-08-08 11:38:36 -0700 | [diff] [blame] | 25 | virtual void set_path(const FilePath &path) { path_ = path; } |
Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame] | 26 | |
Paul Stewart | dd60e45 | 2011-08-08 11:38:36 -0700 | [diff] [blame] | 27 | // Set the default domain name service parameters, given an ipconfig entry |
| 28 | virtual bool SetDNSFromIPConfig(const IPConfigRefPtr &ipconfig); |
| 29 | |
| 30 | // Set the default domain name service parameters, given an ipconfig entry |
| 31 | virtual bool SetDNSFromLists(const std::vector<std::string> &dns_servers, |
| 32 | const std::vector<std::string> &domain_search); |
Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame] | 33 | |
| 34 | // Remove any created domain name service file |
Paul Stewart | dd60e45 | 2011-08-08 11:38:36 -0700 | [diff] [blame] | 35 | virtual bool ClearDNS(); |
Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame] | 36 | |
Paul Stewart | 0d2ada3 | 2011-08-09 17:01:57 -0700 | [diff] [blame] | 37 | protected: |
Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame] | 38 | Resolver(); |
Paul Stewart | 0d2ada3 | 2011-08-09 17:01:57 -0700 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | friend struct base::DefaultLazyInstanceTraits<Resolver>; |
| 42 | friend class ResolverTest; |
Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame] | 43 | |
| 44 | FilePath path_; |
| 45 | |
| 46 | DISALLOW_COPY_AND_ASSIGN(Resolver); |
| 47 | }; |
| 48 | |
| 49 | } // namespace shill |
| 50 | |
| 51 | #endif // SHILL_RESOLVER_ |