Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
libipw.h
Go to the documentation of this file.
1 /*
2  * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
3  * remains copyright by the original authors
4  *
5  * Portions of the merged code are based on Host AP (software wireless
6  * LAN access point) driver for Intersil Prism2/2.5/3.
7  *
8  * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
10  * Copyright (c) 2002-2003, Jouni Malinen <[email protected]>
11  *
12  * Adaption to a generic IEEE 802.11 stack by James Ketrenos
14  * Copyright (c) 2004-2005, Intel Corporation
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License version 2 as
18  * published by the Free Software Foundation. See README and COPYING for
19  * more details.
20  *
21  * API Version History
22  * 1.0.x -- Initial version
23  * 1.1.x -- Added radiotap, QoS, TIM, libipw_geo APIs,
24  * various structure changes, and crypto API init method
25  */
26 #ifndef LIBIPW_H
27 #define LIBIPW_H
28 #include <linux/if_ether.h> /* ETH_ALEN */
29 #include <linux/kernel.h> /* ARRAY_SIZE */
30 #include <linux/wireless.h>
31 #include <linux/ieee80211.h>
32 
33 #include <net/lib80211.h>
34 #include <net/cfg80211.h>
35 
36 #define LIBIPW_VERSION "git-1.1.13"
37 
38 #define LIBIPW_DATA_LEN 2304
39 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
40  6.2.1.1.2.
41 
42  The figure in section 7.1.2 suggests a body size of up to 2312
43  bytes is allowed, which is a bit confusing, I suspect this
44  represents the 2304 bytes of real data, plus a possible 8 bytes of
45  WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
46 
47 #define LIBIPW_1ADDR_LEN 10
48 #define LIBIPW_2ADDR_LEN 16
49 #define LIBIPW_3ADDR_LEN 24
50 #define LIBIPW_4ADDR_LEN 30
51 #define LIBIPW_FCS_LEN 4
52 #define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
53 #define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
54 
55 #define MIN_FRAG_THRESHOLD 256U
56 #define MAX_FRAG_THRESHOLD 2346U
57 
58 /* QOS control */
59 #define LIBIPW_QCTL_TID 0x000F
60 
61 /* debug macros */
62 
63 #ifdef CONFIG_LIBIPW_DEBUG
64 extern u32 libipw_debug_level;
65 #define LIBIPW_DEBUG(level, fmt, args...) \
66 do { if (libipw_debug_level & (level)) \
67  printk(KERN_DEBUG "libipw: %c %s " fmt, \
68  in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
69 #else
70 #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
71 #endif /* CONFIG_LIBIPW_DEBUG */
72 
73 /*
74  * To use the debug system:
75  *
76  * If you are defining a new debug classification, simply add it to the #define
77  * list here in the form of:
78  *
79  * #define LIBIPW_DL_xxxx VALUE
80  *
81  * shifting value to the left one bit from the previous entry. xxxx should be
82  * the name of the classification (for example, WEP)
83  *
84  * You then need to either add a LIBIPW_xxxx_DEBUG() macro definition for your
85  * classification, or use LIBIPW_DEBUG(LIBIPW_DL_xxxx, ...) whenever you want
86  * to send output to that classification.
87  *
88  * To add your debug level to the list of levels seen when you perform
89  *
90  * % cat /proc/net/ieee80211/debug_level
91  *
92  * you simply need to add your entry to the libipw_debug_level array.
93  *
94  * If you do not see debug_level in /proc/net/ieee80211 then you do not have
95  * CONFIG_LIBIPW_DEBUG defined in your kernel configuration
96  *
97  */
98 
99 #define LIBIPW_DL_INFO (1<<0)
100 #define LIBIPW_DL_WX (1<<1)
101 #define LIBIPW_DL_SCAN (1<<2)
102 #define LIBIPW_DL_STATE (1<<3)
103 #define LIBIPW_DL_MGMT (1<<4)
104 #define LIBIPW_DL_FRAG (1<<5)
105 #define LIBIPW_DL_DROP (1<<7)
106 
107 #define LIBIPW_DL_TX (1<<8)
108 #define LIBIPW_DL_RX (1<<9)
109 #define LIBIPW_DL_QOS (1<<31)
110 
111 #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a)
112 #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a)
113 #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
114 
115 #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
116 #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
117 #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
118 #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
119 #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
120 #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
121 #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
122 #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
123 #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
124 #include <linux/netdevice.h>
125 #include <linux/if_arp.h> /* ARPHRD_ETHER */
126 
127 #ifndef WIRELESS_SPY
128 #define WIRELESS_SPY /* enable iwspy support */
129 #endif
130 #include <net/iw_handler.h> /* new driver API */
131 
132 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
133 
134 #ifndef ETH_P_80211_RAW
135 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
136 #endif
137 
138 /* IEEE 802.11 defines */
139 
140 #define P80211_OUI_LEN 3
141 
143 
144  u8 dsap; /* always 0xAA */
145  u8 ssap; /* always 0xAA */
146  u8 ctrl; /* always 0x03 */
147  u8 oui[P80211_OUI_LEN]; /* organizational universal id */
148 
149 } __packed;
150 
151 #define SNAP_SIZE sizeof(struct libipw_snap_hdr)
152 
153 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
154 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
155 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
156 
157 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
158 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
159 
160 #define LIBIPW_STATMASK_SIGNAL (1<<0)
161 #define LIBIPW_STATMASK_RSSI (1<<1)
162 #define LIBIPW_STATMASK_NOISE (1<<2)
163 #define LIBIPW_STATMASK_RATE (1<<3)
164 #define LIBIPW_STATMASK_WEMASK 0x7
165 
166 #define LIBIPW_CCK_MODULATION (1<<0)
167 #define LIBIPW_OFDM_MODULATION (1<<1)
168 
169 #define LIBIPW_24GHZ_BAND (1<<0)
170 #define LIBIPW_52GHZ_BAND (1<<1)
171 
172 #define LIBIPW_CCK_RATE_1MB 0x02
173 #define LIBIPW_CCK_RATE_2MB 0x04
174 #define LIBIPW_CCK_RATE_5MB 0x0B
175 #define LIBIPW_CCK_RATE_11MB 0x16
176 #define LIBIPW_OFDM_RATE_6MB 0x0C
177 #define LIBIPW_OFDM_RATE_9MB 0x12
178 #define LIBIPW_OFDM_RATE_12MB 0x18
179 #define LIBIPW_OFDM_RATE_18MB 0x24
180 #define LIBIPW_OFDM_RATE_24MB 0x30
181 #define LIBIPW_OFDM_RATE_36MB 0x48
182 #define LIBIPW_OFDM_RATE_48MB 0x60
183 #define LIBIPW_OFDM_RATE_54MB 0x6C
184 #define LIBIPW_BASIC_RATE_MASK 0x80
185 
186 #define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
187 #define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
188 #define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
189 #define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
190 #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
191 #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
192 #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
193 #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
194 #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
195 #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
196 #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
197 #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
198 
199 #define LIBIPW_CCK_RATES_MASK 0x0000000F
200 #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
201  LIBIPW_CCK_RATE_2MB_MASK)
202 #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
203  LIBIPW_CCK_RATE_5MB_MASK | \
204  LIBIPW_CCK_RATE_11MB_MASK)
205 
206 #define LIBIPW_OFDM_RATES_MASK 0x00000FF0
207 #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
208  LIBIPW_OFDM_RATE_12MB_MASK | \
209  LIBIPW_OFDM_RATE_24MB_MASK)
210 #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
211  LIBIPW_OFDM_RATE_9MB_MASK | \
212  LIBIPW_OFDM_RATE_18MB_MASK | \
213  LIBIPW_OFDM_RATE_36MB_MASK | \
214  LIBIPW_OFDM_RATE_48MB_MASK | \
215  LIBIPW_OFDM_RATE_54MB_MASK)
216 #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
217  LIBIPW_CCK_DEFAULT_RATES_MASK)
218 
219 #define LIBIPW_NUM_OFDM_RATES 8
220 #define LIBIPW_NUM_CCK_RATES 4
221 #define LIBIPW_OFDM_SHIFT_MASK_A 4
222 
223 /* NOTE: This data is for statistical purposes; not all hardware provides this
224  * information for frames received.
225  * For libipw_rx_mgt, you need to set at least the 'len' parameter.
226  */
232  u16 rate; /* in 100 kbps */
240 };
241 
242 /* IEEE 802.11 requires that STA supports concurrent reception of at least
243  * three fragmented frames. This define can be increased to support more
244  * concurrent frames, but it should be noted that each entry can consume about
245  * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
246 #define LIBIPW_FRAG_CACHE_LEN 4
247 
249  unsigned long first_frag_time;
250  unsigned int seq;
251  unsigned int last_frag;
252  struct sk_buff *skb;
255 };
256 
257 struct libipw_stats {
258  unsigned int tx_unicast_frames;
259  unsigned int tx_multicast_frames;
260  unsigned int tx_fragments;
261  unsigned int tx_unicast_octets;
262  unsigned int tx_multicast_octets;
267  unsigned int tx_discards;
268  unsigned int rx_unicast_frames;
269  unsigned int rx_multicast_frames;
270  unsigned int rx_fragments;
271  unsigned int rx_unicast_octets;
272  unsigned int rx_multicast_octets;
273  unsigned int rx_fcs_errors;
274  unsigned int rx_discards_no_buffer;
275  unsigned int tx_discards_wrong_sa;
279 };
280 
281 struct libipw_device;
282 
283 #define SEC_KEY_1 (1<<0)
284 #define SEC_KEY_2 (1<<1)
285 #define SEC_KEY_3 (1<<2)
286 #define SEC_KEY_4 (1<<3)
287 #define SEC_ACTIVE_KEY (1<<4)
288 #define SEC_AUTH_MODE (1<<5)
289 #define SEC_UNICAST_GROUP (1<<6)
290 #define SEC_LEVEL (1<<7)
291 #define SEC_ENABLED (1<<8)
292 #define SEC_ENCRYPT (1<<9)
293 
294 #define SEC_LEVEL_0 0 /* None */
295 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
296 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
297 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
298 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
299 
300 #define SEC_ALG_NONE 0
301 #define SEC_ALG_WEP 1
302 #define SEC_ALG_TKIP 2
303 #define SEC_ALG_CCMP 3
304 
305 #define WEP_KEYS 4
306 #define WEP_KEY_LEN 13
307 #define SCM_KEY_LEN 32
308 #define SCM_TEMPORAL_KEY_LENGTH 16
309 
318 } __packed;
319 
320 /*
321 
322  802.11 data frame from AP
323 
324  ,-------------------------------------------------------------------.
325 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
326  |------|------|---------|---------|---------|------|---------|------|
327 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
328  | | tion | (BSSID) | | | ence | data | |
329  `-------------------------------------------------------------------'
330 
331 Total: 28-2340 bytes
332 
333 */
334 
335 #define BEACON_PROBE_SSID_ID_POSITION 12
336 
342 } __packed;
343 
350 } __packed;
351 
360 } __packed;
361 
371 } __packed;
372 
382 } __packed;
383 
387  u8 data[0];
388 } __packed;
389 
390 /*
391  * These are the data types that can make up management packets
392  *
393  u16 auth_algorithm;
394  u16 auth_sequence;
395  u16 beacon_interval;
396  u16 capability;
397  u8 current_ap[ETH_ALEN];
398  u16 listen_interval;
399  struct {
400  u16 association_id:14, reserved:2;
401  } __packed;
402  u32 time_stamp[2];
403  u16 reason;
404  u16 status;
405 */
406 
407 struct libipw_auth {
412  /* challenge */
414 } __packed;
415 
422 } __packed;
423 
428  union {
429  struct libipw_action_exchange {
432  } exchange;
434 
435  } format;
436 } __packed;
437 
441 } __packed;
442 
443 /* Alias deauth for disassoc */
444 #define libipw_deauth libipw_disassoc
445 
448  /* SSID, supported rates */
450 } __packed;
451 
457  /* SSID, supported rates, FH params, DS params,
458  * CF params, IBSS params, TIM (if beacon), RSN */
460 } __packed;
461 
462 /* Alias beacon for probe_response */
463 #define libipw_beacon libipw_probe_response
464 
469  /* SSID, supported rates, RSN */
471 } __packed;
472 
479 } __packed;
480 
486  /* supported rates */
488 } __packed;
489 
490 struct libipw_txb {
497  struct sk_buff *fragments[0];
498 };
499 
500 /* SWEEP TABLE ENTRIES NUMBER */
501 #define MAX_SWEEP_TAB_ENTRIES 42
502 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
503 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
504  * only use 8, and then use extended rates for the remaining supported
505  * rates. Other APs, however, stick all of their supported rates on the
506  * main rates information element... */
507 #define MAX_RATES_LENGTH ((u8)12)
508 #define MAX_RATES_EX_LENGTH ((u8)16)
509 #define MAX_NETWORK_COUNT 128
510 
511 #define CRC_LENGTH 4U
512 
513 #define MAX_WPA_IE_LEN 64
514 
515 #define NETWORK_HAS_OFDM (1<<1)
516 #define NETWORK_HAS_CCK (1<<2)
517 
518 /* QoS structure */
519 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
520 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
521 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
522  NETWORK_HAS_QOS_INFORMATION)
523 
524 /* 802.11h */
525 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
526 #define NETWORK_HAS_CSA (1<<6)
527 #define NETWORK_HAS_QUIET (1<<7)
528 #define NETWORK_HAS_IBSS_DFS (1<<8)
529 #define NETWORK_HAS_TPC_REPORT (1<<9)
530 
531 #define NETWORK_HAS_ERP_VALUE (1<<10)
532 
533 #define QOS_QUEUE_NUM 4
534 #define QOS_OUI_LEN 3
535 #define QOS_OUI_TYPE 2
536 #define QOS_ELEMENT_ID 221
537 #define QOS_OUI_INFO_SUB_TYPE 0
538 #define QOS_OUI_PARAM_SUB_TYPE 1
539 #define QOS_VERSION_1 1
540 #define QOS_AIFSN_MIN_VALUE 2
541 
550 } __packed;
551 
556 } __packed;
557 
562 } __packed;
563 
570 } __packed;
571 
574  int active;
578 };
579 
583 } __packed;
584 
585 /*******************************************************/
586 
590 } __packed;
591 
595 } __packed;
596 
602 };
603 
604 struct libipw_csa {
608 } __packed;
609 
610 struct libipw_quiet {
615 } __packed;
616 
618  /* These entries are used to identify a unique network */
621  /* Ensure null-terminated for any debug msgs */
624 
626 
627  /* These are network statistics */
634  unsigned long last_scanned;
644  size_t wpa_ie_len;
646  size_t rsn_ie_len;
648 
649  /* 802.11h info */
650 
651  /* Power Constraint - mandatory if spctrm mgmt required */
653 
654  /* TPC Report - mandatory if spctrm mgmt required */
656 
657  /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
658  * NOTE: This is variable length and so must be allocated dynamically */
660 
661  /* Channel Switch Announcement - optional if spctrm mgmt required */
662  struct libipw_csa csa;
663 
664  /* Quiet - optional if spctrm mgmt required */
666 
667  struct list_head list;
668 };
669 
678 };
679 
680 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
681 #define DEFAULT_FTS 2346
682 
683 #define CFG_LIBIPW_RESERVE_FCS (1<<0)
684 #define CFG_LIBIPW_COMPUTE_FCS (1<<1)
685 #define CFG_LIBIPW_RTS (1<<2)
686 
687 #define LIBIPW_24GHZ_MIN_CHANNEL 1
688 #define LIBIPW_24GHZ_MAX_CHANNEL 14
689 #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
690  LIBIPW_24GHZ_MIN_CHANNEL + 1)
691 
692 #define LIBIPW_52GHZ_MIN_CHANNEL 34
693 #define LIBIPW_52GHZ_MAX_CHANNEL 165
694 #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
695  LIBIPW_52GHZ_MIN_CHANNEL + 1)
696 
697 enum {
700  LIBIPW_CH_B_ONLY = (1 << 2),
701  LIBIPW_CH_NO_IBSS = (1 << 3),
704  LIBIPW_CH_INVALID = (1 << 6),
705 };
706 
708  u32 freq; /* in MHz */
711  u8 max_power; /* in dBm */
712 };
713 
714 struct libipw_geo {
715  u8 name[4];
720 };
721 
723  struct net_device *dev;
726 
727  /* Bookkeeping structures */
729 
730  struct libipw_geo geo;
733 
734  /* Probe / Beacon management */
738  int scans;
739  int scan_age;
740 
741  int iw_mode; /* operating mode (IW_MODE_*) */
742  struct iw_spy_data spy_data; /* iwspy support */
743 
745 
746  int tx_headroom; /* Set to size of any additional room needed at front
747  * of allocated Tx SKBs */
749 
750  /* WEP and other encryption related settings at the device level */
751  int open_wep; /* Set to 1 to allow unencrypted frames */
752 
753  /* If the host performs {en,de}cryption, then set to 1 */
757  /* host performs multicast decryption */
759 
760  /* host should strip IV and ICV from protected frames */
761  /* meaningful only when hardware decryption is being used */
763 
765  int ieee802_1x; /* is IEEE 802.1X used */
766 
767  /* WPA data */
771  size_t wpa_ie_len;
773 
775 
776  int bcrx_sta_key; /* use individual keys to override default keys even
777  * with RX of broad/multicast frames */
778 
779  /* Fragmentation structures */
781  unsigned int frag_next_idx;
782  u16 fts; /* Fragmentation Threshold */
783  u16 rts; /* RTS threshold */
784 
785  /* Association info */
787 
789 
790  int mode; /* A, B, G */
791  int modulation; /* CCK, OFDM */
792  int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
793  int abg_true; /* ABG flag */
794 
797 
798  u16 prev_seq_ctl; /* used to drop duplicate frames */
799 
800  /* Callback functions */
802  struct libipw_security * sec);
804  struct net_device * dev, int pri);
805  int (*is_queue_full) (struct net_device * dev, int pri);
806 
808  struct libipw_network * network, u16 type);
809  int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
810 
811  /* Typical STA methods */
813  struct libipw_auth * auth);
815  struct libipw_deauth * auth);
817  struct libipw_action * action,
818  struct libipw_rx_stats * stats);
820  struct libipw_disassoc * assoc);
822  struct libipw_beacon * beacon,
823  struct libipw_network * network);
825  struct libipw_probe_response * resp,
826  struct libipw_network * network);
828  struct libipw_probe_request * req,
829  struct libipw_rx_stats * stats);
831  struct libipw_assoc_response * resp,
832  struct libipw_network * network);
833 
834  /* Typical AP methods */
837  struct libipw_reassoc_request * req);
838 
839  /* This must be the last item so that it points to the data
840  * allocated beyond this structure by alloc_libipw */
841  u8 priv[0];
842 };
843 
844 #define IEEE_A (1<<0)
845 #define IEEE_B (1<<1)
846 #define IEEE_G (1<<2)
847 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
848 
849 static inline void *libipw_priv(struct net_device *dev)
850 {
851  return ((struct libipw_device *)netdev_priv(dev))->priv;
852 }
853 
854 static inline int libipw_is_valid_mode(struct libipw_device *ieee,
855  int mode)
856 {
857  /*
858  * It is possible for both access points and our device to support
859  * combinations of modes, so as long as there is one valid combination
860  * of ap/device supported modes, then return success
861  *
862  */
863  if ((mode & IEEE_A) &&
865  (ieee->freq_band & LIBIPW_52GHZ_BAND))
866  return 1;
867 
868  if ((mode & IEEE_G) &&
870  (ieee->freq_band & LIBIPW_24GHZ_BAND))
871  return 1;
872 
873  if ((mode & IEEE_B) &&
874  (ieee->modulation & LIBIPW_CCK_MODULATION) &&
875  (ieee->freq_band & LIBIPW_24GHZ_BAND))
876  return 1;
877 
878  return 0;
879 }
880 
881 static inline int libipw_get_hdrlen(u16 fc)
882 {
883  int hdrlen = LIBIPW_3ADDR_LEN;
884  u16 stype = WLAN_FC_GET_STYPE(fc);
885 
886  switch (WLAN_FC_GET_TYPE(fc)) {
888  if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
889  hdrlen = LIBIPW_4ADDR_LEN;
890  if (stype & IEEE80211_STYPE_QOS_DATA)
891  hdrlen += 2;
892  break;
893  case IEEE80211_FTYPE_CTL:
894  switch (WLAN_FC_GET_STYPE(fc)) {
895  case IEEE80211_STYPE_CTS:
896  case IEEE80211_STYPE_ACK:
897  hdrlen = LIBIPW_1ADDR_LEN;
898  break;
899  default:
900  hdrlen = LIBIPW_2ADDR_LEN;
901  break;
902  }
903  break;
904  }
905 
906  return hdrlen;
907 }
908 
909 static inline u8 *libipw_get_payload(struct ieee80211_hdr *hdr)
910 {
911  switch (libipw_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
912  case LIBIPW_1ADDR_LEN:
913  return ((struct libipw_hdr_1addr *)hdr)->payload;
914  case LIBIPW_2ADDR_LEN:
915  return ((struct libipw_hdr_2addr *)hdr)->payload;
916  case LIBIPW_3ADDR_LEN:
917  return ((struct libipw_hdr_3addr *)hdr)->payload;
918  case LIBIPW_4ADDR_LEN:
919  return ((struct libipw_hdr_4addr *)hdr)->payload;
920  }
921  return NULL;
922 }
923 
924 static inline int libipw_is_ofdm_rate(u8 rate)
925 {
926  switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
935  return 1;
936  }
937  return 0;
938 }
939 
940 static inline int libipw_is_cck_rate(u8 rate)
941 {
942  switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
943  case LIBIPW_CCK_RATE_1MB:
944  case LIBIPW_CCK_RATE_2MB:
945  case LIBIPW_CCK_RATE_5MB:
947  return 1;
948  }
949  return 0;
950 }
951 
952 /* libipw.c */
953 extern void free_libipw(struct net_device *dev, int monitor);
954 extern struct net_device *alloc_libipw(int sizeof_priv, int monitor);
955 extern int libipw_change_mtu(struct net_device *dev, int new_mtu);
956 
957 extern void libipw_networks_age(struct libipw_device *ieee,
958  unsigned long age_secs);
959 
960 extern int libipw_set_encryption(struct libipw_device *ieee);
961 
962 /* libipw_tx.c */
963 extern netdev_tx_t libipw_xmit(struct sk_buff *skb,
964  struct net_device *dev);
965 extern void libipw_txb_free(struct libipw_txb *);
966 
967 /* libipw_rx.c */
968 extern void libipw_rx_any(struct libipw_device *ieee,
969  struct sk_buff *skb, struct libipw_rx_stats *stats);
970 extern int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
971  struct libipw_rx_stats *rx_stats);
972 /* make sure to set stats->len */
973 extern void libipw_rx_mgt(struct libipw_device *ieee,
974  struct libipw_hdr_4addr *header,
975  struct libipw_rx_stats *stats);
976 extern void libipw_network_reset(struct libipw_network *network);
977 
978 /* libipw_geo.c */
979 extern const struct libipw_geo *libipw_get_geo(struct libipw_device
980  *ieee);
981 extern int libipw_set_geo(struct libipw_device *ieee,
982  const struct libipw_geo *geo);
983 
984 extern int libipw_is_valid_channel(struct libipw_device *ieee,
985  u8 channel);
986 extern int libipw_channel_to_index(struct libipw_device *ieee,
987  u8 channel);
988 extern u8 libipw_freq_to_channel(struct libipw_device *ieee, u32 freq);
989 extern u8 libipw_get_channel_flags(struct libipw_device *ieee,
990  u8 channel);
991 extern const struct libipw_channel *libipw_get_channel(struct
993  *ieee, u8 channel);
994 extern u32 libipw_channel_to_freq(struct libipw_device * ieee,
995  u8 channel);
996 
997 /* libipw_wx.c */
998 extern int libipw_wx_get_scan(struct libipw_device *ieee,
999  struct iw_request_info *info,
1000  union iwreq_data *wrqu, char *key);
1001 extern int libipw_wx_set_encode(struct libipw_device *ieee,
1002  struct iw_request_info *info,
1003  union iwreq_data *wrqu, char *key);
1004 extern int libipw_wx_get_encode(struct libipw_device *ieee,
1005  struct iw_request_info *info,
1006  union iwreq_data *wrqu, char *key);
1007 extern int libipw_wx_set_encodeext(struct libipw_device *ieee,
1008  struct iw_request_info *info,
1009  union iwreq_data *wrqu, char *extra);
1010 extern int libipw_wx_get_encodeext(struct libipw_device *ieee,
1011  struct iw_request_info *info,
1012  union iwreq_data *wrqu, char *extra);
1013 
1014 static inline void libipw_increment_scans(struct libipw_device *ieee)
1015 {
1016  ieee->scans++;
1017 }
1018 
1019 static inline int libipw_get_scans(struct libipw_device *ieee)
1020 {
1021  return ieee->scans;
1022 }
1023 
1024 #endif /* LIBIPW_H */