• 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 #ifndef OHOS_MDNS_SERVICE_INFO_H
16 #define OHOS_MDNS_SERVICE_INFO_H
17 
18 #include <string>
19 
20 #include "parcel.h"
21 
22 #include "mdns_common.h"
23 #include "netmgr_ext_log_wrapper.h"
24 
25 namespace OHOS {
26 namespace NetManagerStandard {
27 
28 struct MDnsServiceInfo : public Parcelable {
29     enum {
30         UNKNOWN = -1,
31         IPV4 = 0,
32         IPV6 = 1,
33     };
34 
35     // read https://www.rfc-editor.org/rfc/rfc2782.html and https://www.rfc-editor.org/rfc/rfc6763#section-6
36     std::string name;
37     std::string type;
38     int32_t family = UNKNOWN;
39     std::string addr;
40     int32_t port = -1;
41     TxtRecordEncoded txtRecord;
42 
43     bool Marshalling(Parcel &parcel) const override;
44     static bool Marshalling(Parcel &data, const sptr<MDnsServiceInfo> &obj);
45     static sptr<MDnsServiceInfo> Unmarshalling(Parcel &parcel);
46 
47     bool IsKeyValueVaild(const ::std::string &key, const std::vector<uint8_t> &value);
48     TxtRecord GetAttrMap();
49     void SetAttrMap(const TxtRecord &map);
50 };
51 } // namespace NetManagerStandard
52 } // namespace OHOS
53 #endif // OHOS_MDNS_SERVICE_INFO_H