1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NETSYS_NET_DNS_RESULT_DATA_H 17 #define NETSYS_NET_DNS_RESULT_DATA_H 18 19 #include <iostream> 20 #include <list> 21 22 #include "parcel.h" 23 24 namespace OHOS { 25 namespace NetsysNative { 26 namespace { 27 constexpr uint32_t DNS_RESULT_MAX_SIZE = 32; 28 } // namespace 29 30 enum NetDnsResultAddrType : uint32_t { 31 ADDR_TYPE_IPV4 = 0, 32 ADDR_TYPE_IPV6 = 1, 33 }; 34 #define NET_SYMBOL_VISIBLE __attribute__ ((visibility("default"))) 35 36 struct NET_SYMBOL_VISIBLE NetDnsResultAddrInfo final : public Parcelable { 37 uint32_t type_; 38 std::string addr_; 39 40 bool Marshalling(Parcel &parcel) const override; 41 static bool Unmarshalling(Parcel &parcel, NetDnsResultAddrInfo &addrinfo); 42 }; 43 44 struct NET_SYMBOL_VISIBLE NetDnsResultReport final : public Parcelable { 45 uint32_t netid_; 46 uint32_t uid_; 47 uint32_t pid_; 48 uint32_t timeused_; 49 uint32_t queryresult_; 50 std::string host_; 51 std::list<NetDnsResultAddrInfo> addrlist_; 52 53 bool Marshalling(Parcel &parcel) const override; 54 static bool Unmarshalling(Parcel &parcel, NetDnsResultReport &result); 55 }; 56 } // namespace NetsysNative 57 } // namespace OHOS 58 #endif // NETSYS_NET_DNS_RESULT_DATA_H 59