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 16#ifndef OHOS_HDI_WLAN_HOSTAPD_V1_0_IHOSTAPDINTERFACE_H 17#define OHOS_HDI_WLAN_HOSTAPD_V1_0_IHOSTAPDINTERFACE_H 18 19#include <stdbool.h> 20#include <stdint.h> 21#include <hdf_base.h> 22#include "wlan/hostapd/v1_0/hostapd_types.h" 23#include "wlan/hostapd/v1_0/ihostapd_callback.h" 24 25#ifdef __cplusplus 26extern "C" { 27#endif /* __cplusplus */ 28 29struct HdfRemoteService; 30 31#define IHOSTAPDINTERFACE_INTERFACE_DESC "ohos.hdi.wlan.hostapd.v1_0.IHostapdInterface" 32 33#define IHOSTAPD_INTERFACE_MAJOR_VERSION 1 34#define IHOSTAPD_INTERFACE_MINOR_VERSION 0 35 36#ifndef HDI_BUFF_MAX_SIZE 37#define HDI_BUFF_MAX_SIZE (1024 * 200) 38#endif 39 40#ifndef HDI_CHECK_VALUE_RETURN 41#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \ 42 if ((lv) compare (rv)) { \ 43 return ret; \ 44 } \ 45} while (false) 46#endif 47 48#ifndef HDI_CHECK_VALUE_RET_GOTO 49#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \ 50 if ((lv) compare (rv)) { \ 51 ret = value; \ 52 goto table; \ 53 } \ 54} while (false) 55#endif 56 57enum { 58 CMD_HOSTAPD_INTERFACE_GET_VERSION = 0, 59 CMD_HOSTAPD_INTERFACE_START_AP = 1, 60 CMD_HOSTAPD_INTERFACE_STOP_AP = 2, 61 CMD_HOSTAPD_INTERFACE_ENABLE_AP = 3, 62 CMD_HOSTAPD_INTERFACE_DISABLE_AP = 4, 63 CMD_HOSTAPD_INTERFACE_SET_AP_PASSWD = 5, 64 CMD_HOSTAPD_INTERFACE_SET_AP_NAME = 6, 65 CMD_HOSTAPD_INTERFACE_SET_AP_WPA_VALUE = 7, 66 CMD_HOSTAPD_INTERFACE_SET_AP_BAND = 8, 67 CMD_HOSTAPD_INTERFACE_SET_AP80211N = 9, 68 CMD_HOSTAPD_INTERFACE_SET_AP_WMM = 10, 69 CMD_HOSTAPD_INTERFACE_SET_AP_CHANNEL = 11, 70 CMD_HOSTAPD_INTERFACE_SET_AP_MAX_CONN = 12, 71 CMD_HOSTAPD_INTERFACE_SET_MAC_FILTER = 13, 72 CMD_HOSTAPD_INTERFACE_DEL_MAC_FILTER = 14, 73 CMD_HOSTAPD_INTERFACE_GET_STA_INFOS = 15, 74 CMD_HOSTAPD_INTERFACE_DISASSOCIATE_STA = 16, 75 CMD_HOSTAPD_INTERFACE_REGISTER_EVENT_CALLBACK = 17, 76 CMD_HOSTAPD_INTERFACE_UNREGISTER_EVENT_CALLBACK = 18, 77 CMD_HOSTAPD_INTERFACE_HOST_APD_SHELL_CMD = 19, 78}; 79 80struct IHostapdInterface { 81 int32_t (*StartAp)(struct IHostapdInterface *self); 82 83 int32_t (*StopAp)(struct IHostapdInterface *self); 84 85 int32_t (*EnableAp)(struct IHostapdInterface *self, const char* ifName, int32_t id); 86 87 int32_t (*DisableAp)(struct IHostapdInterface *self, const char* ifName, int32_t id); 88 89 int32_t (*SetApPasswd)(struct IHostapdInterface *self, const char* ifName, const char* pass, int32_t id); 90 91 int32_t (*SetApName)(struct IHostapdInterface *self, const char* ifName, const char* name, int32_t id); 92 93 int32_t (*SetApWpaValue)(struct IHostapdInterface *self, const char* ifName, int32_t securityType, int32_t id); 94 95 int32_t (*SetApBand)(struct IHostapdInterface *self, const char* ifName, int32_t band, int32_t id); 96 97 int32_t (*SetAp80211n)(struct IHostapdInterface *self, const char* ifName, int32_t value, int32_t id); 98 99 int32_t (*SetApWmm)(struct IHostapdInterface *self, const char* ifName, int32_t value, int32_t id); 100 101 int32_t (*SetApChannel)(struct IHostapdInterface *self, const char* ifName, int32_t channel, int32_t id); 102 103 int32_t (*SetApMaxConn)(struct IHostapdInterface *self, const char* ifName, int32_t maxConn, int32_t id); 104 105 int32_t (*SetMacFilter)(struct IHostapdInterface *self, const char* ifName, const char* mac, int32_t id); 106 107 int32_t (*DelMacFilter)(struct IHostapdInterface *self, const char* ifName, const char* mac, int32_t id); 108 109 int32_t (*GetStaInfos)(struct IHostapdInterface *self, const char* ifName, char* buf, uint32_t bufLen, int32_t size, 110 int32_t id); 111 112 int32_t (*DisassociateSta)(struct IHostapdInterface *self, const char* ifName, const char* mac, int32_t id); 113 114 int32_t (*RegisterEventCallback)(struct IHostapdInterface *self, struct IHostapdCallback* cbFunc, 115 const char* ifName); 116 117 int32_t (*UnregisterEventCallback)(struct IHostapdInterface *self, struct IHostapdCallback* cbFunc, 118 const char* ifName); 119 120 int32_t (*HostApdShellCmd)(struct IHostapdInterface *self, const char* ifName, const char* cmd); 121 122 int32_t (*GetVersion)(struct IHostapdInterface *self, uint32_t* majorVer, uint32_t* minorVer); 123 124 struct HdfRemoteService* (*AsObject)(struct IHostapdInterface *self); 125}; 126 127// external method used to create client object, it support ipc and passthrought mode 128struct IHostapdInterface *IHostapdInterfaceGet(bool isStub); 129struct IHostapdInterface *IHostapdInterfaceGetInstance(const char *serviceName, bool isStub); 130 131// external method used to create release object, it support ipc and passthrought mode 132void IHostapdInterfaceRelease(struct IHostapdInterface *instance, bool isStub); 133void IHostapdInterfaceReleaseInstance(const char *serviceName, struct IHostapdInterface *instance, bool isStub); 134#ifdef __cplusplus 135} 136#endif /* __cplusplus */ 137 138#endif // OHOS_HDI_WLAN_HOSTAPD_V1_0_IHOSTAPDINTERFACE_H