This commit was generated by cvs2svn to compensate for changes in r925,
[linux-2.6.git] / drivers / net / wireless / ieee80211 / ieee80211_crypt.h
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  * <jkmaline@cc.hut.fi>
7  * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.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 #ifdef CONFIG_IEEE80211_CRYPT_MODULE
27 #ifndef CONFIG_IEEE80211_CRYPT
28 #define CONFIG_IEEE80211_CRYPT
29 #endif
30 #endif
31
32 #ifdef CONFIG_IEEE80211_CRYPT
33 #include <linux/skbuff.h>
34
35 struct ieee80211_crypto_ops {
36         const char *name;
37
38         /* init new crypto context (e.g., allocate private data space,
39          * select IV, etc.); returns NULL on failure or pointer to allocated
40          * private data on success */
41         void * (*init)(int keyidx);
42
43         /* deinitialize crypto context and free allocated private data */
44         void (*deinit)(void *priv);
45
46         /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
47          * value from decrypt_mpdu is passed as the keyidx value for
48          * decrypt_msdu. skb must have enough head and tail room for the
49          * encryption; if not, error will be returned; these functions are
50          * called for all MPDUs (i.e., fragments).
51          */
52         int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
53         int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
54
55         /* These functions are called for full MSDUs, i.e. full frames.
56          * These can be NULL if full MSDU operations are not needed. */
57         int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
58         int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
59                             void *priv);
60
61         int (*set_key)(void *key, int len, u8 *seq, void *priv);
62         int (*get_key)(void *key, int len, u8 *seq, void *priv);
63
64         /* procfs handler for printing out key information and possible
65          * statistics */
66         char * (*print_stats)(char *p, void *priv);
67
68         /* maximum number of bytes added by encryption; encrypt buf is
69          * allocated with extra_prefix_len bytes, copy of in_buf, and
70          * extra_postfix_len; encrypt need not use all this space, but
71          * the result must start at the beginning of the buffer and correct
72          * length must be returned */
73         int extra_prefix_len, extra_postfix_len;
74
75         struct module *owner;
76 };
77
78 struct ieee80211_crypt_data {
79         struct list_head list; /* delayed deletion list */
80         struct ieee80211_crypto_ops *ops;
81         void *priv;
82         atomic_t refcnt;
83 };
84
85 int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
86 int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
87 struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
88 void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
89 void ieee80211_crypt_deinit_handler(unsigned long);
90 void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
91                                     struct ieee80211_crypt_data **crypt);
92
93 #else
94
95 struct ieee80211_crypt_data {
96         struct list_head list; /* delayed deletion list */
97         void *ops;
98         void *priv;
99         atomic_t refcnt;
100 };
101
102 #endif /* CONFIG_IEEE80211_NOWEP */
103
104 #endif