Home | History | Annotate | Download | only in shill
      1 //
      2 // Copyright (C) 2011 The Android Open Source Project
      3 //
      4 // Licensed under the Apache License, Version 2.0 (the "License");
      5 // you may not use this file except in compliance with the License.
      6 // You may obtain a copy of the License at
      7 //
      8 //      http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unless required by applicable law or agreed to in writing, software
     11 // distributed under the License is distributed on an "AS IS" BASIS,
     12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 // See the License for the specific language governing permissions and
     14 // limitations under the License.
     15 //
     16 
     17 #include "shill/shill_ares.h"
     18 
     19 namespace shill {
     20 
     21 namespace {
     22 base::LazyInstance<Ares> g_ares = LAZY_INSTANCE_INITIALIZER;
     23 }  // namespace
     24 
     25 Ares::Ares() { }
     26 
     27 Ares::~Ares() { }
     28 
     29 Ares* Ares::GetInstance() {
     30   return g_ares.Pointer();
     31 }
     32 
     33 void Ares::Destroy(ares_channel channel) {
     34   ares_destroy(channel);
     35 }
     36 
     37 void Ares::GetHostByName(ares_channel channel,
     38                          const char* hostname,
     39                          int family,
     40                          ares_host_callback callback,
     41                          void* arg) {
     42   ares_gethostbyname(channel, hostname, family, callback, arg);
     43 }
     44 
     45 int Ares::GetSock(ares_channel channel,
     46                   ares_socket_t* socks,
     47                   int numsocks) {
     48   return ares_getsock(channel, socks, numsocks);
     49 }
     50 
     51 int Ares::InitOptions(ares_channel* channelptr,
     52                       struct ares_options* options,
     53                       int optmask) {
     54   return ares_init_options(channelptr, options, optmask);
     55 }
     56 
     57 
     58 void Ares::ProcessFd(ares_channel channel,
     59                      ares_socket_t read_fd,
     60                      ares_socket_t write_fd) {
     61   return ares_process_fd(channel, read_fd, write_fd);
     62 }
     63 
     64 void Ares::SetLocalDev(ares_channel channel, const char* local_dev_name) {
     65   ares_set_local_dev(channel, local_dev_name);
     66 }
     67 
     68 struct timeval* Ares::Timeout(ares_channel channel,
     69                               struct timeval* maxtv,
     70                               struct timeval* tv) {
     71   return ares_timeout(channel, maxtv, tv);
     72 }
     73 
     74 int Ares::SetServersCsv(ares_channel channel, const char* servers) {
     75   return ares_set_servers_csv(channel, servers);
     76 }
     77 
     78 }  // namespace shill
     79