1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 * Description: oal net interface 15 * Create: 2020-05-02 16 */ 17 18 #ifndef __OAL_NET_CFG80211_HCM_H__ 19 #define __OAL_NET_CFG80211_HCM_H__ 20 21 #if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) 22 #include <net/iw_handler.h> 23 #include <net/rtnetlink.h> 24 #include <net/netlink.h> 25 #include <net/sch_generic.h> 26 #include <net/ip6_checksum.h> 27 #include <net/ipv6.h> 28 #include <net/arp.h> 29 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) 30 #include <net/sock.h> 31 #endif 32 33 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)) 34 #include <net/cfg80211.h> 35 #else 36 #include <net/wireless.h> 37 #endif 38 #include <../net/wireless/nl80211.h> 39 40 #include <linux/version.h> 41 #include <linux/netdevice.h> 42 #include <linux/if.h> 43 #include <linux/etherdevice.h> 44 #include <linux/wireless.h> 45 #include <linux/socket.h> 46 #include <linux/if_vlan.h> 47 #include <linux/if_ether.h> 48 #include <linux/ip.h> 49 #include <linux/rtnetlink.h> 50 #include <linux/netfilter_bridge.h> 51 #include <linux/if_arp.h> 52 #include <linux/in.h> 53 #include <linux/udp.h> 54 #include <linux/icmpv6.h> 55 #include <linux/ipv6.h> 56 #include <linux/inet.h> 57 #include <linux/nl80211.h> 58 #include <linux/ieee80211.h> 59 #endif 60 #if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 61 #include "lwip/netif.h" 62 #include "oal_skbuff.h" 63 #endif 64 65 #include "wlan_spec.h" 66 67 #ifdef __cplusplus 68 #if __cplusplus 69 extern "C" { 70 #endif 71 #endif 72 73 typedef osal_u8 app_ie_type_uint8; 74 #define OAL_MAC_ADDR_LEN 6 75 #define OAL_IF_NAME_SIZE 16 76 #define OAL_IEEE80211_MAX_SSID_LEN 32 /* 最大SSID长度 */ 77 #define OAL_NL80211_MAX_NR_CIPHER_SUITES 5 78 #define BSS_MEMBERSHIP_SELECTOR_SAE_H2E_ONLY 123 79 #define MAX_STA_NUM_OF_ONE_GROUP 8 /* 一个组播组最大支持32个用户 */ 80 #define MAX_NUM_OF_GROUP 8 /* 最大支持256个组播组 */ 81 82 typedef enum { 83 OAL_NETDEV_TX_OK = 0x00, 84 OAL_NETDEV_TX_BUSY = 0x10, 85 OAL_NETDEV_TX_LOCKED = 0x20, 86 } oal_net_dev_tx_enum; 87 88 #if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 89 /***************************************************************************** 90 2 宏定义 91 *****************************************************************************/ 92 #define IEEE80211_HT_MCS_MASK_LEN 10 93 #define OAL_NL80211_MAX_NR_AKM_SUITES 2 94 #define OAL_WLAN_SA_QUERY_TR_ID_LEN 2 95 #ifdef _PRE_WLAN_FEATURE_015CHANNEL_EXP 96 #define OAL_MAX_SCAN_CHANNELS 16 97 #else 98 #define OAL_MAX_SCAN_CHANNELS 14 99 #endif 100 #define WLAN_SA_QUERY_TR_ID_LEN 2 101 #define NL80211_RRF_NO_OFDM (1<<0) 102 #define NL80211_RRF_DFS (1<<4) 103 #define NL80211_RRF_NO_OUTDOOR (1<<3) 104 105 typedef td_u8 oal_nl80211_channel_type_uint8; 106 typedef td_u8 nl80211_iftype_uint8; 107 typedef td_u8 cfg80211_signal_type_uint8; 108 typedef td_u8 oal_ieee80211_band_enum_uint8; 109 /***************************************************************************** 110 3 枚举定义 111 *****************************************************************************/ 112 enum nl80211_band { 113 NL80211_BAND_2GHZ, 114 NL80211_BAND_5GHZ, 115 }; 116 117 enum ieee80211_band { 118 IEEE80211_BAND_2GHZ = NL80211_BAND_2GHZ, 119 IEEE80211_BAND_5GHZ = NL80211_BAND_5GHZ, 120 121 /* keep last */ 122 IEEE80211_NUM_BANDS 123 }; 124 125 #define OAL_IEEE80211_BAND_2GHZ IEEE80211_BAND_2GHZ 126 #define OAL_IEEE80211_BAND_5GHZ IEEE80211_BAND_5GHZ 127 #define OAL_IEEE80211_NUM_BANDS IEEE80211_NUM_BANDS 128 129 enum nl80211_channel_type { 130 NL80211_CHAN_NO_HT, 131 NL80211_CHAN_HT20, 132 NL80211_CHAN_HT40MINUS, 133 NL80211_CHAN_HT40PLUS 134 }; 135 typedef enum nl80211_channel_type oal_nl80211_channel_type; 136 137 enum nl80211_key_type { 138 NL80211_KEYTYPE_GROUP, 139 NL80211_KEYTYPE_PAIRWISE, 140 NL80211_KEYTYPE_PEERKEY, 141 NUM_NL80211_KEYTYPES 142 }; 143 typedef enum nl80211_key_type oal_nl80211_key_type; 144 145 enum nl80211_iftype { 146 NL80211_IFTYPE_UNSPECIFIED, 147 NL80211_IFTYPE_ADHOC, 148 NL80211_IFTYPE_STATION, 149 NL80211_IFTYPE_AP, 150 NL80211_IFTYPE_AP_VLAN, 151 NL80211_IFTYPE_WDS, 152 NL80211_IFTYPE_MONITOR, 153 NL80211_IFTYPE_MESH_POINT, 154 NL80211_IFTYPE_P2P_CLIENT, 155 NL80211_IFTYPE_P2P_GO, 156 NL80211_IFTYPE_P2P_DEVICE, 157 /* keep last */ 158 NUM_NL80211_IFTYPES, 159 NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1 160 }; 161 162 enum cfg80211_signal_type { 163 CFG80211_SIGNAL_TYPE_NONE, 164 CFG80211_SIGNAL_TYPE_MBM, 165 CFG80211_SIGNAL_TYPE_UNSPEC, 166 }; 167 168 enum station_info_flags { 169 STATION_INFO_INACTIVE_TIME = 1 << 0, 170 STATION_INFO_RX_BYTES = 1 << 1, 171 STATION_INFO_TX_BYTES = 1 << 2, 172 STATION_INFO_LLID = 1 << 3, 173 STATION_INFO_PLID = 1 << 4, 174 STATION_INFO_PLINK_STATE = 1 << 5, 175 STATION_INFO_SIGNAL = 1 << 6, 176 STATION_INFO_TX_BITRATE = 1 << 7, 177 STATION_INFO_RX_PACKETS = 1 << 8, 178 STATION_INFO_TX_PACKETS = 1 << 9, 179 STATION_INFO_TX_RETRIES = 1 << 10, 180 STATION_INFO_TX_FAILED = 1 << 11, 181 STATION_INFO_RX_DROP_MISC = 1 << 12, 182 STATION_INFO_SIGNAL_AVG = 1 << 13, 183 STATION_INFO_RX_BITRATE = 1 << 14, 184 STATION_INFO_BSS_PARAM = 1 << 15, 185 STATION_INFO_CONNECTED_TIME = 1 << 16, 186 STATION_INFO_ASSOC_REQ_IES = 1 << 17, 187 STATION_INFO_STA_FLAGS = 1 << 18, 188 STATION_INFO_BEACON_LOSS_COUNT = 1 << 19, 189 STATION_INFO_T_OFFSET = 1 << 20, 190 STATION_INFO_LOCAL_PM = 1 << 21, 191 STATION_INFO_PEER_PM = 1 << 22, 192 STATION_INFO_NONPEER_PM = 1 << 23, 193 STATION_INFO_RX_BYTES64 = 1 << 24, 194 STATION_INFO_TX_BYTES64 = 1 << 25, 195 }; 196 197 /* 原hmac和dmac结构体SAE/EAP成员定义是反的。dmac未使用以hmac为准 */ 198 typedef enum nl80211_auth_type { 199 NL80211_AUTHTYPE_OPEN_SYSTEM, 200 NL80211_AUTHTYPE_SHARED_KEY, 201 NL80211_AUTHTYPE_FT, 202 NL80211_AUTHTYPE_SAE, 203 NL80211_AUTHTYPE_NETWORK_EAP, 204 /* keep last */ 205 NL80211_AUTHTYPE_AUTOMATIC 206 } oal_nl80211_auth_type_enum; 207 typedef td_u8 oal_nl80211_auth_type_enum_uint8; 208 209 enum nl80211_sae_pwe_mechanism { 210 NL80211_SAE_PWE_UNSPECIFIED, 211 NL80211_SAE_PWE_HUNT_AND_PECK, 212 NL80211_SAE_PWE_HASH_TO_ELEMENT, 213 NL80211_SAE_PWE_BOTH, 214 }; 215 216 enum nl80211_hidden_ssid { 217 NL80211_HIDDEN_SSID_NOT_IN_USE, 218 NL80211_HIDDEN_SSID_ZERO_LEN, 219 NL80211_HIDDEN_SSID_ZERO_CONTENTS 220 }; 221 222 /* enum nl80211_mfp - Management frame protection state 223 * @NL80211_MFP_NO: Management frame protection not used 224 * @NL80211_MFP_REQUIRED: Management frame protection required */ 225 typedef enum nl80211_mfp { 226 NL80211_MFP_NO, 227 NL80211_MFP_REQUIRED, 228 } oal_nl80211_mfp_enum; 229 typedef td_u8 oal_nl80211_mfp_enum_uint8; 230 231 enum nl80211_acl_policy { 232 NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED, 233 NL80211_ACL_POLICY_DENY_UNLESS_LISTED, 234 }; 235 236 enum wiphy_flags { 237 WIPHY_FLAG_CUSTOM_REGULATORY = bit(0), 238 WIPHY_FLAG_STRICT_REGULATORY = bit(1), 239 WIPHY_FLAG_DISABLE_BEACON_HINTS = bit(2), 240 WIPHY_FLAG_NETNS_OK = bit(3), 241 WIPHY_FLAG_PS_ON_BY_DEFAULT = bit(4), 242 WIPHY_FLAG_4ADDR_AP = bit(5), 243 WIPHY_FLAG_4ADDR_STATION = bit(6), 244 WIPHY_FLAG_CONTROL_PORT_PROTOCOL = bit(7), 245 WIPHY_FLAG_IBSS_RSN = bit(8), 246 WIPHY_FLAG_MESH_AUTH = bit(10), 247 WIPHY_FLAG_SUPPORTS_SCHED_SCAN = bit(11), 248 /* use hole at 12 */ 249 WIPHY_FLAG_SUPPORTS_FW_ROAM = bit(13), 250 WIPHY_FLAG_AP_UAPSD = bit(14), 251 WIPHY_FLAG_SUPPORTS_TDLS = bit(15), 252 WIPHY_FLAG_TDLS_EXTERNAL_SETUP = bit(16), 253 WIPHY_FLAG_HAVE_AP_SME = bit(17), 254 WIPHY_FLAG_REPORTS_OBSS = bit(18), 255 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = bit(19), 256 WIPHY_FLAG_OFFCHAN_TX = bit(20), 257 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = bit(21), 258 }; 259 260 enum nl80211_mesh_power_mode { 261 NL80211_MESH_POWER_UNKNOWN, 262 NL80211_MESH_POWER_ACTIVE, 263 NL80211_MESH_POWER_LIGHT_SLEEP, 264 NL80211_MESH_POWER_DEEP_SLEEP, 265 266 __NL80211_MESH_POWER_AFTER_LAST, 267 NL80211_MESH_POWER_MAX = __NL80211_MESH_POWER_AFTER_LAST - 1 268 }; 269 270 enum rate_info_flags { 271 RATE_INFO_FLAGS_MCS = bit(0), 272 RATE_INFO_FLAGS_VHT_MCS = bit(1), 273 RATE_INFO_FLAGS_40_MHZ_WIDTH = bit(2), 274 RATE_INFO_FLAGS_80_MHZ_WIDTH = bit(3), 275 RATE_INFO_FLAGS_80P80_MHZ_WIDTH = bit(4), 276 RATE_INFO_FLAGS_160_MHZ_WIDTH = bit(5), 277 RATE_INFO_FLAGS_SHORT_GI = bit(6), 278 RATE_INFO_FLAGS_60G = bit(7), 279 }; 280 281 /***************************************************************************** 282 4 全局变量声明 283 *****************************************************************************/ 284 285 /***************************************************************************** 286 5 消息头定义 287 *****************************************************************************/ 288 289 /***************************************************************************** 290 6 消息定义 291 *****************************************************************************/ 292 293 /***************************************************************************** 294 7 STRUCT定义 295 *****************************************************************************/ 296 typedef struct { 297 td_u32 handle; 298 } oal_qdisc_stru; 299 300 /* iw_handler_def结构体封装 */ 301 typedef struct { 302 td_u16 cmd; /* Wireless Extension command */ 303 td_u16 flags; /* More to come ;-) */ 304 } oal_iw_request_info_stru; 305 306 typedef struct { 307 td_void* pointer; /* Pointer to the data (in user space) */ 308 td_u16 length; /* number of fields or size in bytes */ 309 td_u16 flags; /* Optional params */ 310 } oal_iw_point_stru; 311 312 typedef struct { 313 td_s32 value; /* The value of the parameter itself */ 314 td_u8 fixed; /* Hardware should not use auto select */ 315 td_u8 disabled; /* Disable the feature */ 316 td_u16 flags; /* Various specifc flags (if any) */ 317 } oal_iw_param_stru; 318 319 typedef struct { 320 td_s32 m; /* Mantissa */ 321 td_s16 e; /* Exponent */ 322 td_u8 i; /* List index (when in range struct) */ 323 td_u8 flags; /* Flags (fixed/auto) */ 324 } oal_iw_freq_stru; 325 326 typedef struct { 327 td_u8 qual; /* link quality (%retries, SNR, %missed beacons or better...) */ 328 td_u8 level; /* signal level (dBm) */ 329 td_u8 noise; /* noise level (dBm) */ 330 td_u8 updated; /* Flags to know if updated */ 331 } oal_iw_quality_stru; 332 333 typedef struct { 334 td_u16 sa_family; /* address family, AF_xxx */ 335 td_u8 sa_data[14]; /* 14 bytes of protocol address */ 336 } oal_sockaddr_stru; 337 338 typedef struct netif oal_lwip_netif; 339 struct ieee80211_mcs_info { 340 td_u8 rx_mask[IEEE80211_HT_MCS_MASK_LEN]; 341 td_u16 rx_highest; 342 td_u8 tx_params; 343 td_u8 reserved[3]; /* 保留3字节对齐 */ 344 }; 345 346 struct ieee80211_freq_range { 347 td_u32 start_freq_khz; 348 td_u32 end_freq_khz; 349 td_u32 max_bandwidth_khz; 350 }; 351 352 struct ieee80211_power_rule { 353 td_u32 max_antenna_gain; 354 td_u32 max_eirp; 355 }; 356 357 struct ieee80211_reg_rule { 358 struct ieee80211_freq_range freq_range; 359 struct ieee80211_power_rule power_rule; 360 td_u32 flags; 361 }; 362 363 struct ieee80211_msrment_ie { 364 td_u8 token; 365 td_u8 mode; 366 td_u8 type; 367 td_u8 request[0]; 368 }; 369 370 struct ieee80211_ext_chansw_ie { 371 td_u8 mode; 372 td_u8 new_operating_class; 373 td_u8 new_ch_num; 374 td_u8 count; 375 }; 376 377 struct callback_head { 378 struct callback_head *next; 379 td_void (*func)(struct callback_head *head); 380 }; 381 382 #define RCU_HEAD callback_head 383 384 struct ieee80211_regdomain { 385 struct RCU_HEAD RCU_HEAD; 386 td_u32 n_reg_rules; 387 td_char alpha2[2]; /* 国家码2字符 */ 388 td_u8 dfs_region; 389 struct ieee80211_reg_rule reg_rules[]; 390 }; 391 392 typedef struct ieee80211_regdomain oal_ieee80211_regdomain_stru; 393 394 typedef struct oal_cfg80211_ssid_tag { 395 td_u8 ssid[OAL_IEEE80211_MAX_SSID_LEN]; 396 td_u8 ssid_len; 397 td_u8 arry[3]; /* 3: SIZE(0..3) */ 398 } oal_cfg80211_ssid_stru; 399 400 /* 原结构体hmac和dmac不一致 以hmac为准 */ 401 typedef struct ieee80211_channel { 402 oal_ieee80211_band_enum_uint8 band; 403 td_u16 center_freq; 404 td_u16 hw_value; 405 td_u32 flags; 406 td_s32 max_antenna_gain; 407 td_s32 max_power; 408 td_bool beacon_found; 409 td_u8 resv[3]; /* 3 字节对齐 */ 410 td_u32 orig_flags; 411 td_s32 orig_mag; 412 td_s32 orig_mpwr; 413 } oal_ieee80211_channel_stru; 414 typedef struct ieee80211_channel oal_ieee80211_channel; 415 416 typedef struct oal_cfg80211_crypto_settings_tag { 417 td_u32 wpa_versions; 418 td_u32 cipher_group; 419 td_s32 n_ciphers_pairwise; 420 td_u32 ciphers_pairwise[OAL_NL80211_MAX_NR_CIPHER_SUITES]; 421 td_s32 n_akm_suites; 422 td_u32 akm_suites[OAL_NL80211_MAX_NR_AKM_SUITES]; 423 enum nl80211_sae_pwe_mechanism sae_pwe; 424 425 td_u8 control_port; 426 td_u8 arry[3]; /* 3: SIZE(0..3) */ 427 } oal_cfg80211_crypto_settings_stru; 428 429 typedef struct cfg80211_add_key_info_stru { 430 td_u8 key_index; 431 td_bool pairwise; 432 }cfg80211_add_key_info_stru; 433 434 typedef struct cfg80211_get_key_info_stru { 435 td_u8 key_index; 436 td_u8 arsvd[2]; /* 2: 保留字段 */ 437 bool pairwise; 438 const td_u8 *mac_addr; 439 }cfg80211_get_key_info_stru; 440 441 /* net_device ioctl结构体定义 */ 442 /* hostapd/wpa_supplicant 下发的信息元素结构 */ 443 /* 该结构为事件内存池大小,保存从hostapd/wpa_supplicant下发的ie 信息 */ 444 /* 注意: 整个结构体长度为事件内存池大小,如果事件内存池有修改,则需要同步修改app 数据结构 */ 445 struct oal_app_ie { 446 osal_u32 ie_len; 447 app_ie_type_uint8 app_ie_type; 448 osal_u8 ie_type_bitmap; 449 osal_u8 rsv[2]; /* 保留2字节对齐 */ 450 /* ie 中保存信息元素,长度 = (事件内存池大小 - 保留长度) */ 451 osal_u8 ie[WLAN_WPS_IE_MAX_SIZE]; 452 }; 453 typedef struct oal_app_ie oal_app_ie_stru; 454 455 typedef struct { 456 td_u32 fake; 457 } oal_iw_statistics_stru; 458 459 typedef union { 460 /* Config - generic */ 461 td_char name[OAL_IF_NAME_SIZE]; 462 oal_iw_point_stru essid; /* Extended network name */ 463 oal_iw_param_stru nwid; /* network id (or domain - the cell) */ 464 oal_iw_freq_stru freq; /* frequency or channel : * 0-1000 = channel * > 1000 = frequency in Hz */ 465 oal_iw_param_stru sens; /* signal level threshold */ 466 oal_iw_param_stru bitrate; /* default bit rate */ 467 oal_iw_param_stru txpower; /* default transmit power */ 468 oal_iw_param_stru rts; /* RTS threshold threshold */ 469 oal_iw_param_stru frag; /* Fragmentation threshold */ 470 td_u32 mode; /* Operation mode */ 471 oal_iw_param_stru retry; /* Retry limits & lifetime */ 472 oal_iw_point_stru encoding; /* Encoding stuff : tokens */ 473 oal_iw_param_stru power; /* PM duration/timeout */ 474 oal_iw_quality_stru qual; /* Quality part of statistics */ 475 oal_sockaddr_stru ap_addr; /* Access point address */ 476 oal_sockaddr_stru addr; /* Destination address (hw/mac) */ 477 oal_iw_param_stru param; /* Other small parameters */ 478 oal_iw_point_stru data; /* Other large parameters */ 479 } oal_iwreq_data_union; 480 481 struct oal_net_device; 482 typedef td_u32 (*oal_iw_handler)(struct oal_net_device* dev, oal_iw_request_info_stru* info, 483 oal_iwreq_data_union* wrqu, td_s8* extra); 484 485 /* 私有IOCTL接口信息 */ 486 typedef struct { 487 td_u32 cmd; /* ioctl命令号 */ 488 td_u16 set_args; /* 类型和参数字符个数 */ 489 td_u16 get_args; /* 类型和参数字符个数 */ 490 td_char name[OAL_IF_NAME_SIZE]; /* 私有命令名 */ 491 } oal_iw_priv_args_stru; 492 493 typedef struct { 494 const oal_iw_handler* standard; 495 td_u16 num_standard; 496 td_u16 num_private; 497 498 /* FangBaoshun For wrl31 Compile */ 499 const oal_iw_handler* private; 500 /* FangBaoshun For wrl31 Compile */ 501 td_u8 auc_resv[2]; /* 2: bytes保留字段 */ 502 td_u16 num_private_args; 503 504 const oal_iw_handler* private_win32; 505 506 const oal_iw_priv_args_stru* private_args; 507 oal_iw_statistics_stru* (*get_wireless_stats)(struct oal_net_device* dev); 508 } oal_iw_handler_def_stru; 509 510 typedef struct _oal_ext_eapol_stru { 511 td_bool register_code; 512 td_u8 eapol_cnt; /* 当前链表中eapol数量 */ 513 td_u16 enqueue_time; /* 记录的eapol帧最早入队时间 单位s 用于超时老化 */ 514 td_void* context; 515 td_void (*notify_callback)(td_void* name, td_void* context); 516 oal_netbuf_head_stru eapol_skb_head; 517 } oal_ext_eapol_stru; 518 519 typedef struct { 520 td_u32 rx_packets; /* total packets received */ 521 td_u32 tx_packets; /* total packets transmitted */ 522 td_u32 rx_bytes; /* total bytes received */ 523 td_u32 tx_bytes; /* total bytes transmitted */ 524 td_u32 rx_errors; /* bad packets received */ 525 td_u32 tx_errors; /* packet transmit problems */ 526 td_u32 rx_dropped; /* no space in linux buffers */ 527 td_u32 tx_dropped; /* no space available in linux */ 528 td_u32 multicast; /* multicast packets received */ 529 td_u32 collisions; 530 531 /* detailed rx_errors: */ 532 td_u32 rx_length_errors; 533 td_u32 rx_over_errors; /* receiver ring buff overflow */ 534 td_u32 rx_crc_errors; /* recved pkt with crc error */ 535 td_u32 rx_frame_errors; /* recv'd frame alignment error */ 536 td_u32 rx_fifo_errors; /* recv'r fifo overrun */ 537 td_u32 rx_missed_errors; /* receiver missed packet */ 538 539 /* detailed tx_errors */ 540 td_u32 tx_aborted_errors; 541 td_u32 tx_carrier_errors; 542 td_u32 tx_fifo_errors; 543 td_u32 tx_heartbeat_errors; 544 td_u32 tx_window_errors; 545 546 /* for cslip etc */ 547 td_u32 rx_compressed; 548 td_u32 tx_compressed; 549 } oal_net_device_stats_stru; 550 551 /* 原hmac和dmac结构体不一致 以HMAC为准 */ 552 typedef struct oal_net_device { 553 td_char name[OAL_IF_NAME_SIZE]; 554 td_void* ml_priv; 555 struct oal_net_device_ops* netdev_ops; 556 td_u32 last_rx; 557 td_u32 flags; 558 oal_iw_handler_def_stru* wireless_handlers; 559 td_u8 dev_addr[ETHER_ADDR_LEN]; 560 td_u8 addr_idx; 561 td_u8 resv; 562 td_s32 tx_queue_len; 563 td_u16 hard_header_len; 564 td_u16 type; 565 td_u16 needed_headroom; 566 td_u16 needed_tailroom; 567 struct oal_net_device* master; 568 struct wireless_dev* ieee80211_ptr; 569 oal_qdisc_stru* qdisc; 570 td_u8* ifalias; 571 td_u8 addr_len; 572 td_u8 resv2[3]; /* 3: bytes保留字段 */ 573 td_s32 watchdog_timeo; 574 oal_net_device_stats_stru stats; 575 td_u32 mtu; 576 td_void (*destructor)(struct oal_net_device*); 577 td_void* priv; 578 td_u32 num_tx_queues; 579 oal_ext_eapol_stru ext_eapol; /* EAPOL报文收发数据结构 */ 580 oal_lwip_netif* lwip_netif; /* LWIP协议栈数据结构 */ 581 #ifdef _PRE_WLAN_FEATURE_VLWIP 582 oal_lwip_netif* vlwip_netif; 583 #endif 584 #ifdef _PRE_WLAN_LWIP_PAYLOAD_COPY_TRANS 585 oal_netbuf_stru* rx_pkt; 586 #endif 587 } oal_net_device_stru; 588 589 typedef struct oal_net_notify { 590 td_u32 ip_addr; 591 td_u32 notify_type; 592 } oal_net_notify_stru; 593 594 // 适配HW_LITEOS_OPEN_VERSION_NUM >= kernel_version(1,4,2)) 595 typedef struct ifreq oal_ifreq_stru; 596 597 typedef struct oal_net_device_ops { 598 td_s32 (*ndo_init)(oal_net_device_stru*); 599 td_s32 (*ndo_open)(struct oal_net_device*); 600 td_s32 (*ndo_stop)(struct oal_net_device*); 601 oal_net_dev_tx_enum (*ndo_start_xmit) (oal_netbuf_stru*, struct oal_net_device*); 602 td_void (*ndo_set_multicast_list)(struct oal_net_device*); 603 oal_net_device_stats_stru* (*ndo_get_stats)(oal_net_device_stru*); 604 td_s32 (*ndo_do_ioctl)(struct oal_net_device*, oal_ifreq_stru*, td_s32); 605 td_s32 (*ndo_change_mtu)(struct oal_net_device*, td_s32); 606 td_s32 (*ndo_set_mac_address)(struct oal_net_device*, oal_sockaddr_stru*); 607 td_s16 (*ndo_select_queue)(oal_net_device_stru* dev, oal_netbuf_stru*); 608 td_s32 (*ndo_netif_notify)(oal_net_device_stru*, oal_net_notify_stru*); 609 } oal_net_device_ops_stru; 610 611 /* 此结构体成员命名是为了保持跟linux一致 */ 612 typedef struct ieee80211_rate { 613 td_u32 flags; 614 td_u16 bitrate; 615 td_u16 hw_value; 616 td_u16 hw_value_short; 617 td_u8 rsv[2]; /* 2: bytes保留字段 */ 618 } oal_ieee80211_rate; 619 620 typedef struct ieee80211_sta_ht_cap { 621 td_u16 cap; /* use IEEE80211_HT_CAP_ */ 622 td_u8 ht_supported; 623 td_u8 ampdu_factor; 624 td_u8 ampdu_density; 625 td_u8 rsv[3]; /* 3: bytes保留字段 */ 626 struct ieee80211_mcs_info mcs; 627 } oal_ieee80211_sta_ht_cap; 628 629 typedef struct ieee80211_supported_band { 630 oal_ieee80211_channel* channels; 631 oal_ieee80211_rate* bitrates; 632 oal_ieee80211_band_enum_uint8 band; 633 td_s32 n_channels; 634 td_s32 n_bitrates; 635 oal_ieee80211_sta_ht_cap ht_cap; 636 } oal_ieee80211_supported_band; 637 638 typedef struct oal_wiphy_tag { 639 oal_ieee80211_supported_band* bands[IEEE80211_NUM_BANDS]; 640 td_u8 priv[4]; /* 4: SIZE(0..4) */ 641 } oal_wiphy_stru; 642 643 typedef struct cfg80211_chan_def { 644 oal_ieee80211_channel* chan; 645 oal_nl80211_channel_type width; 646 td_s32 center_freq1; 647 td_s32 center_freq2; 648 } oal_cfg80211_chan_def; 649 650 typedef struct cfg80211_pmksa oal_cfg80211_pmksa_stru; 651 652 typedef struct oal_key_params_tag { 653 td_u8* key; 654 td_u8* seq; 655 td_s32 key_len; 656 td_s32 seq_len; 657 td_u32 cipher; 658 } oal_key_params_stru; 659 660 typedef struct oal_cfg80211_scan_request_tag { 661 oal_cfg80211_ssid_stru* ssids; 662 td_u32 n_ssids; 663 td_u32 n_channels; 664 td_u32 ie_len; 665 666 /* internal */ 667 oal_net_device_stru* dev; 668 struct wireless_dev* wdev; 669 670 td_u8 aborted; 671 td_u8 prefix_ssid_scan_flag; 672 #if defined(_PRE_WLAN_FEATURE_WS92_MERGE) && defined(_PRE_WLAN_FEATURE_ACS) 673 td_u8 acs_scan_flag; 674 td_u8 resv; 675 #else 676 td_u8 resv[2]; /* 2: 锟斤拷锟斤拷锟街讹拷 */ 677 #endif 678 679 td_u8* ie; 680 /* keep last */ 681 oal_ieee80211_channel_stru* channels[OAL_MAX_SCAN_CHANNELS]; 682 } oal_cfg80211_scan_request_stru; 683 684 typedef struct cfg80211_sched_scan_request { 685 struct cfg80211_ssid* ssids; 686 td_s32 n_ssids; 687 td_u32 n_channels; 688 td_u32 interval; 689 const td_u8* ie; 690 size_t ie_len; 691 td_u32 flags; 692 struct cfg80211_match_set* match_sets; 693 td_s32 n_match_sets; 694 td_s32 min_rssi_thold; 695 td_s32 rssi_thold; /* just for backward compatible */ 696 697 /* internal */ 698 struct wiphy* wiphy; 699 struct oal_net_device_stru* dev; 700 td_u32 scan_start; 701 /* keep last */ 702 struct ieee80211_channel* channels[0]; 703 } oal_cfg80211_sched_scan_request_stru; 704 705 typedef struct oal_cfg80211_connect_params_tag { 706 oal_ieee80211_channel_stru* channel; 707 708 td_u8* bssid; 709 td_u8* ssid; 710 td_u8* ie; 711 712 td_u32 ssid_len; 713 td_u32 ie_len; 714 oal_cfg80211_crypto_settings_stru crypto; 715 const td_u8* key; 716 717 oal_nl80211_auth_type_enum_uint8 auth_type; 718 td_u8 privacy; 719 td_u8 key_len; 720 td_u8 key_idx; 721 oal_nl80211_mfp_enum_uint8 mfp; 722 td_u8 auc_resv[3]; /* 3: 閿熸枻鎷烽敓鏂ゆ嫹閿熻鏂ゆ嫹 */ 723 } oal_cfg80211_connect_params_stru; 724 725 typedef struct ieee80211_mgmt { 726 td_u16 frame_control; 727 td_u16 duration; 728 td_u8 da[6]; /* 6: SIZE(0..6) */ 729 td_u8 sa[6]; /* 6: SIZE(0..6) */ 730 td_u8 bssid[6]; /* 6: SIZE(0..6) */ 731 td_u16 seq_ctrl; 732 union { 733 struct { 734 td_u16 auth_alg; 735 td_u16 auth_transaction; 736 td_u16 status_code; 737 /* possibly followed by Challenge text */ 738 td_u8 variable[0]; 739 } auth; 740 struct { 741 td_u16 reason_code; 742 } deauth; 743 struct { 744 td_u16 capab_info; 745 td_u16 listen_interval; 746 /* followed by SSID and Supported rates */ 747 td_u8 variable[0]; 748 } assoc_req; 749 struct { 750 td_u16 capab_info; 751 td_u16 status_code; 752 td_u16 aid; 753 /* followed by Supported rates */ 754 td_u8 variable[0]; 755 } assoc_resp, reassoc_resp; 756 struct { 757 td_u16 capab_info; 758 td_u16 listen_interval; 759 td_u8 current_ap[6]; /* 6: SIZE(0..6) */ 760 /* followed by SSID and Supported rates */ 761 td_u8 variable[0]; 762 } reassoc_req; 763 struct { 764 td_u16 reason_code; 765 } disassoc; 766 struct { 767 td_u64 timestamp; 768 td_u16 beacon_int; 769 td_u16 capab_info; 770 /* followed by some of SSID, Supported rates, 771 * FH Params, DS Params, CF Params, IBSS Params, TIM */ 772 td_u8 variable[4]; /* 4: FH Params, DS Params, CF Params, IBSS Params */ 773 } beacon; 774 struct { 775 td_u64 timestamp; 776 td_u16 beacon_int; 777 td_u16 capab_info; 778 /* followed by some of SSID, Supported rates, 779 * FH Params, DS Params, CF Params, IBSS Params */ 780 td_u8 variable[4]; /* 4: FH Params, DS Params, CF Params, IBSS Params */ 781 } probe_resp; 782 struct { 783 td_u8 category; 784 union { 785 struct { 786 td_u8 action_code; 787 td_u8 dialog_token; 788 td_u8 status_code; 789 td_u8 variable[0]; 790 } wme_action; 791 struct { 792 td_u8 action_code; 793 td_u8 variable[0]; 794 } chan_switch; 795 struct { 796 td_u8 action_code; 797 struct ieee80211_ext_chansw_ie data; 798 td_u8 variable[0]; 799 } ext_chan_switch; 800 struct { 801 td_u8 action_code; 802 td_u8 dialog_token; 803 td_u8 element_id; 804 td_u8 length; 805 struct ieee80211_msrment_ie msr_elem; 806 } measurement; 807 struct { 808 td_u8 action_code; 809 td_u8 dialog_token; 810 td_u16 capab; 811 td_u16 timeout; 812 td_u16 start_seq_num; 813 } addba_req; 814 struct { 815 td_u8 action_code; 816 td_u8 dialog_token; 817 td_u16 status; 818 td_u16 capab; 819 td_u16 timeout; 820 } addba_resp; 821 struct { 822 td_u8 action_code; 823 td_u8 resv; 824 td_u16 params; 825 td_u16 reason_code; 826 } delba; 827 struct { 828 td_u8 action_code; 829 td_u8 variable[0]; 830 } self_prot; 831 struct { 832 td_u8 action_code; 833 td_u8 variable[0]; 834 } mesh_action; 835 struct { 836 td_u8 action; 837 td_u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN]; 838 } sa_query; 839 struct { 840 td_u8 action; 841 td_u8 smps_control; 842 } ht_smps; 843 struct { 844 td_u8 action_code; 845 td_u8 chanwidth; 846 } ht_notify_cw; 847 struct { 848 td_u8 action_code; 849 td_u8 dialog_token; 850 td_u16 capability; 851 td_u8 variable[0]; 852 } tdls_discover_resp; 853 struct { 854 td_u8 action_code; 855 td_u8 operating_mode; 856 } vht_opmode_notif; 857 } u; 858 } action; 859 } u; 860 } oal_ieee80211_mgmt_stru; 861 862 struct cfg80211_crypto_settings { 863 td_u32 wpa_versions; 864 td_u32 cipher_group; 865 td_s32 n_ciphers_pairwise; 866 td_u32 ciphers_pairwise[OAL_NL80211_MAX_NR_CIPHER_SUITES]; 867 td_s32 n_akm_suites; 868 td_u32 akm_suites[OAL_NL80211_MAX_NR_AKM_SUITES]; 869 td_u16 control_port_ethertype; 870 td_bool control_port; 871 td_bool control_port_no_encrypt; 872 }; 873 874 struct ieee80211_vht_mcs_info { 875 td_u16 rx_mcs_map; 876 td_u16 rx_highest; 877 td_u16 tx_mcs_map; 878 td_u16 tx_highest; 879 }; 880 881 typedef struct cfg80211_bss oal_cfg80211_bss_stru; 882 883 typedef struct rate_info { 884 td_u8 flags; 885 td_u8 mcs; 886 td_u16 legacy; 887 td_u8 nss; 888 td_u8 resv; 889 } oal_rate_info_stru; 890 891 typedef struct vif_params { 892 td_s32 use_4addr; 893 td_u8* macaddr; 894 } oal_vif_params_stru; 895 896 typedef struct cfg80211_update_ft_ies_params { 897 td_u16 md; 898 const td_u8 *ie; 899 size_t ie_len; 900 } oal_cfg80211_update_ft_ies_stru; 901 902 typedef struct cfg80211_ft_event_params { 903 td_u8 *ies; 904 size_t ies_len; 905 td_u8 target_ap[OAL_MAC_ADDR_LEN]; 906 td_u8 resv[2]; 907 const td_u8 *ric_ies; 908 size_t ric_ies_len; 909 } oal_cfg80211_ft_event_stru; 910 911 /* To be implement! */ 912 typedef struct cfg80211_beacon_data { 913 const td_u8 *head; 914 const td_u8 *tail; 915 const td_u8 *beacon_ies; 916 const td_u8 *proberesp_ies; 917 const td_u8 *assocresp_ies; 918 const td_u8 *probe_resp; 919 920 size_t head_len, tail_len; 921 size_t beacon_ies_len; 922 size_t proberesp_ies_len; 923 size_t assocresp_ies_len; 924 size_t probe_resp_len; 925 } oal_beacon_data_stru; 926 927 struct oal_mac_address { 928 td_u8 addr[OAL_MAC_ADDR_LEN]; 929 }; 930 931 struct cfg80211_acl_data { 932 enum nl80211_acl_policy acl_policy; 933 td_s32 n_acl_entries; 934 935 /* Keep it last */ 936 struct oal_mac_address mac_addrs[]; 937 }; 938 939 typedef struct cfg80211_ap_settings { 940 struct cfg80211_chan_def chandef; 941 struct cfg80211_beacon_data beacon; 942 943 td_s32 beacon_interval; 944 td_s32 dtim_period; 945 const td_u8* ssid; 946 size_t ssid_len; 947 948 enum nl80211_hidden_ssid hidden_ssid; 949 enum nl80211_auth_type auth_type; 950 enum nl80211_sae_pwe_mechanism sae_pwe; 951 struct cfg80211_crypto_settings crypto; 952 953 td_s32 inactivity_timeout; 954 td_bool privacy; 955 td_bool p2p_opp_ps; 956 td_u8 p2p_ctwindow; 957 td_bool radar_required; 958 959 const struct cfg80211_acl_data* acl; 960 } oal_ap_settings_stru; 961 962 typedef struct bss_parameters { 963 td_s32 use_cts_prot; 964 td_s32 use_short_preamble; 965 td_s32 use_short_slot_time; 966 const td_u8 *basic_rates; 967 td_u8 basic_rates_len; 968 td_s32 ap_isolate; 969 td_s32 ht_opmode; 970 td_s8 p2p_ctwindow; 971 td_s8 p2p_opp_ps; 972 } oal_bss_parameters; 973 974 struct beacon_parameters { 975 td_u8 *head, *tail; 976 td_s32 interval, dtim_period; 977 td_s32 head_len, tail_len; 978 }; 979 typedef struct beacon_parameters oal_beacon_parameters; 980 typedef struct ieee80211_mgmt oal_ieee80211_mgmt; 981 982 /* dmac未使用 */ 983 #if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 984 #ifndef _PRE_WLAN_FEATURE_MFG_ONLY 985 typedef ip4_addr_t oal_ip_addr_t; 986 #if LWIP_API_MESH 987 typedef linklayer_event_ap_conn_t oal_event_ap_conn_stru; 988 #endif 989 #endif 990 #endif 991 992 993 typedef struct { 994 td_s32 sk_wmem_queued; 995 } oal_sock_stru; 996 997 struct sta_bss_parameters { 998 td_u8 flags; 999 td_u8 dtim_period; 1000 td_u16 beacon_interval; 1001 }; 1002 1003 struct nl80211_sta_flag_update { 1004 td_u32 mask; 1005 td_u32 set; 1006 }; 1007 1008 typedef struct oal_station_info_tag { 1009 td_u32 filled; 1010 const td_u8* assoc_req_ies; 1011 td_u32 assoc_req_ies_len; 1012 } oal_station_info_stru; 1013 1014 typedef struct module oal_module_stru; 1015 1016 typedef struct ieee80211_iface_limit { 1017 td_u16 max; 1018 td_u16 types; 1019 } oal_ieee80211_iface_limit; 1020 1021 typedef struct ieee80211_iface_combination { 1022 const struct ieee80211_iface_limit* limits; 1023 td_u32 num_different_channels; 1024 td_u16 max_interfaces; 1025 td_u8 n_limits; 1026 td_u8 radar_detect_widths; 1027 td_bool beacon_int_infra_match; 1028 td_u8 resv[3]; /* 3: 娣囨繄鏆€鐎涙顔? */ 1029 } oal_ieee80211_iface_combination; 1030 1031 typedef struct wireless_dev { 1032 struct oal_net_device* netdev; 1033 oal_wiphy_stru* wiphy; 1034 nl80211_iftype_uint8 iftype; 1035 td_u8 resv[3]; /* reserve 3byte */ 1036 /* 新内核新增字段 */ 1037 oal_cfg80211_chan_def preset_chandef; 1038 } oal_wireless_dev; 1039 1040 typedef oal_wireless_dev oal_wireless_dev_stru; 1041 1042 /***************************************************************************** 1043 8 UNION定义 1044 *****************************************************************************/ 1045 1046 /***************************************************************************** 1047 9 OTHERS定义 1048 *****************************************************************************/ 1049 1050 /***************************************************************************** 1051 10 函数声明 1052 *****************************************************************************/ 1053 typedef struct oal_cfg80211_ops_tag { 1054 td_s32 (*add_key)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, 1055 cfg80211_add_key_info_stru *p_cfg80211_add_key_info, 1056 const td_u8* mac_addr, oal_key_params_stru* params); 1057 td_s32 (*get_key)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, 1058 cfg80211_get_key_info_stru *p_cfg80211_get_key_info, td_void* cookie, 1059 td_void (*callback)(td_void* cookie, oal_key_params_stru* key)); 1060 td_s32 (*del_key)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, td_u8 key_index, td_bool pairwise, 1061 const td_u8* mac_addr); 1062 td_s32 (*set_default_key)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, td_u8 key_index, td_bool unicast, 1063 td_bool multicast); 1064 td_s32 (*set_default_mgmt_key)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, td_u8 key_index); 1065 td_s32 (*scan)(oal_wiphy_stru* wiphy, oal_cfg80211_scan_request_stru* request); 1066 td_s32 (*connect)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, 1067 oal_cfg80211_connect_params_stru* sme); 1068 td_s32 (*disconnect)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, td_u16 reason_code); 1069 td_s32 (*set_channel)(oal_wiphy_stru* wiphy, oal_ieee80211_channel* chan, 1070 oal_nl80211_channel_type channel_type); 1071 td_s32 (*set_wiphy_params)(oal_wiphy_stru* wiphy, td_u32 changed); 1072 td_s32 (*add_beacon)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, oal_beacon_parameters* info); 1073 td_s32 (*change_virtual_intf)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, nl80211_iftype_uint8 type, 1074 td_u32* pul_flags, oal_vif_params_stru* params); 1075 td_s32 (*add_station)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, td_u8* mac_addr, td_void* sta_parms); 1076 td_s32 (*del_station)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, const td_u8* mac_addr); 1077 td_s32 (*change_station)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, td_u8* mac_addr, 1078 td_void* sta_parms); 1079 td_s32 (*get_station)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, td_u8* mac_addr, 1080 oal_station_info_stru* sta_info); 1081 td_s32 (*dump_station)(oal_wiphy_stru* wiphy, oal_net_device_stru* dev, td_s32 idx, td_u8* mac, 1082 oal_station_info_stru* sta_info); 1083 td_s32 (*change_beacon)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, 1084 oal_beacon_data_stru* beacon_info); 1085 td_s32 (*start_ap)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, 1086 oal_ap_settings_stru* ap_settings); 1087 td_s32 (*stop_ap)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev); 1088 td_s32 (*change_bss)(oal_wiphy_stru* wiphy, oal_net_device_stru* netdev, 1089 td_void* bss_params); 1090 td_s32 (*set_power_mgmt)(oal_wiphy_stru* wiphy, oal_net_device_stru* ndev, td_bool enabled, 1091 td_s32 timeout); 1092 td_s32 (*sched_scan_start)(oal_wiphy_stru* wiphy, oal_net_device_stru* dev, 1093 struct cfg80211_sched_scan_request* request); 1094 td_s32 (*sched_scan_stop)(oal_wiphy_stru* wiphy, oal_net_device_stru* dev); 1095 td_s32 (*remain_on_channel)(oal_wiphy_stru* wiphy, struct wireless_dev* wdev, struct ieee80211_channel* chan, 1096 td_u32 duration, td_u64* cookie); 1097 td_s32 (*cancel_remain_on_channel)(oal_wiphy_stru* wiphy, struct wireless_dev* wdev, td_u64 cookie); 1098 td_s32 (*mgmt_tx)(oal_wiphy_stru* wiphy, struct wireless_dev* wdev, struct ieee80211_channel* chan, 1099 td_bool offchan, td_u32 wait, const td_u8* buf, size_t len, td_bool no_cck, 1100 td_bool dont_wait_for_ack, td_u64* cookie); 1101 td_void (*mgmt_frame_register)(struct wiphy* wiphy, struct wireless_dev* wdev, td_u16 frame_type, td_bool reg); 1102 struct wireless_dev* (*add_virtual_intf)(oal_wiphy_stru* wiphy, const td_char* name, nl80211_iftype_uint8 type, 1103 td_u32* flags, struct vif_params* params); 1104 td_s32 (*del_virtual_intf)(oal_wiphy_stru* wiphy, struct wireless_dev* wdev); 1105 td_s32 (*mgmt_tx_cancel_wait)(oal_wiphy_stru* wiphy, struct wireless_dev* wdev, td_u64 cookie); 1106 td_s32 (*start_p2p_device)(oal_wiphy_stru* wiphy, struct wireless_dev* wdev); 1107 td_void (*stop_p2p_device)(oal_wiphy_stru* wiphy, struct wireless_dev* wdev); 1108 } oal_cfg80211_ops; 1109 1110 #endif 1111 1112 #define MAX_BLACKLIST_NUM 128 1113 1114 typedef struct { 1115 osal_u8 blkwhtlst_cnt; /* 黑白名单个数 */ 1116 osal_u8 mode; /* 黑白名单模式 */ 1117 osal_u8 auc_resv[2]; 1118 osal_u8 blkwhtlst_mac[MAX_BLACKLIST_NUM][OAL_MAC_ADDR_LEN]; 1119 } oal_blkwhtlst_stru; 1120 1121 #if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) 1122 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0)) 1123 #define OAL_IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ 1124 #define OAL_IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ 1125 #define OAL_IEEE80211_NUM_BANDS NUM_NL80211_BANDS 1126 #else 1127 #define OAL_IEEE80211_BAND_2GHZ IEEE80211_BAND_2GHZ 1128 #define OAL_IEEE80211_BAND_5GHZ IEEE80211_BAND_5GHZ 1129 #define OAL_IEEE80211_NUM_BANDS IEEE80211_NUM_BANDS 1130 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0)) */ 1131 1132 typedef td_u8 oal_ieee80211_band_enum_uint8; 1133 #endif 1134 1135 #if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) 1136 /* ================================================================ */ 1137 /* 以下结构体copy from hmac oal_net.h 适配dmac编译 1138 * 原dmac头文件linux也使用自定义的,未引用linux定义。 1139 */ 1140 1141 /* linux 结构体 */ 1142 typedef struct iw_statistics oal_iw_statistics_stru; 1143 typedef struct net_device oal_net_device_stru; 1144 typedef struct net_device_ops oal_net_device_ops_stru; 1145 typedef struct ethtool_ops oal_ethtool_ops_stru; 1146 typedef struct iw_priv_args oal_iw_priv_args_stru; 1147 typedef struct iw_handler_def oal_iw_handler_def_stru; 1148 typedef struct iw_point oal_iw_point_stru; 1149 typedef struct iw_param oal_iw_param_stru; 1150 typedef struct iw_freq oal_iw_freq_stru; 1151 typedef struct iw_request_info oal_iw_request_info_stru; 1152 typedef struct rtnl_link_ops oal_rtnl_link_ops_stru; 1153 typedef struct sockaddr oal_sockaddr_stru; 1154 typedef struct net_device_stats oal_net_device_stats_stru; 1155 typedef struct ifreq oal_ifreq_stru; 1156 typedef struct Qdisc oal_qdisc_stru; 1157 typedef struct vlan_ethhdr oal_vlan_ethhdr_stru; 1158 typedef struct wiphy oal_wiphy_stru; 1159 typedef struct wireless_dev oal_wireless_dev_stru; 1160 typedef struct cfg80211_ops oal_cfg80211_ops_stru; 1161 typedef struct wiphy_vendor_command oal_wiphy_vendor_command_stru; 1162 typedef struct nl80211_vendor_cmd_info oal_nl80211_vendor_cmd_info_stru; 1163 1164 typedef struct kobj_uevent_env oal_kobj_uevent_env_stru; 1165 typedef struct iw_quality oal_iw_quality_stru; 1166 typedef struct cfg80211_gtk_rekey_data oal_cfg80211_gtk_rekey_data; 1167 typedef union iwreq_data oal_iwreq_data_union; 1168 1169 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) 1170 typedef struct cfg80211_pmksa oal_cfg80211_pmksa_stru; 1171 #endif 1172 1173 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) 1174 typedef struct survey_info oal_survey_info_stru; 1175 #endif 1176 1177 typedef struct key_params oal_key_params_stru; 1178 1179 typedef struct cfg80211_scan_request oal_cfg80211_scan_request_stru; 1180 typedef struct cfg80211_ssid oal_cfg80211_ssid_stru; 1181 typedef struct cfg80211_sched_scan_request oal_cfg80211_sched_scan_request_stru; 1182 /* linux-2.6.34内核才有以下两个结构体,加密相关 */ 1183 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) 1184 typedef enum nl80211_mfp oal_nl80211_mfp_enum_uint8; 1185 typedef struct cfg80211_connect_params oal_cfg80211_conn_stru; 1186 typedef struct cfg80211_crypto_settings oal_cfg80211_crypto_settings_stru; 1187 #else 1188 /* linux-2.6.30内核没有这两个加密相关的结构体,命令下发上报也是内核透传,这里打桩 */ 1189 typedef struct cfg80211_crypto_settings { 1190 td_u32 wpa_versions; 1191 td_u32 cipher_group; 1192 td_s32 n_ciphers_pairwise; 1193 td_u32 ciphers_pairwise[OAL_NL80211_MAX_NR_CIPHER_SUITES]; 1194 td_s32 n_akm_suites; 1195 td_u32 akm_suites[OAL_NL80211_MAX_NR_AKM_SUITES]; 1196 1197 oal_bool_enum_uint8 control_port; 1198 td_u8 arry[3]; 1199 }oal_cfg80211_crypto_settings_stru; 1200 1201 #endif 1202 1203 typedef struct ieee80211_mgmt oal_ieee80211_mgmt_stru; 1204 typedef struct ieee80211_channel oal_ieee80211_channel_stru; 1205 typedef struct cfg80211_bss oal_cfg80211_bss_stru; 1206 typedef struct rate_info oal_rate_info_stru; 1207 typedef struct station_info oal_station_info_stru; 1208 typedef struct station_parameters oal_station_parameters_stru; 1209 typedef enum station_info_flags oal_station_info_flags; 1210 1211 typedef struct nlattr oal_nlattr_stru; 1212 typedef struct genl_family oal_genl_family_stru; 1213 typedef struct genl_multicast_group oal_genl_multicast_group_stru; 1214 typedef struct cfg80211_registered_device oal_cfg80211_registered_device_stru; 1215 1216 typedef struct ieee80211_rate oal_ieee80211_rate; 1217 typedef struct ieee80211_channel oal_ieee80211_channel; 1218 typedef struct ieee80211_supported_band oal_ieee80211_supported_band; 1219 typedef enum cfg80211_signal_type oal_cfg80211_signal_type; 1220 typedef enum nl80211_channel_type oal_nl80211_channel_type; 1221 typedef struct cfg80211_update_owe_info oal_cfg80211_update_owe_info; 1222 1223 #ifdef CONTROLLER_CUSTOMIZATION 1224 typedef struct cfg80211_update_p2p_ie oal_cfg80211_update_p2p_ie; 1225 #endif 1226 1227 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) 1228 typedef enum wiphy_params_flags oal_wiphy_params_flags; 1229 typedef enum wiphy_flags oal_wiphy_flags; 1230 #else 1231 /* linux-2.6.30内核打桩一份wiphy_flags枚举 */ 1232 typedef enum wiphy_flags { 1233 WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), 1234 WIPHY_FLAG_STRICT_REGULATORY = BIT(1), 1235 WIPHY_FLAG_DISABLE_BEACON_HINTS = BIT(2), 1236 WIPHY_FLAG_NETNS_OK = BIT(3), 1237 WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4), 1238 WIPHY_FLAG_4ADDR_AP = BIT(5), 1239 WIPHY_FLAG_4ADDR_STATION = BIT(6), 1240 WIPHY_FLAG_HAVE_AP_SME = BIT(17), 1241 WIPHY_FLAG_OFFCHAN_TX = BIT(20), 1242 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21), 1243 }oal_wiphy_flags; 1244 #endif 1245 1246 typedef struct vif_params oal_vif_params_stru; 1247 1248 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) 1249 typedef enum nl80211_key_type oal_nl80211_key_type; 1250 #else 1251 enum nl80211_key_type { 1252 NL80211_KEYTYPE_GROUP, 1253 NL80211_KEYTYPE_PAIRWISE, 1254 NL80211_KEYTYPE_PEERKEY, 1255 NUM_NL80211_KEYTYPES 1256 }; 1257 typedef enum nl80211_key_type oal_nl80211_key_type; 1258 #endif 1259 1260 typedef struct ieee80211_sta_ht_cap oal_ieee80211_sta_ht_cap; 1261 typedef struct ieee80211_regdomain oal_ieee80211_regdomain_stru; 1262 typedef struct cfg80211_update_ft_ies_params oal_cfg80211_update_ft_ies_stru; 1263 typedef struct cfg80211_ft_event_params oal_cfg80211_ft_event_stru; 1264 typedef struct cfg80211_chan_def oal_cfg80211_chan_def; 1265 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) 1266 /* To be implement! */ 1267 typedef struct cfg80211_beacon_data oal_beacon_data_stru; 1268 typedef struct cfg80211_ap_settings oal_ap_settings_stru; 1269 typedef struct bss_parameters oal_bss_parameters; 1270 struct beacon_parameters { 1271 td_u8 *head, *tail; 1272 td_s32 interval, dtim_period; 1273 td_s32 head_len, tail_len; 1274 }; 1275 typedef struct beacon_parameters oal_beacon_parameters; 1276 #else 1277 typedef struct beacon_parameters oal_beacon_parameters; 1278 #endif 1279 typedef struct ieee80211_channel_sw_ie oal_ieee80211_channel_sw_ie; 1280 typedef struct ieee80211_msrment_ie oal_ieee80211_msrment_ie; 1281 typedef struct ieee80211_mgmt oal_ieee80211_mgmt; 1282 1283 /* ================================================================ */ 1284 /* 以下结构体copy from liteos 适配dmac编译 */ 1285 1286 /* net_device ioctl结构体定义 */ 1287 /* hostapd/wpa_supplicant 下发的信息元素结构 */ 1288 /* 该结构为事件内存池大小,保存从hostapd/wpa_supplicant下发的ie 信息 */ 1289 /* 注意: 整个结构体长度为事件内存池大小,如果事件内存池有修改,则需要同步修改app 数据结构 */ 1290 struct oal_app_ie { 1291 osal_u32 ie_len; 1292 app_ie_type_uint8 app_ie_type; 1293 osal_u8 ie_type_bitmap; 1294 osal_u8 rsv[2]; /* 保留2字节对齐 */ 1295 /* ie 中保存信息元素,长度 = (事件内存池大小 - 保留长度) */ 1296 osal_u8 ie[WLAN_WPS_IE_MAX_SIZE]; 1297 }; 1298 typedef struct oal_app_ie oal_app_ie_stru; 1299 1300 typedef td_u8 oal_nl80211_auth_type_enum_uint8; 1301 1302 /* ================================================================ */ 1303 /* 以下dmac原始定义和linux冲突 待特性确认 */ 1304 #endif // (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) 1305 1306 typedef struct { 1307 osal_u8 sta_mac[WLAN_MAC_ADDR_LEN]; /* 要获取的sta的mac */ 1308 oal_bool_enum_uint8 support_11h; /* 保存sta是否支持11h,为出参 */ 1309 osal_u8 reserve; 1310 } oal_hilink_get_sta_11h_ability; 1311 1312 typedef struct { 1313 osal_u8 sta_mac[OAL_MAC_ADDR_LEN]; /* 要获取的sta的mac */ 1314 oal_bool_enum_uint8 support_11r; /* 保存sta是否支持11r,为出参 */ 1315 osal_u8 reserve; 1316 } oal_hilink_get_sta_11r_ability; 1317 1318 1319 struct hostap_sta_link_info { 1320 osal_u8 addr[OAL_MAC_ADDR_LEN]; 1321 osal_u8 rx_rssi; /* 0 ~ 100 ,0xff为无效值 */ 1322 osal_u8 tx_pwr; /* 0 ~ 100 */ 1323 osal_u32 rx_rate; /* avr nego rate in kpbs */ 1324 osal_u32 tx_rate; /* avr nego rate in kpbs */ 1325 osal_u32 rx_minrate; /* min nego rx rate in last duration, clean to 0 when app read over */ 1326 osal_u32 rx_maxrate; /* max nego rx rate in last duration, clean to 0 when app read over */ 1327 osal_u32 tx_minrate; /* min nego tx rate in last duration, clean to 0 when app read over */ 1328 osal_u32 tx_maxrate; /* max nego tx rate in last duration, clean to 0 when app read over */ 1329 osal_u64 rx_bytes; 1330 osal_u64 tx_bytes; 1331 osal_u32 tx_frames_rty; /* tx frame retry cnt */ 1332 osal_u32 tx_frames_all; /* tx total frame cnt */ 1333 osal_u32 tx_frames_fail; /* tx fail */ 1334 osal_u32 SNR; /* snr */ 1335 }; 1336 1337 struct hostap_all_sta_link_info { 1338 unsigned long buf_cnt; /* input: sta_info count provided */ 1339 unsigned long sta_cnt; /* outpu: how many sta really */ 1340 unsigned int cur_channel; 1341 struct hostap_sta_link_info *sta_info; /* output */ 1342 }; 1343 typedef struct hostap_sta_link_info oal_net_sta_link_info_stru; 1344 typedef struct hostap_all_sta_link_info oal_net_all_sta_link_info_stru; 1345 1346 /* sta包含增量信息结构体 */ 1347 struct hostap_sta_link_info_ext { 1348 osal_u8 auth_st; /* 认证状态 */ 1349 oal_bool_enum_uint8 band; /* 工作频段 */ 1350 oal_bool_enum_uint8 wmm_switch; /* wmm是否使能 */ 1351 osal_u8 ps_st; /* 节能状态 */ 1352 osal_u8 sta_num; /* 空间流数 */ 1353 osal_u8 work_mode; /* 协议模式 */ 1354 osal_s8 c_noise; /* 节点的噪声值 */ 1355 osal_u8 auc_resv[1]; 1356 osal_u32 associated_time; /* 用户已连接的时长 */ 1357 }; 1358 1359 struct hostap_all_sta_link_info_ext { 1360 unsigned long buf_cnt; /* input: sta_info count provided */ 1361 unsigned long sta_cnt; /* outpu: how many sta really */ 1362 unsigned int cur_channel; 1363 struct hostap_sta_link_info *sta_info; 1364 struct hostap_sta_link_info_ext *sta_info_ext; 1365 }; 1366 typedef struct hostap_sta_link_info_ext oal_net_sta_link_info_ext_stru; 1367 typedef struct hostap_all_sta_link_info_ext oal_net_all_sta_link_info_ext_stru; 1368 1369 1370 typedef struct { 1371 osal_u8 group_mac[WLAN_MAC_ADDR_LEN]; 1372 osal_u8 sta_num; 1373 osal_u8 reserve; 1374 osal_u8 sta_mac[MAX_STA_NUM_OF_ONE_GROUP][WLAN_MAC_ADDR_LEN]; 1375 } oal_snoop_group_stru; 1376 1377 typedef struct { 1378 osal_u16 group_cnt; 1379 osal_u8 auc_resv[3]; 1380 oal_snoop_group_stru *buf; 1381 } oal_snoop_all_group_stru; 1382 1383 /* net_device ioctl结构体定义 */ 1384 typedef struct oal_net_dev_ioctl_data_tag { 1385 osal_s32 l_cmd; /* 命令号 */ 1386 union { 1387 struct { 1388 osal_u8 mac[OAL_MAC_ADDR_LEN]; 1389 osal_u8 rsv[2]; 1390 osal_u32 buf_size; /* 用户空间ie 缓冲大小 */ 1391 osal_u8 *buf; /* 用户空间ie 缓冲地址 */ 1392 } assoc_req_ie; /* AP 模式,用于获取STA 关联请求ie 信息 */ 1393 1394 struct { 1395 osal_u32 auth_alg; 1396 } auth_params; 1397 1398 struct { 1399 osal_u8 auc_country_code[4]; 1400 } country_code; 1401 1402 osal_u8 ssid[OAL_IEEE80211_MAX_SSID_LEN + 4]; 1403 osal_u32 vap_max_user; 1404 1405 struct { 1406 osal_s32 l_freq; 1407 osal_s32 l_channel; 1408 osal_s32 l_ht_enabled; 1409 osal_s32 l_sec_channel_offset; 1410 osal_s32 l_vht_enabled; 1411 osal_s32 l_center_freq1; 1412 osal_s32 l_center_freq2; 1413 osal_s32 l_bandwidth; 1414 } freq; 1415 1416 oal_app_ie_stru app_ie; /* beacon ie,index 0; proberesp ie index 1; assocresp ie index 2 */ 1417 1418 struct { 1419 osal_s32 l_freq; /* ap所在频段,与linux-2.6.34内核中定义不同 */ 1420 osal_u32 ssid_len; /* SSID 长度 */ 1421 osal_u32 ie_len; 1422 1423 osal_u8 *ie; 1424 OAL_CONST osal_u8 *ssid; /* 期望关联的AP SSID */ 1425 OAL_CONST osal_u8 *bssid; /* 期望关联的AP BSSID */ 1426 1427 osal_u8 privacy; /* 是否加密标志 */ 1428 oal_nl80211_auth_type_enum_uint8 auth_type; /* 认证类型,OPEN or SHARE-KEY */ 1429 1430 osal_u8 wep_key_len; /* WEP KEY长度 */ 1431 osal_u8 wep_key_index; /* WEP KEY索引 */ 1432 OAL_CONST osal_u8 *wep_key; /* WEP KEY密钥 */ 1433 1434 oal_cfg80211_crypto_settings_stru crypto; /* 密钥套件信息 */ 1435 } cfg80211_connect_params; 1436 struct { 1437 osal_u8 mac[OAL_MAC_ADDR_LEN]; 1438 osal_u16 reason_code; /* 去关联 reason code */ 1439 } kick_user_params; 1440 1441 oal_net_all_sta_link_info_stru all_sta_link_info; 1442 oal_hilink_get_sta_11h_ability fbt_get_sta_11h_ability; 1443 osal_s32 l_frag; /* 分片门限值 */ 1444 osal_s32 l_rts; /* RTS 门限值 */ 1445 1446 oal_snoop_all_group_stru all_snoop_group; 1447 oal_net_all_sta_link_info_ext_stru all_sta_link_info_ext; 1448 oal_blkwhtlst_stru blkwhtlst; 1449 } pri_data; 1450 } oal_net_dev_ioctl_data_stru; 1451 1452 #endif /* end of file */ 1453 1454