blob: a5d69ae9e4f4693c80407f907767b62fc11d06c9 [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>
Mattias Falk89c1e972011-04-29 14:48:51 +020028
29#include "ResolverController.h"
30
Szymon Jakubczaka0efaec2014-02-14 17:09:43 -050031int ResolverController::setDnsServers(unsigned netId, const char* domains,
Sasha Levitskiy938ab2a2013-02-27 16:29:43 -080032 const char** servers, int numservers) {
Mattias Falk89c1e972011-04-29 14:48:51 +020033 if (DBG) {
Szymon Jakubczaka0efaec2014-02-14 17:09:43 -050034 ALOGD("setDnsServers netId = %u\n", netId);
Mattias Falk89c1e972011-04-29 14:48:51 +020035 }
Szymon Jakubczaka0efaec2014-02-14 17:09:43 -050036 _resolv_set_nameservers_for_net(netId, servers, numservers, domains);
Mattias Falk89c1e972011-04-29 14:48:51 +020037
38 return 0;
39}
40
Szymon Jakubczaka0efaec2014-02-14 17:09:43 -050041int ResolverController::flushDnsCache(unsigned netId) {
Mattias Falk89c1e972011-04-29 14:48:51 +020042 if (DBG) {
Szymon Jakubczaka0efaec2014-02-14 17:09:43 -050043 ALOGD("flushDnsCache netId = %u\n", netId);
Mattias Falk89c1e972011-04-29 14:48:51 +020044 }
45
Szymon Jakubczaka0efaec2014-02-14 17:09:43 -050046 _resolv_flush_cache_for_net(netId);
Chad Brubaker9928ec52013-06-07 15:17:45 -070047
48 return 0;
49}