blob: fb7ecbda8cfa9591b92a5a4b49c56e5610466af8 [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#include "shill/shill_ares.h"
6
7namespace shill {
8
Ben Chanbbdef5f2012-04-23 13:58:15 -07009namespace {
10base::LazyInstance<Ares> g_ares = LAZY_INSTANCE_INITIALIZER;
11} // namespace
Paul Stewartc2350ee2011-10-19 12:28:40 -070012
13Ares::Ares() { }
14
15Ares::~Ares() { }
16
17Ares* Ares::GetInstance() {
18 return g_ares.Pointer();
19}
20
21void Ares::Destroy(ares_channel channel) {
22 ares_destroy(channel);
23}
24
25void Ares::GetHostByName(ares_channel channel,
Paul Stewart1a212a62015-06-16 13:13:10 -070026 const char* hostname,
Paul Stewartc2350ee2011-10-19 12:28:40 -070027 int family,
28 ares_host_callback callback,
Paul Stewart1a212a62015-06-16 13:13:10 -070029 void* arg) {
Paul Stewartc2350ee2011-10-19 12:28:40 -070030 ares_gethostbyname(channel, hostname, family, callback, arg);
31}
32
33int Ares::GetSock(ares_channel channel,
Paul Stewart1a212a62015-06-16 13:13:10 -070034 ares_socket_t* socks,
Paul Stewartc2350ee2011-10-19 12:28:40 -070035 int numsocks) {
36 return ares_getsock(channel, socks, numsocks);
37}
38
Paul Stewart1a212a62015-06-16 13:13:10 -070039int Ares::InitOptions(ares_channel* channelptr,
40 struct ares_options* options,
Paul Stewartc2350ee2011-10-19 12:28:40 -070041 int optmask) {
42 return ares_init_options(channelptr, options, optmask);
43}
44
45
46void Ares::ProcessFd(ares_channel channel,
47 ares_socket_t read_fd,
48 ares_socket_t write_fd) {
49 return ares_process_fd(channel, read_fd, write_fd);
50}
51
Paul Stewart1a212a62015-06-16 13:13:10 -070052void Ares::SetLocalDev(ares_channel channel, const char* local_dev_name) {
Paul Stewartc2350ee2011-10-19 12:28:40 -070053 ares_set_local_dev(channel, local_dev_name);
54}
55
Paul Stewart1a212a62015-06-16 13:13:10 -070056struct timeval* Ares::Timeout(ares_channel channel,
57 struct timeval* maxtv,
58 struct timeval* tv) {
Paul Stewartc2350ee2011-10-19 12:28:40 -070059 return ares_timeout(channel, maxtv, tv);
60}
61
Paul Stewart1a212a62015-06-16 13:13:10 -070062int Ares::SetServersCsv(ares_channel channel, const char* servers) {
Peter Qiuf3a8f902014-08-20 10:05:42 -070063 return ares_set_servers_csv(channel, servers);
64}
65
Paul Stewartc2350ee2011-10-19 12:28:40 -070066} // namespace shill