OSDN Git Service

Merge "DO NOT MERGE: NatController: remove flushing the INPUT/OUTPUT tables." into...
[android-x86/system-netd.git] / ResolverController.cpp
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 <linux/if.h>
23 #include <resolv.h>
24
25 #include "ResolverController.h"
26
27 int ResolverController::setDefaultInterface(const char* iface) {
28     if (DBG) {
29         LOGD("setDefaultInterface iface = %s\n", iface);
30     }
31
32     _resolv_set_default_iface(iface);
33
34     return 0;
35 }
36
37 int ResolverController::setInterfaceDnsServers(const char* iface, char** servers, int numservers) {
38     if (DBG) {
39         LOGD("setInterfaceDnsServers iface = %s\n", iface);
40     }
41
42     _resolv_set_nameservers_for_iface(iface, servers, numservers);
43
44     return 0;
45 }
46
47 int ResolverController::setInterfaceAddress(const char* iface, struct in_addr* addr) {
48     if (DBG) {
49         LOGD("setInterfaceAddress iface = %s\n", iface);
50     }
51
52     _resolv_set_addr_of_iface(iface, addr);
53
54     return 0;
55 }
56
57 int ResolverController::flushDefaultDnsCache() {
58     if (DBG) {
59         LOGD("flushDefaultDnsCache\n");
60     }
61
62     _resolv_flush_cache_for_default_iface();
63
64     return 0;
65 }
66
67 int ResolverController::flushInterfaceDnsCache(const char* iface) {
68     if (DBG) {
69         LOGD("flushInterfaceDnsCache iface = %s\n", iface);
70     }
71
72     _resolv_flush_cache_for_iface(iface);
73
74     return 0;
75 }