Replace PTKSA cache inline stubs with wrapper function stubs

PTKSA cache API is included in libpasn.so used by external modules,
e.g., Wi-Fi Aware. To avoid dependency on CONFIG_PTKSA_CACHE define for
the external modules at compile time, remove PTKSA cache static inline
functions from the header file and add wrapper function stubs.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Vinay Gannevaram 2024-02-01 08:38:33 +05:30 committed by Jouni Malinen
parent e2ae53e1db
commit ba55088a73
6 changed files with 47 additions and 42 deletions

View file

@ -154,6 +154,7 @@ OBJS += src/utils/crc32.c
OBJS += src/common/ieee802_11_common.c OBJS += src/common/ieee802_11_common.c
OBJS += src/common/wpa_common.c OBJS += src/common/wpa_common.c
OBJS += src/common/hw_features_common.c OBJS += src/common/hw_features_common.c
OBJS += src/common/ptksa_cache.c
OBJS += src/eapol_auth/eapol_auth_sm.c OBJS += src/eapol_auth/eapol_auth_sm.c
@ -594,7 +595,6 @@ NEED_HMAC_SHA256_KDF=y
NEED_HMAC_SHA384_KDF=y NEED_HMAC_SHA384_KDF=y
NEED_SHA256=y NEED_SHA256=y
NEED_SHA384=y NEED_SHA384=y
OBJS += src/common/ptksa_cache.c
endif endif
ifdef CONFIG_EAP_IKEV2 ifdef CONFIG_EAP_IKEV2

View file

@ -84,6 +84,7 @@ OBJS += ../src/ap/beacon.o
OBJS += ../src/ap/bss_load.o OBJS += ../src/ap/bss_load.o
OBJS += ../src/ap/neighbor_db.o OBJS += ../src/ap/neighbor_db.o
OBJS += ../src/ap/rrm.o OBJS += ../src/ap/rrm.o
OBJS += ../src/common/ptksa_cache.o
OBJS_c = hostapd_cli.o OBJS_c = hostapd_cli.o
OBJS_c += ../src/common/wpa_ctrl.o OBJS_c += ../src/common/wpa_ctrl.o
@ -620,7 +621,6 @@ NEED_HMAC_SHA256_KDF=y
NEED_HMAC_SHA384_KDF=y NEED_HMAC_SHA384_KDF=y
NEED_SHA256=y NEED_SHA256=y
NEED_SHA384=y NEED_SHA384=y
OBJS += ../src/common/ptksa_cache.o
endif endif
ifdef CONFIG_EAP_IKEV2 ifdef CONFIG_EAP_IKEV2

View file

@ -19,6 +19,8 @@ struct ptksa_cache {
unsigned int n_ptksa; unsigned int n_ptksa;
}; };
#ifdef CONFIG_PTKSA_CACHE
static void ptksa_cache_set_expiration(struct ptksa_cache *ptksa); static void ptksa_cache_set_expiration(struct ptksa_cache *ptksa);
@ -342,3 +344,44 @@ struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa,
return entry; return entry;
} }
#else /* CONFIG_PTKSA_CACHE */
struct ptksa_cache * ptksa_cache_init(void)
{
return (struct ptksa_cache *) 1;
}
void ptksa_cache_deinit(struct ptksa_cache *ptksa)
{
}
struct ptksa_cache_entry *
ptksa_cache_get(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher)
{
return NULL;
}
int ptksa_cache_list(struct ptksa_cache *ptksa, char *buf, size_t len)
{
return -1;
}
struct ptksa_cache_entry *
ptksa_cache_add(struct ptksa_cache *ptksa, const u8 *own_addr, const u8 *addr,
u32 cipher, u32 life_time, const struct wpa_ptk *ptk,
void (*cb)(struct ptksa_cache_entry *e), void *ctx, u32 akmp)
{
return NULL;
}
void ptksa_cache_flush(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher)
{
}
#endif /* CONFIG_PTKSA_CACHE */

