xref: /freebsd/contrib/wpa/src/common/ptksa_cache.h (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
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];
26 };
27 
28 #ifdef CONFIG_PTKSA_CACHE
29 
30 struct ptksa_cache;
31 
32 struct ptksa_cache * ptksa_cache_init(void);
33 void ptksa_cache_deinit(struct ptksa_cache *ptksa);
34 struct ptksa_cache_entry * ptksa_cache_get(struct ptksa_cache *ptksa,
35 					   const u8 *addr, u32 cipher);
36 int ptksa_cache_list(struct ptksa_cache *ptksa, char *buf, size_t len);
37 struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa,
38 					   const u8 *addr, u32 cipher,
39 					   u32 life_time,
40 					   const struct wpa_ptk *ptk);
41 void ptksa_cache_flush(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher);
42 
43 #else /* CONFIG_PTKSA_CACHE */
44 
45 static inline struct ptksa_cache * ptksa_cache_init(void)
46 {
47 	return (struct ptksa_cache *) 1;
48 }
49 
50 static inline void ptksa_cache_deinit(struct ptksa_cache *ptksa)
51 {
52 }
53 
54 static inline struct ptksa_cache_entry *
55 ptksa_cache_get(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher)
56 {
57 	return NULL;
58 }
59 
60 static inline int ptksa_cache_list(struct ptksa_cache *ptksa,
61 				   char *buf, size_t len)
62 {
63 	return -1;
64 }
65 
66 static inline struct ptksa_cache_entry *
67 ptksa_cache_add(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher,
68 		u32 life_time, const struct wpa_ptk *ptk)
69 {
70 	return NULL;
71 }
72 
73 static inline void ptksa_cache_flush(struct ptksa_cache *ptksa,
74 				     const u8 *addr, u32 cipher)
75 {
76 }
77 
78 #endif /* CONFIG_PTKSA_CACHE */
79 #endif /* PTKSA_CACHE_H */
80