Linux Audio

Check our new training course

Loading...
v4.6
 
  1#ifndef HOSTAP_AP_H
  2#define HOSTAP_AP_H
  3
  4#include "hostap_80211.h"
  5
  6/* AP data structures for STAs */
  7
  8/* maximum number of frames to buffer per STA */
  9#define STA_MAX_TX_BUFFER 32
 10
 11/* STA flags */
 12#define WLAN_STA_AUTH BIT(0)
 13#define WLAN_STA_ASSOC BIT(1)
 14#define WLAN_STA_PS BIT(2)
 15#define WLAN_STA_TIM BIT(3) /* TIM bit is on for PS stations */
 16#define WLAN_STA_PERM BIT(4) /* permanent; do not remove entry on expiration */
 17#define WLAN_STA_AUTHORIZED BIT(5) /* If 802.1X is used, this flag is
 18				    * controlling whether STA is authorized to
 19				    * send and receive non-IEEE 802.1X frames
 20				    */
 21#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
 22
 23#define WLAN_RATE_1M BIT(0)
 24#define WLAN_RATE_2M BIT(1)
 25#define WLAN_RATE_5M5 BIT(2)
 26#define WLAN_RATE_11M BIT(3)
 27#define WLAN_RATE_COUNT 4
 28
 29/* Maximum size of Supported Rates info element. IEEE 802.11 has a limit of 8,
 30 * but some pre-standard IEEE 802.11g products use longer elements. */
 31#define WLAN_SUPP_RATES_MAX 32
 32
 33/* Try to increase TX rate after # successfully sent consecutive packets */
 34#define WLAN_RATE_UPDATE_COUNT 50
 35
 36/* Decrease TX rate after # consecutive dropped packets */
 37#define WLAN_RATE_DECREASE_THRESHOLD 2
 38
 39struct sta_info {
 40	struct list_head list;
 41	struct sta_info *hnext; /* next entry in hash table list */
 42	atomic_t users; /* number of users (do not remove if > 0) */
 43	struct proc_dir_entry *proc;
 44
 45	u8 addr[6];
 46	u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
 47	u32 flags;
 48	u16 capability;
 49	u16 listen_interval; /* or beacon_int for APs */
 50	u8 supported_rates[WLAN_SUPP_RATES_MAX];
 51
 52	unsigned long last_auth;
 53	unsigned long last_assoc;
 54	unsigned long last_rx;
 55	unsigned long last_tx;
 56	unsigned long rx_packets, tx_packets;
 57	unsigned long rx_bytes, tx_bytes;
 58	struct sk_buff_head tx_buf;
 59	/* FIX: timeout buffers with an expiry time somehow derived from
 60	 * listen_interval */
 61
 62	s8 last_rx_silence; /* Noise in dBm */
 63	s8 last_rx_signal; /* Signal strength in dBm */
 64	u8 last_rx_rate; /* TX rate in 0.1 Mbps */
 65	u8 last_rx_updated; /* IWSPY's struct iw_quality::updated */
 66
 67	u8 tx_supp_rates; /* bit field of supported TX rates */
 68	u8 tx_rate; /* current TX rate (in 0.1 Mbps) */
 69	u8 tx_rate_idx; /* current TX rate (WLAN_RATE_*) */
 70	u8 tx_max_rate; /* max TX rate (WLAN_RATE_*) */
 71	u32 tx_count[WLAN_RATE_COUNT]; /* number of frames sent (per rate) */
 72	u32 rx_count[WLAN_RATE_COUNT]; /* number of frames received (per rate)
 73					*/
 74	u32 tx_since_last_failure;
 75	u32 tx_consecutive_exc;
 76
 77	struct lib80211_crypt_data *crypt;
 78
 79	int ap; /* whether this station is an AP */
 80
 81	local_info_t *local;
 82
 83#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
 84	union {
 85		struct {
 86			char *challenge; /* shared key authentication
 87					  * challenge */
 88		} sta;
 89		struct {
 90			int ssid_len;
 91			unsigned char ssid[MAX_SSID_LEN + 1]; /* AP's ssid */
 92			int channel;
 93			unsigned long last_beacon; /* last RX beacon time */
 94		} ap;
 95	} u;
 96
 97	struct timer_list timer;
 98	enum { STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH } timeout_next;
 99#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
100};
101
102
103#define MAX_STA_COUNT 1024
104
105/* Maximum number of AIDs to use for STAs; must be 2007 or lower
106 * (8802.11 limitation) */
107#define MAX_AID_TABLE_SIZE 128
108
109#define STA_HASH_SIZE 256
110#define STA_HASH(sta) (sta[5])
111
112
113/* Default value for maximum station inactivity. After AP_MAX_INACTIVITY_SEC
114 * has passed since last received frame from the station, a nullfunc data
115 * frame is sent to the station. If this frame is not acknowledged and no other
116 * frames have been received, the station will be disassociated after
117 * AP_DISASSOC_DELAY. Similarly, a the station will be deauthenticated after
118 * AP_DEAUTH_DELAY. AP_TIMEOUT_RESOLUTION is the resolution that is used with
119 * max inactivity timer. */
120#define AP_MAX_INACTIVITY_SEC (5 * 60)
121#define AP_DISASSOC_DELAY (HZ)
122#define AP_DEAUTH_DELAY (HZ)
123
124/* ap_policy: whether to accept frames to/from other APs/IBSS */
125typedef enum {
126	AP_OTHER_AP_SKIP_ALL = 0,
127	AP_OTHER_AP_SAME_SSID = 1,
128	AP_OTHER_AP_ALL = 2,
129	AP_OTHER_AP_EVEN_IBSS = 3
130} ap_policy_enum;
131
132#define PRISM2_AUTH_OPEN BIT(0)
133#define PRISM2_AUTH_SHARED_KEY BIT(1)
134
135
136/* MAC address-based restrictions */
137struct mac_entry {
138	struct list_head list;
139	u8 addr[6];
140};
141
142struct mac_restrictions {
143	enum { MAC_POLICY_OPEN = 0, MAC_POLICY_ALLOW, MAC_POLICY_DENY } policy;
144	unsigned int entries;
145	struct list_head mac_list;
146	spinlock_t lock;
147};
148
149
150struct add_sta_proc_data {
151	u8 addr[ETH_ALEN];
152	struct add_sta_proc_data *next;
153};
154
155
156typedef enum { WDS_ADD, WDS_DEL } wds_oper_type;
157struct wds_oper_data {
158	wds_oper_type type;
159	u8 addr[ETH_ALEN];
160	struct wds_oper_data *next;
161};
162
163
164struct ap_data {
165	int initialized; /* whether ap_data has been initialized */
166	local_info_t *local;
167	int bridge_packets; /* send packet to associated STAs directly to the
168			     * wireless media instead of higher layers in the
169			     * kernel */
170	unsigned int bridged_unicast; /* number of unicast frames bridged on
171				       * wireless media */
172	unsigned int bridged_multicast; /* number of non-unicast frames
173					 * bridged on wireless media */
174	unsigned int tx_drop_nonassoc; /* number of unicast TX packets dropped
175					* because they were to an address that
176					* was not associated */
177	int nullfunc_ack; /* use workaround for nullfunc frame ACKs */
178
179	spinlock_t sta_table_lock;
180	int num_sta; /* number of entries in sta_list */
181	struct list_head sta_list; /* STA info list head */
182	struct sta_info *sta_hash[STA_HASH_SIZE];
183
184	struct proc_dir_entry *proc;
185
186	ap_policy_enum ap_policy;
187	unsigned int max_inactivity;
188	int autom_ap_wds;
189
190	struct mac_restrictions mac_restrictions; /* MAC-based auth */
191	int last_tx_rate;
192
193	struct work_struct add_sta_proc_queue;
194	struct add_sta_proc_data *add_sta_proc_entries;
195
196	struct work_struct wds_oper_queue;
197	struct wds_oper_data *wds_oper_entries;
198
199	u16 tx_callback_idx;
200
201#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
202	/* pointers to STA info; based on allocated AID or NULL if AID free
203	 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
204	 * and so on
205	 */
206	struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
207
208	u16 tx_callback_auth, tx_callback_assoc, tx_callback_poll;
209
210	/* WEP operations for generating challenges to be used with shared key
211	 * authentication */
212	struct lib80211_crypto_ops *crypt;
213	void *crypt_priv;
214#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
215};
216
217
218void hostap_rx(struct net_device *dev, struct sk_buff *skb,
219	       struct hostap_80211_rx_status *rx_stats);
220void hostap_init_data(local_info_t *local);
221void hostap_init_ap_proc(local_info_t *local);
222void hostap_free_data(struct ap_data *ap);
223void hostap_check_sta_fw_version(struct ap_data *ap, int sta_fw_ver);
224
225typedef enum {
226	AP_TX_CONTINUE, AP_TX_DROP, AP_TX_RETRY, AP_TX_BUFFERED,
227	AP_TX_CONTINUE_NOT_AUTHORIZED
228} ap_tx_ret;
229struct hostap_tx_data {
230	struct sk_buff *skb;
231	int host_encrypt;
232	struct lib80211_crypt_data *crypt;
233	void *sta_ptr;
234};
235ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx);
236void hostap_handle_sta_release(void *ptr);
237void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb);
238int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr *hdr);
239typedef enum {
240	AP_RX_CONTINUE, AP_RX_DROP, AP_RX_EXIT, AP_RX_CONTINUE_NOT_AUTHORIZED
241} ap_rx_ret;
242ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
243			       struct sk_buff *skb,
244			       struct hostap_80211_rx_status *rx_stats,
245			       int wds);
246int hostap_handle_sta_crypto(local_info_t *local, struct ieee80211_hdr *hdr,
247			     struct lib80211_crypt_data **crypt,
248			     void **sta_ptr);
249int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr);
250int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr);
251int hostap_add_sta(struct ap_data *ap, u8 *sta_addr);
252int hostap_update_rx_stats(struct ap_data *ap, struct ieee80211_hdr *hdr,
253			   struct hostap_80211_rx_status *rx_stats);
254void hostap_update_rates(local_info_t *local);
255void hostap_add_wds_links(local_info_t *local);
256void hostap_wds_link_oper(local_info_t *local, u8 *addr, wds_oper_type type);
257
258#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
259void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap,
260			    int resend);
261#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
262
263#endif /* HOSTAP_AP_H */
v5.9
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef HOSTAP_AP_H
  3#define HOSTAP_AP_H
  4
  5#include "hostap_80211.h"
  6
  7/* AP data structures for STAs */
  8
  9/* maximum number of frames to buffer per STA */
 10#define STA_MAX_TX_BUFFER 32
 11
 12/* STA flags */
 13#define WLAN_STA_AUTH BIT(0)
 14#define WLAN_STA_ASSOC BIT(1)
 15#define WLAN_STA_PS BIT(2)
 16#define WLAN_STA_TIM BIT(3) /* TIM bit is on for PS stations */
 17#define WLAN_STA_PERM BIT(4) /* permanent; do not remove entry on expiration */
 18#define WLAN_STA_AUTHORIZED BIT(5) /* If 802.1X is used, this flag is
 19				    * controlling whether STA is authorized to
 20				    * send and receive non-IEEE 802.1X frames
 21				    */
 22#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
 23
 24#define WLAN_RATE_1M BIT(0)
 25#define WLAN_RATE_2M BIT(1)
 26#define WLAN_RATE_5M5 BIT(2)
 27#define WLAN_RATE_11M BIT(3)
 28#define WLAN_RATE_COUNT 4
 29
 30/* Maximum size of Supported Rates info element. IEEE 802.11 has a limit of 8,
 31 * but some pre-standard IEEE 802.11g products use longer elements. */
 32#define WLAN_SUPP_RATES_MAX 32
 33
 34/* Try to increase TX rate after # successfully sent consecutive packets */
 35#define WLAN_RATE_UPDATE_COUNT 50
 36
 37/* Decrease TX rate after # consecutive dropped packets */
 38#define WLAN_RATE_DECREASE_THRESHOLD 2
 39
 40struct sta_info {
 41	struct list_head list;
 42	struct sta_info *hnext; /* next entry in hash table list */
 43	atomic_t users; /* number of users (do not remove if > 0) */
 44	struct proc_dir_entry *proc;
 45
 46	u8 addr[6];
 47	u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
 48	u32 flags;
 49	u16 capability;
 50	u16 listen_interval; /* or beacon_int for APs */
 51	u8 supported_rates[WLAN_SUPP_RATES_MAX];
 52
 53	unsigned long last_auth;
 54	unsigned long last_assoc;
 55	unsigned long last_rx;
 56	unsigned long last_tx;
 57	unsigned long rx_packets, tx_packets;
 58	unsigned long rx_bytes, tx_bytes;
 59	struct sk_buff_head tx_buf;
 60	/* FIX: timeout buffers with an expiry time somehow derived from
 61	 * listen_interval */
 62
 63	s8 last_rx_silence; /* Noise in dBm */
 64	s8 last_rx_signal; /* Signal strength in dBm */
 65	u8 last_rx_rate; /* TX rate in 0.1 Mbps */
 66	u8 last_rx_updated; /* IWSPY's struct iw_quality::updated */
 67
 68	u8 tx_supp_rates; /* bit field of supported TX rates */
 69	u8 tx_rate; /* current TX rate (in 0.1 Mbps) */
 70	u8 tx_rate_idx; /* current TX rate (WLAN_RATE_*) */
 71	u8 tx_max_rate; /* max TX rate (WLAN_RATE_*) */
 72	u32 tx_count[WLAN_RATE_COUNT]; /* number of frames sent (per rate) */
 73	u32 rx_count[WLAN_RATE_COUNT]; /* number of frames received (per rate)
 74					*/
 75	u32 tx_since_last_failure;
 76	u32 tx_consecutive_exc;
 77
 78	struct lib80211_crypt_data *crypt;
 79
 80	int ap; /* whether this station is an AP */
 81
 82	local_info_t *local;
 83
 84#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
 85	union {
 86		struct {
 87			char *challenge; /* shared key authentication
 88					  * challenge */
 89		} sta;
 90		struct {
 91			int ssid_len;
 92			unsigned char ssid[MAX_SSID_LEN + 1]; /* AP's ssid */
 93			int channel;
 94			unsigned long last_beacon; /* last RX beacon time */
 95		} ap;
 96	} u;
 97
 98	struct timer_list timer;
 99	enum { STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH } timeout_next;
100#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
101};
102
103
104#define MAX_STA_COUNT 1024
105
106/* Maximum number of AIDs to use for STAs; must be 2007 or lower
107 * (8802.11 limitation) */
108#define MAX_AID_TABLE_SIZE 128
109
110#define STA_HASH_SIZE 256
111#define STA_HASH(sta) (sta[5])
112
113
114/* Default value for maximum station inactivity. After AP_MAX_INACTIVITY_SEC
115 * has passed since last received frame from the station, a nullfunc data
116 * frame is sent to the station. If this frame is not acknowledged and no other
117 * frames have been received, the station will be disassociated after
118 * AP_DISASSOC_DELAY. Similarly, a the station will be deauthenticated after
119 * AP_DEAUTH_DELAY. AP_TIMEOUT_RESOLUTION is the resolution that is used with
120 * max inactivity timer. */
121#define AP_MAX_INACTIVITY_SEC (5 * 60)
122#define AP_DISASSOC_DELAY (HZ)
123#define AP_DEAUTH_DELAY (HZ)
124
125/* ap_policy: whether to accept frames to/from other APs/IBSS */
126typedef enum {
127	AP_OTHER_AP_SKIP_ALL = 0,
128	AP_OTHER_AP_SAME_SSID = 1,
129	AP_OTHER_AP_ALL = 2,
130	AP_OTHER_AP_EVEN_IBSS = 3
131} ap_policy_enum;
132
133#define PRISM2_AUTH_OPEN BIT(0)
134#define PRISM2_AUTH_SHARED_KEY BIT(1)
135
136
137/* MAC address-based restrictions */
138struct mac_entry {
139	struct list_head list;
140	u8 addr[6];
141};
142
143struct mac_restrictions {
144	enum { MAC_POLICY_OPEN = 0, MAC_POLICY_ALLOW, MAC_POLICY_DENY } policy;
145	unsigned int entries;
146	struct list_head mac_list;
147	spinlock_t lock;
148};
149
150
151struct add_sta_proc_data {
152	u8 addr[ETH_ALEN];
153	struct add_sta_proc_data *next;
154};
155
156
157typedef enum { WDS_ADD, WDS_DEL } wds_oper_type;
158struct wds_oper_data {
159	wds_oper_type type;
160	u8 addr[ETH_ALEN];
161	struct wds_oper_data *next;
162};
163
164
165struct ap_data {
166	int initialized; /* whether ap_data has been initialized */
167	local_info_t *local;
168	int bridge_packets; /* send packet to associated STAs directly to the
169			     * wireless media instead of higher layers in the
170			     * kernel */
171	unsigned int bridged_unicast; /* number of unicast frames bridged on
172				       * wireless media */
173	unsigned int bridged_multicast; /* number of non-unicast frames
174					 * bridged on wireless media */
175	unsigned int tx_drop_nonassoc; /* number of unicast TX packets dropped
176					* because they were to an address that
177					* was not associated */
178	int nullfunc_ack; /* use workaround for nullfunc frame ACKs */
179
180	spinlock_t sta_table_lock;
181	int num_sta; /* number of entries in sta_list */
182	struct list_head sta_list; /* STA info list head */
183	struct sta_info *sta_hash[STA_HASH_SIZE];
184
185	struct proc_dir_entry *proc;
186
187	ap_policy_enum ap_policy;
188	unsigned int max_inactivity;
189	int autom_ap_wds;
190
191	struct mac_restrictions mac_restrictions; /* MAC-based auth */
192	int last_tx_rate;
193
194	struct work_struct add_sta_proc_queue;
195	struct add_sta_proc_data *add_sta_proc_entries;
196
197	struct work_struct wds_oper_queue;
198	struct wds_oper_data *wds_oper_entries;
199
200	u16 tx_callback_idx;
201
202#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
203	/* pointers to STA info; based on allocated AID or NULL if AID free
204	 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
205	 * and so on
206	 */
207	struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
208
209	u16 tx_callback_auth, tx_callback_assoc, tx_callback_poll;
210
211	/* WEP operations for generating challenges to be used with shared key
212	 * authentication */
213	struct lib80211_crypto_ops *crypt;
214	void *crypt_priv;
215#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
216};
217
218
219void hostap_rx(struct net_device *dev, struct sk_buff *skb,
220	       struct hostap_80211_rx_status *rx_stats);
221void hostap_init_data(local_info_t *local);
222void hostap_init_ap_proc(local_info_t *local);
223void hostap_free_data(struct ap_data *ap);
224void hostap_check_sta_fw_version(struct ap_data *ap, int sta_fw_ver);
225
226typedef enum {
227	AP_TX_CONTINUE, AP_TX_DROP, AP_TX_RETRY, AP_TX_BUFFERED,
228	AP_TX_CONTINUE_NOT_AUTHORIZED
229} ap_tx_ret;
230struct hostap_tx_data {
231	struct sk_buff *skb;
232	int host_encrypt;
233	struct lib80211_crypt_data *crypt;
234	void *sta_ptr;
235};
236ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx);
237void hostap_handle_sta_release(void *ptr);
238void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb);
239int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr *hdr);
240typedef enum {
241	AP_RX_CONTINUE, AP_RX_DROP, AP_RX_EXIT, AP_RX_CONTINUE_NOT_AUTHORIZED
242} ap_rx_ret;
243ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
244			       struct sk_buff *skb,
245			       struct hostap_80211_rx_status *rx_stats,
246			       int wds);
247int hostap_handle_sta_crypto(local_info_t *local, struct ieee80211_hdr *hdr,
248			     struct lib80211_crypt_data **crypt,
249			     void **sta_ptr);
250int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr);
251int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr);
252int hostap_add_sta(struct ap_data *ap, u8 *sta_addr);
253int hostap_update_rx_stats(struct ap_data *ap, struct ieee80211_hdr *hdr,
254			   struct hostap_80211_rx_status *rx_stats);
255void hostap_update_rates(local_info_t *local);
256void hostap_add_wds_links(local_info_t *local);
257void hostap_wds_link_oper(local_info_t *local, u8 *addr, wds_oper_type type);
258
259#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
260void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap,
261			    int resend);
262#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
263
264#endif /* HOSTAP_AP_H */