blob: 33c10fb65a9747196495e12258ae6ee86ffb10f5 [file] [log] [blame]
Paul Stewartc2350ee2011-10-19 12:28:40 -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_ARES_H_
6#define SHILL_ARES_H_
7
8#include <ares.h>
9
10#include <base/lazy_instance.h>
11
12namespace shill {
13
14// A "ares.h" abstraction allowing mocking in tests.
15class Ares {
16 public:
17 virtual ~Ares();
18
19 static Ares *GetInstance();
20
21 // ares_destroy
22 virtual void Destroy(ares_channel channel);
23
24 // ares_gethostbyname
25 virtual void GetHostByName(ares_channel channel,
26 const char *hostname,
27 int family,
28 ares_host_callback callback,
29 void *arg);
30
31 // ares_getsock
32 virtual int GetSock(ares_channel channel,
33 ares_socket_t *socks,
34 int numsocks);
35
36 // ares_init_options
37 virtual int InitOptions(ares_channel *channelptr,
38 struct ares_options *options,
39 int optmask);
40
41 // ares_process_fd
42 virtual void ProcessFd(ares_channel channel,
43 ares_socket_t read_fd,
44 ares_socket_t write_fd);
45
46 // ares_set_local_dev
47 virtual void SetLocalDev(ares_channel channel, const char *local_dev_name);
48
49 // ares_timeout
50 virtual struct timeval *Timeout(ares_channel channel,
51 struct timeval *maxtv,
52 struct timeval *tv);
53
54 protected:
55 Ares();
56
57 private:
58 friend struct base::DefaultLazyInstanceTraits<Ares>;
59
60 DISALLOW_COPY_AND_ASSIGN(Ares);
61};
62
63} // namespace shill
64
65#endif // SHILL_ARES_H_