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