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 #undef LOG_DOMAIN 27 #define LOG_DOMAIN 0xD001566 28 29 #define WPA_MESSAGE_KEY_LENGTH 64 30 #define WPA_MESSAGE_VALUE_LENGTH 256 31 #define IFNAME_LEN_MIN 3 32 #define IFNAME_LEN_MAX 15 33 34 typedef struct StWpaCtrl { 35 struct wpa_ctrl *pSend; 36 struct wpa_ctrl *pRecv; 37 } WpaCtrl; 38 39 typedef struct StWpaKeyValue { 40 char key[WPA_MESSAGE_KEY_LENGTH]; 41 char value[WPA_MESSAGE_VALUE_LENGTH]; 42 } WpaKeyValue; 43 44 #define INIT_WPA_KEY_VALUE {{0}, {0}} 45 46 int InitWpaCtrl(WpaCtrl *pCtrl, const char *ifname); 47 void ReleaseWpaCtrl(WpaCtrl *pCtrl); 48 int WpaCliCmd(const char *cmd, char *buf, size_t bufLen); 49 int Hex2Dec(const char *str); 50 void TrimQuotationMark(char *str, char c); 51 int IsSockRemoved(const char *ifName, int len); 52 53 #ifdef __cplusplus 54 } 55 #endif 56 #endif