• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_qos_info.h"
17 
18 namespace OHOS {
19 namespace NetManagerStandard {
Marshalling(OHOS::Parcel & parcel) const20 bool NetQosInfo::Marshalling(OHOS::Parcel &parcel) const
21 {
22     // Write qosLevel_
23     if (!parcel.WriteUint32(qosLevel_)) {
24         return false;
25     }
26     // Write rttTx_
27     if (!parcel.WriteUint32(rttTx_)) {
28         return false;
29     }
30     // Write rttRx_
31     if (!parcel.WriteUint32(rttRx_)) {
32         return false;
33     }
34     // Write rateTx_
35     if (!parcel.WriteUint32(rateTx_)) {
36         return false;
37     }
38     // Write rateRx_
39     if (!parcel.WriteUint32(rateRx_)) {
40         return false;
41     }
42     // Write pkgLossRate_
43     if (!parcel.WriteUint32(pkgLossRate_)) {
44         return false;
45     }
46     return true;
47 }
Unmarshalling(Parcel & parcel)48 sptr<NetQosInfo> NetQosInfo::Unmarshalling(Parcel &parcel)
49 {
50     sptr<NetQosInfo> info = new (std::nothrow) NetQosInfo;
51     if (info != nullptr) {
52         if (!parcel.ReadUint32(info->qosLevel_) || !parcel.ReadUint32(rttTx_) || !parcel.ReadUint32(rttRx_) ||
53             !parcel.ReadUint32(rateTx_) || !parcel.ReadUint32(rateRx_) || !parcel.ReadUint32(pkgLossRate_)) {
54             return nullptr;
55         }
56     }
57     return info;
58 }
59 
operator ==(const NetQosInfo & rhs) const60 bool NetQosInfo::operator==(const NetQosInfo &rhs) const
61 {
62     if (this == &rhs) {
63         return true;
64     }
65     return qosLevel_ == rhs.qosLevel_ && rttTx_ == rhs.rttTx_ && rttRx_ == rhs.rttRx_ && rateTx_ == rhs.rateTx_ &&
66            rateRx_ == rhs.rateRx_ && pkgLossRate_ == rhs.pkgLossRate_;
67 }
68 
operator !=(const NetQosInfo & rhs) const69 bool NetQosInfo::operator!=(const NetQosInfo &rhs) const
70 {
71     return !(rhs == *this);
72 }
73 } // namespace NetManagerStandard
74 } // namespace OHOS
75