• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "ethernet_device_info.h"
17 
18 namespace OHOS {
19 namespace NetManagerStandard {
Marshalling(Parcel & parcel) const20 bool EthernetDeviceInfo::Marshalling(Parcel &parcel) const
21 {
22     if (!parcel.WriteString(ifaceName_)) {
23         return false;
24     }
25     if (!parcel.WriteString(deviceName_)) {
26         return false;
27     }
28     if (!parcel.WriteInt32(static_cast<int32_t>(connectionMode_))) {
29         return false;
30     }
31     if (!parcel.WriteString(supplierName_)) {
32         return false;
33     }
34     if (!parcel.WriteString(supplierId_)) {
35         return false;
36     }
37     if (!parcel.WriteString(productName_)) {
38         return false;
39     }
40     if (!parcel.WriteString(maximumRate_)) {
41         return false;
42     }
43     return true;
44 }
45 
Unmarshalling(Parcel & parcel)46 EthernetDeviceInfo* EthernetDeviceInfo::Unmarshalling(Parcel &parcel)
47 {
48     std::unique_ptr<EthernetDeviceInfo> ptr = std::make_unique<EthernetDeviceInfo>();
49     if (ptr == nullptr) {
50         return nullptr;
51     }
52     if (!parcel.ReadString(ptr->ifaceName_)) {
53         return nullptr;
54     }
55     if (!parcel.ReadString(ptr->deviceName_)) {
56         return nullptr;
57     }
58     int32_t mode = 0;
59     if (!parcel.ReadInt32(mode)) {
60         return nullptr;
61     }
62     ptr->connectionMode_ = static_cast<DeviceConnectionType>(mode);
63     if (!parcel.ReadString(ptr->supplierName_)) {
64         return nullptr;
65     }
66     if (!parcel.ReadString(ptr->supplierId_)) {
67         return nullptr;
68     }
69     if (!parcel.ReadString(ptr->productName_)) {
70         return nullptr;
71     }
72     if (!parcel.ReadString(ptr->maximumRate_)) {
73         return nullptr;
74     }
75     return ptr.release();
76 }
77 } // namespace NetManagerStandard
78 } // namespace OHOS