blob: 1a1c9e786b6a8e077af0c5eb219c08094c69eef7 [file] [log] [blame]
Luke Huang9353da82019-02-25 15:33:42 +08001/**
2 * Copyright (c) 2019, 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#ifndef _DNS_RESOLVER_SERVICE_H_
18#define _DNS_RESOLVER_SERVICE_H_
19
20#include <vector>
21
22#include <aidl/android/net/BnDnsResolver.h>
waynema85f22d62019-04-17 07:48:31 -070023#include <aidl/android/net/ResolverParamsParcel.h>
Luke Huang9353da82019-02-25 15:33:42 +080024#include <android/binder_ibinder.h>
25
26#include "netd_resolv/resolv.h"
27
28namespace android {
29namespace net {
30
31class DnsResolverService : public aidl::android::net::BnDnsResolver {
32 public:
Luke Huang71eac7c2019-03-13 02:54:45 +080033 static binder_status_t start();
Luke Huang9353da82019-02-25 15:33:42 +080034 static char const* getServiceName() { return "dnsresolver"; }
Luke Huang43754b42019-03-28 14:09:24 +080035
36 binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
Luke Huang9353da82019-02-25 15:33:42 +080037
38 ::ndk::ScopedAStatus isAlive(bool* alive) override;
Hungming Chen5e81d4d2019-01-25 10:47:40 +080039 ::ndk::ScopedAStatus registerEventListener(
40 const std::shared_ptr<aidl::android::net::metrics::INetdEventListener>& listener)
41 override;
Luke Huang9353da82019-02-25 15:33:42 +080042
Luke Huang43754b42019-03-28 14:09:24 +080043 // Resolver commands.
44 ::ndk::ScopedAStatus setResolverConfiguration(
waynema85f22d62019-04-17 07:48:31 -070045 const aidl::android::net::ResolverParamsParcel& resolverParams) override;
Luke Huang43754b42019-03-28 14:09:24 +080046 ::ndk::ScopedAStatus getResolverInfo(
Luke Huangf5846de2019-04-03 11:20:12 +080047 int32_t netId, std::vector<std::string>* servers, std::vector<std::string>* domains,
48 std::vector<std::string>* tlsServers, std::vector<int32_t>* params,
Luke Huang43754b42019-03-28 14:09:24 +080049 std::vector<int32_t>* stats,
50 std::vector<int32_t>* wait_for_pending_req_timeout_count) override;
Lorenzo Colittibb65ae22019-04-25 18:06:41 -070051 ::ndk::ScopedAStatus destroyNetworkCache(int32_t netId) override;
52 ::ndk::ScopedAStatus createNetworkCache(int32_t netId) override;
Luke Huang43754b42019-03-28 14:09:24 +080053
54 // DNS64-related commands
55 ::ndk::ScopedAStatus startPrefix64Discovery(int32_t netId) override;
56 ::ndk::ScopedAStatus stopPrefix64Discovery(int32_t netId) override;
57 // (internal use only)
58 ::ndk::ScopedAStatus getPrefix64(int netId, std::string* stringPrefix) override;
59
Ken Chen7871ccf2019-04-29 18:00:29 -070060 // Debug log command
61 ::ndk::ScopedAStatus setLogSeverity(int32_t logSeverity) override;
62
Luke Huang9353da82019-02-25 15:33:42 +080063 private:
Luke Huang363587c2019-05-08 21:54:28 -070064 DnsResolverService();
Luke Huang9353da82019-02-25 15:33:42 +080065 // TODO: Remove below items after libbiner_ndk supports check_permission.
66 ::ndk::ScopedAStatus checkAnyPermission(const std::vector<const char*>& permissions);
Luke Huang9353da82019-02-25 15:33:42 +080067};
68
69} // namespace net
70} // namespace android
71
72#endif // _DNS_RESOLVER_SERVICE_H_