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_CLIENT_CALLBACK_STUB_H 16 #define OHOS_DHCP_CLIENT_CALLBACK_STUB_H 17 #ifndef OHOS_ARCH_LITE 18 #include "iremote_stub.h" 19 #include "iremote_object.h" 20 #endif 21 #include "i_dhcp_client_callback.h" 22 #include "dhcp_errcode.h" 23 24 namespace OHOS { 25 namespace DHCP { 26 #define DHCP_MAX_DNS_SIZE 64 27 class DhcpClientCallBackStub : public IRemoteStub<IDhcpClientCallBack> { 28 public: 29 DhcpClientCallBackStub(); 30 virtual ~DhcpClientCallBackStub(); 31 32 virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, 33 MessageOption &option) override; 34 void RegisterCallBack(const sptr<IDhcpClientCallBack> &callBack); 35 bool IsRemoteDied() const; 36 void SetRemoteDied(bool val); 37 void OnIpSuccessChanged(int status, const std::string& ifname, DhcpResult& result) override; 38 void OnIpFailChanged(int status, const std::string& ifname, const std::string& reason) override; 39 void OnDhcpOfferReport(int status, const std::string& ifname, DhcpResult& result) override; 40 private: 41 int RemoteOnIpSuccessChanged(uint32_t code, MessageParcel &data, MessageParcel &reply); 42 int RemoteOnIpFailChanged(uint32_t code, MessageParcel &data, MessageParcel &reply); 43 int RemoteOnDhcpOfferReport(uint32_t code, MessageParcel &data, MessageParcel &reply); 44 45 sptr<IDhcpClientCallBack> callback_; 46 bool mRemoteDied; 47 }; 48 } // namespace DHCP 49 } // namespace OHOS 50 #endif