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 ::ndk::ScopedAStatus registerUnsolicitedEventListener( 43 const std::shared_ptr< 44 aidl::android::net::resolv::aidl::IDnsResolverUnsolicitedEventListener>& 45 listener) override; 46 47 // Resolver commands. 48 ::ndk::ScopedAStatus setResolverConfiguration( 49 const aidl::android::net::ResolverParamsParcel& resolverParams) override; 50 ::ndk::ScopedAStatus getResolverInfo( 51 int32_t netId, std::vector<std::string>* servers, std::vector<std::string>* domains, 52 std::vector<std::string>* tlsServers, std::vector<int32_t>* params, 53 std::vector<int32_t>* stats, 54 std::vector<int32_t>* wait_for_pending_req_timeout_count) override; 55 ::ndk::ScopedAStatus destroyNetworkCache(int32_t netId) override; 56 ::ndk::ScopedAStatus createNetworkCache(int32_t netId) override; 57 ::ndk::ScopedAStatus flushNetworkCache(int32_t netId) override; 58 ::ndk::ScopedAStatus setResolverOptions( 59 int32_t netId, const aidl::android::net::ResolverOptionsParcel& options) override; 60 61 // DNS64-related commands 62 ::ndk::ScopedAStatus startPrefix64Discovery(int32_t netId) override; 63 ::ndk::ScopedAStatus stopPrefix64Discovery(int32_t netId) override; 64 // (internal use only) 65 ::ndk::ScopedAStatus getPrefix64(int32_t netId, std::string* stringPrefix) override; 66 ::ndk::ScopedAStatus setPrefix64(int32_t netId, const std::string& stringPrefix) override; 67 68 // Debug log command 69 ::ndk::ScopedAStatus setLogSeverity(int32_t logSeverity) override; 70 71 DnsResolverService(); 72 73 private: 74 // TODO: Remove below items after libbiner_ndk supports check_permission. 75 ::ndk::ScopedAStatus checkAnyPermission(const std::vector<const char*>& permissions); 76 }; 77 78 } // namespace net 79 } // namespace android 80 81 #endif // _DNS_RESOLVER_SERVICE_H_ 82