• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 "dhcp_server_callback_proxy.h"
17 #include "dhcp_logger.h"
18 #include "dhcp_manager_service_ipc_interface_code.h"
19 
20 DEFINE_DHCPLOG_DHCP_LABEL("DhcpServerCallbackProxy");
21 
22 namespace OHOS {
23 namespace Wifi {
DhcpServerCallbackProxy(const sptr<IRemoteObject> & impl)24 DhcpServerCallbackProxy::DhcpServerCallbackProxy(const sptr<IRemoteObject> &impl) :
25     IRemoteProxy<IDhcpServerCallBack>(impl)
26 {}
27 
~DhcpServerCallbackProxy()28 DhcpServerCallbackProxy::~DhcpServerCallbackProxy()
29 {}
30 
OnServerStatusChanged(int status)31 void DhcpServerCallbackProxy::OnServerStatusChanged(int status)
32 {
33     DHCP_LOGI("DhcpServerCallbackProxy::OnServerStatusChanged");
34     MessageOption option;
35     MessageParcel data;
36     MessageParcel reply;
37     if (!data.WriteInterfaceToken(GetDescriptor())) {
38         DHCP_LOGE("Write interface token error: %{public}s", __func__);
39         return;
40     }
41     data.WriteInt32(0);
42     data.WriteInt32(status);
43     DHCP_LOGI("start server requeset");
44     int error = Remote()->SendRequest(
45         static_cast<uint32_t>(DhcpServerInterfaceCode::DHCP_SERVER_CBK_SERVER_STATUS_CHANGE), data, reply, option);
46     if (error != ERR_NONE) {
47         DHCP_LOGE("Set Attr(%{public}d) failed,error code is %{public}d",
48             static_cast<int32_t>(DhcpServerInterfaceCode::DHCP_SERVER_CBK_SERVER_STATUS_CHANGE), error);
49         return;
50     }
51     int exception = reply.ReadInt32();
52     if (exception) {
53         DHCP_LOGE("notify wifi state change failed!");
54     }
55     DHCP_LOGI("send server request success");
56 
57     return;
58 }
59 
OnServerLeasesChanged(const std::string & ifname,std::vector<std::string> & leases)60 void DhcpServerCallbackProxy::OnServerLeasesChanged(const std::string& ifname, std::vector<std::string>& leases)
61 {
62     DHCP_LOGI("DhcpServerCallbackProxy::OnServerLeasesChanged");
63     return;
64 }
OnServerSerExitChanged(const std::string & ifname)65 void DhcpServerCallbackProxy::OnServerSerExitChanged(const std::string& ifname)
66 {
67     DHCP_LOGI("DhcpServerCallbackProxy::OnServerSerExitChanged");
68     return;
69 }
70 
71 }  // namespace Wifi
72 }  // namespace OHOS
73