1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef LIBIPW_H
27#define LIBIPW_H
28#include <linux/if_ether.h>
29#include <linux/kernel.h>
30#include <linux/wireless.h>
31#include <linux/ieee80211.h>
32
33#include <net/lib80211.h>
34
35#define LIBIPW_VERSION "git-1.1.13"
36
37#define LIBIPW_DATA_LEN 2304
38
39
40
41
42
43
44
45
46#define LIBIPW_1ADDR_LEN 10
47#define LIBIPW_2ADDR_LEN 16
48#define LIBIPW_3ADDR_LEN 24
49#define LIBIPW_4ADDR_LEN 30
50#define LIBIPW_FCS_LEN 4
51#define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
52#define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
53
54#define MIN_FRAG_THRESHOLD 256U
55#define MAX_FRAG_THRESHOLD 2346U
56
57
58#define LIBIPW_QCTL_TID 0x000F
59
60
61
62#ifdef CONFIG_LIBIPW_DEBUG
63extern u32 libipw_debug_level;
64#define LIBIPW_DEBUG(level, fmt, args...) \
65do { if (libipw_debug_level & (level)) \
66 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
67 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
68static inline bool libipw_ratelimit_debug(u32 level)
69{
70 return (libipw_debug_level & level) && net_ratelimit();
71}
72#else
73#define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
74static inline bool libipw_ratelimit_debug(u32 level)
75{
76 return false;
77}
78#endif
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106#define LIBIPW_DL_INFO (1<<0)
107#define LIBIPW_DL_WX (1<<1)
108#define LIBIPW_DL_SCAN (1<<2)
109#define LIBIPW_DL_STATE (1<<3)
110#define LIBIPW_DL_MGMT (1<<4)
111#define LIBIPW_DL_FRAG (1<<5)
112#define LIBIPW_DL_DROP (1<<7)
113
114#define LIBIPW_DL_TX (1<<8)
115#define LIBIPW_DL_RX (1<<9)
116#define LIBIPW_DL_QOS (1<<31)
117
118#define LIBIPW_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
119#define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
120#define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
121
122#define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
123#define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
124#define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
125#define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
126#define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
127#define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
128#define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
129#define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
130#define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
131#include <linux/netdevice.h>
132#include <linux/if_arp.h>
133
134#ifndef WIRELESS_SPY
135#define WIRELESS_SPY
136#endif
137#include <net/iw_handler.h>
138
139#define ETH_P_PREAUTH 0x88C7
140
141#ifndef ETH_P_80211_RAW
142#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
143#endif
144
145
146
147#define P80211_OUI_LEN 3
148
149struct libipw_snap_hdr {
150
151 u8 dsap;
152 u8 ssap;
153 u8 ctrl;
154 u8 oui[P80211_OUI_LEN];
155
156} __attribute__ ((packed));
157
158#define SNAP_SIZE sizeof(struct libipw_snap_hdr)
159
160#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
161#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
162#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
163
164#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
165#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
166
167#define LIBIPW_STATMASK_SIGNAL (1<<0)
168#define LIBIPW_STATMASK_RSSI (1<<1)
169#define LIBIPW_STATMASK_NOISE (1<<2)
170#define LIBIPW_STATMASK_RATE (1<<3)
171#define LIBIPW_STATMASK_WEMASK 0x7
172
173#define LIBIPW_CCK_MODULATION (1<<0)
174#define LIBIPW_OFDM_MODULATION (1<<1)
175
176#define LIBIPW_24GHZ_BAND (1<<0)
177#define LIBIPW_52GHZ_BAND (1<<1)
178
179#define LIBIPW_CCK_RATE_1MB 0x02
180#define LIBIPW_CCK_RATE_2MB 0x04
181#define LIBIPW_CCK_RATE_5MB 0x0B
182#define LIBIPW_CCK_RATE_11MB 0x16
183#define LIBIPW_OFDM_RATE_6MB 0x0C
184#define LIBIPW_OFDM_RATE_9MB 0x12
185#define LIBIPW_OFDM_RATE_12MB 0x18
186#define LIBIPW_OFDM_RATE_18MB 0x24
187#define LIBIPW_OFDM_RATE_24MB 0x30
188#define LIBIPW_OFDM_RATE_36MB 0x48
189#define LIBIPW_OFDM_RATE_48MB 0x60
190#define LIBIPW_OFDM_RATE_54MB 0x6C
191#define LIBIPW_BASIC_RATE_MASK 0x80
192
193#define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
194#define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
195#define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
196#define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
197#define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
198#define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
199#define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
200#define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
201#define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
202#define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
203#define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
204#define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
205
206#define LIBIPW_CCK_RATES_MASK 0x0000000F
207#define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
208 LIBIPW_CCK_RATE_2MB_MASK)
209#define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
210 LIBIPW_CCK_RATE_5MB_MASK | \
211 LIBIPW_CCK_RATE_11MB_MASK)
212
213#define LIBIPW_OFDM_RATES_MASK 0x00000FF0
214#define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
215 LIBIPW_OFDM_RATE_12MB_MASK | \
216 LIBIPW_OFDM_RATE_24MB_MASK)
217#define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
218 LIBIPW_OFDM_RATE_9MB_MASK | \
219 LIBIPW_OFDM_RATE_18MB_MASK | \
220 LIBIPW_OFDM_RATE_36MB_MASK | \
221 LIBIPW_OFDM_RATE_48MB_MASK | \
222 LIBIPW_OFDM_RATE_54MB_MASK)
223#define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
224 LIBIPW_CCK_DEFAULT_RATES_MASK)
225
226#define LIBIPW_NUM_OFDM_RATES 8
227#define LIBIPW_NUM_CCK_RATES 4
228#define LIBIPW_OFDM_SHIFT_MASK_A 4
229
230
231
232
233
234struct libipw_rx_stats {
235 u32 mac_time;
236 s8 rssi;
237 u8 signal;
238 u8 noise;
239 u16 rate;
240 u8 received_channel;
241 u8 control;
242 u8 mask;
243 u8 freq;
244 u16 len;
245 u64 tsf;
246 u32 beacon_time;
247};
248
249
250
251
252
253#define LIBIPW_FRAG_CACHE_LEN 4
254
255struct libipw_frag_entry {
256 unsigned long first_frag_time;
257 unsigned int seq;
258 unsigned int last_frag;
259 struct sk_buff *skb;
260 u8 src_addr[ETH_ALEN];
261 u8 dst_addr[ETH_ALEN];
262};
263
264struct libipw_stats {
265 unsigned int tx_unicast_frames;
266 unsigned int tx_multicast_frames;
267 unsigned int tx_fragments;
268 unsigned int tx_unicast_octets;
269 unsigned int tx_multicast_octets;
270 unsigned int tx_deferred_transmissions;
271 unsigned int tx_single_retry_frames;
272 unsigned int tx_multiple_retry_frames;
273 unsigned int tx_retry_limit_exceeded;
274 unsigned int tx_discards;
275 unsigned int rx_unicast_frames;
276 unsigned int rx_multicast_frames;
277 unsigned int rx_fragments;
278 unsigned int rx_unicast_octets;
279 unsigned int rx_multicast_octets;
280 unsigned int rx_fcs_errors;
281 unsigned int rx_discards_no_buffer;
282 unsigned int tx_discards_wrong_sa;
283 unsigned int rx_discards_undecryptable;
284 unsigned int rx_message_in_msg_fragments;
285 unsigned int rx_message_in_bad_msg_fragments;
286};
287
288struct libipw_device;
289
290#define SEC_KEY_1 (1<<0)
291#define SEC_KEY_2 (1<<1)
292#define SEC_KEY_3 (1<<2)
293#define SEC_KEY_4 (1<<3)
294#define SEC_ACTIVE_KEY (1<<4)
295#define SEC_AUTH_MODE (1<<5)
296#define SEC_UNICAST_GROUP (1<<6)
297#define SEC_LEVEL (1<<7)
298#define SEC_ENABLED (1<<8)
299#define SEC_ENCRYPT (1<<9)
300
301#define SEC_LEVEL_0 0
302#define SEC_LEVEL_1 1
303#define SEC_LEVEL_2 2
304#define SEC_LEVEL_2_CKIP 3
305#define SEC_LEVEL_3 4
306
307#define SEC_ALG_NONE 0
308#define SEC_ALG_WEP 1
309#define SEC_ALG_TKIP 2
310#define SEC_ALG_CCMP 3
311
312#define WEP_KEYS 4
313#define WEP_KEY_LEN 13
314#define SCM_KEY_LEN 32
315#define SCM_TEMPORAL_KEY_LENGTH 16
316
317struct libipw_security {
318 u16 active_key:2, enabled:1, unicast_uses_group:1, encrypt:1;
319 u8 auth_mode;
320 u8 encode_alg[WEP_KEYS];
321 u8 key_sizes[WEP_KEYS];
322 u8 keys[WEP_KEYS][SCM_KEY_LEN];
323 u8 level;
324 u16 flags;
325} __attribute__ ((packed));
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342#define BEACON_PROBE_SSID_ID_POSITION 12
343
344struct libipw_hdr_1addr {
345 __le16 frame_ctl;
346 __le16 duration_id;
347 u8 addr1[ETH_ALEN];
348 u8 payload[0];
349} __attribute__ ((packed));
350
351struct libipw_hdr_2addr {
352 __le16 frame_ctl;
353 __le16 duration_id;
354 u8 addr1[ETH_ALEN];
355 u8 addr2[ETH_ALEN];
356 u8 payload[0];
357} __attribute__ ((packed));
358
359struct libipw_hdr_3addr {
360 __le16 frame_ctl;
361 __le16 duration_id;
362 u8 addr1[ETH_ALEN];
363 u8 addr2[ETH_ALEN];
364 u8 addr3[ETH_ALEN];
365 __le16 seq_ctl;
366 u8 payload[0];
367} __attribute__ ((packed));
368
369struct libipw_hdr_4addr {
370 __le16 frame_ctl;
371 __le16 duration_id;
372 u8 addr1[ETH_ALEN];
373 u8 addr2[ETH_ALEN];
374 u8 addr3[ETH_ALEN];
375 __le16 seq_ctl;
376 u8 addr4[ETH_ALEN];
377 u8 payload[0];
378} __attribute__ ((packed));
379
380struct libipw_hdr_3addrqos {
381 __le16 frame_ctl;
382 __le16 duration_id;
383 u8 addr1[ETH_ALEN];
384 u8 addr2[ETH_ALEN];
385 u8 addr3[ETH_ALEN];
386 __le16 seq_ctl;
387 u8 payload[0];
388 __le16 qos_ctl;
389} __attribute__ ((packed));
390
391struct libipw_info_element {
392 u8 id;
393 u8 len;
394 u8 data[0];
395} __attribute__ ((packed));
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414struct libipw_auth {
415 struct libipw_hdr_3addr header;
416 __le16 algorithm;
417 __le16 transaction;
418 __le16 status;
419
420 struct libipw_info_element info_element[0];
421} __attribute__ ((packed));
422
423struct libipw_channel_switch {
424 u8 id;
425 u8 len;
426 u8 mode;
427 u8 channel;
428 u8 count;
429} __attribute__ ((packed));
430
431struct libipw_action {
432 struct libipw_hdr_3addr header;
433 u8 category;
434 u8 action;
435 union {
436 struct libipw_action_exchange {
437 u8 token;
438 struct libipw_info_element info_element[0];
439 } exchange;
440 struct libipw_channel_switch channel_switch;
441
442 } format;
443} __attribute__ ((packed));
444
445struct libipw_disassoc {
446 struct libipw_hdr_3addr header;
447 __le16 reason;
448} __attribute__ ((packed));
449
450
451#define libipw_deauth libipw_disassoc
452
453struct libipw_probe_request {
454 struct libipw_hdr_3addr header;
455
456 struct libipw_info_element info_element[0];
457} __attribute__ ((packed));
458
459struct libipw_probe_response {
460 struct libipw_hdr_3addr header;
461 __le32 time_stamp[2];
462 __le16 beacon_interval;
463 __le16 capability;
464
465
466 struct libipw_info_element info_element[0];
467} __attribute__ ((packed));
468
469
470#define libipw_beacon libipw_probe_response
471
472struct libipw_assoc_request {
473 struct libipw_hdr_3addr header;
474 __le16 capability;
475 __le16 listen_interval;
476
477 struct libipw_info_element info_element[0];
478} __attribute__ ((packed));
479
480struct libipw_reassoc_request {
481 struct libipw_hdr_3addr header;
482 __le16 capability;
483 __le16 listen_interval;
484 u8 current_ap[ETH_ALEN];
485 struct libipw_info_element info_element[0];
486} __attribute__ ((packed));
487
488struct libipw_assoc_response {
489 struct libipw_hdr_3addr header;
490 __le16 capability;
491 __le16 status;
492 __le16 aid;
493
494 struct libipw_info_element info_element[0];
495} __attribute__ ((packed));
496
497struct libipw_txb {
498 u8 nr_frags;
499 u8 encrypted;
500 u8 rts_included;
501 u8 reserved;
502 u16 frag_size;
503 u16 payload_size;
504 struct sk_buff *fragments[0];
505};
506
507
508#define MAX_SWEEP_TAB_ENTRIES 42
509#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
510
511
512
513
514#define MAX_RATES_LENGTH ((u8)12)
515#define MAX_RATES_EX_LENGTH ((u8)16)
516#define MAX_NETWORK_COUNT 128
517
518#define CRC_LENGTH 4U
519
520#define MAX_WPA_IE_LEN 64
521
522#define NETWORK_HAS_OFDM (1<<1)
523#define NETWORK_HAS_CCK (1<<2)
524
525
526#define NETWORK_HAS_QOS_PARAMETERS (1<<3)
527#define NETWORK_HAS_QOS_INFORMATION (1<<4)
528#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
529 NETWORK_HAS_QOS_INFORMATION)
530
531
532#define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
533#define NETWORK_HAS_CSA (1<<6)
534#define NETWORK_HAS_QUIET (1<<7)
535#define NETWORK_HAS_IBSS_DFS (1<<8)
536#define NETWORK_HAS_TPC_REPORT (1<<9)
537
538#define NETWORK_HAS_ERP_VALUE (1<<10)
539
540#define QOS_QUEUE_NUM 4
541#define QOS_OUI_LEN 3
542#define QOS_OUI_TYPE 2
543#define QOS_ELEMENT_ID 221
544#define QOS_OUI_INFO_SUB_TYPE 0
545#define QOS_OUI_PARAM_SUB_TYPE 1
546#define QOS_VERSION_1 1
547#define QOS_AIFSN_MIN_VALUE 2
548
549struct libipw_qos_information_element {
550 u8 elementID;
551 u8 length;
552 u8 qui[QOS_OUI_LEN];
553 u8 qui_type;
554 u8 qui_subtype;
555 u8 version;
556 u8 ac_info;
557} __attribute__ ((packed));
558
559struct libipw_qos_ac_parameter {
560 u8 aci_aifsn;
561 u8 ecw_min_max;
562 __le16 tx_op_limit;
563} __attribute__ ((packed));
564
565struct libipw_qos_parameter_info {
566 struct libipw_qos_information_element info_element;
567 u8 reserved;
568 struct libipw_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
569} __attribute__ ((packed));
570
571struct libipw_qos_parameters {
572 __le16 cw_min[QOS_QUEUE_NUM];
573 __le16 cw_max[QOS_QUEUE_NUM];
574 u8 aifs[QOS_QUEUE_NUM];
575 u8 flag[QOS_QUEUE_NUM];
576 __le16 tx_op_limit[QOS_QUEUE_NUM];
577} __attribute__ ((packed));
578
579struct libipw_qos_data {
580 struct libipw_qos_parameters parameters;
581 int active;
582 int supported;
583 u8 param_count;
584 u8 old_param_count;
585};
586
587struct libipw_tim_parameters {
588 u8 tim_count;
589 u8 tim_period;
590} __attribute__ ((packed));
591
592
593
594enum {
595 LIBIPW_BASIC_MAP_BSS = (1 << 0),
596 LIBIPW_BASIC_MAP_OFDM = (1 << 1),
597 LIBIPW_BASIC_MAP_UNIDENTIFIED = (1 << 2),
598 LIBIPW_BASIC_MAP_RADAR = (1 << 3),
599 LIBIPW_BASIC_MAP_UNMEASURED = (1 << 4),
600
601
602};
603struct libipw_basic_report {
604 u8 channel;
605 __le64 start_time;
606 __le16 duration;
607 u8 map;
608} __attribute__ ((packed));
609
610enum {
611
612 LIBIPW_MEASUREMENT_ENABLE = (1 << 1),
613 LIBIPW_MEASUREMENT_REQUEST = (1 << 2),
614 LIBIPW_MEASUREMENT_REPORT = (1 << 3),
615
616};
617
618enum {
619 LIBIPW_REPORT_BASIC = 0,
620 LIBIPW_REPORT_CCA = 1,
621 LIBIPW_REPORT_RPI = 2,
622
623};
624
625struct libipw_measurement_params {
626 u8 channel;
627 __le64 start_time;
628 __le16 duration;
629} __attribute__ ((packed));
630
631struct libipw_measurement_request {
632 struct libipw_info_element ie;
633 u8 token;
634 u8 mode;
635 u8 type;
636 struct libipw_measurement_params params[0];
637} __attribute__ ((packed));
638
639struct libipw_measurement_report {
640 struct libipw_info_element ie;
641 u8 token;
642 u8 mode;
643 u8 type;
644 union {
645 struct libipw_basic_report basic[0];
646 } u;
647} __attribute__ ((packed));
648
649struct libipw_tpc_report {
650 u8 transmit_power;
651 u8 link_margin;
652} __attribute__ ((packed));
653
654struct libipw_channel_map {
655 u8 channel;
656 u8 map;
657} __attribute__ ((packed));
658
659struct libipw_ibss_dfs {
660 struct libipw_info_element ie;
661 u8 owner[ETH_ALEN];
662 u8 recovery_interval;
663 struct libipw_channel_map channel_map[0];
664};
665
666struct libipw_csa {
667 u8 mode;
668 u8 channel;
669 u8 count;
670} __attribute__ ((packed));
671
672struct libipw_quiet {
673 u8 count;
674 u8 period;
675 u8 duration;
676 u8 offset;
677} __attribute__ ((packed));
678
679struct libipw_network {
680
681 u8 bssid[ETH_ALEN];
682 u8 channel;
683
684 u8 ssid[IW_ESSID_MAX_SIZE + 1];
685 u8 ssid_len;
686
687 struct libipw_qos_data qos_data;
688
689
690 struct libipw_rx_stats stats;
691 u16 capability;
692 u8 rates[MAX_RATES_LENGTH];
693 u8 rates_len;
694 u8 rates_ex[MAX_RATES_EX_LENGTH];
695 u8 rates_ex_len;
696 unsigned long last_scanned;
697 u8 mode;
698 u32 flags;
699 u32 last_associate;
700 u32 time_stamp[2];
701 u16 beacon_interval;
702 u16 listen_interval;
703 u16 atim_window;
704 u8 erp_value;
705 u8 wpa_ie[MAX_WPA_IE_LEN];
706 size_t wpa_ie_len;
707 u8 rsn_ie[MAX_WPA_IE_LEN];
708 size_t rsn_ie_len;
709 struct libipw_tim_parameters tim;
710
711
712
713
714 u8 power_constraint;
715
716
717 struct libipw_tpc_report tpc_report;
718
719
720
721 struct libipw_ibss_dfs *ibss_dfs;
722
723
724 struct libipw_csa csa;
725
726
727 struct libipw_quiet quiet;
728
729 struct list_head list;
730};
731
732enum libipw_state {
733 LIBIPW_UNINITIALIZED = 0,
734 LIBIPW_INITIALIZED,
735 LIBIPW_ASSOCIATING,
736 LIBIPW_ASSOCIATED,
737 LIBIPW_AUTHENTICATING,
738 LIBIPW_AUTHENTICATED,
739 LIBIPW_SHUTDOWN
740};
741
742#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
743#define DEFAULT_FTS 2346
744
745#define CFG_LIBIPW_RESERVE_FCS (1<<0)
746#define CFG_LIBIPW_COMPUTE_FCS (1<<1)
747#define CFG_LIBIPW_RTS (1<<2)
748
749#define LIBIPW_24GHZ_MIN_CHANNEL 1
750#define LIBIPW_24GHZ_MAX_CHANNEL 14
751#define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
752 LIBIPW_24GHZ_MIN_CHANNEL + 1)
753
754#define LIBIPW_52GHZ_MIN_CHANNEL 34
755#define LIBIPW_52GHZ_MAX_CHANNEL 165
756#define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
757 LIBIPW_52GHZ_MIN_CHANNEL + 1)
758
759enum {
760 LIBIPW_CH_PASSIVE_ONLY = (1 << 0),
761 LIBIPW_CH_80211H_RULES = (1 << 1),
762 LIBIPW_CH_B_ONLY = (1 << 2),
763 LIBIPW_CH_NO_IBSS = (1 << 3),
764 LIBIPW_CH_UNIFORM_SPREADING = (1 << 4),
765 LIBIPW_CH_RADAR_DETECT = (1 << 5),
766 LIBIPW_CH_INVALID = (1 << 6),
767};
768
769struct libipw_channel {
770 u32 freq;
771 u8 channel;
772 u8 flags;
773 u8 max_power;
774};
775
776struct libipw_geo {
777 u8 name[4];
778 u8 bg_channels;
779 u8 a_channels;
780 struct libipw_channel bg[LIBIPW_24GHZ_CHANNELS];
781 struct libipw_channel a[LIBIPW_52GHZ_CHANNELS];
782};
783
784struct libipw_device {
785 struct net_device *dev;
786 struct libipw_security sec;
787
788
789 struct libipw_stats ieee_stats;
790
791 struct libipw_geo geo;
792
793
794 struct list_head network_free_list;
795 struct list_head network_list;
796 struct libipw_network *networks;
797 int scans;
798 int scan_age;
799
800 int iw_mode;
801 struct iw_spy_data spy_data;
802
803 spinlock_t lock;
804
805 int tx_headroom;
806
807 u32 config;
808
809
810 int open_wep;
811
812 int reset_on_keychange;
813
814
815
816 int host_encrypt;
817 int host_encrypt_msdu;
818 int host_decrypt;
819
820 int host_mc_decrypt;
821
822
823
824 int host_strip_iv_icv;
825
826 int host_open_frag;
827 int host_build_iv;
828 int ieee802_1x;
829
830
831 int wpa_enabled;
832 int drop_unencrypted;
833 int privacy_invoked;
834 size_t wpa_ie_len;
835 u8 *wpa_ie;
836
837 struct lib80211_crypt_info crypt_info;
838
839 int bcrx_sta_key;
840
841
842
843 struct libipw_frag_entry frag_cache[LIBIPW_FRAG_CACHE_LEN];
844 unsigned int frag_next_idx;
845 u16 fts;
846 u16 rts;
847
848
849 u8 bssid[ETH_ALEN];
850
851 enum libipw_state state;
852
853 int mode;
854 int modulation;
855 int freq_band;
856 int abg_true;
857
858 int perfect_rssi;
859 int worst_rssi;
860
861 u16 prev_seq_ctl;
862
863
864 void (*set_security) (struct net_device * dev,
865 struct libipw_security * sec);
866 netdev_tx_t (*hard_start_xmit) (struct libipw_txb * txb,
867 struct net_device * dev, int pri);
868 int (*reset_port) (struct net_device * dev);
869 int (*is_queue_full) (struct net_device * dev, int pri);
870
871 int (*handle_management) (struct net_device * dev,
872 struct libipw_network * network, u16 type);
873 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
874
875
876 int (*handle_auth) (struct net_device * dev,
877 struct libipw_auth * auth);
878 int (*handle_deauth) (struct net_device * dev,
879 struct libipw_deauth * auth);
880 int (*handle_action) (struct net_device * dev,
881 struct libipw_action * action,
882 struct libipw_rx_stats * stats);
883 int (*handle_disassoc) (struct net_device * dev,
884 struct libipw_disassoc * assoc);
885 int (*handle_beacon) (struct net_device * dev,
886 struct libipw_beacon * beacon,
887 struct libipw_network * network);
888 int (*handle_probe_response) (struct net_device * dev,
889 struct libipw_probe_response * resp,
890 struct libipw_network * network);
891 int (*handle_probe_request) (struct net_device * dev,
892 struct libipw_probe_request * req,
893 struct libipw_rx_stats * stats);
894 int (*handle_assoc_response) (struct net_device * dev,
895 struct libipw_assoc_response * resp,
896 struct libipw_network * network);
897
898
899 int (*handle_assoc_request) (struct net_device * dev);
900 int (*handle_reassoc_request) (struct net_device * dev,
901 struct libipw_reassoc_request * req);
902
903
904
905 u8 priv[0];
906};
907
908#define IEEE_A (1<<0)
909#define IEEE_B (1<<1)
910#define IEEE_G (1<<2)
911#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
912
913static inline void *libipw_priv(struct net_device *dev)
914{
915 return ((struct libipw_device *)netdev_priv(dev))->priv;
916}
917
918static inline int libipw_is_valid_mode(struct libipw_device *ieee,
919 int mode)
920{
921
922
923
924
925
926
927 if ((mode & IEEE_A) &&
928 (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
929 (ieee->freq_band & LIBIPW_52GHZ_BAND))
930 return 1;
931
932 if ((mode & IEEE_G) &&
933 (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
934 (ieee->freq_band & LIBIPW_24GHZ_BAND))
935 return 1;
936
937 if ((mode & IEEE_B) &&
938 (ieee->modulation & LIBIPW_CCK_MODULATION) &&
939 (ieee->freq_band & LIBIPW_24GHZ_BAND))
940 return 1;
941
942 return 0;
943}
944
945static inline int libipw_get_hdrlen(u16 fc)
946{
947 int hdrlen = LIBIPW_3ADDR_LEN;
948 u16 stype = WLAN_FC_GET_STYPE(fc);
949
950 switch (WLAN_FC_GET_TYPE(fc)) {
951 case IEEE80211_FTYPE_DATA:
952 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
953 hdrlen = LIBIPW_4ADDR_LEN;
954 if (stype & IEEE80211_STYPE_QOS_DATA)
955 hdrlen += 2;
956 break;
957 case IEEE80211_FTYPE_CTL:
958 switch (WLAN_FC_GET_STYPE(fc)) {
959 case IEEE80211_STYPE_CTS:
960 case IEEE80211_STYPE_ACK:
961 hdrlen = LIBIPW_1ADDR_LEN;
962 break;
963 default:
964 hdrlen = LIBIPW_2ADDR_LEN;
965 break;
966 }
967 break;
968 }
969
970 return hdrlen;
971}
972
973static inline u8 *libipw_get_payload(struct ieee80211_hdr *hdr)
974{
975 switch (libipw_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
976 case LIBIPW_1ADDR_LEN:
977 return ((struct libipw_hdr_1addr *)hdr)->payload;
978 case LIBIPW_2ADDR_LEN:
979 return ((struct libipw_hdr_2addr *)hdr)->payload;
980 case LIBIPW_3ADDR_LEN:
981 return ((struct libipw_hdr_3addr *)hdr)->payload;
982 case LIBIPW_4ADDR_LEN:
983 return ((struct libipw_hdr_4addr *)hdr)->payload;
984 }
985 return NULL;
986}
987
988static inline int libipw_is_ofdm_rate(u8 rate)
989{
990 switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
991 case LIBIPW_OFDM_RATE_6MB:
992 case LIBIPW_OFDM_RATE_9MB:
993 case LIBIPW_OFDM_RATE_12MB:
994 case LIBIPW_OFDM_RATE_18MB:
995 case LIBIPW_OFDM_RATE_24MB:
996 case LIBIPW_OFDM_RATE_36MB:
997 case LIBIPW_OFDM_RATE_48MB:
998 case LIBIPW_OFDM_RATE_54MB:
999 return 1;
1000 }
1001 return 0;
1002}
1003
1004static inline int libipw_is_cck_rate(u8 rate)
1005{
1006 switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
1007 case LIBIPW_CCK_RATE_1MB:
1008 case LIBIPW_CCK_RATE_2MB:
1009 case LIBIPW_CCK_RATE_5MB:
1010 case LIBIPW_CCK_RATE_11MB:
1011 return 1;
1012 }
1013 return 0;
1014}
1015
1016
1017extern void free_ieee80211(struct net_device *dev);
1018extern struct net_device *alloc_ieee80211(int sizeof_priv);
1019extern int libipw_change_mtu(struct net_device *dev, int new_mtu);
1020
1021extern void libipw_networks_age(struct libipw_device *ieee,
1022 unsigned long age_secs);
1023
1024extern int libipw_set_encryption(struct libipw_device *ieee);
1025
1026
1027extern netdev_tx_t libipw_xmit(struct sk_buff *skb,
1028 struct net_device *dev);
1029extern void libipw_txb_free(struct libipw_txb *);
1030
1031
1032extern void libipw_rx_any(struct libipw_device *ieee,
1033 struct sk_buff *skb, struct libipw_rx_stats *stats);
1034extern int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
1035 struct libipw_rx_stats *rx_stats);
1036
1037extern void libipw_rx_mgt(struct libipw_device *ieee,
1038 struct libipw_hdr_4addr *header,
1039 struct libipw_rx_stats *stats);
1040extern void libipw_network_reset(struct libipw_network *network);
1041
1042
1043extern const struct libipw_geo *libipw_get_geo(struct libipw_device
1044 *ieee);
1045extern int libipw_set_geo(struct libipw_device *ieee,
1046 const struct libipw_geo *geo);
1047
1048extern int libipw_is_valid_channel(struct libipw_device *ieee,
1049 u8 channel);
1050extern int libipw_channel_to_index(struct libipw_device *ieee,
1051 u8 channel);
1052extern u8 libipw_freq_to_channel(struct libipw_device *ieee, u32 freq);
1053extern u8 libipw_get_channel_flags(struct libipw_device *ieee,
1054 u8 channel);
1055extern const struct libipw_channel *libipw_get_channel(struct
1056 libipw_device
1057 *ieee, u8 channel);
1058extern u32 libipw_channel_to_freq(struct libipw_device * ieee,
1059 u8 channel);
1060
1061
1062extern int libipw_wx_get_scan(struct libipw_device *ieee,
1063 struct iw_request_info *info,
1064 union iwreq_data *wrqu, char *key);
1065extern int libipw_wx_set_encode(struct libipw_device *ieee,
1066 struct iw_request_info *info,
1067 union iwreq_data *wrqu, char *key);
1068extern int libipw_wx_get_encode(struct libipw_device *ieee,
1069 struct iw_request_info *info,
1070 union iwreq_data *wrqu, char *key);
1071extern int libipw_wx_set_encodeext(struct libipw_device *ieee,
1072 struct iw_request_info *info,
1073 union iwreq_data *wrqu, char *extra);
1074extern int libipw_wx_get_encodeext(struct libipw_device *ieee,
1075 struct iw_request_info *info,
1076 union iwreq_data *wrqu, char *extra);
1077
1078static inline void libipw_increment_scans(struct libipw_device *ieee)
1079{
1080 ieee->scans++;
1081}
1082
1083static inline int libipw_get_scans(struct libipw_device *ieee)
1084{
1085 return ieee->scans;
1086}
1087
1088#endif
1089