/* SPDX-License-Identifier: GPL-2.0-only */ /* * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11 * remains copyright by the original authors * * Portions of the merged code are based on Host AP (software wireless * LAN access point) driver for Intersil Prism2/2.5/3. * * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen * <j@w1.fi> * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi> * * Adaption to a generic IEEE 802.11 stack by James Ketrenos * <jketreno@linux.intel.com> * Copyright (c) 2004-2005, Intel Corporation * * API Version History * 1.0.x -- Initial version * 1.1.x -- Added radiotap, QoS, TIM, libipw_geo APIs, * various structure changes, and crypto API init method
*/ #ifndef LIBIPW_H #define LIBIPW_H #include <linux/if_ether.h> /* ETH_ALEN */ #include <linux/kernel.h> /* ARRAY_SIZE */ #include <linux/wireless.h> #include <linux/ieee80211.h> #include <net/cfg80211.h>
#define LIBIPW_VERSION "git-1.1.13"
#define LIBIPW_DATA_LEN 2304 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 6.2.1.1.2.
The figure in section 7.1.2 suggests a body size of up to 2312 bytes is allowed, which is a bit confusing, I suspect this represents the 2304 bytes of real data, plus a possible 8 bytes of
WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
#ifdef CONFIG_LIBIPW_DEBUG extern u32 libipw_debug_level; #define LIBIPW_DEBUG(level, fmt, args...) \ do { if (libipw_debug_level & (level)) \
printk(KERN_DEBUG "libipw: %s " fmt, __func__ , ## args); } while (0) #else #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0) #endif/* CONFIG_LIBIPW_DEBUG */
/* * To use the debug system: * * If you are defining a new debug classification, simply add it to the #define * list here in the form of: * * #define LIBIPW_DL_xxxx VALUE * * shifting value to the left one bit from the previous entry. xxxx should be * the name of the classification (for example, WEP) * * You then need to either add a LIBIPW_xxxx_DEBUG() macro definition for your * classification, or use LIBIPW_DEBUG(LIBIPW_DL_xxxx, ...) whenever you want * to send output to that classification. * * To add your debug level to the list of levels seen when you perform * * % cat /proc/net/ieee80211/debug_level * * you simply need to add your entry to the libipw_debug_level array. * * If you do not see debug_level in /proc/net/ieee80211 then you do not have * CONFIG_LIBIPW_DEBUG defined in your kernel configuration *
*/
/* NOTE: This data is for statistical purposes; not all hardware provides this * information for frames received. * For libipw_rx_mgt, you need to set at least the 'len' parameter.
*/ struct libipw_rx_stats {
u32 mac_time;
s8 rssi;
u8 signal;
u8 noise;
u16 rate; /* in 100 kbps */
u8 received_channel;
u8 control;
u8 mask;
u8 freq;
u16 len;
u64 tsf;
u32 beacon_time;
};
/* IEEE 802.11 requires that STA supports concurrent reception of at least * three fragmented frames. This define can be increased to support more * concurrent frames, but it should be noted that each entry can consume about
* 2 kB of RAM and increasing cache size will slow down frame reassembly. */ #define LIBIPW_FRAG_CACHE_LEN 4
/* * These are the data types that can make up management packets * u16 auth_algorithm; u16 auth_sequence; u16 beacon_interval; u16 capability; u8 current_ap[ETH_ALEN]; u16 listen_interval; struct { u16 association_id:14, reserved:2; } __packed; u32 time_stamp[2]; u16 reason; u16 status;
*/
/* SWEEP TABLE ENTRIES NUMBER */ #define MAX_SWEEP_TAB_ENTRIES 42 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the
* main rates information element... */ #define MAX_RATES_LENGTH ((u8)12) #define MAX_RATES_EX_LENGTH ((u8)16) #define MAX_NETWORK_COUNT 128
struct libipw_network { /* These entries are used to identify a unique network */
u8 bssid[ETH_ALEN];
u8 channel; /* Ensure null-terminated for any debug msgs */
u8 ssid[IW_ESSID_MAX_SIZE + 1];
u8 ssid_len;
/* init new crypto context (e.g., allocate private data space, * select IV, etc.); returns NULL on failure or pointer to allocated
* private data on success */ void *(*init) (int keyidx);
/* deinitialize crypto context and free allocated private data */ void (*deinit) (void *priv);
/* encrypt/decrypt return < 0 on error or >= 0 on success. The return * value from decrypt_mpdu is passed as the keyidx value for * decrypt_msdu. skb must have enough head and tail room for the * encryption; if not, error will be returned; these functions are * called for all MPDUs (i.e., fragments).
*/ int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
/* These functions are called for full MSDUs, i.e. full frames.
* These can be NULL if full MSDU operations are not needed. */ int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv); int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len, void *priv);
int (*set_key) (void *key, int len, u8 * seq, void *priv); int (*get_key) (void *key, int len, u8 * seq, void *priv);
/* procfs handler for printing out key information and possible
* statistics */ void (*print_stats) (struct seq_file *m, void *priv);
/* Crypto specific flag get/set for configuration settings */ unsignedlong (*get_flags) (void *priv); unsignedlong (*set_flags) (unsignedlong flags, void *priv);
/* maximum number of bytes added by encryption; encrypt buf is * allocated with extra_prefix_len bytes, copy of in_buf, and * extra_postfix_len; encrypt need not use all this space, but * the result must start at the beginning of the buffer and correct
* length must be returned */ int extra_mpdu_prefix_len, extra_mpdu_postfix_len; int extra_msdu_prefix_len, extra_msdu_postfix_len;
struct module *owner;
};
struct libipw_crypt_info { char *name; /* Most clients will already have a lock,
so just point to that. */
spinlock_t *lock;
struct libipw_crypt_data *crypt[NUM_WEP_KEYS]; int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ struct list_head crypt_deinit_list; struct timer_list crypt_deinit_timer; int crypt_quiesced;
};
/* Probe / Beacon management */ struct list_head network_free_list; struct list_head network_list; struct libipw_network *networks[MAX_NETWORK_COUNT]; int scans; int scan_age;
int iw_mode; /* operating mode (IW_MODE_*) */ struct iw_spy_data spy_data; /* iwspy support */ bool spy_enabled;
spinlock_t lock;
int tx_headroom; /* Set to size of any additional room needed at front
* of allocated Tx SKBs */
u32 config;
/* WEP and other encryption related settings at the device level */ int open_wep; /* Set to 1 to allow unencrypted frames */
/* If the host performs {en,de}cryption, then set to 1 */ int host_encrypt; int host_encrypt_msdu; int host_decrypt; /* host performs multicast decryption */ int host_mc_decrypt;
/* host should strip IV and ICV from protected frames */ /* meaningful only when hardware decryption is being used */ int host_strip_iv_icv;
int host_open_frag; int ieee802_1x; /* is IEEE 802.1X used */
/* WPA data */ int wpa_enabled; int drop_unencrypted; int privacy_invoked;
size_t wpa_ie_len;
u8 *wpa_ie;
struct libipw_crypt_info crypt_info;
int bcrx_sta_key; /* use individual keys to override default keys even
* with RX of broad/multicast frames */
staticinlineint libipw_is_valid_mode(struct libipw_device *ieee, int mode)
{ /* * It is possible for both access points and our device to support * combinations of modes, so as long as there is one valid combination * of ap/device supported modes, then return success *
*/ if ((mode & IEEE_A) &&
(ieee->modulation & LIBIPW_OFDM_MODULATION) &&
(ieee->freq_band & LIBIPW_52GHZ_BAND)) return 1;
switch (WLAN_FC_GET_TYPE(fc)) { case IEEE80211_FTYPE_DATA: if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
hdrlen = LIBIPW_4ADDR_LEN; if (stype & IEEE80211_STYPE_QOS_DATA)
hdrlen += 2; break; case IEEE80211_FTYPE_CTL: switch (WLAN_FC_GET_STYPE(fc)) { case IEEE80211_STYPE_CTS: case IEEE80211_STYPE_ACK:
hdrlen = LIBIPW_1ADDR_LEN; break; default:
hdrlen = LIBIPW_2ADDR_LEN; break;
} break;
}
return hdrlen;
}
staticinline u8 *libipw_get_payload(struct ieee80211_hdr *hdr)
{ switch (libipw_get_hdrlen(le16_to_cpu(hdr->frame_control))) { case LIBIPW_1ADDR_LEN: return ((struct libipw_hdr_1addr *)hdr)->payload; case LIBIPW_2ADDR_LEN: return ((struct libipw_hdr_2addr *)hdr)->payload; case LIBIPW_3ADDR_LEN: return ((struct libipw_hdr_3addr *)hdr)->payload; case LIBIPW_4ADDR_LEN: return ((struct libipw_hdr_4addr *)hdr)->payload;
} return NULL;
}
staticinlineint libipw_is_ofdm_rate(u8 rate)
{ switch (rate & ~LIBIPW_BASIC_RATE_MASK) { case LIBIPW_OFDM_RATE_6MB: case LIBIPW_OFDM_RATE_9MB: case LIBIPW_OFDM_RATE_12MB: case LIBIPW_OFDM_RATE_18MB: case LIBIPW_OFDM_RATE_24MB: case LIBIPW_OFDM_RATE_36MB: case LIBIPW_OFDM_RATE_48MB: case LIBIPW_OFDM_RATE_54MB: return 1;
} return 0;
}
staticinlineint libipw_is_cck_rate(u8 rate)
{ switch (rate & ~LIBIPW_BASIC_RATE_MASK) { case LIBIPW_CCK_RATE_1MB: case LIBIPW_CCK_RATE_2MB: case LIBIPW_CCK_RATE_5MB: case LIBIPW_CCK_RATE_11MB: return 1;
} return 0;
}
/* libipw.c */ void free_libipw(struct net_device *dev, int monitor); struct net_device *alloc_libipw(int sizeof_priv, int monitor);
/* must be called in the listed order */ int libipw_crypto_init(void); int libipw_crypto_ccmp_init(void); int libipw_crypto_tkip_init(void); int libipw_crypto_wep_init(void);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.