0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #ifndef LIBIPW_H
0023 #define LIBIPW_H
0024 #include <linux/if_ether.h> /* ETH_ALEN */
0025 #include <linux/kernel.h> /* ARRAY_SIZE */
0026 #include <linux/wireless.h>
0027 #include <linux/ieee80211.h>
0028
0029 #include <net/lib80211.h>
0030 #include <net/cfg80211.h>
0031
0032 #define LIBIPW_VERSION "git-1.1.13"
0033
0034 #define LIBIPW_DATA_LEN 2304
0035
0036
0037
0038
0039
0040
0041
0042
0043 #define LIBIPW_1ADDR_LEN 10
0044 #define LIBIPW_2ADDR_LEN 16
0045 #define LIBIPW_3ADDR_LEN 24
0046 #define LIBIPW_4ADDR_LEN 30
0047 #define LIBIPW_FCS_LEN 4
0048 #define LIBIPW_HLEN (LIBIPW_4ADDR_LEN)
0049 #define LIBIPW_FRAME_LEN (LIBIPW_DATA_LEN + LIBIPW_HLEN)
0050
0051 #define MIN_FRAG_THRESHOLD 256U
0052 #define MAX_FRAG_THRESHOLD 2346U
0053
0054
0055 #define LIBIPW_QCTL_TID 0x000F
0056
0057
0058
0059 #ifdef CONFIG_LIBIPW_DEBUG
0060 extern u32 libipw_debug_level;
0061 #define LIBIPW_DEBUG(level, fmt, args...) \
0062 do { if (libipw_debug_level & (level)) \
0063 printk(KERN_DEBUG "libipw: %s " fmt, __func__ , ## args); } while (0)
0064 #else
0065 #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0)
0066 #endif
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 #define LIBIPW_DL_INFO (1<<0)
0095 #define LIBIPW_DL_WX (1<<1)
0096 #define LIBIPW_DL_SCAN (1<<2)
0097 #define LIBIPW_DL_STATE (1<<3)
0098 #define LIBIPW_DL_MGMT (1<<4)
0099 #define LIBIPW_DL_FRAG (1<<5)
0100 #define LIBIPW_DL_DROP (1<<7)
0101
0102 #define LIBIPW_DL_TX (1<<8)
0103 #define LIBIPW_DL_RX (1<<9)
0104 #define LIBIPW_DL_QOS (1<<31)
0105
0106 #define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a)
0107 #define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a)
0108 #define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
0109
0110 #define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
0111 #define LIBIPW_DEBUG_SCAN(f, a...) LIBIPW_DEBUG(LIBIPW_DL_SCAN, f, ## a)
0112 #define LIBIPW_DEBUG_STATE(f, a...) LIBIPW_DEBUG(LIBIPW_DL_STATE, f, ## a)
0113 #define LIBIPW_DEBUG_MGMT(f, a...) LIBIPW_DEBUG(LIBIPW_DL_MGMT, f, ## a)
0114 #define LIBIPW_DEBUG_FRAG(f, a...) LIBIPW_DEBUG(LIBIPW_DL_FRAG, f, ## a)
0115 #define LIBIPW_DEBUG_DROP(f, a...) LIBIPW_DEBUG(LIBIPW_DL_DROP, f, ## a)
0116 #define LIBIPW_DEBUG_TX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_TX, f, ## a)
0117 #define LIBIPW_DEBUG_RX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_RX, f, ## a)
0118 #define LIBIPW_DEBUG_QOS(f, a...) LIBIPW_DEBUG(LIBIPW_DL_QOS, f, ## a)
0119 #include <linux/netdevice.h>
0120 #include <linux/if_arp.h> /* ARPHRD_ETHER */
0121
0122 #ifndef WIRELESS_SPY
0123 #define WIRELESS_SPY
0124 #endif
0125 #include <net/iw_handler.h> /* new driver API */
0126
0127 #define ETH_P_PREAUTH 0x88C7
0128
0129 #ifndef ETH_P_80211_RAW
0130 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
0131 #endif
0132
0133
0134
0135 #define P80211_OUI_LEN 3
0136
0137 struct libipw_snap_hdr {
0138
0139 u8 dsap;
0140 u8 ssap;
0141 u8 ctrl;
0142 u8 oui[P80211_OUI_LEN];
0143
0144 } __packed;
0145
0146 #define SNAP_SIZE sizeof(struct libipw_snap_hdr)
0147
0148 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
0149 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
0150 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
0151
0152 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
0153 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
0154
0155 #define LIBIPW_STATMASK_SIGNAL (1<<0)
0156 #define LIBIPW_STATMASK_RSSI (1<<1)
0157 #define LIBIPW_STATMASK_NOISE (1<<2)
0158 #define LIBIPW_STATMASK_RATE (1<<3)
0159 #define LIBIPW_STATMASK_WEMASK 0x7
0160
0161 #define LIBIPW_CCK_MODULATION (1<<0)
0162 #define LIBIPW_OFDM_MODULATION (1<<1)
0163
0164 #define LIBIPW_24GHZ_BAND (1<<0)
0165 #define LIBIPW_52GHZ_BAND (1<<1)
0166
0167 #define LIBIPW_CCK_RATE_1MB 0x02
0168 #define LIBIPW_CCK_RATE_2MB 0x04
0169 #define LIBIPW_CCK_RATE_5MB 0x0B
0170 #define LIBIPW_CCK_RATE_11MB 0x16
0171 #define LIBIPW_OFDM_RATE_6MB 0x0C
0172 #define LIBIPW_OFDM_RATE_9MB 0x12
0173 #define LIBIPW_OFDM_RATE_12MB 0x18
0174 #define LIBIPW_OFDM_RATE_18MB 0x24
0175 #define LIBIPW_OFDM_RATE_24MB 0x30
0176 #define LIBIPW_OFDM_RATE_36MB 0x48
0177 #define LIBIPW_OFDM_RATE_48MB 0x60
0178 #define LIBIPW_OFDM_RATE_54MB 0x6C
0179 #define LIBIPW_BASIC_RATE_MASK 0x80
0180
0181 #define LIBIPW_CCK_RATE_1MB_MASK (1<<0)
0182 #define LIBIPW_CCK_RATE_2MB_MASK (1<<1)
0183 #define LIBIPW_CCK_RATE_5MB_MASK (1<<2)
0184 #define LIBIPW_CCK_RATE_11MB_MASK (1<<3)
0185 #define LIBIPW_OFDM_RATE_6MB_MASK (1<<4)
0186 #define LIBIPW_OFDM_RATE_9MB_MASK (1<<5)
0187 #define LIBIPW_OFDM_RATE_12MB_MASK (1<<6)
0188 #define LIBIPW_OFDM_RATE_18MB_MASK (1<<7)
0189 #define LIBIPW_OFDM_RATE_24MB_MASK (1<<8)
0190 #define LIBIPW_OFDM_RATE_36MB_MASK (1<<9)
0191 #define LIBIPW_OFDM_RATE_48MB_MASK (1<<10)
0192 #define LIBIPW_OFDM_RATE_54MB_MASK (1<<11)
0193
0194 #define LIBIPW_CCK_RATES_MASK 0x0000000F
0195 #define LIBIPW_CCK_BASIC_RATES_MASK (LIBIPW_CCK_RATE_1MB_MASK | \
0196 LIBIPW_CCK_RATE_2MB_MASK)
0197 #define LIBIPW_CCK_DEFAULT_RATES_MASK (LIBIPW_CCK_BASIC_RATES_MASK | \
0198 LIBIPW_CCK_RATE_5MB_MASK | \
0199 LIBIPW_CCK_RATE_11MB_MASK)
0200
0201 #define LIBIPW_OFDM_RATES_MASK 0x00000FF0
0202 #define LIBIPW_OFDM_BASIC_RATES_MASK (LIBIPW_OFDM_RATE_6MB_MASK | \
0203 LIBIPW_OFDM_RATE_12MB_MASK | \
0204 LIBIPW_OFDM_RATE_24MB_MASK)
0205 #define LIBIPW_OFDM_DEFAULT_RATES_MASK (LIBIPW_OFDM_BASIC_RATES_MASK | \
0206 LIBIPW_OFDM_RATE_9MB_MASK | \
0207 LIBIPW_OFDM_RATE_18MB_MASK | \
0208 LIBIPW_OFDM_RATE_36MB_MASK | \
0209 LIBIPW_OFDM_RATE_48MB_MASK | \
0210 LIBIPW_OFDM_RATE_54MB_MASK)
0211 #define LIBIPW_DEFAULT_RATES_MASK (LIBIPW_OFDM_DEFAULT_RATES_MASK | \
0212 LIBIPW_CCK_DEFAULT_RATES_MASK)
0213
0214 #define LIBIPW_NUM_OFDM_RATES 8
0215 #define LIBIPW_NUM_CCK_RATES 4
0216 #define LIBIPW_OFDM_SHIFT_MASK_A 4
0217
0218
0219
0220
0221
0222 struct libipw_rx_stats {
0223 u32 mac_time;
0224 s8 rssi;
0225 u8 signal;
0226 u8 noise;
0227 u16 rate;
0228 u8 received_channel;
0229 u8 control;
0230 u8 mask;
0231 u8 freq;
0232 u16 len;
0233 u64 tsf;
0234 u32 beacon_time;
0235 };
0236
0237
0238
0239
0240
0241 #define LIBIPW_FRAG_CACHE_LEN 4
0242
0243 struct libipw_frag_entry {
0244 unsigned long first_frag_time;
0245 unsigned int seq;
0246 unsigned int last_frag;
0247 struct sk_buff *skb;
0248 u8 src_addr[ETH_ALEN];
0249 u8 dst_addr[ETH_ALEN];
0250 };
0251
0252 struct libipw_stats {
0253 unsigned int tx_unicast_frames;
0254 unsigned int tx_multicast_frames;
0255 unsigned int tx_fragments;
0256 unsigned int tx_unicast_octets;
0257 unsigned int tx_multicast_octets;
0258 unsigned int tx_deferred_transmissions;
0259 unsigned int tx_single_retry_frames;
0260 unsigned int tx_multiple_retry_frames;
0261 unsigned int tx_retry_limit_exceeded;
0262 unsigned int tx_discards;
0263 unsigned int rx_unicast_frames;
0264 unsigned int rx_multicast_frames;
0265 unsigned int rx_fragments;
0266 unsigned int rx_unicast_octets;
0267 unsigned int rx_multicast_octets;
0268 unsigned int rx_fcs_errors;
0269 unsigned int rx_discards_no_buffer;
0270 unsigned int tx_discards_wrong_sa;
0271 unsigned int rx_discards_undecryptable;
0272 unsigned int rx_message_in_msg_fragments;
0273 unsigned int rx_message_in_bad_msg_fragments;
0274 };
0275
0276 struct libipw_device;
0277
0278 #define SEC_KEY_1 (1<<0)
0279 #define SEC_KEY_2 (1<<1)
0280 #define SEC_KEY_3 (1<<2)
0281 #define SEC_KEY_4 (1<<3)
0282 #define SEC_ACTIVE_KEY (1<<4)
0283 #define SEC_AUTH_MODE (1<<5)
0284 #define SEC_UNICAST_GROUP (1<<6)
0285 #define SEC_LEVEL (1<<7)
0286 #define SEC_ENABLED (1<<8)
0287 #define SEC_ENCRYPT (1<<9)
0288
0289 #define SEC_LEVEL_0 0
0290 #define SEC_LEVEL_1 1
0291 #define SEC_LEVEL_2 2
0292 #define SEC_LEVEL_2_CKIP 3
0293 #define SEC_LEVEL_3 4
0294
0295 #define SEC_ALG_NONE 0
0296 #define SEC_ALG_WEP 1
0297 #define SEC_ALG_TKIP 2
0298 #define SEC_ALG_CCMP 3
0299
0300 #define WEP_KEYS 4
0301 #define WEP_KEY_LEN 13
0302 #define SCM_KEY_LEN 32
0303 #define SCM_TEMPORAL_KEY_LENGTH 16
0304
0305 struct libipw_security {
0306 u16 active_key:2, enabled:1, unicast_uses_group:1, encrypt:1;
0307 u8 auth_mode;
0308 u8 encode_alg[WEP_KEYS];
0309 u8 key_sizes[WEP_KEYS];
0310 u8 keys[WEP_KEYS][SCM_KEY_LEN];
0311 u8 level;
0312 u16 flags;
0313 } __packed;
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330 #define BEACON_PROBE_SSID_ID_POSITION 12
0331
0332 struct libipw_hdr_1addr {
0333 __le16 frame_ctl;
0334 __le16 duration_id;
0335 u8 addr1[ETH_ALEN];
0336 u8 payload[];
0337 } __packed;
0338
0339 struct libipw_hdr_2addr {
0340 __le16 frame_ctl;
0341 __le16 duration_id;
0342 u8 addr1[ETH_ALEN];
0343 u8 addr2[ETH_ALEN];
0344 u8 payload[];
0345 } __packed;
0346
0347 struct libipw_hdr_3addr {
0348 __le16 frame_ctl;
0349 __le16 duration_id;
0350 u8 addr1[ETH_ALEN];
0351 u8 addr2[ETH_ALEN];
0352 u8 addr3[ETH_ALEN];
0353 __le16 seq_ctl;
0354 u8 payload[];
0355 } __packed;
0356
0357 struct libipw_hdr_4addr {
0358 __le16 frame_ctl;
0359 __le16 duration_id;
0360 u8 addr1[ETH_ALEN];
0361 u8 addr2[ETH_ALEN];
0362 u8 addr3[ETH_ALEN];
0363 __le16 seq_ctl;
0364 u8 addr4[ETH_ALEN];
0365 u8 payload[];
0366 } __packed;
0367
0368 struct libipw_hdr_3addrqos {
0369 __le16 frame_ctl;
0370 __le16 duration_id;
0371 u8 addr1[ETH_ALEN];
0372 u8 addr2[ETH_ALEN];
0373 u8 addr3[ETH_ALEN];
0374 __le16 seq_ctl;
0375 u8 payload[0];
0376 __le16 qos_ctl;
0377 } __packed;
0378
0379 struct libipw_info_element {
0380 u8 id;
0381 u8 len;
0382 u8 data[];
0383 } __packed;
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402 struct libipw_auth {
0403 struct libipw_hdr_3addr header;
0404 __le16 algorithm;
0405 __le16 transaction;
0406 __le16 status;
0407
0408 struct libipw_info_element info_element[];
0409 } __packed;
0410
0411 struct libipw_channel_switch {
0412 u8 id;
0413 u8 len;
0414 u8 mode;
0415 u8 channel;
0416 u8 count;
0417 } __packed;
0418
0419 struct libipw_action {
0420 struct libipw_hdr_3addr header;
0421 u8 category;
0422 u8 action;
0423 union {
0424 struct libipw_action_exchange {
0425 u8 token;
0426 struct libipw_info_element info_element[0];
0427 } exchange;
0428 struct libipw_channel_switch channel_switch;
0429
0430 } format;
0431 } __packed;
0432
0433 struct libipw_disassoc {
0434 struct libipw_hdr_3addr header;
0435 __le16 reason;
0436 } __packed;
0437
0438
0439 #define libipw_deauth libipw_disassoc
0440
0441 struct libipw_probe_request {
0442 struct libipw_hdr_3addr header;
0443
0444 struct libipw_info_element info_element[];
0445 } __packed;
0446
0447 struct libipw_probe_response {
0448 struct libipw_hdr_3addr header;
0449 __le32 time_stamp[2];
0450 __le16 beacon_interval;
0451 __le16 capability;
0452
0453
0454 struct libipw_info_element info_element[];
0455 } __packed;
0456
0457
0458 #define libipw_beacon libipw_probe_response
0459
0460 struct libipw_assoc_request {
0461 struct libipw_hdr_3addr header;
0462 __le16 capability;
0463 __le16 listen_interval;
0464
0465 struct libipw_info_element info_element[];
0466 } __packed;
0467
0468 struct libipw_reassoc_request {
0469 struct libipw_hdr_3addr header;
0470 __le16 capability;
0471 __le16 listen_interval;
0472 u8 current_ap[ETH_ALEN];
0473 struct libipw_info_element info_element[];
0474 } __packed;
0475
0476 struct libipw_assoc_response {
0477 struct libipw_hdr_3addr header;
0478 __le16 capability;
0479 __le16 status;
0480 __le16 aid;
0481
0482 struct libipw_info_element info_element[];
0483 } __packed;
0484
0485 struct libipw_txb {
0486 u8 nr_frags;
0487 u8 encrypted;
0488 u8 rts_included;
0489 u8 reserved;
0490 u16 frag_size;
0491 u16 payload_size;
0492 struct sk_buff *fragments[];
0493 };
0494
0495
0496 #define MAX_SWEEP_TAB_ENTRIES 42
0497 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
0498
0499
0500
0501
0502 #define MAX_RATES_LENGTH ((u8)12)
0503 #define MAX_RATES_EX_LENGTH ((u8)16)
0504 #define MAX_NETWORK_COUNT 128
0505
0506 #define CRC_LENGTH 4U
0507
0508 #define MAX_WPA_IE_LEN 64
0509
0510 #define NETWORK_HAS_OFDM (1<<1)
0511 #define NETWORK_HAS_CCK (1<<2)
0512
0513
0514 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
0515 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
0516 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
0517 NETWORK_HAS_QOS_INFORMATION)
0518
0519
0520 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
0521 #define NETWORK_HAS_CSA (1<<6)
0522 #define NETWORK_HAS_QUIET (1<<7)
0523 #define NETWORK_HAS_IBSS_DFS (1<<8)
0524 #define NETWORK_HAS_TPC_REPORT (1<<9)
0525
0526 #define NETWORK_HAS_ERP_VALUE (1<<10)
0527
0528 #define QOS_QUEUE_NUM 4
0529 #define QOS_OUI_LEN 3
0530 #define QOS_OUI_TYPE 2
0531 #define QOS_ELEMENT_ID 221
0532 #define QOS_OUI_INFO_SUB_TYPE 0
0533 #define QOS_OUI_PARAM_SUB_TYPE 1
0534 #define QOS_VERSION_1 1
0535 #define QOS_AIFSN_MIN_VALUE 2
0536
0537 struct libipw_qos_information_element {
0538 u8 elementID;
0539 u8 length;
0540 u8 qui[QOS_OUI_LEN];
0541 u8 qui_type;
0542 u8 qui_subtype;
0543 u8 version;
0544 u8 ac_info;
0545 } __packed;
0546
0547 struct libipw_qos_ac_parameter {
0548 u8 aci_aifsn;
0549 u8 ecw_min_max;
0550 __le16 tx_op_limit;
0551 } __packed;
0552
0553 struct libipw_qos_parameter_info {
0554 struct libipw_qos_information_element info_element;
0555 u8 reserved;
0556 struct libipw_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
0557 } __packed;
0558
0559 struct libipw_qos_parameters {
0560 __le16 cw_min[QOS_QUEUE_NUM];
0561 __le16 cw_max[QOS_QUEUE_NUM];
0562 u8 aifs[QOS_QUEUE_NUM];
0563 u8 flag[QOS_QUEUE_NUM];
0564 __le16 tx_op_limit[QOS_QUEUE_NUM];
0565 } __packed;
0566
0567 struct libipw_qos_data {
0568 struct libipw_qos_parameters parameters;
0569 int active;
0570 int supported;
0571 u8 param_count;
0572 u8 old_param_count;
0573 };
0574
0575 struct libipw_tim_parameters {
0576 u8 tim_count;
0577 u8 tim_period;
0578 } __packed;
0579
0580
0581
0582 struct libipw_tpc_report {
0583 u8 transmit_power;
0584 u8 link_margin;
0585 } __packed;
0586
0587 struct libipw_channel_map {
0588 u8 channel;
0589 u8 map;
0590 } __packed;
0591
0592 struct libipw_ibss_dfs {
0593 struct libipw_info_element ie;
0594 u8 owner[ETH_ALEN];
0595 u8 recovery_interval;
0596 struct libipw_channel_map channel_map[];
0597 };
0598
0599 struct libipw_csa {
0600 u8 mode;
0601 u8 channel;
0602 u8 count;
0603 } __packed;
0604
0605 struct libipw_quiet {
0606 u8 count;
0607 u8 period;
0608 u8 duration;
0609 u8 offset;
0610 } __packed;
0611
0612 struct libipw_network {
0613
0614 u8 bssid[ETH_ALEN];
0615 u8 channel;
0616
0617 u8 ssid[IW_ESSID_MAX_SIZE + 1];
0618 u8 ssid_len;
0619
0620 struct libipw_qos_data qos_data;
0621
0622
0623 struct libipw_rx_stats stats;
0624 u16 capability;
0625 u8 rates[MAX_RATES_LENGTH];
0626 u8 rates_len;
0627 u8 rates_ex[MAX_RATES_EX_LENGTH];
0628 u8 rates_ex_len;
0629 unsigned long last_scanned;
0630 u8 mode;
0631 u32 flags;
0632 u32 last_associate;
0633 u32 time_stamp[2];
0634 u16 beacon_interval;
0635 u16 listen_interval;
0636 u16 atim_window;
0637 u8 erp_value;
0638 u8 wpa_ie[MAX_WPA_IE_LEN];
0639 size_t wpa_ie_len;
0640 u8 rsn_ie[MAX_WPA_IE_LEN];
0641 size_t rsn_ie_len;
0642 struct libipw_tim_parameters tim;
0643
0644
0645
0646
0647 u8 power_constraint;
0648
0649
0650 struct libipw_tpc_report tpc_report;
0651
0652
0653 struct libipw_csa csa;
0654
0655
0656 struct libipw_quiet quiet;
0657
0658 struct list_head list;
0659 };
0660
0661 enum libipw_state {
0662 LIBIPW_UNINITIALIZED = 0,
0663 LIBIPW_INITIALIZED,
0664 LIBIPW_ASSOCIATING,
0665 LIBIPW_ASSOCIATED,
0666 LIBIPW_AUTHENTICATING,
0667 LIBIPW_AUTHENTICATED,
0668 LIBIPW_SHUTDOWN
0669 };
0670
0671 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
0672 #define DEFAULT_FTS 2346
0673
0674 #define CFG_LIBIPW_RESERVE_FCS (1<<0)
0675 #define CFG_LIBIPW_COMPUTE_FCS (1<<1)
0676 #define CFG_LIBIPW_RTS (1<<2)
0677
0678 #define LIBIPW_24GHZ_MIN_CHANNEL 1
0679 #define LIBIPW_24GHZ_MAX_CHANNEL 14
0680 #define LIBIPW_24GHZ_CHANNELS (LIBIPW_24GHZ_MAX_CHANNEL - \
0681 LIBIPW_24GHZ_MIN_CHANNEL + 1)
0682
0683 #define LIBIPW_52GHZ_MIN_CHANNEL 34
0684 #define LIBIPW_52GHZ_MAX_CHANNEL 165
0685 #define LIBIPW_52GHZ_CHANNELS (LIBIPW_52GHZ_MAX_CHANNEL - \
0686 LIBIPW_52GHZ_MIN_CHANNEL + 1)
0687
0688 enum {
0689 LIBIPW_CH_PASSIVE_ONLY = (1 << 0),
0690 LIBIPW_CH_80211H_RULES = (1 << 1),
0691 LIBIPW_CH_B_ONLY = (1 << 2),
0692 LIBIPW_CH_NO_IBSS = (1 << 3),
0693 LIBIPW_CH_UNIFORM_SPREADING = (1 << 4),
0694 LIBIPW_CH_RADAR_DETECT = (1 << 5),
0695 LIBIPW_CH_INVALID = (1 << 6),
0696 };
0697
0698 struct libipw_channel {
0699 u32 freq;
0700 u8 channel;
0701 u8 flags;
0702 u8 max_power;
0703 };
0704
0705 struct libipw_geo {
0706 u8 name[4];
0707 u8 bg_channels;
0708 u8 a_channels;
0709 struct libipw_channel bg[LIBIPW_24GHZ_CHANNELS];
0710 struct libipw_channel a[LIBIPW_52GHZ_CHANNELS];
0711 };
0712
0713 struct libipw_device {
0714 struct net_device *dev;
0715 struct wireless_dev wdev;
0716 struct libipw_security sec;
0717
0718
0719 struct libipw_stats ieee_stats;
0720
0721 struct libipw_geo geo;
0722 struct ieee80211_supported_band bg_band;
0723 struct ieee80211_supported_band a_band;
0724
0725
0726 struct list_head network_free_list;
0727 struct list_head network_list;
0728 struct libipw_network *networks[MAX_NETWORK_COUNT];
0729 int scans;
0730 int scan_age;
0731
0732 int iw_mode;
0733 struct iw_spy_data spy_data;
0734
0735 spinlock_t lock;
0736
0737 int tx_headroom;
0738
0739 u32 config;
0740
0741
0742 int open_wep;
0743
0744
0745 int host_encrypt;
0746 int host_encrypt_msdu;
0747 int host_decrypt;
0748
0749 int host_mc_decrypt;
0750
0751
0752
0753 int host_strip_iv_icv;
0754
0755 int host_open_frag;
0756 int ieee802_1x;
0757
0758
0759 int wpa_enabled;
0760 int drop_unencrypted;
0761 int privacy_invoked;
0762 size_t wpa_ie_len;
0763 u8 *wpa_ie;
0764
0765 struct lib80211_crypt_info crypt_info;
0766
0767 int bcrx_sta_key;
0768
0769
0770
0771 struct libipw_frag_entry frag_cache[LIBIPW_FRAG_CACHE_LEN];
0772 unsigned int frag_next_idx;
0773 u16 fts;
0774 u16 rts;
0775
0776
0777 u8 bssid[ETH_ALEN];
0778
0779 enum libipw_state state;
0780
0781 int mode;
0782 int modulation;
0783 int freq_band;
0784 int abg_true;
0785
0786 int perfect_rssi;
0787 int worst_rssi;
0788
0789 u16 prev_seq_ctl;
0790
0791
0792 void (*set_security) (struct net_device * dev,
0793 struct libipw_security * sec);
0794 netdev_tx_t (*hard_start_xmit) (struct libipw_txb * txb,
0795 struct net_device * dev, int pri);
0796 int (*is_queue_full) (struct net_device * dev, int pri);
0797
0798 int (*handle_management) (struct net_device * dev,
0799 struct libipw_network * network, u16 type);
0800 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
0801
0802
0803 int (*handle_auth) (struct net_device * dev,
0804 struct libipw_auth * auth);
0805 int (*handle_deauth) (struct net_device * dev,
0806 struct libipw_deauth * auth);
0807 int (*handle_action) (struct net_device * dev,
0808 struct libipw_action * action,
0809 struct libipw_rx_stats * stats);
0810 int (*handle_disassoc) (struct net_device * dev,
0811 struct libipw_disassoc * assoc);
0812 int (*handle_beacon) (struct net_device * dev,
0813 struct libipw_beacon * beacon,
0814 struct libipw_network * network);
0815 int (*handle_probe_response) (struct net_device * dev,
0816 struct libipw_probe_response * resp,
0817 struct libipw_network * network);
0818 int (*handle_probe_request) (struct net_device * dev,
0819 struct libipw_probe_request * req,
0820 struct libipw_rx_stats * stats);
0821 int (*handle_assoc_response) (struct net_device * dev,
0822 struct libipw_assoc_response * resp,
0823 struct libipw_network * network);
0824
0825
0826 int (*handle_assoc_request) (struct net_device * dev);
0827 int (*handle_reassoc_request) (struct net_device * dev,
0828 struct libipw_reassoc_request * req);
0829
0830
0831
0832 u8 priv[];
0833 };
0834
0835 #define IEEE_A (1<<0)
0836 #define IEEE_B (1<<1)
0837 #define IEEE_G (1<<2)
0838 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
0839
0840 static inline void *libipw_priv(struct net_device *dev)
0841 {
0842 return ((struct libipw_device *)netdev_priv(dev))->priv;
0843 }
0844
0845 static inline int libipw_is_valid_mode(struct libipw_device *ieee,
0846 int mode)
0847 {
0848
0849
0850
0851
0852
0853
0854 if ((mode & IEEE_A) &&
0855 (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
0856 (ieee->freq_band & LIBIPW_52GHZ_BAND))
0857 return 1;
0858
0859 if ((mode & IEEE_G) &&
0860 (ieee->modulation & LIBIPW_OFDM_MODULATION) &&
0861 (ieee->freq_band & LIBIPW_24GHZ_BAND))
0862 return 1;
0863
0864 if ((mode & IEEE_B) &&
0865 (ieee->modulation & LIBIPW_CCK_MODULATION) &&
0866 (ieee->freq_band & LIBIPW_24GHZ_BAND))
0867 return 1;
0868
0869 return 0;
0870 }
0871
0872 static inline int libipw_get_hdrlen(u16 fc)
0873 {
0874 int hdrlen = LIBIPW_3ADDR_LEN;
0875 u16 stype = WLAN_FC_GET_STYPE(fc);
0876
0877 switch (WLAN_FC_GET_TYPE(fc)) {
0878 case IEEE80211_FTYPE_DATA:
0879 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
0880 hdrlen = LIBIPW_4ADDR_LEN;
0881 if (stype & IEEE80211_STYPE_QOS_DATA)
0882 hdrlen += 2;
0883 break;
0884 case IEEE80211_FTYPE_CTL:
0885 switch (WLAN_FC_GET_STYPE(fc)) {
0886 case IEEE80211_STYPE_CTS:
0887 case IEEE80211_STYPE_ACK:
0888 hdrlen = LIBIPW_1ADDR_LEN;
0889 break;
0890 default:
0891 hdrlen = LIBIPW_2ADDR_LEN;
0892 break;
0893 }
0894 break;
0895 }
0896
0897 return hdrlen;
0898 }
0899
0900 static inline u8 *libipw_get_payload(struct ieee80211_hdr *hdr)
0901 {
0902 switch (libipw_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
0903 case LIBIPW_1ADDR_LEN:
0904 return ((struct libipw_hdr_1addr *)hdr)->payload;
0905 case LIBIPW_2ADDR_LEN:
0906 return ((struct libipw_hdr_2addr *)hdr)->payload;
0907 case LIBIPW_3ADDR_LEN:
0908 return ((struct libipw_hdr_3addr *)hdr)->payload;
0909 case LIBIPW_4ADDR_LEN:
0910 return ((struct libipw_hdr_4addr *)hdr)->payload;
0911 }
0912 return NULL;
0913 }
0914
0915 static inline int libipw_is_ofdm_rate(u8 rate)
0916 {
0917 switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
0918 case LIBIPW_OFDM_RATE_6MB:
0919 case LIBIPW_OFDM_RATE_9MB:
0920 case LIBIPW_OFDM_RATE_12MB:
0921 case LIBIPW_OFDM_RATE_18MB:
0922 case LIBIPW_OFDM_RATE_24MB:
0923 case LIBIPW_OFDM_RATE_36MB:
0924 case LIBIPW_OFDM_RATE_48MB:
0925 case LIBIPW_OFDM_RATE_54MB:
0926 return 1;
0927 }
0928 return 0;
0929 }
0930
0931 static inline int libipw_is_cck_rate(u8 rate)
0932 {
0933 switch (rate & ~LIBIPW_BASIC_RATE_MASK) {
0934 case LIBIPW_CCK_RATE_1MB:
0935 case LIBIPW_CCK_RATE_2MB:
0936 case LIBIPW_CCK_RATE_5MB:
0937 case LIBIPW_CCK_RATE_11MB:
0938 return 1;
0939 }
0940 return 0;
0941 }
0942
0943
0944 void free_libipw(struct net_device *dev, int monitor);
0945 struct net_device *alloc_libipw(int sizeof_priv, int monitor);
0946
0947 void libipw_networks_age(struct libipw_device *ieee, unsigned long age_secs);
0948
0949 int libipw_set_encryption(struct libipw_device *ieee);
0950
0951
0952 netdev_tx_t libipw_xmit(struct sk_buff *skb, struct net_device *dev);
0953 void libipw_txb_free(struct libipw_txb *);
0954
0955
0956 void libipw_rx_any(struct libipw_device *ieee, struct sk_buff *skb,
0957 struct libipw_rx_stats *stats);
0958 int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
0959 struct libipw_rx_stats *rx_stats);
0960
0961 void libipw_rx_mgt(struct libipw_device *ieee, struct libipw_hdr_4addr *header,
0962 struct libipw_rx_stats *stats);
0963
0964
0965 const struct libipw_geo *libipw_get_geo(struct libipw_device *ieee);
0966 void libipw_set_geo(struct libipw_device *ieee, const struct libipw_geo *geo);
0967
0968 int libipw_is_valid_channel(struct libipw_device *ieee, u8 channel);
0969 int libipw_channel_to_index(struct libipw_device *ieee, u8 channel);
0970 u8 libipw_freq_to_channel(struct libipw_device *ieee, u32 freq);
0971 u8 libipw_get_channel_flags(struct libipw_device *ieee, u8 channel);
0972 const struct libipw_channel *libipw_get_channel(struct libipw_device *ieee,
0973 u8 channel);
0974 u32 libipw_channel_to_freq(struct libipw_device *ieee, u8 channel);
0975
0976
0977 int libipw_wx_get_scan(struct libipw_device *ieee, struct iw_request_info *info,
0978 union iwreq_data *wrqu, char *key);
0979 int libipw_wx_set_encode(struct libipw_device *ieee,
0980 struct iw_request_info *info, union iwreq_data *wrqu,
0981 char *key);
0982 int libipw_wx_get_encode(struct libipw_device *ieee,
0983 struct iw_request_info *info, union iwreq_data *wrqu,
0984 char *key);
0985 int libipw_wx_set_encodeext(struct libipw_device *ieee,
0986 struct iw_request_info *info,
0987 union iwreq_data *wrqu, char *extra);
0988 int libipw_wx_get_encodeext(struct libipw_device *ieee,
0989 struct iw_request_info *info,
0990 union iwreq_data *wrqu, char *extra);
0991
0992 static inline void libipw_increment_scans(struct libipw_device *ieee)
0993 {
0994 ieee->scans++;
0995 }
0996
0997 static inline int libipw_get_scans(struct libipw_device *ieee)
0998 {
0999 return ieee->scans;
1000 }
1001
1002 #endif