Mattias Falk | 89c1e97 | 2011-04-29 14:48:51 +0200 | [diff] [blame] | 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 | |
Elliott Hughes | 970274a | 2012-09-11 18:56:36 -0700 | [diff] [blame^] | 22 | #include <net/if.h> |
David 'Digit' Turner | 4da10dd | 2012-01-13 13:43:43 +0100 | [diff] [blame] | 23 | |
| 24 | // NOTE: <resolv_iface.h> is a private C library header that provides |
| 25 | // declarations for _resolv_set_default_iface() and others. |
| 26 | #include <resolv_iface.h> |
Mattias Falk | 89c1e97 | 2011-04-29 14:48:51 +0200 | [diff] [blame] | 27 | |
| 28 | #include "ResolverController.h" |
| 29 | |
| 30 | int ResolverController::setDefaultInterface(const char* iface) { |
| 31 | if (DBG) { |
Steve Block | 7b984e3 | 2011-12-20 16:22:42 +0000 | [diff] [blame] | 32 | ALOGD("setDefaultInterface iface = %s\n", iface); |
Mattias Falk | 89c1e97 | 2011-04-29 14:48:51 +0200 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | _resolv_set_default_iface(iface); |
| 36 | |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | int ResolverController::setInterfaceDnsServers(const char* iface, char** servers, int numservers) { |
| 41 | if (DBG) { |
Steve Block | 7b984e3 | 2011-12-20 16:22:42 +0000 | [diff] [blame] | 42 | ALOGD("setInterfaceDnsServers iface = %s\n", iface); |
Mattias Falk | 89c1e97 | 2011-04-29 14:48:51 +0200 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | _resolv_set_nameservers_for_iface(iface, servers, numservers); |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | int ResolverController::setInterfaceAddress(const char* iface, struct in_addr* addr) { |
| 51 | if (DBG) { |
Steve Block | 7b984e3 | 2011-12-20 16:22:42 +0000 | [diff] [blame] | 52 | ALOGD("setInterfaceAddress iface = %s\n", iface); |
Mattias Falk | 89c1e97 | 2011-04-29 14:48:51 +0200 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | _resolv_set_addr_of_iface(iface, addr); |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | int ResolverController::flushDefaultDnsCache() { |
| 61 | if (DBG) { |
Steve Block | 7b984e3 | 2011-12-20 16:22:42 +0000 | [diff] [blame] | 62 | ALOGD("flushDefaultDnsCache\n"); |
Mattias Falk | 89c1e97 | 2011-04-29 14:48:51 +0200 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | _resolv_flush_cache_for_default_iface(); |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | int ResolverController::flushInterfaceDnsCache(const char* iface) { |
| 71 | if (DBG) { |
Steve Block | 7b984e3 | 2011-12-20 16:22:42 +0000 | [diff] [blame] | 72 | ALOGD("flushInterfaceDnsCache iface = %s\n", iface); |
Mattias Falk | 89c1e97 | 2011-04-29 14:48:51 +0200 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | _resolv_flush_cache_for_iface(iface); |
| 76 | |
| 77 | return 0; |
| 78 | } |