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 HOSTAPD_CLIENT_H
17 #define HOSTAPD_CLIENT_H
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 #endif
27 
28 #define IFNAMSIZ 16
29 #define WIFI_HOSTAPD_CB_CONTENT_LENGTH 1024
30 
31 typedef enum {
32     HOSTAPD_EVENT_STA_JOIN = 0,
33     HOSTAPD_EVENT_AP_STATE,
34     HOSTAPD_EVENT_HOSTAPD_NOTIFY
35 } HostapdCallBackEventType;
36 
37 enum HostapdClientType {
38     /* 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 | 1<<9 | 1<<10 */
39     WIFI_HOSTAPD_TO_HAL_CLIENT = 33554431,
40     WIFI_HOSTAPD_CLIENT_BUTT
41 };
42 
43 typedef int32_t (*OnReceiveFunc)(uint32_t event, void *data, const char *ifName);
44 
45 struct HostapdApCbParm {
46     unsigned char content[WIFI_HOSTAPD_CB_CONTENT_LENGTH];
47     int id;
48 };
49 
50 struct HostapdCallbackEvent {
51     uint32_t eventType; /* eventmap */
52     char ifName[IFNAMSIZ + 1];
53     OnReceiveFunc onRecFunc;
54 };
55 
56 void HostapdEventReport(const char *ifName, uint32_t event, void *data);
57 int32_t HostapdRegisterEventCallback(OnReceiveFunc onRecFunc, uint32_t eventType, const char *ifName);
58 int32_t  HostapdUnregisterEventCallback(OnReceiveFunc onRecFunc,  uint32_t eventType, const char *ifName);
59 
60 #endif
61