1 /* 2 * Copyright (c) 2021 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 "net_stats_info.h" 17 18 #include "parcel.h" 19 20 namespace OHOS { 21 namespace NetManagerStandard { Marshalling(Parcel & parcel) const22bool NetStatsInfo::Marshalling(Parcel &parcel) const 23 { 24 if (!parcel.WriteInt64(rxBytes_)) { 25 return false; 26 } 27 if (!parcel.WriteInt64(txBytes_)) { 28 return false; 29 } 30 if (!parcel.WriteInt64(rxPackets_)) { 31 return false; 32 } 33 if (!parcel.WriteInt64(txPackets_)) { 34 return false; 35 } 36 return true; 37 } 38 Marshalling(Parcel & parcel,const NetStatsInfo & stats)39bool NetStatsInfo::Marshalling(Parcel &parcel, const NetStatsInfo &stats) 40 { 41 if (!parcel.WriteInt64(stats.rxBytes_)) { 42 return false; 43 } 44 if (!parcel.WriteInt64(stats.txBytes_)) { 45 return false; 46 } 47 if (!parcel.WriteInt64(stats.rxPackets_)) { 48 return false; 49 } 50 if (!parcel.WriteInt64(stats.txPackets_)) { 51 return false; 52 } 53 return true; 54 } 55 Unmarshalling(Parcel & parcel,NetStatsInfo & stats)56bool NetStatsInfo::Unmarshalling(Parcel &parcel, NetStatsInfo &stats) 57 { 58 if (!parcel.ReadInt64(stats.rxBytes_)) { 59 return false; 60 } 61 if (!parcel.ReadInt64(stats.txBytes_)) { 62 return false; 63 } 64 if (!parcel.ReadInt64(stats.rxPackets_)) { 65 return false; 66 } 67 if (!parcel.ReadInt64(stats.txPackets_)) { 68 return false; 69 } 70 return true; 71 } 72 } // namespace NetManagerStandard 73 } // namespace OHOS 74