[6319] | 1 | /** @file wlan_mac_bss_info.h |
---|
| 2 | * @brief BSS Info Subsystem |
---|
| 3 | * |
---|
| 4 | * This contains code tracking BSS information. It also contains code for managing |
---|
| 5 | * the active scan state machine. |
---|
| 6 | * |
---|
| 7 | * @copyright Copyright 2014-2019, Mango Communications. All rights reserved. |
---|
| 8 | * Distributed under the Mango Communications Reference Design License |
---|
| 9 | * See LICENSE.txt included in the design archive or |
---|
| 10 | * at http://mangocomm.com/802.11/license |
---|
| 11 | * |
---|
| 12 | * This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11) |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #ifndef WLAN_MAC_NETWORK_INFO_H_ |
---|
| 16 | #define WLAN_MAC_NETWORK_INFO_H_ |
---|
| 17 | |
---|
| 18 | /***************************** Include Files *********************************/ |
---|
| 19 | |
---|
| 20 | #include "wlan_mac_high_sw_config.h" |
---|
| 21 | #include "xil_types.h" |
---|
| 22 | #include "wlan_high_types.h" |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | // Forward declarations |
---|
| 26 | struct station_info_t; |
---|
| 27 | |
---|
| 28 | /*************************** Constant Definitions ****************************/ |
---|
| 29 | |
---|
| 30 | //----------------------------------------------- |
---|
| 31 | // Timeout used to remove inactive network_info_t structs |
---|
| 32 | // - Part of bss_info_timestamp_check() |
---|
| 33 | // |
---|
| 34 | #define NETWORK_INFO_TIMEOUT_USEC 600000000 |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | //----------------------------------------------- |
---|
| 38 | // Field size defines |
---|
| 39 | // |
---|
| 40 | #define NUM_BASIC_RATES_MAX 10 |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | //----------------------------------------------- |
---|
| 44 | // BSS Beacon Interval defines |
---|
| 45 | // |
---|
| 46 | #define BSS_MICROSECONDS_IN_A_TU 1024 |
---|
| 47 | #define BEACON_INTERVAL_NO_BEACON_TX 0x0 |
---|
| 48 | #define BEACON_INTERVAL_UNKNOWN 0xFFFF |
---|
| 49 | |
---|
| 50 | //----------------------------------------------- |
---|
| 51 | // BSS Capabilities defines |
---|
| 52 | // - Uses some values from wlan_mac_802_11_defs.h for to map BSS |
---|
| 53 | // capabilities to the capabilities transmitted in a beacon. |
---|
| 54 | // |
---|
| 55 | #define BSS_CAPABILITIES_BEACON_MASK (CAPABILITIES_ESS | CAPABILITIES_IBSS | CAPABILITIES_PRIVACY) |
---|
| 56 | |
---|
| 57 | #define BSS_CAPABILITIES_ESS CAPABILITIES_ESS |
---|
| 58 | #define BSS_CAPABILITIES_IBSS CAPABILITIES_IBSS |
---|
| 59 | #define BSS_CAPABILITIES_PRIVACY CAPABILITIES_PRIVACY |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | //----------------------------------------------- |
---|
| 63 | // Network Flags defines |
---|
| 64 | // |
---|
| 65 | #define NETWORK_FLAGS_KEEP 0x0001 |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | //----------------------------------------------- |
---|
| 69 | // BSS Configuration Bit Masks |
---|
| 70 | // |
---|
| 71 | #define BSS_FIELD_MASK_BSSID 0x00000001 |
---|
| 72 | #define BSS_FIELD_MASK_CHAN 0x00000002 |
---|
| 73 | #define BSS_FIELD_MASK_SSID 0x00000004 |
---|
| 74 | #define BSS_FIELD_MASK_BEACON_INTERVAL 0x00000008 |
---|
| 75 | #define BSS_FIELD_MASK_HT_CAPABLE 0x00000010 |
---|
| 76 | #define BSS_FIELD_MASK_DTIM_PERIOD 0x00000020 |
---|
| 77 | #define BSS_FIELD_MASK_ALL (BSS_FIELD_MASK_BSSID | \ |
---|
| 78 | BSS_FIELD_MASK_CHAN | \ |
---|
| 79 | BSS_FIELD_MASK_SSID | \ |
---|
| 80 | BSS_FIELD_MASK_BEACON_INTERVAL | \ |
---|
| 81 | BSS_FIELD_MASK_HT_CAPABLE | \ |
---|
| 82 | BSS_FIELD_MASK_DTIM_PERIOD) |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | //----------------------------------------------- |
---|
| 86 | // configure_bss() return error flags |
---|
| 87 | // |
---|
| 88 | #define BSS_CONFIG_FAILURE_BSSID_INVALID 0x00000001 |
---|
| 89 | #define BSS_CONFIG_FAILURE_BSSID_INSUFFICIENT_ARGUMENTS 0x00000002 |
---|
| 90 | #define BSS_CONFIG_FAILURE_CHANNEL_INVALID 0x00000004 |
---|
| 91 | #define BSS_CONFIG_FAILURE_BEACON_INTERVAL_INVALID 0x00000008 |
---|
| 92 | #define BSS_CONFIG_FAILURE_HT_CAPABLE_INVALID 0x00000010 |
---|
| 93 | #define BSS_CONFIG_FAILURE_DTIM_PERIOD_INVALID 0x00000020 |
---|
| 94 | |
---|
| 95 | /*********************** Global Structure Definitions ************************/ |
---|
| 96 | |
---|
| 97 | /******************************************************************** |
---|
| 98 | * @brief Network Information Structure |
---|
| 99 | * |
---|
| 100 | * This struct contains information about the basic service set for the node. |
---|
| 101 | ********************************************************************/ |
---|
| 102 | |
---|
| 103 | //--------------- |
---|
| 104 | // BSS Config |
---|
| 105 | // |
---|
| 106 | typedef struct __attribute__((__packed__)) bss_config_t{ |
---|
| 107 | u8 bssid[MAC_ADDR_LEN]; /* BSS ID - 48 bit HW address */ |
---|
| 108 | chan_spec_t chan_spec; /* Channel Specification */ |
---|
| 109 | //----- 4-byte boundary ------ |
---|
| 110 | char ssid[SSID_LEN_MAX + 1]; /* SSID of the BSS - 33 bytes */ |
---|
| 111 | u8 ht_capable; /* Support HTMF Tx/Rx */ |
---|
| 112 | u16 beacon_interval; /* Beacon interval - In time units of 1024 us */ |
---|
| 113 | //----- 4-byte boundary ------ |
---|
| 114 | u8 dtim_period; /* DTIM Period (in beacon intervals) */ |
---|
| 115 | u8 padding[3]; |
---|
| 116 | //----- 4-byte boundary ------ |
---|
| 117 | } bss_config_t; |
---|
| 118 | ASSERT_TYPE_SIZE(bss_config_t, 48); |
---|
| 119 | |
---|
| 120 | typedef struct __attribute__((__packed__)) network_info_t{ |
---|
| 121 | bss_config_t bss_config; |
---|
| 122 | u32 flags; |
---|
| 123 | u32 capabilities; |
---|
| 124 | u64 latest_beacon_rx_time; |
---|
| 125 | s8 latest_beacon_rx_power; |
---|
| 126 | u8 padding1[3]; |
---|
| 127 | dl_list members; |
---|
| 128 | } network_info_t; |
---|
| 129 | ASSERT_TYPE_SIZE(network_info_t, 80); |
---|
| 130 | |
---|
| 131 | // For wlan_exp retrieval purposes, we need to make sure that the members field is located |
---|
| 132 | // at the end of the struct Here we can construct a compile time assertion that will fail if |
---|
| 133 | // that assumption is broken. |
---|
| 134 | ASSERT_FIELD_END_ALIGNMENT(network_info_t, members, sizeof(dl_list)); |
---|
| 135 | |
---|
| 136 | //Define a new type of dl_entry for pointing to network_info_t |
---|
| 137 | // structs that contains some extra fields for faster searching |
---|
| 138 | // without needing to jump to DRAM. |
---|
| 139 | typedef struct network_info_entry_t network_info_entry_t; |
---|
| 140 | struct network_info_entry_t{ |
---|
| 141 | network_info_entry_t* next; |
---|
| 142 | network_info_entry_t* prev; |
---|
| 143 | network_info_t* data; |
---|
| 144 | u8 bssid[6]; |
---|
| 145 | u16 padding; |
---|
| 146 | }; |
---|
| 147 | ASSERT_TYPE_SIZE(network_info_entry_t, 20); |
---|
| 148 | |
---|
| 149 | /*************************** Function Prototypes *****************************/ |
---|
| 150 | |
---|
| 151 | void network_info_init(); |
---|
| 152 | void network_info_init_finish(); |
---|
| 153 | |
---|
| 154 | network_info_entry_t* network_info_checkout(); |
---|
| 155 | void network_info_checkin(network_info_entry_t* network_info_entry); |
---|
| 156 | |
---|
| 157 | void network_info_rx_process(void* pkt_buf_addr); |
---|
| 158 | |
---|
| 159 | void print_network_info(); |
---|
| 160 | void network_info_timestamp_check(); |
---|
| 161 | |
---|
| 162 | dl_list* wlan_mac_high_find_network_info_SSID(char* ssid); |
---|
| 163 | network_info_entry_t* wlan_mac_high_find_network_info_BSSID(u8* bssid); |
---|
| 164 | |
---|
| 165 | network_info_t* wlan_mac_high_create_network_info(u8* bssid, char* ssid, u8 chan); |
---|
| 166 | void wlan_mac_high_reset_network_list(); |
---|
| 167 | void wlan_mac_high_clear_network_info(network_info_t* info); |
---|
| 168 | |
---|
| 169 | dl_list* wlan_mac_high_get_network_info_list(); |
---|
| 170 | |
---|
| 171 | struct station_info_t* network_info_add_member(network_info_t* network_info, u8* addr, u32 max_queue_size); |
---|
| 172 | int network_info_remove_member(network_info_t* network_info, u8* addr); |
---|
| 173 | |
---|
| 174 | #endif |
---|