From 395acc8203d0b8478a5b29b2702d787a6dfcc5a2 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Fri, 5 Oct 2018 16:03:12 -0700 Subject: [PATCH] netdev: simplify netdev_choose_key_address The key address can be chosen regardless of iftype. The deciding factor is the authenticator bit in the handshake. --- src/netdev.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index a46d689d..027ad30d 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1187,6 +1187,12 @@ static bool netdev_copy_tk(uint8_t *tk_buf, const uint8_t *tk, return true; } +static const uint8_t *netdev_choose_key_address( + struct netdev_handshake_state *nhs) +{ + return (nhs->super.authenticator) ? nhs->super.spa : nhs->super.aa; +} + static void netdev_set_gtk(struct handshake_state *hs, uint8_t key_index, const uint8_t *gtk, uint8_t gtk_len, const uint8_t *rsc, uint8_t rsc_len, @@ -1273,24 +1279,6 @@ static void netdev_set_igtk(struct handshake_state *hs, uint8_t key_index, netdev_setting_keys_failed(nhs, MMPDU_REASON_CODE_UNSPECIFIED); } -static const uint8_t *netdev_choose_key_address( - struct netdev_handshake_state *nhs) -{ - switch (nhs->netdev->type) { - case NL80211_IFTYPE_STATION: - return nhs->super.aa; - case NL80211_IFTYPE_AP: - return nhs->super.spa; - case NL80211_IFTYPE_ADHOC: - if (nhs->super.authenticator) - return nhs->super.spa; - else - return nhs->super.aa; - default: - return NULL; - } -} - static void netdev_new_pairwise_key_cb(struct l_genl_msg *msg, void *data) { struct netdev_handshake_state *nhs = data;