1 /* 2 * Copyright (c) 2024 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 "mac_address_info.h" 17 18 #include "netmgr_ext_log_wrapper.h" 19 #include "parcel.h" 20 #include "refbase.h" 21 22 namespace OHOS { 23 namespace NetManagerStandard { Marshalling(Parcel & parcel) const24bool MacAddressInfo::Marshalling(Parcel &parcel) const 25 { 26 if (!parcel.WriteString(iface_)) { 27 return false; 28 } 29 if (!parcel.WriteString(macAddress_)) { 30 return false; 31 } 32 return true; 33 } 34 Unmarshalling(Parcel & parcel)35sptr<MacAddressInfo> MacAddressInfo::Unmarshalling(Parcel &parcel) 36 { 37 sptr<MacAddressInfo> ptr = new (std::nothrow) MacAddressInfo(); 38 if (ptr == nullptr) { 39 NETMGR_EXT_LOG_E("create MacAddressInfo failed"); 40 return nullptr; 41 } 42 if (!parcel.ReadString(ptr->iface_)) { 43 return nullptr; 44 } 45 if (!parcel.ReadString(ptr->macAddress_)) { 46 return nullptr; 47 } 48 return ptr; 49 } 50 } // namespace NetManagerStandard 51 } // namespace OHOS