1 /* 2 * Copyright (C) 2021-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_IMPL_H 16 #define OHOS_DHCP_CLIENT_IMPL_H 17 18 #include <string> 19 #include "singleton.h" 20 #include "i_dhcp_client.h" 21 #include "i_dhcp_client_callback.h" 22 #include "inner_api/dhcp_client.h" 23 24 namespace OHOS { 25 namespace DHCP { 26 class DhcpClientImpl : public DhcpClient { 27 DECLARE_DELAYED_SINGLETON(DhcpClientImpl); 28 public: 29 bool Init(int systemAbilityId); 30 bool IsRemoteDied(); 31 #ifdef OHOS_ARCH_LITE 32 ErrCode RegisterDhcpClientCallBack(const std::string& ifname, 33 const std::shared_ptr<IDhcpClientCallBack> &callback) override; 34 #else 35 ErrCode RegisterDhcpClientCallBack(const std::string& ifname, 36 const sptr<IDhcpClientCallBack> &callback) override; 37 #endif 38 39 ErrCode StartDhcpClient(const std::string& ifname, bool bIpv6) override; 40 ErrCode SetConfiguration(const std::string& ifname, const RouterConfig& config) override; 41 ErrCode StopDhcpClient(const std::string& ifname, bool bIpv6) override; 42 private: 43 bool GetDhcpClientProxy(); 44 int systemAbilityId_; 45 std::mutex mutex_; 46 #ifdef OHOS_ARCH_LITE 47 IDhcpClient *client_; 48 #else 49 sptr<IDhcpClient> client_; 50 #endif 51 }; 52 } // namespace DHCP 53 } // namespace OHOS 54 #endif 55