1 /*
2  * Copyright (C) 2021-2023 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 #include "dhcp_server_proxy.h"
16 #include "dhcp_manager_service_ipc_interface_code.h"
17 #include "dhcp_server_callback_stub.h"
18 #include "dhcp_c_utils.h"
19 #include "dhcp_errcode.h"
20 #include "dhcp_logger.h"
21 
22 DEFINE_DHCPLOG_DHCP_LABEL("DhcpServerProxy");
23 
24 namespace OHOS {
25 namespace DHCP {
26 static sptr<DhcpServreCallBackStub> g_dhcpServerCallBackStub =
27     sptr<DhcpServreCallBackStub>(new (std::nothrow)DhcpServreCallBackStub());
28 
DhcpServerProxy(const sptr<IRemoteObject> & impl)29 DhcpServerProxy::DhcpServerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IDhcpServer>(impl),
30     remote_(nullptr), mRemoteDied(false), deathRecipient_(nullptr)
31 {
32     std::lock_guard<std::mutex> lock(mutex_);
33     if (impl) {
34         if (!impl->IsProxyObject()) {
35             DHCP_LOGW("not proxy object!");
36             return;
37         }
38         deathRecipient_ = new (std::nothrow)DhcpServerDeathRecipient(*this);
39         if (deathRecipient_ == nullptr) {
40             DHCP_LOGW("deathRecipient_ is nullptr!");
41         }
42         if (!impl->AddDeathRecipient(deathRecipient_)) {
43             DHCP_LOGW("AddDeathRecipient failed!");
44             return;
45         }
46         remote_ = impl;
47         DHCP_LOGI("AddDeathRecipient success! ");
48     }
49 }
50 
~DhcpServerProxy()51 DhcpServerProxy::~DhcpServerProxy()
52 {
53     DHCP_LOGI("enter ~DhcpServerProxy!");
54     RemoveDeathRecipient();
55 }
56 
RemoveDeathRecipient(void)57 void DhcpServerProxy::RemoveDeathRecipient(void)
58 {
59     DHCP_LOGI("enter RemoveDeathRecipient!");
60     std::lock_guard<std::mutex> lock(mutex_);
61     if (remote_ == nullptr) {
62         DHCP_LOGI("remote_ is nullptr!");
63         return;
64     }
65     if (deathRecipient_ == nullptr) {
66         DHCP_LOGI("deathRecipient_ is nullptr!");
67         return;
68     }
69     remote_->RemoveDeathRecipient(deathRecipient_);
70     remote_ = nullptr;
71 }
72 
OnRemoteDied(const wptr<IRemoteObject> & remoteObject)73 void DhcpServerProxy::OnRemoteDied(const wptr<IRemoteObject> &remoteObject)
74 {
75     DHCP_LOGI("Remote service is died! remoteObject: %{private}p", &remoteObject);
76     mRemoteDied = true;
77     RemoveDeathRecipient();
78     if (g_dhcpServerCallBackStub == nullptr) {
79         DHCP_LOGE("g_dhcpServerCallBackStub is nullptr");
80         return;
81     }
82     if (g_dhcpServerCallBackStub != nullptr) {
83         g_dhcpServerCallBackStub->SetRemoteDied(true);
84     }
85 }
86 
IsRemoteDied(void)87 bool DhcpServerProxy::IsRemoteDied(void)
88 {
89     if (mRemoteDied) {
90         DHCP_LOGI("IsRemoteDied! remote is died now!");
91     }
92     return mRemoteDied;
93 }
94 
RegisterDhcpServerCallBack(const std::string & ifname,const sptr<IDhcpServerCallBack> & callback)95 ErrCode DhcpServerProxy::RegisterDhcpServerCallBack(const std::string& ifname,
96     const sptr<IDhcpServerCallBack> &callback)
97 {
98     DHCP_LOGI("DhcpServerProxy enter RegisterDhcpServerCallBack mRemoteDied:%{public}d", mRemoteDied);
99     if (mRemoteDied) {
100         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
101         return DHCP_E_FAILED;
102     }
103     MessageParcel data, reply;
104     MessageOption option;
105     if (!data.WriteInterfaceToken(GetDescriptor())) {
106         DHCP_LOGE("Write interface token error: %{public}s", __func__);
107         return DHCP_E_FAILED;
108     }
109     data.WriteInt32(0);
110     if (g_dhcpServerCallBackStub == nullptr) {
111         DHCP_LOGE("g_dhcpServerCallBackStub is nullptr");
112         return DHCP_E_FAILED;
113     }
114     g_dhcpServerCallBackStub->RegisterCallBack(callback);
115 
116     if (!data.WriteRemoteObject(g_dhcpServerCallBackStub->AsObject())) {
117         DHCP_LOGE("DhcpServerProxy::RegisterCallBack WriteRemoteObject failed!");
118         return DHCP_E_FAILED;
119     }
120 
121     int pid = GetCallingPid();
122     int tokenId = GetCallingTokenId();
123     data.WriteInt32(pid);
124     data.WriteInt32(tokenId);
125     data.WriteString(ifname);
126     DHCP_LOGI("%{public}s, calling uid:%{public}d, pid:%{public}d, ifname:%{public}s",
127         __func__, GetCallingUid(), pid, ifname.c_str());
128     int error = Remote()->SendRequest(static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_REG_CALL_BACK),
129         data, reply, option);
130     if (error != ERR_NONE) {
131         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
132             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_REG_CALL_BACK), error);
133         return DHCP_E_FAILED;
134     }
135     int exception = reply.ReadInt32();
136     if (exception) {
137         DHCP_LOGE("exception failed, exception:%{public}d", exception);
138         return DHCP_E_FAILED;
139     }
140     DHCP_LOGI("DhcpServerProxy RegisterDhcpServerCallBack ok, exception:%{public}d", exception);
141     return DHCP_E_SUCCESS;
142 }
143 
StartDhcpServer(const std::string & ifname)144 ErrCode DhcpServerProxy::StartDhcpServer(const std::string& ifname)
145 {
146     DHCP_LOGI("DhcpServerProxy enter StartDhcpServer mRemoteDied:%{public}d", mRemoteDied);
147     if (mRemoteDied) {
148         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
149         return DHCP_E_FAILED;
150     }
151     MessageParcel data, reply;
152     MessageOption option;
153     if (!data.WriteInterfaceToken(GetDescriptor())) {
154         DHCP_LOGE("Write interface token error: %{public}s", __func__);
155         return DHCP_E_FAILED;
156     }
157     data.WriteInt32(0);
158 
159     int pid = GetCallingPid();
160     int tokenId = GetCallingTokenId();
161     data.WriteInt32(pid);
162     data.WriteInt32(tokenId);
163     data.WriteString(ifname);
164     DHCP_LOGI("%{public}s, calling uid:%{public}d, pid:%{public}d, ifname:%{public}s",
165         __func__, GetCallingUid(), pid, ifname.c_str());
166     int error = Remote()->SendRequest(
167         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_START_DHCP_SERVER), data, reply, option);
168     if (error != ERR_NONE) {
169         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
170             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_START_DHCP_SERVER), error);
171         return DHCP_E_FAILED;
172     }
173     int exception = reply.ReadInt32();
174     if (exception) {
175         DHCP_LOGE("exception failed, exception:%{public}d", exception);
176         return DHCP_E_FAILED;
177     }
178     DHCP_LOGI("DhcpServerProxy StartDhcpServer ok, exception:%{public}d", exception);
179     return DHCP_E_SUCCESS;
180 }
181 
SetDhcpRange(const std::string & ifname,const DhcpRange & range)182 ErrCode DhcpServerProxy::SetDhcpRange(const std::string& ifname, const DhcpRange& range)
183 {
184     DHCP_LOGI("DhcpServerProxy enter SetDhcpRange mRemoteDied:%{public}d", mRemoteDied);
185     if (mRemoteDied) {
186         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
187         return DHCP_E_FAILED;
188     }
189     MessageParcel data, reply;
190     MessageOption option;
191     if (!data.WriteInterfaceToken(GetDescriptor())) {
192         DHCP_LOGE("Write interface token error: %{public}s", __func__);
193         return DHCP_E_FAILED;
194     }
195     data.WriteInt32(0);
196 
197     data.WriteInt32(range.iptype);
198     data.WriteInt32(range.leaseHours);
199     data.WriteString(range.strTagName);
200     data.WriteString(range.strStartip);
201     data.WriteString(range.strEndip);
202     data.WriteString(range.strSubnet);
203     data.WriteString(ifname);
204     DHCP_LOGI("%{public}s, LINE :%{public}d ifname:%{public}s iptype %{public}d leaseHours %{public}d"
205         "TagName:%{public}s Startip:%{public}s strEndip:%{public}s strSubnet:%{public}s",
206         __func__, __LINE__, ifname.c_str(), range.iptype, range.leaseHours, range.strTagName.c_str(),
207         range.strStartip.c_str(), range.strEndip.c_str(), range.strSubnet.c_str());
208     int error = Remote()->SendRequest(
209         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_SET_DHCP_RANGE), data, reply, option);
210     if (error != ERR_NONE) {
211         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
212             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_SET_DHCP_RANGE), error);
213         return DHCP_E_FAILED;
214     }
215     int exception = reply.ReadInt32();
216     if (exception) {
217         DHCP_LOGE("exception failed, exception:%{public}d", exception);
218         return DHCP_E_FAILED;
219     }
220     DHCP_LOGI("DhcpServerProxy SetDhcpRange ok, exception:%{public}d", exception);
221     return DHCP_E_SUCCESS;
222 }
223 
SetDhcpName(const std::string & ifname,const std::string & tagName)224 ErrCode DhcpServerProxy::SetDhcpName(const std::string& ifname, const std::string& tagName)
225 {
226 
227     DHCP_LOGI("DhcpServerProxy enter SetDhcpName mRemoteDied:%{public}d", mRemoteDied);
228     if (mRemoteDied) {
229         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
230         return DHCP_E_FAILED;
231     }
232     MessageParcel data, reply;
233     MessageOption option;
234     if (!data.WriteInterfaceToken(GetDescriptor())) {
235         DHCP_LOGE("Write interface token error: %{public}s", __func__);
236         return DHCP_E_FAILED;
237     }
238     data.WriteInt32(0);
239 
240     data.WriteString(tagName);
241     data.WriteString(ifname);
242      DHCP_LOGI("%{public}s, LINE :%{public}d ifname:%{public}s tagName %{public}s", __func__, __LINE__, ifname.c_str(),
243         tagName.c_str());
244     int error = Remote()->SendRequest(
245         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_SET_DHCP_NAME), data, reply, option);
246     if (error != ERR_NONE) {
247         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
248             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_SET_DHCP_NAME), error);
249         return DHCP_E_FAILED;
250     }
251     int exception = reply.ReadInt32();
252     if (exception) {
253         DHCP_LOGE("exception failed, exception:%{public}d", exception);
254         return DHCP_E_FAILED;
255     }
256     DHCP_LOGI("DhcpServerProxy SetDhcpName ok, exception:%{public}d", exception);
257     return DHCP_E_SUCCESS;
258 }
PutDhcpRange(const std::string & tagName,const DhcpRange & range)259 ErrCode DhcpServerProxy::PutDhcpRange(const std::string& tagName, const DhcpRange& range)
260 {
261     DHCP_LOGI("DhcpServerProxy enter PutDhcpRange mRemoteDied:%{public}d", mRemoteDied);
262     if (mRemoteDied) {
263         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
264         return DHCP_E_FAILED;
265     }
266     MessageParcel data, reply;
267     MessageOption option;
268     if (!data.WriteInterfaceToken(GetDescriptor())) {
269         DHCP_LOGE("Write interface token error: %{public}s", __func__);
270         return DHCP_E_FAILED;
271     }
272     data.WriteInt32(0);
273     data.WriteInt32(range.iptype);
274     data.WriteInt32(range.leaseHours);
275     data.WriteString(range.strTagName);
276     data.WriteString(range.strStartip);
277     data.WriteString(range.strEndip);
278     data.WriteString(range.strSubnet);
279     data.WriteString(tagName);
280      DHCP_LOGI("%{public}s, LINE :%{public}d tagName:%{public}s iptype %{public}d  leaseHours %{public}d"
281         "strTagName:%{public}s strStartip:%{public}s strEndip:%{public}s strSubnet:%{public}s",
282         __func__, __LINE__, tagName.c_str(), range.iptype, range.leaseHours, range.strTagName.c_str(),
283         range.strStartip.c_str(), range.strEndip.c_str(), range.strSubnet.c_str());
284     int error = Remote()->SendRequest(
285         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_PUT_DHCP_RANGE), data, reply, option);
286     if (error != ERR_NONE) {
287         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
288             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_PUT_DHCP_RANGE), error);
289         return DHCP_E_FAILED;
290     }
291     int exception = reply.ReadInt32();
292     if (exception) {
293         DHCP_LOGE("exception failed, exception:%{public}d", exception);
294         return DHCP_E_FAILED;
295     }
296     DHCP_LOGI("DhcpServerProxy SetDhcpRange ok, exception:%{public}d", exception);
297     return DHCP_E_SUCCESS;
298 }
299 
RemoveAllDhcpRange(const std::string & tagName)300 ErrCode DhcpServerProxy::RemoveAllDhcpRange(const std::string& tagName)
301 {
302     DHCP_LOGI("DhcpServerProxy enter RemoveAllDhcpRange mRemoteDied:%{public}d", mRemoteDied);
303     if (mRemoteDied) {
304         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
305         return DHCP_E_FAILED;
306     }
307     MessageParcel data, reply;
308     MessageOption option;
309     if (!data.WriteInterfaceToken(GetDescriptor())) {
310         DHCP_LOGE("Write interface token error: %{public}s", __func__);
311         return DHCP_E_FAILED;
312     }
313     data.WriteInt32(0);
314 
315     data.WriteString(tagName);
316     DHCP_LOGI("%{public}s, calling tagName:%{public}s", __func__, tagName.c_str());
317     int error = Remote()->SendRequest(
318         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_REMOVE_ALL_DHCP_RANGE), data, reply, option);
319     if (error != ERR_NONE) {
320         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
321             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_REMOVE_ALL_DHCP_RANGE), error);
322         return DHCP_E_FAILED;
323     }
324     int exception = reply.ReadInt32();
325     if (exception) {
326         DHCP_LOGE("exception failed, exception:%{public}d", exception);
327         return DHCP_E_FAILED;
328     }
329     DHCP_LOGI("DhcpServerProxy RemoveAllDhcpRange ok, exception:%{public}d", exception);
330     return DHCP_E_SUCCESS;
331 }
332 
UpdateLeasesTime(const std::string & leaseTime)333 ErrCode DhcpServerProxy::UpdateLeasesTime(const std::string& leaseTime)
334 {
335     DHCP_LOGI("DhcpServerProxy enter UpdateLeasesTime mRemoteDied:%{public}d", mRemoteDied);
336     if (mRemoteDied) {
337         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
338         return DHCP_E_FAILED;
339     }
340     MessageParcel data, reply;
341     MessageOption option;
342     if (!data.WriteInterfaceToken(GetDescriptor())) {
343         DHCP_LOGE("Write interface token error: %{public}s", __func__);
344         return DHCP_E_FAILED;
345     }
346     data.WriteInt32(0);
347 
348     data.WriteString(leaseTime);
349     DHCP_LOGI("%{public}s, calling  leaseTime:%{public}s", __func__, leaseTime.c_str());
350     int error = Remote()->SendRequest(
351         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_UPDATE_RENEW_TIME), data, reply, option);
352     if (error != ERR_NONE) {
353         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
354             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_UPDATE_RENEW_TIME), error);
355         return DHCP_E_FAILED;
356     }
357     int exception = reply.ReadInt32();
358     if (exception) {
359         DHCP_LOGE("exception failed, exception:%{public}d", exception);
360         return DHCP_E_FAILED;
361     }
362     DHCP_LOGI("DhcpServerProxy UpdateLeasesTime ok, exception:%{public}d", exception);
363     return DHCP_E_SUCCESS;
364 }
365 
StopDhcpServer(const std::string & ifname)366 ErrCode DhcpServerProxy::StopDhcpServer(const std::string& ifname)
367 {
368     DHCP_LOGI("DhcpServerProxy enter StopDhcpServer mRemoteDied:%{public}d", mRemoteDied);
369     if (mRemoteDied) {
370         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
371         return DHCP_E_FAILED;
372     }
373     MessageParcel data, reply;
374     MessageOption option;
375     if (!data.WriteInterfaceToken(GetDescriptor())) {
376         DHCP_LOGE("Write interface token error: %{public}s", __func__);
377         return DHCP_E_FAILED;
378     }
379     data.WriteInt32(0);
380     data.WriteString(ifname);
381     DHCP_LOGI("%{public}s, calling tagName:%{public}s", __func__, ifname.c_str());
382     int error = Remote()->SendRequest(
383         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_STOP_DHCP_SERVER), data, reply, option);
384     if (error != ERR_NONE) {
385         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
386             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_STOP_DHCP_SERVER), error);
387         return DHCP_E_FAILED;
388     }
389     int exception = reply.ReadInt32();
390     if (exception) {
391         DHCP_LOGE("exception failed, exception:%{public}d", exception);
392         return DHCP_E_FAILED;
393     }
394     DHCP_LOGI("DhcpServerProxy StopDhcpServer ok, exception:%{public}d", exception);
395     return DHCP_E_SUCCESS;
396 }
RemoveDhcpRange(const std::string & tagName,const DhcpRange & range)397 ErrCode DhcpServerProxy::RemoveDhcpRange(const std::string& tagName, const DhcpRange& range)
398 {
399     DHCP_LOGI("DhcpServerProxy enter RemoveDhcpRange mRemoteDied:%{public}d", mRemoteDied);
400     if (mRemoteDied) {
401         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
402         return DHCP_E_FAILED;
403     }
404     MessageParcel data, reply;
405     MessageOption option;
406     if (!data.WriteInterfaceToken(GetDescriptor())) {
407         DHCP_LOGE("Write interface token error: %{public}s", __func__);
408         return DHCP_E_FAILED;
409     }
410     data.WriteInt32(0);
411     data.WriteInt32(range.iptype);
412     data.WriteInt32(range.leaseHours);
413     data.WriteString(range.strTagName);
414     data.WriteString(range.strStartip);
415     data.WriteString(range.strEndip);
416     data.WriteString(range.strSubnet);
417     data.WriteString(tagName);
418      DHCP_LOGI("%{public}s, LINE :%{public}d ifname:%{public}s iptype %{public}d leaseHours %{public}d"
419         "strTagName:%{public}s strStartip:%{public}s strEndip:%{public}s strSubnet:%{public}s",
420         __func__, __LINE__, tagName.c_str(), range.iptype, range.leaseHours, range.strTagName.c_str(),
421         range.strStartip.c_str(), range.strEndip.c_str(), range.strSubnet.c_str());
422     int error = Remote()->SendRequest(
423         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_REMOVE_DHCP_RANGE), data, reply, option);
424     if (error != ERR_NONE) {
425         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
426             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_REMOVE_DHCP_RANGE), error);
427         return DHCP_E_FAILED;
428     }
429     int exception = reply.ReadInt32();
430     if (exception) {
431         DHCP_LOGE("exception failed, exception:%{public}d", exception);
432         return DHCP_E_FAILED;
433     }
434     DHCP_LOGI("DhcpServerProxy SetDhcpRange ok, exception:%{public}d", exception);
435     return DHCP_E_SUCCESS;
436 }
GetDhcpClientInfos(const std::string & ifname,std::vector<std::string> & dhcpClientInfo)437 ErrCode DhcpServerProxy::GetDhcpClientInfos(const std::string& ifname, std::vector<std::string>& dhcpClientInfo)
438 {
439     DHCP_LOGI("DhcpServerProxy enter GetDhcpClientInfos mRemoteDied:%{public}d", mRemoteDied);
440     if (mRemoteDied) {
441         DHCP_LOGE("failed to `%{public}s`,remote service is died!", __func__);
442         return DHCP_E_FAILED;
443     }
444     MessageParcel data, reply;
445     MessageOption option;
446     if (!data.WriteInterfaceToken(GetDescriptor())) {
447         DHCP_LOGE("Write interface token error: %{public}s", __func__);
448         return DHCP_E_FAILED;
449     }
450     data.WriteInt32(0);
451     data.WriteString(ifname);
452     DHCP_LOGI("%{public}s, LINE :%{public}d %{public}s", __func__, __LINE__, ifname.c_str());
453     int error = Remote()->SendRequest(
454         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_GET_DHCP_CLIENT_INFO), data, reply, option);
455     if (error != ERR_NONE) {
456         DHCP_LOGE("Set Attr(%{public}d) failed, code is %{public}d",
457             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_SVR_CMD_GET_DHCP_CLIENT_INFO), error);
458         return DHCP_E_FAILED;
459     }
460     int exception = reply.ReadInt32();
461     if (exception) {
462         DHCP_LOGE("exception failed, exception:%{public}d", exception);
463         return DHCP_E_FAILED;
464     }
465     int ret = reply.ReadInt32();
466     if (ret == DHCP_E_SUCCESS) {
467         int tmpsize = reply.ReadInt32();
468         DHCP_LOGI("DhcpServerProxy GetDhcpClientInfos ok, exception:%{public}d, reply data size:%{public}d", exception,
469             tmpsize);
470         for (int i = 0; i < tmpsize; i++) {
471             std::string str = reply.ReadString();
472             dhcpClientInfo.push_back(str);
473         }
474     }
475     DHCP_LOGI("DhcpServerProxy GetDhcpClientInfos 1");
476     return DHCP_E_SUCCESS;
477 }
478 }  // namespace DHCP
479 }  // namespace OHOS
480