1 /*
2  * Copyright (C) 2021 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 WIFI_WPA_COMMON_H
16 #define WIFI_WPA_COMMON_H
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include "wpa_ctrl.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 
29 typedef unsigned char u8;
30 typedef struct stWpaCtrl {
31     struct wpa_ctrl *pSend;
32     struct wpa_ctrl *pRecv;
33 } WpaCtrl;
34 
35 typedef struct stWpaKeyValue {
36     char key[WPA_MESSAGE_KEY_LENGTH];
37     char value[WPA_MESSAGE_VALUE_LENGTH];
38 } WpaKeyValue;
39 
40 #define INIT_WPA_KEY_VALUE {{0}, {0}}
41 
42 int InitWpaCtrl(WpaCtrl *pCtrl, const char *ifname);
43 void ReleaseWpaCtrl(WpaCtrl *pCtrl);
44 int WpaCliCmd(const char *cmd, char *buf, size_t bufLen);
45 void GetStrKeyVal(char *src, const char *split, WpaKeyValue *out);
46 int Hex2Dec(const char *str);
47 void TrimQuotationMark(char *str, char c);
48 size_t PrintfDecode(u8 *buf, size_t maxlen, const char *str);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 #endif