• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
57 struct NET_SYMBOL_VISIBLE NetDnsQueryResultAddrInfo final : public Parcelable {
58     uint16_t	    type_;
59     std::string     addr_;
60 
61     bool Marshalling(Parcel &parcel) const override;
62     static bool Unmarshalling(Parcel &parcel, NetDnsQueryResultAddrInfo &addrinfo);
63 };
64 
65 struct NET_SYMBOL_VISIBLE NetDnsQueryResultReport final : public Parcelable {
66     uint32_t        uid_;
67     uint32_t        pid_;
68     std::string     srcAddr_;
69     uint8_t         addrSize_;
70     uint64_t        queryTime_;
71     std::string     host_;
72     int32_t         retCode_;
73     uint32_t        firstQueryEndDuration_;
74     uint32_t        firstQueryEnd2AppDuration_;
75     int32_t         ipv4RetCode_;
76     std::string     ipv4ServerName_;
77     int32_t         ipv6RetCode_;
78     std::string     ipv6ServerName_;
79     uint8_t         sourceFrom_;
80     uint8_t         dnsServerSize_;
81     uint16_t        resBitInfo_;
82     std::vector<std::string> dnsServerList_;
83     std::vector<NetDnsQueryResultAddrInfo> addrlist_;
84 
85     bool Marshalling(Parcel &parcel) const override;
86     bool MarshallingExt(Parcel &parcel) const;
87     static bool Unmarshalling(Parcel &parcel, NetDnsQueryResultReport &result);
88     static bool UnmarshallingExt(Parcel &parcel, NetDnsQueryResultReport &result);
89 };
90 } // namespace NetsysNative
91 } // namespace OHOS
92 #endif // NETSYS_NET_DNS_RESULT_DATA_H
93