blob: 70f344e7fc5d2291db4238b1580f1f4348900428 [file] [log] [blame]
Paul Stewartb6063942011-08-05 10:17:29 -07001// 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 Stewart0d2ada32011-08-09 17:01:57 -07009#include <base/lazy_instance.h>
Paul Stewartb6063942011-08-05 10:17:29 -070010#include <base/memory/ref_counted.h>
Paul Stewartb6063942011-08-05 10:17:29 -070011
12#include "shill/refptr_types.h"
13
14namespace shill {
15
16// This provides a static function for dumping the DNS information out
17// of an ipconfig into a "resolv.conf" formatted file.
18class Resolver {
19 public:
Paul Stewart0d2ada32011-08-09 17:01:57 -070020 virtual ~Resolver();
21
Paul Stewartb6063942011-08-05 10:17:29 -070022 // Since this is a singleton, use Resolver::GetInstance()->Foo()
23 static Resolver *GetInstance();
24
Paul Stewartdd60e452011-08-08 11:38:36 -070025 virtual void set_path(const FilePath &path) { path_ = path; }
Paul Stewartb6063942011-08-05 10:17:29 -070026
Paul Stewartdd60e452011-08-08 11:38:36 -070027 // 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 Stewartb6063942011-08-05 10:17:29 -070033
34 // Remove any created domain name service file
Paul Stewartdd60e452011-08-08 11:38:36 -070035 virtual bool ClearDNS();
Paul Stewartb6063942011-08-05 10:17:29 -070036
Paul Stewart0d2ada32011-08-09 17:01:57 -070037 protected:
Paul Stewartb6063942011-08-05 10:17:29 -070038 Resolver();
Paul Stewart0d2ada32011-08-09 17:01:57 -070039
40 private:
41 friend struct base::DefaultLazyInstanceTraits<Resolver>;
42 friend class ResolverTest;
Paul Stewartb6063942011-08-05 10:17:29 -070043
44 FilePath path_;
45
46 DISALLOW_COPY_AND_ASSIGN(Resolver);
47};
48
49} // namespace shill
50
51#endif // SHILL_RESOLVER_