blob: 382fdd956528041520f492b72ae023b383ccf236 [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
Hristo Stefanoved2c28c2011-11-29 15:37:30 -08008#include <string>
9#include <vector>
10
Paul Stewartb6063942011-08-05 10:17:29 -070011#include <base/file_path.h>
Paul Stewart0d2ada32011-08-09 17:01:57 -070012#include <base/lazy_instance.h>
Paul Stewartb6063942011-08-05 10:17:29 -070013#include <base/memory/ref_counted.h>
Paul Stewartb6063942011-08-05 10:17:29 -070014
15#include "shill/refptr_types.h"
16
17namespace shill {
18
19// This provides a static function for dumping the DNS information out
20// of an ipconfig into a "resolv.conf" formatted file.
21class Resolver {
22 public:
Paul Stewart0d2ada32011-08-09 17:01:57 -070023 virtual ~Resolver();
24
Paul Stewartb6063942011-08-05 10:17:29 -070025 // Since this is a singleton, use Resolver::GetInstance()->Foo()
26 static Resolver *GetInstance();
27
Paul Stewartdd60e452011-08-08 11:38:36 -070028 virtual void set_path(const FilePath &path) { path_ = path; }
Paul Stewartb6063942011-08-05 10:17:29 -070029
Paul Stewartdd60e452011-08-08 11:38:36 -070030 // Set the default domain name service parameters, given an ipconfig entry
31 virtual bool SetDNSFromIPConfig(const IPConfigRefPtr &ipconfig);
32
33 // Set the default domain name service parameters, given an ipconfig entry
34 virtual bool SetDNSFromLists(const std::vector<std::string> &dns_servers,
35 const std::vector<std::string> &domain_search);
Paul Stewartb6063942011-08-05 10:17:29 -070036
37 // Remove any created domain name service file
Paul Stewartdd60e452011-08-08 11:38:36 -070038 virtual bool ClearDNS();
Paul Stewartb6063942011-08-05 10:17:29 -070039
Paul Stewart0d2ada32011-08-09 17:01:57 -070040 protected:
Paul Stewartb6063942011-08-05 10:17:29 -070041 Resolver();
Paul Stewart0d2ada32011-08-09 17:01:57 -070042
43 private:
44 friend struct base::DefaultLazyInstanceTraits<Resolver>;
45 friend class ResolverTest;
Paul Stewartb6063942011-08-05 10:17:29 -070046
47 FilePath path_;
48
49 DISALLOW_COPY_AND_ASSIGN(Resolver);
50};
51
52} // namespace shill
53
54#endif // SHILL_RESOLVER_