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_SERVICE_INTERFACE_H 17 #define OHOS_DHCP_SERVICE_INTERFACE_H 18 19 #include "i_dhcp_result_notify.h" 20 #include "dhcp_define.h" 21 22 23 namespace OHOS { 24 namespace Wifi { 25 class IDhcpService { 26 public: 27 /** 28 * @Description : Construct a new dhcp base service object. 29 * 30 */ IDhcpService()31 IDhcpService() 32 { 33 } 34 35 /** 36 * @Description : Destroy the dhcp base service object. 37 * 38 */ ~IDhcpService()39 virtual ~IDhcpService() 40 { 41 } 42 43 /** 44 * @Description : Start dhcp client service of specified interface. 45 * 46 * @param ifname - interface name, eg:wlan0 [in] 47 * @param bIpv6 - can or not get ipv6 [in] 48 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 49 */ 50 virtual int StartDhcpClient(const std::string& ifname, bool bIpv6) = 0; 51 52 /** 53 * @Description : Stop dhcp client service of specified interface. 54 * 55 * @param ifname - interface name, eg:wlan0 [in] 56 * @param bIpv6 - can or not get ipv6 [in] 57 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 58 */ 59 virtual int StopDhcpClient(const std::string& ifname, bool bIpv6) = 0; 60 61 /** 62 * @Description : Obtain the dhcp result of specified interface asynchronously. 63 * 64 * @param ifname - interface name, eg:wlan0 [in] 65 * @param dhcp - dhcp result notify [in] 66 * @param timeouts - timeout interval [in] 67 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 68 */ 69 virtual int GetDhcpResult(const std::string& ifname, IDhcpResultNotify *pResultNotify, int timeouts) = 0; 70 71 /** 72 * @Description : Obtain the dhcp info of specified interface synchronously. 73 * 74 * @param ifname - interface name, eg:wlan0 [in] 75 * @param dhcp - dhcp info [out] 76 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 77 */ 78 virtual int GetDhcpInfo(const std::string& ifname, DhcpServiceInfo& dhcp) = 0; 79 80 /** 81 * @Description : Renew dhcp client service of specified interface. 82 * 83 * @param ifname - interface name, eg:wlan0 [in] 84 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 85 */ 86 virtual int RenewDhcpClient(const std::string& ifname) = 0; 87 88 /** 89 * @Description : Release dhcp client service of specified interface. 90 * 91 * @param ifname - interface name, eg:wlan0 [in] 92 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 93 */ 94 virtual int ReleaseDhcpClient(const std::string& ifname) = 0; 95 96 /** 97 * @Description : Start dhcp server service of specified interface. 98 * 99 * @param ifname - interface name, eg:wlan0 [in] 100 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 101 */ 102 virtual int StartDhcpServer(const std::string& ifname) = 0; 103 104 /** 105 * @Description : Stop dhcp server service of specified interface. 106 * 107 * @param ifname - interface name, eg:wlan0 [in] 108 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 109 */ 110 virtual int StopDhcpServer(const std::string& ifname) = 0; 111 112 /** 113 * @Description : Get dhcp server service running status. 114 * 115 * @Return : 0 - not start, 1 - normal started. 116 */ 117 virtual int GetServerStatus(void) = 0; 118 119 /** 120 * @Description : Add or update dhcp ip address pool. 121 * 122 * @param tagName - ip address pool tag name [in] 123 * @param range - ip address range [in] 124 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 125 */ 126 virtual int PutDhcpRange(const std::string& tagName, const DhcpRange& range) = 0; 127 128 /** 129 * @Description : Remove dhcp ip address pool. 130 * 131 * @param tagName - ip address pool tag name [in] 132 * @param range - ip address range [in] 133 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 134 */ 135 virtual int RemoveDhcpRange(const std::string& tagName, const DhcpRange& range) = 0; 136 137 /** 138 * @Description : Remove all dhcp ip address pool. 139 * 140 * @param tagName - ip address pool tag name [in] 141 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 142 */ 143 virtual int RemoveAllDhcpRange(const std::string& tagName) = 0; 144 145 /** 146 * @Description : Set dhcp ip address pool of specified interface. 147 * 148 * @param ifname - interface name, eg:wlan0 [in] 149 * @param range - ip address range [in] 150 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 151 */ 152 virtual int SetDhcpRange(const std::string& ifname, const DhcpRange& range) = 0; 153 154 /** 155 * @Description : Set dhcp ip address pool of specified interface. 156 * 157 * @param ifname - interface name, eg:wlan0 [in] 158 * @param tagName - ip address pool tag name [in] 159 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 160 */ 161 virtual int SetDhcpRange(const std::string& ifname, const std::string& tagName) = 0; 162 163 /** 164 * @Description : Get dhcp server lease info. 165 * 166 * @param ifname - interface name, eg:wlan0 [in] 167 * @param leases - lease info [out] 168 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 169 */ 170 virtual int GetLeases(const std::string& ifname, std::vector<std::string>& leases) = 0; 171 172 /** 173 * @Description : Obtain the abnormal exit status of dhcp server process. 174 * 175 * @param ifname - interface name, eg:wlan0 [in] 176 * @param pResultNotify - pointer to dhcp result notify [in] 177 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 178 */ 179 virtual int GetDhcpSerProExit(const std::string& ifname, IDhcpResultNotify *pResultNotify) = 0; 180 }; 181 } // namespace Wifi 182 } // namespace OHOS 183 #endif