]>
Commit | Line | Data |
---|---|---|
7e272fcf JL |
1 | /* |
2 | * lib80211.h -- common bits for IEEE802.11 wireless drivers | |
3 | * | |
4 | * Copyright (c) 2008, John W. Linville <[email protected]> | |
5 | * | |
274bfb8d JL |
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 | * <[email protected]> | |
14 | * Copyright (c) 2002-2003, Jouni Malinen <[email protected]> | |
15 | * | |
16 | * Adaption to a generic IEEE 802.11 stack by James Ketrenos | |
17 | * <[email protected]> | |
18 | * | |
19 | * Copyright (c) 2004, Intel Corporation | |
20 | * | |
7e272fcf JL |
21 | */ |
22 | ||
23 | #ifndef LIB80211_H | |
24 | #define LIB80211_H | |
25 | ||
274bfb8d JL |
26 | #include <linux/types.h> |
27 | #include <linux/list.h> | |
60063497 | 28 | #include <linux/atomic.h> |
274bfb8d JL |
29 | #include <linux/if.h> |
30 | #include <linux/skbuff.h> | |
72118015 | 31 | #include <linux/ieee80211.h> |
a1eb5fe3 | 32 | #include <linux/timer.h> |
9387b7ca | 33 | /* print_ssid() is intended to be used in debug (and possibly error) |
7e272fcf | 34 | * messages. It should never be used for passing ssid to user space. */ |
9387b7ca | 35 | const char *print_ssid(char *buf, const char *ssid, u8 ssid_len); |
72118015 | 36 | #define DECLARE_SSID_BUF(var) char var[IEEE80211_MAX_SSID_LEN * 4 + 1] __maybe_unused |
7e272fcf | 37 | |
274bfb8d JL |
38 | #define NUM_WEP_KEYS 4 |
39 | ||
40 | enum { | |
41 | IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), | |
42 | }; | |
43 | ||
de477254 PG |
44 | struct module; |
45 | ||
274bfb8d JL |
46 | struct lib80211_crypto_ops { |
47 | const char *name; | |
48 | struct list_head list; | |
49 | ||
50 | /* init new crypto context (e.g., allocate private data space, | |
51 | * select IV, etc.); returns NULL on failure or pointer to allocated | |
52 | * private data on success */ | |
53 | void *(*init) (int keyidx); | |
54 | ||
55 | /* deinitialize crypto context and free allocated private data */ | |
56 | void (*deinit) (void *priv); | |
57 | ||
274bfb8d JL |
58 | /* encrypt/decrypt return < 0 on error or >= 0 on success. The return |
59 | * value from decrypt_mpdu is passed as the keyidx value for | |
60 | * decrypt_msdu. skb must have enough head and tail room for the | |
61 | * encryption; if not, error will be returned; these functions are | |
62 | * called for all MPDUs (i.e., fragments). | |
63 | */ | |
64 | int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); | |
65 | int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); | |
66 | ||
67 | /* These functions are called for full MSDUs, i.e. full frames. | |
68 | * These can be NULL if full MSDU operations are not needed. */ | |
69 | int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv); | |
70 | int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len, | |
71 | void *priv); | |
72 | ||
73 | int (*set_key) (void *key, int len, u8 * seq, void *priv); | |
74 | int (*get_key) (void *key, int len, u8 * seq, void *priv); | |
75 | ||
76 | /* procfs handler for printing out key information and possible | |
77 | * statistics */ | |
78 | char *(*print_stats) (char *p, void *priv); | |
79 | ||
80 | /* Crypto specific flag get/set for configuration settings */ | |
81 | unsigned long (*get_flags) (void *priv); | |
82 | unsigned long (*set_flags) (unsigned long flags, void *priv); | |
83 | ||
84 | /* maximum number of bytes added by encryption; encrypt buf is | |
85 | * allocated with extra_prefix_len bytes, copy of in_buf, and | |
86 | * extra_postfix_len; encrypt need not use all this space, but | |
87 | * the result must start at the beginning of the buffer and correct | |
88 | * length must be returned */ | |
89 | int extra_mpdu_prefix_len, extra_mpdu_postfix_len; | |
90 | int extra_msdu_prefix_len, extra_msdu_postfix_len; | |
91 | ||
92 | struct module *owner; | |
93 | }; | |
94 | ||
95 | struct lib80211_crypt_data { | |
96 | struct list_head list; /* delayed deletion list */ | |
97 | struct lib80211_crypto_ops *ops; | |
98 | void *priv; | |
99 | atomic_t refcnt; | |
100 | }; | |
101 | ||
102 | struct lib80211_crypt_info { | |
103 | char *name; | |
104 | /* Most clients will already have a lock, | |
105 | so just point to that. */ | |
106 | spinlock_t *lock; | |
107 | ||
108 | struct lib80211_crypt_data *crypt[NUM_WEP_KEYS]; | |
109 | int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ | |
110 | struct list_head crypt_deinit_list; | |
111 | struct timer_list crypt_deinit_timer; | |
112 | int crypt_quiesced; | |
113 | }; | |
114 | ||
2ba4b32e JL |
115 | int lib80211_crypt_info_init(struct lib80211_crypt_info *info, char *name, |
116 | spinlock_t *lock); | |
117 | void lib80211_crypt_info_free(struct lib80211_crypt_info *info); | |
274bfb8d JL |
118 | int lib80211_register_crypto_ops(struct lib80211_crypto_ops *ops); |
119 | int lib80211_unregister_crypto_ops(struct lib80211_crypto_ops *ops); | |
120 | struct lib80211_crypto_ops *lib80211_get_crypto_ops(const char *name); | |
274bfb8d JL |
121 | void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info, |
122 | struct lib80211_crypt_data **crypt); | |
274bfb8d | 123 | |
7e272fcf | 124 | #endif /* LIB80211_H */ |