• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 #ifndef OHOS_DHCP_SERVER_CALLBACK_STUB_H
16 #define OHOS_DHCP_SERVER_CALLBACK_STUB_H
17 
18 #include <map>
19 #ifdef OHOS_ARCH_LITE
20 #include "serializer.h"
21 #else
22 #include "iremote_stub.h"
23 #include "iremote_object.h"
24 #endif
25 #include "../interfaces/i_dhcp_server_callback.h"
26 #include "dhcp_errcode.h"
27 
28 namespace OHOS {
29 namespace Wifi {
30 #ifdef OHOS_ARCH_LITE
31 class DhcpServreCallBackStub : public IDhcpServerCallBack {
32 #else
33 class DhcpServreCallBackStub : public IRemoteStub<IDhcpServerCallBack> {
34 #endif
35 public:
36     DhcpServreCallBackStub();
37     virtual ~DhcpServreCallBackStub();
38 
39 #ifdef OHOS_ARCH_LITE
40     int OnRemoteRequest(uint32_t code, IpcIo *data);
41     void RegisterCallBack(const std::shared_ptr<IDhcpServerCallBack> &callBack);
42 #else
43     virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
44         MessageOption &option) override;
45     void RegisterCallBack(const sptr<IDhcpServerCallBack> &callBack);
46 #endif
47     bool IsRemoteDied() const;
48     void SetRemoteDied(bool val);
49 
50     virtual void OnServerStatusChanged(int status) override;
51     virtual void OnServerLeasesChanged(const std::string& ifname, std::vector<std::string>& leases) override;
52     virtual void OnServerSerExitChanged(const std::string& ifname) override;
53 private:
54 #ifdef OHOS_ARCH_LITE
55     int RemoteOnServerStatusChanged(uint32_t code, IpcIo *data);
56     int RemoteOnServerLeasesChanged(uint32_t code, IpcIo *data);
57     int RemoteOnServerSerExitChanged(uint32_t code, IpcIo *data);
58     std::shared_ptr<IDhcpServerCallBack> callback_;
59 #else
60     int RemoteOnServerStatusChanged(uint32_t code, MessageParcel &data, MessageParcel &reply);
61     int RemoteOnServerLeasesChanged(uint32_t code, MessageParcel &data, MessageParcel &reply);
62     int RemoteOnServerSerExitChanged(uint32_t code, MessageParcel &data, MessageParcel &reply);
63     sptr<IDhcpServerCallBack> callback_;
64 #endif
65     bool mRemoteDied;
66 };
67 }  // namespace Wifi
68 }  // namespace OHOS
69 #endif