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 | |
| 9 | static base::LazyInstance<Ares> g_ares(base::LINKER_INITIALIZED); |
| 10 | |
| 11 | Ares::Ares() { } |
| 12 | |
| 13 | Ares::~Ares() { } |
| 14 | |
| 15 | Ares* Ares::GetInstance() { |
| 16 | return g_ares.Pointer(); |
| 17 | } |
| 18 | |
| 19 | void Ares::Destroy(ares_channel channel) { |
| 20 | ares_destroy(channel); |
| 21 | } |
| 22 | |
| 23 | void Ares::GetHostByName(ares_channel channel, |
| 24 | const char *hostname, |
| 25 | int family, |
| 26 | ares_host_callback callback, |
| 27 | void *arg) { |
| 28 | ares_gethostbyname(channel, hostname, family, callback, arg); |
| 29 | } |
| 30 | |
| 31 | int Ares::GetSock(ares_channel channel, |
| 32 | ares_socket_t *socks, |
| 33 | int numsocks) { |
| 34 | return ares_getsock(channel, socks, numsocks); |
| 35 | } |
| 36 | |
| 37 | int Ares::InitOptions(ares_channel *channelptr, |
| 38 | struct ares_options *options, |
| 39 | int optmask) { |
| 40 | return ares_init_options(channelptr, options, optmask); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | void Ares::ProcessFd(ares_channel channel, |
| 45 | ares_socket_t read_fd, |
| 46 | ares_socket_t write_fd) { |
| 47 | return ares_process_fd(channel, read_fd, write_fd); |
| 48 | } |
| 49 | |
| 50 | void Ares::SetLocalDev(ares_channel channel, const char *local_dev_name) { |
| 51 | ares_set_local_dev(channel, local_dev_name); |
| 52 | } |
| 53 | |
| 54 | struct timeval *Ares::Timeout(ares_channel channel, |
| 55 | struct timeval *maxtv, |
| 56 | struct timeval *tv) { |
| 57 | return ares_timeout(channel, maxtv, tv); |
| 58 | } |
| 59 | |
| 60 | } // namespace shill |