1 /** 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> 23 #include <aidl/android/net/ResolverParamsParcel.h> 24 #include <android/binder_ibinder.h> 25 26 #include "netd_resolv/resolv.h" 27 28 namespace android { 29 namespace net { 30 31 class DnsResolverService : public aidl::android::net::BnDnsResolver { 32 public: 33 static binder_status_t start(); getServiceName()34 static char const* getServiceName() { return "dnsresolver"; } 35 36 binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; 37 38 ::ndk::ScopedAStatus isAlive(bool* alive) override; 39 ::ndk::ScopedAStatus registerEventListener( 40 const std::shared_ptr<aidl::android::net::metrics::INetdEventListener>& listener) 41 override; 42 43 // Resolver commands. 44 ::ndk::ScopedAStatus setResolverConfiguration( 45 const aidl::android::net::ResolverParamsParcel& resolverParams) override; 46 ::ndk::ScopedAStatus getResolverInfo( 47 int32_t netId, std::vector<std::string>* servers, std::vector<std::string>* domains, 48 std::vector<std::string>* tlsServers, std::vector<int32_t>* params, 49 std::vector<int32_t>* stats, 50 std::vector<int32_t>* wait_for_pending_req_timeout_count) override; 51 ::ndk::ScopedAStatus destroyNetworkCache(int32_t netId) override; 52 ::ndk::ScopedAStatus createNetworkCache(int32_t netId) override; 53 ::ndk::ScopedAStatus flushNetworkCache(int32_t netId) override; 54 55 // DNS64-related commands 56 ::ndk::ScopedAStatus startPrefix64Discovery(int32_t netId) override; 57 ::ndk::ScopedAStatus stopPrefix64Discovery(int32_t netId) override; 58 // (internal use only) 59 ::ndk::ScopedAStatus getPrefix64(int32_t netId, std::string* stringPrefix) override; 60 ::ndk::ScopedAStatus setPrefix64(int32_t netId, const std::string& stringPrefix) override; 61 62 // Debug log command 63 ::ndk::ScopedAStatus setLogSeverity(int32_t logSeverity) override; 64 65 DnsResolverService(); 66 67 private: 68 // TODO: Remove below items after libbiner_ndk supports check_permission. 69 ::ndk::ScopedAStatus checkAnyPermission(const std::vector<const char*>& permissions); 70 }; 71 72 } // namespace net 73 } // namespace android 74 75 #endif // _DNS_RESOLVER_SERVICE_H_ 76