blob: 6d08cdbe3857819c948d60bbb60a73c41583205b [file] [log] [blame]
Mattias Falk89c1e972011-04-29 14:48:51 +02001/*
Luke Huang43754b42019-03-28 14:09:24 +08002 * Copyright (C) 2019 The Android Open Source Project
Mattias Falk89c1e972011-04-29 14:48:51 +02003 *
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 _RESOLVER_CONTROLLER_H_
18#define _RESOLVER_CONTROLLER_H_
19
Erik Kline1564d482018-03-07 17:09:35 +090020#include <list>
Luke Huang43754b42019-03-28 14:09:24 +080021#include <set>
Pierre Imaibeedec32016-04-13 06:44:51 +090022#include <vector>
Bernie Innocenti189eb502018-10-01 23:10:18 +090023
waynema85f22d62019-04-17 07:48:31 -070024#include <aidl/android/net/ResolverParamsParcel.h>
Mike Yu5ae61542018-10-19 22:11:43 +080025#include "Dns64Configuration.h"
Luke Huang43754b42019-03-28 14:09:24 +080026#include "netd_resolv/resolv.h"
Luke Huangb257d612019-03-14 21:19:13 +080027#include "netdutils/DumpWriter.h"
Mattias Falk89c1e972011-04-29 14:48:51 +020028
Bernie Innocenti34de3ba2019-02-19 18:08:36 +090029struct res_params;
Pierre Imai95f5f942016-03-09 18:09:25 +090030
Pierre Imaibeedec32016-04-13 06:44:51 +090031namespace android {
32namespace net {
Lorenzo Colitti7035f222017-02-13 18:29:00 +090033
Pierre Imaibeedec32016-04-13 06:44:51 +090034struct ResolverStats;
Pierre Imaibeedec32016-04-13 06:44:51 +090035
Mattias Falk89c1e972011-04-29 14:48:51 +020036class ResolverController {
Erik Klined26a2c22018-05-11 19:33:19 +090037 public:
Luke Huang43754b42019-03-28 14:09:24 +080038 ResolverController();
39 ~ResolverController() = default;
Pierre Imaibeedec32016-04-13 06:44:51 +090040
Lorenzo Colittibb65ae22019-04-25 18:06:41 -070041 void destroyNetworkCache(unsigned netid);
42 int createNetworkCache(unsigned netid);
Pierre Imaibeedec32016-04-13 06:44:51 +090043
nuccachenf52f7a52018-07-17 18:07:23 +080044 int getPrefix64(unsigned netId, netdutils::IPPrefix* prefix);
45
waynema85f22d62019-04-17 07:48:31 -070046 // Binder specific functions, which convert between the ResolverParamsParcel and the
Pierre Imaibeedec32016-04-13 06:44:51 +090047 // actual data structures, and call setDnsServer() / getDnsInfo() for the actual processing.
waynema85f22d62019-04-17 07:48:31 -070048 int setResolverConfiguration(const aidl::android::net::ResolverParamsParcel& resolverParams,
Luke Huang43754b42019-03-28 14:09:24 +080049 const std::set<std::vector<uint8_t>>& tlsFingerprints);
Pierre Imaibeedec32016-04-13 06:44:51 +090050
51 int getResolverInfo(int32_t netId, std::vector<std::string>* servers,
Mike Yuda77e8e2018-11-26 13:26:21 +090052 std::vector<std::string>* domains, std::vector<std::string>* tlsServers,
Ken Chen2a429352018-12-22 21:46:55 +080053 std::vector<int32_t>* params, std::vector<int32_t>* stats,
54 std::vector<int32_t>* wait_for_pending_req_timeout_count);
dalyk6250dbd2017-12-28 16:20:04 -050055
Lorenzo Colittib5d45872019-02-18 10:59:29 +090056 void startPrefix64Discovery(int32_t netId);
57 void stopPrefix64Discovery(int32_t netId);
58
Luke Huangb257d612019-03-14 21:19:13 +080059 void dump(netdutils::DumpWriter& dw, unsigned netId);
Ben Schwartze7601812017-04-28 16:38:29 -040060
Erik Klined26a2c22018-05-11 19:33:19 +090061 private:
62 Dns64Configuration mDns64Configuration;
Mattias Falk89c1e972011-04-29 14:48:51 +020063};
Lorenzo Colitti7035f222017-02-13 18:29:00 +090064} // namespace net
65} // namespace android
66
Mattias Falk89c1e972011-04-29 14:48:51 +020067#endif /* _RESOLVER_CONTROLLER_H_ */