Blame view

include/net/lib80211.h 3.88 KB
7e272fcff   John W. Linville   wireless: consoli...
1
2
3
4
5
  /*
   * lib80211.h -- common bits for IEEE802.11 wireless drivers
   *
   * Copyright (c) 2008, John W. Linville <linville@tuxdriver.com>
   *
274bfb8dc   John W. Linville   lib80211: absorb ...
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
   * Some bits copied from old ieee80211 component, w/ original copyright
   * notices below:
   *
   * Original code 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, Intel Corporation
   *
7e272fcff   John W. Linville   wireless: consoli...
21
22
23
24
   */
  
  #ifndef LIB80211_H
  #define LIB80211_H
274bfb8dc   John W. Linville   lib80211: absorb ...
25
26
  #include <linux/types.h>
  #include <linux/list.h>
60063497a   Arun Sharma   atomic: use <linu...
27
  #include <linux/atomic.h>
274bfb8dc   John W. Linville   lib80211: absorb ...
28
29
  #include <linux/if.h>
  #include <linux/skbuff.h>
721180152   John W. Linville   wireless: avoid s...
30
  #include <linux/ieee80211.h>
a1eb5fe31   Rami Rosen   wireless: missing...
31
  #include <linux/timer.h>
6bbefe867   David Howells   hostap: Don't use...
32
  #include <linux/seq_file.h>
274bfb8dc   John W. Linville   lib80211: absorb ...
33
34
35
36
37
  #define NUM_WEP_KEYS	4
  
  enum {
  	IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0),
  };
de4772542   Paul Gortmaker   include: replace ...
38
  struct module;
274bfb8dc   John W. Linville   lib80211: absorb ...
39
40
41
42
43
44
45
46
47
48
49
  struct lib80211_crypto_ops {
  	const char *name;
  	struct list_head list;
  
  	/* 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);
274bfb8dc   John W. Linville   lib80211: absorb ...
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  	/* 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 */
6bbefe867   David Howells   hostap: Don't use...
70
  	void (*print_stats) (struct seq_file *m, void *priv);
274bfb8dc   John W. Linville   lib80211: absorb ...
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  
  	/* Crypto specific flag get/set for configuration settings */
  	unsigned long (*get_flags) (void *priv);
  	unsigned long (*set_flags) (unsigned long 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 lib80211_crypt_data {
  	struct list_head list;	/* delayed deletion list */
  	struct lib80211_crypto_ops *ops;
  	void *priv;
  	atomic_t refcnt;
  };
  
  struct lib80211_crypt_info {
  	char *name;
  	/* Most clients will already have a lock,
  	   so just point to that. */
  	spinlock_t *lock;
  
  	struct lib80211_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;
  };
2ba4b32ec   John W. Linville   lib80211: consoli...
106
107
108
  int lib80211_crypt_info_init(struct lib80211_crypt_info *info, char *name,
                                  spinlock_t *lock);
  void lib80211_crypt_info_free(struct lib80211_crypt_info *info);
274bfb8dc   John W. Linville   lib80211: absorb ...
109
110
111
  int lib80211_register_crypto_ops(struct lib80211_crypto_ops *ops);
  int lib80211_unregister_crypto_ops(struct lib80211_crypto_ops *ops);
  struct lib80211_crypto_ops *lib80211_get_crypto_ops(const char *name);
274bfb8dc   John W. Linville   lib80211: absorb ...
112
113
  void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info,
  				    struct lib80211_crypt_data **crypt);
274bfb8dc   John W. Linville   lib80211: absorb ...
114

7e272fcff   John W. Linville   wireless: consoli...
115
  #endif /* LIB80211_H */