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 #ifndef HDI_WPA_COMMON_H
16 #define HDI_WPA_COMMON_H
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <pthread.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define WPA_MESSAGE_KEY_LENGTH 64
27 #define WPA_MESSAGE_VALUE_LENGTH 256
28 #define IFNAME_LEN_MIN 3
29 #define IFNAME_LEN_MAX 15
30 
31 typedef struct StWpaCtrl {
32     struct wpa_ctrl *pSend;
33     struct wpa_ctrl *pRecv;
34 } WpaCtrl;
35 
36 typedef struct StWpaKeyValue {
37     char key[WPA_MESSAGE_KEY_LENGTH];
38     char value[WPA_MESSAGE_VALUE_LENGTH];
39 } WpaKeyValue;
40 
41 #define INIT_WPA_KEY_VALUE {{0}, {0}}
42 
43 int InitWpaCtrl(WpaCtrl *pCtrl, const char *ifname);
44 void ReleaseWpaCtrl(WpaCtrl *pCtrl);
45 int WpaCliCmd(const char *cmd, char *buf, size_t bufLen);
46 int Hex2Dec(const char *str);
47 void TrimQuotationMark(char *str, char c);
48 int IsSockRemoved(const char *ifName, int len);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 #endif