blob: 29f411cb0e208003721d9bed3a7913eb5c68b140 [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
Ben Chanc45688b2014-07-02 23:50:45 -07005#ifndef SHILL_SHILL_ARES_H_
6#define SHILL_SHILL_ARES_H_
Paul Stewartc2350ee2011-10-19 12:28:40 -07007
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
Peter Qiuf3a8f902014-08-20 10:05:42 -070054 // ares_set_servers_csv
55 virtual int SetServersCsv(ares_channel channel, const char *servers);
56
Paul Stewartc2350ee2011-10-19 12:28:40 -070057 protected:
58 Ares();
59
60 private:
61 friend struct base::DefaultLazyInstanceTraits<Ares>;
62
63 DISALLOW_COPY_AND_ASSIGN(Ares);
64};
65
66} // namespace shill
67
Ben Chanc45688b2014-07-02 23:50:45 -070068#endif // SHILL_SHILL_ARES_H_