blob: 16cfd5300d0b48face78188e9b330f55318b949a [file] [log] [blame]
Mattias Falk89c1e972011-04-29 14:48:51 +02001/*
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 Hughes970274a2012-09-11 18:56:36 -070022#include <net/if.h>
David 'Digit' Turner4da10dd2012-01-13 13:43:43 +010023
Szymon Jakubczaka0efaec2014-02-14 17:09:43 -050024// 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>
Pierre Imai95f5f942016-03-09 18:09:25 +090028#include <resolv_params.h>
Mattias Falk89c1e972011-04-29 14:48:51 +020029
30#include "ResolverController.h"
31
Pierre Imai95f5f942016-03-09 18:09:25 +090032int ResolverController::setDnsServers(unsigned netId, const char* searchDomains,
33 const char** servers, int numservers, const __res_params* params) {
Mattias Falk89c1e972011-04-29 14:48:51 +020034 if (DBG) {
Szymon Jakubczaka0efaec2014-02-14 17:09:43 -050035 ALOGD("setDnsServers netId = %u\n", netId);
Mattias Falk89c1e972011-04-29 14:48:51 +020036 }
Pierre Imai95f5f942016-03-09 18:09:25 +090037 _resolv_set_nameservers_for_net(netId, servers, numservers, searchDomains, params);
Mattias Falk89c1e972011-04-29 14:48:51 +020038 return 0;
39}
Paul Jensen6a46f332014-08-06 18:42:27 +000040
Lorenzo Colittidadc5f82014-11-29 13:54:25 +090041int ResolverController::clearDnsServers(unsigned netId) {
Pierre Imai95f5f942016-03-09 18:09:25 +090042 _resolv_set_nameservers_for_net(netId, NULL, 0, "", NULL);
Lorenzo Colittidadc5f82014-11-29 13:54:25 +090043 if (DBG) {
44 ALOGD("clearDnsServers netId = %u\n", netId);
45 }
46 return 0;
47}
48
Paul Jensen6a46f332014-08-06 18:42:27 +000049int 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}