1 /* 2 * Copyright (C) 2020 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 #pragma once 18 19 namespace android::net { 20 21 enum class PrivateDnsTransport : uint8_t { 22 kDot, // DNS over TLS. 23 kDoh, // DNS over HTTPS. 24 }; 25 26 // Validation status of a private DNS server on a specific netId. 27 enum class Validation : uint8_t { 28 in_process, 29 success, 30 success_but_expired, 31 fail, 32 unknown_server, 33 unknown_netid, 34 }; 35 36 // The private DNS mode on a specific netId. 37 enum class PrivateDnsMode : uint8_t { 38 OFF, 39 OPPORTUNISTIC, 40 STRICT, 41 }; 42 43 constexpr const char* validationStatusToString(Validation value) { 44 switch (value) { 45 case Validation::in_process: 46 return "in_process"; 47 case Validation::success: 48 return "success"; 49 case Validation::success_but_expired: 50 return "success_but_expired"; 51 case Validation::fail: 52 return "fail"; 53 case Validation::unknown_server: 54 return "unknown_server"; 55 case Validation::unknown_netid: 56 return "unknown_netid"; 57 default: 58 return "unknown_status"; 59 } 60 } 61 62 constexpr const char* getPrivateDnsModeString(PrivateDnsMode mode) { 63 switch (mode) { 64 case PrivateDnsMode::OFF: 65 return "OFF"; 66 case PrivateDnsMode::OPPORTUNISTIC: 67 return "OPPORTUNISTIC"; 68 case PrivateDnsMode::STRICT: 69 return "STRICT"; 70 } 71 } 72 73 } // namespace android::net 74