diff options
author | John W. Linville <linville@tuxdriver.com> | 2008-10-29 11:35:05 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-11-21 11:08:17 -0500 |
commit | 274bfb8dc5ffa16cb073801bebe76ab7f4e2e73d (patch) | |
tree | 04cd3f6a062496911b56737daa6a0858b769ccd6 /include | |
parent | dfe1bafdbac1c7b48b636fb7ace799e78170e0d6 (diff) |
lib80211: absorb crypto bits from net/ieee80211
These bits are shared already between ipw2x00 and hostap, and could
probably be shared both more cleanly and with other drivers. This
commit simply relocates the code to lib80211 and adjusts the drivers
appropriately.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/ieee80211.h | 10 | ||||
-rw-r--r-- | include/net/ieee80211_crypt.h | 108 | ||||
-rw-r--r-- | include/net/lib80211.h | 108 |
3 files changed, 111 insertions, 115 deletions
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h index 738734a4653b..7ab3ed2bbccb 100644 --- a/include/net/ieee80211.h +++ b/include/net/ieee80211.h | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <linux/wireless.h> | 30 | #include <linux/wireless.h> |
31 | #include <linux/ieee80211.h> | 31 | #include <linux/ieee80211.h> |
32 | 32 | ||
33 | #include <net/lib80211.h> | ||
34 | |||
33 | #define IEEE80211_VERSION "git-1.1.13" | 35 | #define IEEE80211_VERSION "git-1.1.13" |
34 | 36 | ||
35 | #define IEEE80211_DATA_LEN 2304 | 37 | #define IEEE80211_DATA_LEN 2304 |
@@ -355,8 +357,6 @@ struct ieee80211_stats { | |||
355 | 357 | ||
356 | struct ieee80211_device; | 358 | struct ieee80211_device; |
357 | 359 | ||
358 | #include "ieee80211_crypt.h" | ||
359 | |||
360 | #define SEC_KEY_1 (1<<0) | 360 | #define SEC_KEY_1 (1<<0) |
361 | #define SEC_KEY_2 (1<<1) | 361 | #define SEC_KEY_2 (1<<1) |
362 | #define SEC_KEY_3 (1<<2) | 362 | #define SEC_KEY_3 (1<<2) |
@@ -937,11 +937,7 @@ struct ieee80211_device { | |||
937 | size_t wpa_ie_len; | 937 | size_t wpa_ie_len; |
938 | u8 *wpa_ie; | 938 | u8 *wpa_ie; |
939 | 939 | ||
940 | struct list_head crypt_deinit_list; | 940 | struct lib80211_crypt_info crypt_info; |
941 | struct ieee80211_crypt_data *crypt[WEP_KEYS]; | ||
942 | int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ | ||
943 | struct timer_list crypt_deinit_timer; | ||
944 | int crypt_quiesced; | ||
945 | 941 | ||
946 | int bcrx_sta_key; /* use individual keys to override default keys even | 942 | int bcrx_sta_key; /* use individual keys to override default keys even |
947 | * with RX of broad/multicast frames */ | 943 | * with RX of broad/multicast frames */ |
diff --git a/include/net/ieee80211_crypt.h b/include/net/ieee80211_crypt.h deleted file mode 100644 index b3d65e0bedd3..000000000000 --- a/include/net/ieee80211_crypt.h +++ /dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | /* | ||
2 | * Original code based on Host AP (software wireless LAN access point) driver | ||
3 | * for Intersil Prism2/2.5/3. | ||
4 | * | ||
5 | * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen | ||
6 | * <j@w1.fi> | ||
7 | * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi> | ||
8 | * | ||
9 | * Adaption to a generic IEEE 802.11 stack by James Ketrenos | ||
10 | * <jketreno@linux.intel.com> | ||
11 | * | ||
12 | * Copyright (c) 2004, Intel Corporation | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. See README and COPYING for | ||
17 | * more details. | ||
18 | */ | ||
19 | |||
20 | /* | ||
21 | * This file defines the interface to the ieee80211 crypto module. | ||
22 | */ | ||
23 | #ifndef IEEE80211_CRYPT_H | ||
24 | #define IEEE80211_CRYPT_H | ||
25 | |||
26 | #include <linux/types.h> | ||
27 | #include <linux/list.h> | ||
28 | #include <net/ieee80211.h> | ||
29 | #include <asm/atomic.h> | ||
30 | |||
31 | enum { | ||
32 | IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), | ||
33 | }; | ||
34 | |||
35 | struct sk_buff; | ||
36 | struct module; | ||
37 | |||
38 | struct ieee80211_crypto_ops { | ||
39 | const char *name; | ||
40 | struct list_head list; | ||
41 | |||
42 | /* init new crypto context (e.g., allocate private data space, | ||
43 | * select IV, etc.); returns NULL on failure or pointer to allocated | ||
44 | * private data on success */ | ||
45 | void *(*init) (int keyidx); | ||
46 | |||
47 | /* deinitialize crypto context and free allocated private data */ | ||
48 | void (*deinit) (void *priv); | ||
49 | |||
50 | int (*build_iv) (struct sk_buff * skb, int hdr_len, | ||
51 | u8 *key, int keylen, void *priv); | ||
52 | |||
53 | /* encrypt/decrypt return < 0 on error or >= 0 on success. The return | ||
54 | * value from decrypt_mpdu is passed as the keyidx value for | ||
55 | * decrypt_msdu. skb must have enough head and tail room for the | ||
56 | * encryption; if not, error will be returned; these functions are | ||
57 | * called for all MPDUs (i.e., fragments). | ||
58 | */ | ||
59 | int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); | ||
60 | int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); | ||
61 | |||
62 | /* These functions are called for full MSDUs, i.e. full frames. | ||
63 | * These can be NULL if full MSDU operations are not needed. */ | ||
64 | int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv); | ||
65 | int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len, | ||
66 | void *priv); | ||
67 | |||
68 | int (*set_key) (void *key, int len, u8 * seq, void *priv); | ||
69 | int (*get_key) (void *key, int len, u8 * seq, void *priv); | ||
70 | |||
71 | /* procfs handler for printing out key information and possible | ||
72 | * statistics */ | ||
73 | char *(*print_stats) (char *p, void *priv); | ||
74 | |||
75 | /* Crypto specific flag get/set for configuration settings */ | ||
76 | unsigned long (*get_flags) (void *priv); | ||
77 | unsigned long (*set_flags) (unsigned long flags, void *priv); | ||
78 | |||
79 | /* maximum number of bytes added by encryption; encrypt buf is | ||
80 | * allocated with extra_prefix_len bytes, copy of in_buf, and | ||
81 | * extra_postfix_len; encrypt need not use all this space, but | ||
82 | * the result must start at the beginning of the buffer and correct | ||
83 | * length must be returned */ | ||
84 | int extra_mpdu_prefix_len, extra_mpdu_postfix_len; | ||
85 | int extra_msdu_prefix_len, extra_msdu_postfix_len; | ||
86 | |||
87 | struct module *owner; | ||
88 | }; | ||
89 | |||
90 | struct ieee80211_crypt_data { | ||
91 | struct list_head list; /* delayed deletion list */ | ||
92 | struct ieee80211_crypto_ops *ops; | ||
93 | void *priv; | ||
94 | atomic_t refcnt; | ||
95 | }; | ||
96 | |||
97 | struct ieee80211_device; | ||
98 | |||
99 | int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); | ||
100 | int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); | ||
101 | struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name); | ||
102 | void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); | ||
103 | void ieee80211_crypt_deinit_handler(unsigned long); | ||
104 | void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, | ||
105 | struct ieee80211_crypt_data **crypt); | ||
106 | void ieee80211_crypt_quiescing(struct ieee80211_device *ieee); | ||
107 | |||
108 | #endif | ||
diff --git a/include/net/lib80211.h b/include/net/lib80211.h index e1558a187ac0..dd1079f98da4 100644 --- a/include/net/lib80211.h +++ b/include/net/lib80211.h | |||
@@ -3,11 +3,32 @@ | |||
3 | * | 3 | * |
4 | * Copyright (c) 2008, John W. Linville <linville@tuxdriver.com> | 4 | * Copyright (c) 2008, John W. Linville <linville@tuxdriver.com> |
5 | * | 5 | * |
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 | * | ||
6 | */ | 21 | */ |
7 | 22 | ||
8 | #ifndef LIB80211_H | 23 | #ifndef LIB80211_H |
9 | #define LIB80211_H | 24 | #define LIB80211_H |
10 | 25 | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/list.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <asm/atomic.h> | ||
30 | #include <linux/if.h> | ||
31 | #include <linux/skbuff.h> | ||
11 | #include <linux/ieee80211.h> | 32 | #include <linux/ieee80211.h> |
12 | 33 | ||
13 | /* print_ssid() is intended to be used in debug (and possibly error) | 34 | /* print_ssid() is intended to be used in debug (and possibly error) |
@@ -15,4 +36,91 @@ | |||
15 | const char *print_ssid(char *buf, const char *ssid, u8 ssid_len); | 36 | const char *print_ssid(char *buf, const char *ssid, u8 ssid_len); |
16 | #define DECLARE_SSID_BUF(var) char var[IEEE80211_MAX_SSID_LEN * 4 + 1] __maybe_unused | 37 | #define DECLARE_SSID_BUF(var) char var[IEEE80211_MAX_SSID_LEN * 4 + 1] __maybe_unused |
17 | 38 | ||
39 | #define NUM_WEP_KEYS 4 | ||
40 | |||
41 | enum { | ||
42 | IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), | ||
43 | }; | ||
44 | |||
45 | struct lib80211_crypto_ops { | ||
46 | const char *name; | ||
47 | struct list_head list; | ||
48 | |||
49 | /* init new crypto context (e.g., allocate private data space, | ||
50 | * select IV, etc.); returns NULL on failure or pointer to allocated | ||
51 | * private data on success */ | ||
52 | void *(*init) (int keyidx); | ||
53 | |||
54 | /* deinitialize crypto context and free allocated private data */ | ||
55 | void (*deinit) (void *priv); | ||
56 | |||
57 | int (*build_iv) (struct sk_buff * skb, int hdr_len, | ||
58 | u8 *key, int keylen, void *priv); | ||
59 | |||
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 */ | ||
80 | char *(*print_stats) (char *p, void *priv); | ||
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 | |||
117 | int lib80211_register_crypto_ops(struct lib80211_crypto_ops *ops); | ||
118 | int lib80211_unregister_crypto_ops(struct lib80211_crypto_ops *ops); | ||
119 | struct lib80211_crypto_ops *lib80211_get_crypto_ops(const char *name); | ||
120 | void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *, int); | ||
121 | void lib80211_crypt_deinit_handler(unsigned long); | ||
122 | void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info, | ||
123 | struct lib80211_crypt_data **crypt); | ||
124 | void lib80211_crypt_quiescing(struct lib80211_crypt_info *info); | ||
125 | |||
18 | #endif /* LIB80211_H */ | 126 | #endif /* LIB80211_H */ |