source: ReferenceDesigns/w3_802.11/c/wlan_mac_high_framework/include/wlan_mac_network_info.h

Last change on this file was 6319, checked in by chunter, 5 years ago

1.8.0 release wlan-mac-se

File size: 6.7 KB
Line 
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
26struct 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//
106typedef 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;
118ASSERT_TYPE_SIZE(bss_config_t, 48);
119
120typedef 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;
129ASSERT_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.
134ASSERT_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.
139typedef struct network_info_entry_t network_info_entry_t;
140struct 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};
147ASSERT_TYPE_SIZE(network_info_entry_t, 20);
148
149/*************************** Function Prototypes *****************************/
150
151void network_info_init();
152void network_info_init_finish();
153
154network_info_entry_t* network_info_checkout();
155void network_info_checkin(network_info_entry_t* network_info_entry);
156
157void network_info_rx_process(void* pkt_buf_addr);
158
159void print_network_info();
160void network_info_timestamp_check();
161
162dl_list* wlan_mac_high_find_network_info_SSID(char* ssid);
163network_info_entry_t* wlan_mac_high_find_network_info_BSSID(u8* bssid);
164
165network_info_t* wlan_mac_high_create_network_info(u8* bssid, char* ssid, u8 chan);
166void wlan_mac_high_reset_network_list();
167void wlan_mac_high_clear_network_info(network_info_t* info);
168
169dl_list* wlan_mac_high_get_network_info_list();
170
171struct station_info_t* network_info_add_member(network_info_t* network_info, u8* addr, u32 max_queue_size);
172int network_info_remove_member(network_info_t* network_info, u8* addr);
173
174#endif
Note: See TracBrowser for help on using the repository browser.