View file

@ -29,7 +29,6 @@ struct ptksa_cache_entry {
u32 akmp; u32 akmp;
}; };
#ifdef CONFIG_PTKSA_CACHE
struct ptksa_cache; struct ptksa_cache;
@ -48,41 +47,4 @@ struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa,
void *ctx, u32 akmp); void *ctx, u32 akmp);
void ptksa_cache_flush(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher); void ptksa_cache_flush(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher);
#else /* CONFIG_PTKSA_CACHE */
static inline struct ptksa_cache * ptksa_cache_init(void)
{
return (struct ptksa_cache *) 1;
}
static inline void ptksa_cache_deinit(struct ptksa_cache *ptksa)
{
}
static inline struct ptksa_cache_entry *
ptksa_cache_get(struct ptksa_cache *ptksa, const u8 *addr, u32 cipher)
{
return NULL;
}
static inline int ptksa_cache_list(struct ptksa_cache *ptksa,
char *buf, size_t len)
{
return -1;
}
static inline struct ptksa_cache_entry *
ptksa_cache_add(struct ptksa_cache *ptksa, const u8 *own_addr, const u8 *addr,
u32 cipher, u32 life_time, const struct wpa_ptk *ptk,
void (*cb)(struct ptksa_cache_entry *e), void *ctx, u32 akmp)
{
return NULL;
}
static inline void ptksa_cache_flush(struct ptksa_cache *ptksa,
const u8 *addr, u32 cipher)
{
}
#endif /* CONFIG_PTKSA_CACHE */
#endif /* PTKSA_CACHE_H */ #endif /* PTKSA_CACHE_H */

View file

@ -100,6 +100,7 @@ OBJS += src/utils/wpabuf.c
OBJS += src/utils/bitfield.c OBJS += src/utils/bitfield.c
OBJS += src/utils/ip_addr.c OBJS += src/utils/ip_addr.c
OBJS += src/utils/crc32.c OBJS += src/utils/crc32.c
OBJS += src/common/ptksa_cache.c
OBJS += twt.c OBJS += twt.c
OBJS_p = wpa_passphrase.c OBJS_p = wpa_passphrase.c
OBJS_p += src/utils/common.c OBJS_p += src/utils/common.c
@ -389,7 +390,6 @@ NEED_HMAC_SHA256_KDF=y
NEED_HMAC_SHA384_KDF=y NEED_HMAC_SHA384_KDF=y
NEED_SHA256=y NEED_SHA256=y
NEED_SHA384=y NEED_SHA384=y
OBJS += src/common/ptksa_cache.c
OBJS += src/pasn/pasn_initiator.c OBJS += src/pasn/pasn_initiator.c
OBJS += pasn_supplicant.c OBJS += pasn_supplicant.c
endif endif

View file

@ -112,6 +112,7 @@ OBJS += ../src/utils/wpabuf.o
OBJS += ../src/utils/bitfield.o OBJS += ../src/utils/bitfield.o
OBJS += ../src/utils/ip_addr.o OBJS += ../src/utils/ip_addr.o
OBJS += ../src/utils/crc32.o OBJS += ../src/utils/crc32.o
OBJS += ../src/common/ptksa_cache.o
OBJS += twt.o OBJS += twt.o
OBJS_p = wpa_passphrase.o OBJS_p = wpa_passphrase.o
OBJS_p += ../src/utils/common.o OBJS_p += ../src/utils/common.o
@ -431,7 +432,6 @@ NEED_HMAC_SHA256_KDF=y
NEED_HMAC_SHA384_KDF=y NEED_HMAC_SHA384_KDF=y
NEED_SHA256=y NEED_SHA256=y
NEED_SHA384=y NEED_SHA384=y
OBJS += ../src/common/ptksa_cache.o
OBJS += ../src/pasn/pasn_initiator.o OBJS += ../src/pasn/pasn_initiator.o
OBJS += pasn_supplicant.o OBJS += pasn_supplicant.o
endif endif