Paul Stewart | c2350ee | 2011-10-19 12:28:40 -0700 | [diff] [blame] | 1 | // 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 | |
| 7 | namespace shill { |
| 8 | |
Ben Chan | bbdef5f | 2012-04-23 13:58:15 -0700 | [diff] [blame] | 9 | namespace { |
| 10 | base::LazyInstance<Ares> g_ares = LAZY_INSTANCE_INITIALIZER; |
| 11 | } // namespace |
Paul Stewart | c2350ee | 2011-10-19 12:28:40 -0700 | [diff] [blame] | 12 | |
| 13 | Ares::Ares() { } |
| 14 | |
| 15 | Ares::~Ares() { } |
| 16 | |
| 17 | Ares* Ares::GetInstance() { |
| 18 | return g_ares.Pointer(); |
| 19 | } |
| 20 | |
| 21 | void Ares::Destroy(ares_channel channel) { |
| 22 | ares_destroy(channel); |
| 23 | } |
| 24 | |
| 25 | void Ares::GetHostByName(ares_channel channel, |
| 26 | const char *hostname, |
| 27 | int family, |
| 28 | ares_host_callback callback, |
| 29 | void *arg) { |
| 30 | ares_gethostbyname(channel, hostname, family, callback, arg); |
| 31 | } |
| 32 | |
| 33 | int Ares::GetSock(ares_channel channel, |
| 34 | ares_socket_t *socks, |
| 35 | int numsocks) { |
| 36 | return ares_getsock(channel, socks, numsocks); |
| 37 | } |
| 38 | |
| 39 | int Ares::InitOptions(ares_channel *channelptr, |
| 40 | struct ares_options *options, |
| 41 | int optmask) { |
| 42 | return ares_init_options(channelptr, options, optmask); |
| 43 | } |
| 44 | |
| 45 | |
| 46 | void 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 | |
| 52 | void Ares::SetLocalDev(ares_channel channel, const char *local_dev_name) { |
| 53 | ares_set_local_dev(channel, local_dev_name); |
| 54 | } |
| 55 | |
| 56 | struct timeval *Ares::Timeout(ares_channel channel, |
| 57 | struct timeval *maxtv, |
| 58 | struct timeval *tv) { |
| 59 | return ares_timeout(channel, maxtv, tv); |
| 60 | } |
| 61 | |
| 62 | } // namespace shill |