1 /*
2  * Copyright (C) 2024 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 HDI_WPA_HAL_H
17 #define HDI_WPA_HAL_H
18 
19 #include <stdbool.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <stdint.h>
23 #include <pthread.h>
24 #include "wpa_hal_define.h"
25 #include "hdi_wpa_common.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define WIFI_CONF_FILE_PATH_LEN 256
32 
33 typedef struct AddInterfaceArgv {
34     char name[WIFI_IFACE_NAME_MAXLEN];
35     char confName[WIFI_CONF_FILE_PATH_LEN];
36 } AddInterfaceArgv;
37 
38 typedef struct StWpaIfaceInfo {
39     char name[WIFI_IFACE_NAME_MAXLEN];
40     int num;
41     struct StWpaIfaceInfo *next;
42 } WpaIfaceInfo;
43 
44 typedef struct StWifiWpaInterface WifiWpaInterface;
45 struct StWifiWpaInterface {
46     WpaCtrl staCtrl;
47     WpaCtrl p2pCtrl;
48     WpaCtrl chbaCtrl;
49     WpaCtrl commonCtrl;
50     pthread_t tid;
51     int threadRunFlag;
52     WpaIfaceInfo *ifaces;
53     int (*wpaCliConnect)(WifiWpaInterface *p);
54     void (*wpaCliClose)(WifiWpaInterface *p);
55     int (*wpaCliAddIface)(WifiWpaInterface *p, const AddInterfaceArgv *argv, bool isWpaAdd);
56     int (*wpaCliRemoveIface)(WifiWpaInterface *p, const char *name);
57     int (*wpaCliTerminate)(void);
58 };
59 
60 WifiWpaInterface *GetWifiWpaGlobalInterface(void);
61 void ReleaseWpaGlobalInterface(void);
62 WpaCtrl *GetStaCtrl(void);
63 WpaCtrl *GetP2pCtrl(void);
64 WpaCtrl *GetChbaCtrl(void);
65 WpaCtrl *GetCommonCtrl(void);
66 void ReleaseIfaceCtrl(char *ifName, int len);
67 void InitWifiWpaGlobalInterface(void);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 #endif
73