pmksa_cache.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * wpa_supplicant - WPA2/RSN PMKSA cache functions
  3. * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef PMKSA_CACHE_H
  15. #define PMKSA_CACHE_H
  16. /**
  17. * struct rsn_pmksa_cache_entry - PMKSA cache entry
  18. */
  19. struct rsn_pmksa_cache_entry {
  20. struct rsn_pmksa_cache_entry *next;
  21. u8 pmkid[PMKID_LEN];
  22. u8 pmk[PMK_LEN];
  23. size_t pmk_len;
  24. os_time_t expiration;
  25. int akmp; /* WPA_KEY_MGMT_* */
  26. u8 aa[ETH_ALEN];
  27. os_time_t reauth_time;
  28. /**
  29. * network_ctx - Network configuration context
  30. *
  31. * This field is only used to match PMKSA cache entries to a specific
  32. * network configuration (e.g., a specific SSID and security policy).
  33. * This can be a pointer to the configuration entry, but PMKSA caching
  34. * code does not dereference the value and this could be any kind of
  35. * identifier.
  36. */
  37. void *network_ctx;
  38. int opportunistic;
  39. };
  40. struct rsn_pmksa_cache;
  41. #if defined(IEEE8021X_EAPOL) && !defined(CONFIG_NO_WPA2)
  42. struct rsn_pmksa_cache *
  43. pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
  44. void *ctx, int replace),
  45. void *ctx, struct wpa_sm *sm);
  46. void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa);
  47. struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa,
  48. const u8 *aa, const u8 *pmkid);
  49. int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len);
  50. struct rsn_pmksa_cache_entry *
  51. pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
  52. const u8 *aa, const u8 *spa, void *network_ctx, int akmp);
  53. void pmksa_cache_notify_reconfig(struct rsn_pmksa_cache *pmksa);
  54. struct rsn_pmksa_cache_entry * pmksa_cache_get_current(struct wpa_sm *sm);
  55. void pmksa_cache_clear_current(struct wpa_sm *sm);
  56. int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid,
  57. const u8 *bssid, void *network_ctx,
  58. int try_opportunistic);
  59. struct rsn_pmksa_cache_entry *
  60. pmksa_cache_get_opportunistic(struct rsn_pmksa_cache *pmksa,
  61. void *network_ctx, const u8 *aa);
  62. #else /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */
  63. static inline struct rsn_pmksa_cache *
  64. pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
  65. void *ctx, int replace),
  66. void *ctx, struct wpa_sm *sm)
  67. {
  68. return (void *) -1;
  69. }
  70. static inline void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa)
  71. {
  72. }
  73. static inline struct rsn_pmksa_cache_entry *
  74. pmksa_cache_get(struct rsn_pmksa_cache *pmksa, const u8 *aa, const u8 *pmkid)
  75. {
  76. return NULL;
  77. }
  78. static inline struct rsn_pmksa_cache_entry *
  79. pmksa_cache_get_current(struct wpa_sm *sm)
  80. {
  81. return NULL;
  82. }
  83. static inline int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf,
  84. size_t len)
  85. {
  86. return -1;
  87. }
  88. static inline struct rsn_pmksa_cache_entry *
  89. pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
  90. const u8 *aa, const u8 *spa, void *network_ctx, int akmp)
  91. {
  92. return NULL;
  93. }
  94. static inline void pmksa_cache_notify_reconfig(struct rsn_pmksa_cache *pmksa)
  95. {
  96. }
  97. static inline void pmksa_cache_clear_current(struct wpa_sm *sm)
  98. {
  99. }
  100. static inline int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid,
  101. const u8 *bssid,
  102. void *network_ctx,
  103. int try_opportunistic)
  104. {
  105. return -1;
  106. }
  107. #endif /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */
  108. #endif /* PMKSA_CACHE_H */