pmksa_cache.h revision 1f69aa52ea2e0a73ac502565df8c666ee49cab6a
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 15#ifndef PMKSA_CACHE_H 16#define PMKSA_CACHE_H 17 18/** 19 * struct rsn_pmksa_cache_entry - PMKSA cache entry 20 */ 21struct rsn_pmksa_cache_entry { 22 struct rsn_pmksa_cache_entry *next; 23 u8 pmkid[PMKID_LEN]; 24 u8 pmk[PMK_LEN]; 25 size_t pmk_len; 26 os_time_t expiration; 27 int akmp; /* WPA_KEY_MGMT_* */ 28 u8 aa[ETH_ALEN]; 29 30 os_time_t reauth_time; 31 32 /** 33 * network_ctx - Network configuration context 34 * 35 * This field is only used to match PMKSA cache entries to a specific 36 * network configuration (e.g., a specific SSID and security policy). 37 * This can be a pointer to the configuration entry, but PMKSA caching 38 * code does not dereference the value and this could be any kind of 39 * identifier. 40 */ 41 void *network_ctx; 42 int opportunistic; 43}; 44 45struct rsn_pmksa_cache; 46 47#if defined(IEEE8021X_EAPOL) && !defined(CONFIG_NO_WPA2) 48 49struct rsn_pmksa_cache * 50pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry, 51 void *ctx, int replace), 52 void *ctx, struct wpa_sm *sm); 53void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa); 54struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa, 55 const u8 *aa, const u8 *pmkid); 56int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len); 57struct rsn_pmksa_cache_entry * 58pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len, 59 const u8 *aa, const u8 *spa, void *network_ctx, int akmp); 60struct rsn_pmksa_cache_entry * pmksa_cache_get_current(struct wpa_sm *sm); 61void pmksa_cache_clear_current(struct wpa_sm *sm); 62int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid, 63 const u8 *bssid, void *network_ctx, 64 int try_opportunistic); 65struct rsn_pmksa_cache_entry * 66pmksa_cache_get_opportunistic(struct rsn_pmksa_cache *pmksa, 67 void *network_ctx, const u8 *aa); 68void pmksa_cache_flush(struct rsn_pmksa_cache *pmksa, void *network_ctx); 69 70#else /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */ 71 72static inline struct rsn_pmksa_cache * 73pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry, 74 void *ctx, int replace), 75 void *ctx, struct wpa_sm *sm) 76{ 77 return (void *) -1; 78} 79 80static inline void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa) 81{ 82} 83 84static inline struct rsn_pmksa_cache_entry * 85pmksa_cache_get(struct rsn_pmksa_cache *pmksa, const u8 *aa, const u8 *pmkid) 86{ 87 return NULL; 88} 89 90static inline struct rsn_pmksa_cache_entry * 91pmksa_cache_get_current(struct wpa_sm *sm) 92{ 93 return NULL; 94} 95 96static inline int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, 97 size_t len) 98{ 99 return -1; 100} 101 102static inline struct rsn_pmksa_cache_entry * 103pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len, 104 const u8 *aa, const u8 *spa, void *network_ctx, int akmp) 105{ 106 return NULL; 107} 108 109static inline void pmksa_cache_clear_current(struct wpa_sm *sm) 110{ 111} 112 113static inline int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid, 114 const u8 *bssid, 115 void *network_ctx, 116 int try_opportunistic) 117{ 118 return -1; 119} 120 121static inline void pmksa_cache_flush(struct rsn_pmksa_cache *pmksa, 122 void *network_ctx) 123{ 124} 125 126#endif /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */ 127 128#endif /* PMKSA_CACHE_H */ 129