John W. Linville | 7e272fc | 2008-09-24 18:13:14 -0400 | [diff] [blame] | 1 | /* |
| 2 | * lib80211.h -- common bits for IEEE802.11 wireless drivers |
| 3 | * |
| 4 | * Copyright (c) 2008, John W. Linville <linville@tuxdriver.com> |
| 5 | * |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 6 | * Some bits copied from old ieee80211 component, w/ original copyright |
| 7 | * notices below: |
| 8 | * |
| 9 | * Original code based on Host AP (software wireless LAN access point) driver |
| 10 | * for Intersil Prism2/2.5/3. |
| 11 | * |
| 12 | * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen |
| 13 | * <j@w1.fi> |
| 14 | * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi> |
| 15 | * |
| 16 | * Adaption to a generic IEEE 802.11 stack by James Ketrenos |
| 17 | * <jketreno@linux.intel.com> |
| 18 | * |
| 19 | * Copyright (c) 2004, Intel Corporation |
| 20 | * |
John W. Linville | 7e272fc | 2008-09-24 18:13:14 -0400 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #ifndef LIB80211_H |
| 24 | #define LIB80211_H |
| 25 | |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 26 | #include <linux/types.h> |
| 27 | #include <linux/list.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 28 | #include <linux/atomic.h> |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 29 | #include <linux/if.h> |
| 30 | #include <linux/skbuff.h> |
John W. Linville | 7211801 | 2008-09-30 21:43:03 -0400 | [diff] [blame] | 31 | #include <linux/ieee80211.h> |
Rami Rosen | a1eb5fe | 2008-11-19 09:37:43 +0200 | [diff] [blame] | 32 | #include <linux/timer.h> |
David Howells | 6bbefe8 | 2013-04-10 21:13:23 +0100 | [diff] [blame] | 33 | #include <linux/seq_file.h> |
| 34 | |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 35 | /* print_ssid() is intended to be used in debug (and possibly error) |
John W. Linville | 7e272fc | 2008-09-24 18:13:14 -0400 | [diff] [blame] | 36 | * messages. It should never be used for passing ssid to user space. */ |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 37 | const char *print_ssid(char *buf, const char *ssid, u8 ssid_len); |
John W. Linville | 7211801 | 2008-09-30 21:43:03 -0400 | [diff] [blame] | 38 | #define DECLARE_SSID_BUF(var) char var[IEEE80211_MAX_SSID_LEN * 4 + 1] __maybe_unused |
John W. Linville | 7e272fc | 2008-09-24 18:13:14 -0400 | [diff] [blame] | 39 | |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 40 | #define NUM_WEP_KEYS 4 |
| 41 | |
| 42 | enum { |
| 43 | IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), |
| 44 | }; |
| 45 | |
Paul Gortmaker | de47725 | 2011-05-26 13:46:22 -0400 | [diff] [blame] | 46 | struct module; |
| 47 | |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 48 | struct lib80211_crypto_ops { |
| 49 | const char *name; |
| 50 | struct list_head list; |
| 51 | |
| 52 | /* init new crypto context (e.g., allocate private data space, |
| 53 | * select IV, etc.); returns NULL on failure or pointer to allocated |
| 54 | * private data on success */ |
| 55 | void *(*init) (int keyidx); |
| 56 | |
| 57 | /* deinitialize crypto context and free allocated private data */ |
| 58 | void (*deinit) (void *priv); |
| 59 | |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 60 | /* encrypt/decrypt return < 0 on error or >= 0 on success. The return |
| 61 | * value from decrypt_mpdu is passed as the keyidx value for |
| 62 | * decrypt_msdu. skb must have enough head and tail room for the |
| 63 | * encryption; if not, error will be returned; these functions are |
| 64 | * called for all MPDUs (i.e., fragments). |
| 65 | */ |
| 66 | int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); |
| 67 | int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); |
| 68 | |
| 69 | /* These functions are called for full MSDUs, i.e. full frames. |
| 70 | * These can be NULL if full MSDU operations are not needed. */ |
| 71 | int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv); |
| 72 | int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len, |
| 73 | void *priv); |
| 74 | |
| 75 | int (*set_key) (void *key, int len, u8 * seq, void *priv); |
| 76 | int (*get_key) (void *key, int len, u8 * seq, void *priv); |
| 77 | |
| 78 | /* procfs handler for printing out key information and possible |
| 79 | * statistics */ |
David Howells | 6bbefe8 | 2013-04-10 21:13:23 +0100 | [diff] [blame] | 80 | void (*print_stats) (struct seq_file *m, void *priv); |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 81 | |
| 82 | /* Crypto specific flag get/set for configuration settings */ |
| 83 | unsigned long (*get_flags) (void *priv); |
| 84 | unsigned long (*set_flags) (unsigned long flags, void *priv); |
| 85 | |
| 86 | /* maximum number of bytes added by encryption; encrypt buf is |
| 87 | * allocated with extra_prefix_len bytes, copy of in_buf, and |
| 88 | * extra_postfix_len; encrypt need not use all this space, but |
| 89 | * the result must start at the beginning of the buffer and correct |
| 90 | * length must be returned */ |
| 91 | int extra_mpdu_prefix_len, extra_mpdu_postfix_len; |
| 92 | int extra_msdu_prefix_len, extra_msdu_postfix_len; |
| 93 | |
| 94 | struct module *owner; |
| 95 | }; |
| 96 | |
| 97 | struct lib80211_crypt_data { |
| 98 | struct list_head list; /* delayed deletion list */ |
| 99 | struct lib80211_crypto_ops *ops; |
| 100 | void *priv; |
| 101 | atomic_t refcnt; |
| 102 | }; |
| 103 | |
| 104 | struct lib80211_crypt_info { |
| 105 | char *name; |
| 106 | /* Most clients will already have a lock, |
| 107 | so just point to that. */ |
| 108 | spinlock_t *lock; |
| 109 | |
| 110 | struct lib80211_crypt_data *crypt[NUM_WEP_KEYS]; |
| 111 | int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ |
| 112 | struct list_head crypt_deinit_list; |
| 113 | struct timer_list crypt_deinit_timer; |
| 114 | int crypt_quiesced; |
| 115 | }; |
| 116 | |
John W. Linville | 2ba4b32 | 2008-11-11 16:00:06 -0500 | [diff] [blame] | 117 | int lib80211_crypt_info_init(struct lib80211_crypt_info *info, char *name, |
| 118 | spinlock_t *lock); |
| 119 | void lib80211_crypt_info_free(struct lib80211_crypt_info *info); |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 120 | int lib80211_register_crypto_ops(struct lib80211_crypto_ops *ops); |
| 121 | int lib80211_unregister_crypto_ops(struct lib80211_crypto_ops *ops); |
| 122 | struct lib80211_crypto_ops *lib80211_get_crypto_ops(const char *name); |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 123 | void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info, |
| 124 | struct lib80211_crypt_data **crypt); |
John W. Linville | 274bfb8 | 2008-10-29 11:35:05 -0400 | [diff] [blame] | 125 | |
John W. Linville | 7e272fc | 2008-09-24 18:13:14 -0400 | [diff] [blame] | 126 | #endif /* LIB80211_H */ |