1 /* 2 * Copyright (c) 2025 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 #include "eap_data.h" 17 #include <sstream> 18 #include "netmanager_base_log.h" 19 #include "refbase.h" 20 21 namespace OHOS { 22 namespace NetManagerStandard { 23 EapData()24EapData::EapData() 25 { 26 } 27 ~EapData()28EapData::~EapData() 29 { 30 } 31 Marshalling(Parcel & parcel) const32bool EapData::Marshalling(Parcel &parcel) const 33 { 34 if (!parcel.WriteUint32(eapCode)) { 35 return false; 36 } 37 if (!parcel.WriteUint32(eapType)) { 38 return false; 39 } 40 if (!parcel.WriteInt32(msgId)) { 41 return false; 42 } 43 if (!parcel.WriteInt32(bufferLen)) { 44 return false; 45 } 46 if (!parcel.WriteUInt8Vector(eapBuffer)) { 47 return false; 48 } 49 return true; 50 } 51 Unmarshalling(Parcel & parcel)52EapData* EapData::Unmarshalling(Parcel &parcel) 53 { 54 std::unique_ptr<EapData> ptr = std::make_unique<EapData>(); 55 if (ptr == nullptr) { 56 return nullptr; 57 } 58 bool allOk = parcel.ReadUint32(ptr->eapCode) && parcel.ReadUint32(ptr->eapType) && parcel.ReadInt32(ptr->msgId) && 59 parcel.ReadInt32(ptr->bufferLen) && parcel.ReadUInt8Vector(&ptr->eapBuffer); 60 return allOk ? ptr.release() : nullptr; 61 } 62 PrintLogInfo()63std::string EapData::PrintLogInfo() 64 { 65 std::ostringstream ss; 66 ss << "code:" << eapCode << " "; 67 ss << "type:" << eapType << " "; 68 ss << "msgId:" << msgId << " "; 69 ss << "bufferLen:" << bufferLen; 70 return ss.str(); 71 } 72 73 } // namespace NetManagerStandard 74 } // namespace OHOS