ResolverController.cpp revision dadc5f850ee7a4dbe9ed418ae9d363b237f7a0e8
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#define LOG_TAG "ResolverController" 18#define DBG 0 19 20#include <cutils/log.h> 21 22#include <net/if.h> 23 24// NOTE: <resolv_netid.h> is a private C library header that provides 25// declarations for _resolv_set_nameservers_for_net and 26// _resolv_flush_cache_for_net 27#include <resolv_netid.h> 28 29#include "ResolverController.h" 30 31int ResolverController::setDnsServers(unsigned netId, const char* domains, 32 const char** servers, int numservers) { 33 if (DBG) { 34 ALOGD("setDnsServers netId = %u\n", netId); 35 } 36 _resolv_set_nameservers_for_net(netId, servers, numservers, domains); 37 38 return 0; 39} 40 41int ResolverController::clearDnsServers(unsigned netId) { 42 _resolv_set_nameservers_for_net(netId, NULL, 0, ""); 43 if (DBG) { 44 ALOGD("clearDnsServers netId = %u\n", netId); 45 } 46 return 0; 47} 48 49int ResolverController::flushDnsCache(unsigned netId) { 50 if (DBG) { 51 ALOGD("flushDnsCache netId = %u\n", netId); 52 } 53 54 _resolv_flush_cache_for_net(netId); 55 56 return 0; 57} 58