pmksa_cache.h 3.4 KB

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