lib80211.h 4.3 KB

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