1 /* 2 * Copyright (C) 2020-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_C_API_H 16 #define OHOS_DHCP_C_API_H 17 18 #include "dhcp_error_code.h" 19 #include "dhcp_result_event.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /** 26 * @Description : Obtain the dhcp result of specified interface asynchronously. 27 * 28 * @param ifname - interface name, eg:wlan0 [in] 29 * @param pResultNotify - dhcp result notify [in] 30 * @Return : success - DHCP_SUCCESS, failed - others. 31 */ 32 DhcpErrorCode RegisterDhcpClientCallBack(const char *ifname, const ClientCallBack *event); 33 34 /** 35 * @Description : Obtain the dhcp offer result of specified interface asynchronously. 36 * 37 * @param ifname - interface name, eg:wlan0 [in] 38 * @param event - dhcp offer result notify [out] 39 * @Return : success - DHCP_SUCCESS, failed - others. 40 */ 41 DhcpErrorCode RegisterDhcpClientReportCallBack(const char *ifname, const DhcpClientReport *event); 42 /** 43 * @Description : Start dhcp client service of specified interface. 44 * 45 * @param ifname - interface name, eg:wlan0 [in] 46 * @param bIpv6 - can or not get ipv6 [in] 47 * @Return : success - DHCP_SUCCESS, failed - others. 48 */ 49 DhcpErrorCode StartDhcpClient(const char *ifname, bool bIpv6); 50 /** 51 * @Description : set bssid of specified interface. 52 * 53 * @param ifname - interface name, eg:wlan0 [in] 54 * @param targetBssid - target Bssid [in] 55 * @Return : success - DHCP_SUCCESS, failed - others. 56 */ 57 DhcpErrorCode SetConfiguration(const char *ifname, const RouterConfig config); 58 /** 59 * @Description : Stop dhcp client service of specified interface. 60 * 61 * @param ifname - interface name, eg:wlan0 [in] 62 * @param bIpv6 - can or not get ipv6 [in] 63 * @Return : success - DHCP_SUCCESS, failed - others. 64 */ 65 DhcpErrorCode StopDhcpClient(const char *ifname, bool bIpv6); 66 67 DhcpErrorCode RegisterDhcpServerCallBack(const char *ifname, const ServerCallBack *event); 68 DhcpErrorCode StartDhcpServer(const char *ifname); 69 DhcpErrorCode StopDhcpServer(const char *ifname); 70 DhcpErrorCode SetDhcpRange(const char *ifname, const DhcpRange *range); 71 DhcpErrorCode SetDhcpName(const char *ifname, const char *tagName); 72 DhcpErrorCode PutDhcpRange(const char *tagName, const DhcpRange *range); 73 DhcpErrorCode RemoveAllDhcpRange(const char *tagName); 74 DhcpErrorCode RemoveDhcpRange(const char *tagName, const void *range); 75 DhcpErrorCode GetDhcpClientInfos(const char *ifname, int staNumber, DhcpStationInfo *staInfo, int *staSize); 76 DhcpErrorCode UpdateLeasesTime(const char *leaseTime); 77 #ifdef __cplusplus 78 } 79 #endif 80 #endif