ResolverController.cpp revision f4cfad361175a7f9ccf4d41e76a9b289c3c3da22
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::flushDnsCache(unsigned netId) {
42    if (DBG) {
43        ALOGD("flushDnsCache netId = %u\n", netId);
44    }
45
46    _resolv_flush_cache_for_net(netId);
47
48    return 0;
49}
50