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 DHCP { 30 class DhcpServerStub : public IRemoteStub<IDhcpServer> { 31 public: 32 using handleFunc = std::function<int(uint32_t &, MessageParcel &, MessageParcel &, MessageOption &)>; 33 using HandleFuncMap = std::map<int, handleFunc>; 34 DhcpServerStub(); 35 36 virtual ~DhcpServerStub(); 37 38 virtual int OnRemoteRequest( 39 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 40 41 bool IsSingleCallback() const; 42 void SetSingleCallback(const bool isSingleCallback); 43 44 int OnRegisterCallBack(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 45 int OnStartDhcpServer(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 46 int OnStopDhcpServer(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 47 int OnUpdateDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 48 int OnSetDhcpName(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 49 int OnSetDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 50 int OnRemoveAllDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 51 int OnRemoveDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 52 int OnGetDhcpClientInfos(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 53 int OnUpdateLeasesTime(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 54 int OnPutDhcpRange(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 55 int OnStopServerSa(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 56 57 private: 58 void InitHandleMap(void); 59 60 private: 61 HandleFuncMap handleFuncMap; 62 sptr<IRemoteObject::DeathRecipient> deathRecipient_; 63 bool mSingleCallback; 64 sptr<IDhcpServerCallBack> callback_; 65 }; 66 } // namespace DHCP 67 } // namespace OHOS 68 #endif