• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 #ifndef OHOS_DHCP_SERVER_STUB_H
17 #define OHOS_DHCP_SERVER_STUB_H
18 
19 #include <map>
20 #ifndef OHOS_ARCH_LITE
21 #include "iremote_stub.h"
22 #include <iremote_broker.h>
23 #include "message_parcel.h"
24 #include "message_option.h"
25 #endif
26 #include "i_dhcp_server.h"
27 
28 namespace OHOS {
29 namespace Wifi {
30 class DhcpServerStub : public IRemoteStub<IDhcpServer> {
31 public:
32     using handleFunc = int (DhcpServerStub::*)(
33         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
34     using HandleFuncMap = std::map<int, handleFunc>;
35     DhcpServerStub();
36 
37     virtual ~DhcpServerStub();
38 
39     virtual int OnRemoteRequest(
40         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
41 
42     bool IsSingleCallback() const;
43     void SetSingleCallback(const bool isSingleCallback);
44 
45     int OnRegisterCallBack(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
46     int OnStartDhcpServer(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
47     int OnStopDhcpServer(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
48     int OnUpdateDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
49     int OnSetDhcpName(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
50     int OnSetDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
51     int OnRemoveAllDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
52     int OnRemoveDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
53     int OnGetDhcpClientInfos(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
54     int OnUpdateLeasesTime(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
55     int OnPutDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
56 public:
57     const int MAC_ADDR_MAX_LEN = 17;
58     const int DHCP_LEASE_FORMAT_SIZE = 5;
59     const int DHCP_LEASE_MAC_ADDR_POS = 0;
60     const int DHCP_LEASE_IP_ADDR_POS = 1;
61     const int DHCP_LEASE_HOSTNAME_POS = 2;
62 
63 private:
64     void InitHandleMap(void);
65 
66 private:
67     HandleFuncMap handleFuncMap;
68     sptr<IRemoteObject::DeathRecipient> deathRecipient_;
69     bool mSingleCallback;
70 };
71 }  // namespace Wifi
72 }  // namespace OHOS
73 #endif