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 16 #ifndef NSTACKX_WIFI_STAT_LINUX_H 17 #define NSTACKX_WIFI_STAT_LINUX_H 18 19 #include <asm/types.h> 20 #include <net/if.h> 21 #include <netlink/msg.h> 22 #include <sys/socket.h> 23 #include <unistd.h> 24 25 #include <linux/nl80211.h> 26 27 #include "nstackx_congestion.h" 28 29 #ifndef ETH_ALEN 30 #define ETH_ALEN 6 31 #endif 32 33 #ifndef SOL_NETLINK 34 #define SOL_NETLINK 270 35 #endif 36 37 #ifndef NETLINK_EXT_ACK 38 #define NETLINK_EXT_ACK 11 39 #endif 40 41 #define WIFI_NEGO_RATE_ACCURACY 10 42 43 typedef struct _NLDevInfo { 44 struct nl_sock *nl_sock; 45 uint32_t if_index; 46 int32_t nl80211_id; 47 }NLDevInfo; 48 49 typedef struct _CallbackResult { 50 unsigned char mac[ETH_ALEN]; 51 WifiStationInfo wifiStationInfo; 52 }CallbackResult; 53 54 typedef struct _HandleParam { 55 char *mac; 56 }HandleParam; 57 typedef int32_t (*handler)(struct nl_msg *msg, HandleParam *handleParam); 58 59 typedef struct _Nl80211MsgSet { 60 NLDevInfo nlDevInfo; 61 uint8_t cmd; 62 int32_t flags; 63 handler handle; 64 HandleParam handleParam; 65 nl_recvmsg_msg_cb_t func; 66 CallbackResult cbRes; 67 }Nl80211MsgSet; 68 69 int32_t GetWifiInfoFromLinux(const char *devName, WifiStationInfo *wifiStationInfo); 70 #endif 71