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 pResultNotify - 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 : remove the dhcp result of specified interface asynchronously. 73 * 74 * @param dhcp - dhcp result notify [in] 75 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 76 */ 77 virtual int RemoveDhcpResult(IDhcpResultNotify *pResultNotify) = 0; 78 79 /** 80 * @Description : Obtain the dhcp info of specified interface synchronously. 81 * 82 * @param ifname - interface name, eg:wlan0 [in] 83 * @param dhcp - dhcp info [out] 84 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 85 */ 86 virtual int GetDhcpInfo(const std::string& ifname, DhcpServiceInfo& dhcp) = 0; 87 88 /** 89 * @Description : Renew 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 RenewDhcpClient(const std::string& ifname) = 0; 95 96 /** 97 * @Description : Release dhcp client 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 ReleaseDhcpClient(const std::string& ifname) = 0; 103 104 /** 105 * @Description : Start 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 StartDhcpServer(const std::string& ifname) = 0; 111 112 /** 113 * @Description : Stop dhcp server service of specified interface. 114 * 115 * @param ifname - interface name, eg:wlan0 [in] 116 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 117 */ 118 virtual int StopDhcpServer(const std::string& ifname) = 0; 119 120 /** 121 * @Description : Get dhcp server service running status. 122 * 123 * @Return : 0 - not start, 1 - normal started. 124 */ 125 virtual int GetServerStatus(void) = 0; 126 127 /** 128 * @Description : Add or update dhcp ip address pool. 129 * 130 * @param tagName - ip address pool tag name [in] 131 * @param range - ip address range [in] 132 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 133 */ 134 virtual int PutDhcpRange(const std::string& tagName, const DhcpRange& range) = 0; 135 136 /** 137 * @Description : Remove dhcp ip address pool. 138 * 139 * @param tagName - ip address pool tag name [in] 140 * @param range - ip address range [in] 141 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 142 */ 143 virtual int RemoveDhcpRange(const std::string& tagName, const DhcpRange& range) = 0; 144 145 /** 146 * @Description : Remove all dhcp ip address pool. 147 * 148 * @param tagName - ip address pool tag name [in] 149 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 150 */ 151 virtual int RemoveAllDhcpRange(const std::string& tagName) = 0; 152 153 /** 154 * @Description : Set dhcp ip address pool of specified interface. 155 * 156 * @param ifname - interface name, eg:wlan0 [in] 157 * @param range - ip address range [in] 158 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 159 */ 160 virtual int SetDhcpRange(const std::string& ifname, const DhcpRange& range) = 0; 161 162 /** 163 * @Description : Set dhcp ip address pool of specified interface. 164 * 165 * @param ifname - interface name, eg:wlan0 [in] 166 * @param tagName - ip address pool tag name [in] 167 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 168 */ 169 virtual int SetDhcpRange(const std::string& ifname, const std::string& tagName) = 0; 170 171 /** 172 * @Description : Get dhcp server lease info. 173 * 174 * @param ifname - interface name, eg:wlan0 [in] 175 * @param leases - lease info [out] 176 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 177 */ 178 virtual int GetLeases(const std::string& ifname, std::vector<std::string>& leases) = 0; 179 180 /** 181 * @Description : Obtain the abnormal exit status of dhcp server process. 182 * 183 * @param ifname - interface name, eg:wlan0 [in] 184 * @param pResultNotify - pointer to dhcp result notify [in] 185 * @Return : success - DHCP_OPT_SUCCESS, failed - others. 186 */ 187 virtual int GetDhcpSerProExit(const std::string& ifname, IDhcpResultNotify *pResultNotify) = 0; 188 }; 189 } // namespace Wifi 190 } // namespace OHOS 191 #endif