Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1 | /* |
| 2 | * RSN PTKSA cache interface |
| 3 | * |
| 4 | * Copyright (C) 2019 Intel Corporation |
| 5 | * |
| 6 | * This software may be distributed under the terms of the BSD license. |
| 7 | * See README for more details. |
| 8 | */ |
| 9 | |
| 10 | #ifndef PTKSA_CACHE_H |
| 11 | #define PTKSA_CACHE_H |
| 12 | |
| 13 | #include "wpa_common.h" |
| 14 | #include "defs.h" |
| 15 | #include "list.h" |
| 16 | |
| 17 | /** |
| 18 | * struct ptksa_cache_entry - PTKSA cache entry |
| 19 | */ |
| 20 | struct ptksa_cache_entry { |
| 21 | struct dl_list list; |
| 22 | struct wpa_ptk ptk; |
| 23 | os_time_t expiration; |
| 24 | u32 cipher; |
| 25 | u8 addr[ETH_ALEN]; |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame] | 26 | u8 own_addr[ETH_ALEN]; |
| 27 | void (*cb)(struct ptksa_cache_entry *e); |
| 28 | void *ctx; |
Sunil Ravi | 38ad1ed | 2023-01-17 23:58:31 +0000 | [diff] [blame^] | 29 | u32 akmp; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | #ifdef CONFIG_PTKSA_CACHE |
| 33 | |
| 34 | struct ptksa_cache; |
| 35 | |
| 36 | struct ptksa_cache * ptksa_cache_init(void); |
| 37 | void ptksa_cache_deinit(struct ptksa_cache *ptksa); |
| 38 | struct ptksa_cache_entry * ptksa_cache_get(struct ptksa_cache *ptksa, |
| 39 | const u8 *addr, u32 cipher); |
| 40 | int ptksa_cache_list(struct ptksa_cache *ptksa, char *buf, size_t len); |
| 41 | struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa, |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame] | 42 | const u8 *own_addr, |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 43 | const u8 *addr, u32 cipher, |
| 44 | u32 life_time, |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame] | 45 | const struct wpa_ptk *ptk, |
| 46 | void (*cb) |
| 47 | (struct ptksa_cache_entry *e), |
Sunil Ravi | 38ad1ed | 2023-01-17 23:58:31 +0000 | [diff] [blame^] | 48 | void *ctx, u32 akmp); |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 49 | void ptksa_cache_flush(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher); |
| 50 | |
| 51 | #else /* CONFIG_PTKSA_CACHE */ |
| 52 | |
| 53 | static inline struct ptksa_cache * ptksa_cache_init(void) |
| 54 | { |
| 55 | return (struct ptksa_cache *) 1; |
| 56 | } |
| 57 | |
| 58 | static inline void ptksa_cache_deinit(struct ptksa_cache *ptksa) |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | static inline struct ptksa_cache_entry * |
| 63 | ptksa_cache_get(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher) |
| 64 | { |
| 65 | return NULL; |
| 66 | } |
| 67 | |
| 68 | static inline int ptksa_cache_list(struct ptksa_cache *ptksa, |
| 69 | char *buf, size_t len) |
| 70 | { |
| 71 | return -1; |
| 72 | } |
| 73 | |
| 74 | static inline struct ptksa_cache_entry * |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame] | 75 | ptksa_cache_add(struct ptksa_cache *ptksa, const u8 *own_addr, const u8 *addr, |
| 76 | u32 cipher, u32 life_time, const struct wpa_ptk *ptk, |
Sunil Ravi | 38ad1ed | 2023-01-17 23:58:31 +0000 | [diff] [blame^] | 77 | void (*cb)(struct ptksa_cache_entry *e), void *ctx, u32 akmp) |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 78 | { |
| 79 | return NULL; |
| 80 | } |
| 81 | |
| 82 | static inline void ptksa_cache_flush(struct ptksa_cache *ptksa, |
| 83 | const u8 *addr, u32 cipher) |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | #endif /* CONFIG_PTKSA_CACHE */ |
| 88 | #endif /* PTKSA_CACHE_H */ |