From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 2/4] common: add security_to_akms()
Date: Tue, 24 Mar 2026 12:20:49 -0700 [thread overview]
Message-ID: <20260324192051.801196-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20260324192051.801196-1-prestwoj@gmail.com>
This takes a security enum and returns a bitmask of all possible
AKMs for that security type. The AKM list was refactored to be
reused by AKM_IS_PSK/AKM_IS_8021X.
---
src/common.c | 41 +++++++++++++++++++++++++++++++----------
src/common.h | 1 +
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/src/common.c b/src/common.c
index 91979423..1e5b3b7b 100644
--- a/src/common.c
+++ b/src/common.c
@@ -28,6 +28,8 @@
#include <stdbool.h>
#include <string.h>
+#include <ell/ell.h>
+
#include "src/iwd.h"
#include "src/common.h"
#include "src/ie.h"
@@ -64,18 +66,15 @@ bool security_from_str(const char *str, enum security *security)
return true;
}
-#define AKM_IS_PSK(akm) \
-( \
- akm & (IE_RSN_AKM_SUITE_PSK | \
+#define AKMS_PSK \
+ (IE_RSN_AKM_SUITE_PSK | \
IE_RSN_AKM_SUITE_PSK_SHA256 | \
IE_RSN_AKM_SUITE_FT_USING_PSK | \
IE_RSN_AKM_SUITE_SAE_SHA256 | \
- IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256) \
-)
+ IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256)
-#define AKM_IS_8021X(akm) \
-( \
- akm & (IE_RSN_AKM_SUITE_8021X | \
+#define AKMS_8021X \
+ (IE_RSN_AKM_SUITE_8021X | \
IE_RSN_AKM_SUITE_8021X_SHA256 | \
IE_RSN_AKM_SUITE_FT_OVER_8021X | \
IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384 | \
@@ -83,8 +82,11 @@ bool security_from_str(const char *str, enum security *security)
IE_RSN_AKM_SUITE_FILS_SHA384 | \
IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256 | \
IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384 | \
- IE_RSN_AKM_SUITE_OSEN) \
-)
+ IE_RSN_AKM_SUITE_OSEN)
+
+#define AKM_IS_PSK(akm) (akm & AKMS_PSK)
+
+#define AKM_IS_8021X(akm) (akm & AKMS_8021X)
enum security security_determine(uint16_t bss_capability,
const struct ie_rsn_info *info)
@@ -103,3 +105,22 @@ enum security security_determine(uint16_t bss_capability,
return SECURITY_NONE;
}
+
+/* Returns all possible AKMs (as bitmask) for a given security type */
+uint32_t security_to_akms(enum security security)
+{
+ switch (security) {
+ case SECURITY_WEP:
+ l_warn("WEP security type not supported");
+ /* Fall through */
+ case SECURITY_NONE:
+ return 0;
+ case SECURITY_PSK:
+ return AKMS_PSK;
+ case SECURITY_8021X:
+ return AKMS_8021X;
+ default:
+ l_warn("Unhandled security type: %u", security);
+ return 0;
+ }
+}
diff --git a/src/common.h b/src/common.h
index ca12d813..7e877299 100644
--- a/src/common.h
+++ b/src/common.h
@@ -36,3 +36,4 @@ const char *security_to_str(enum security security);
bool security_from_str(const char *str, enum security *security);
enum security security_determine(uint16_t bss_capability,
const struct ie_rsn_info *info);
+uint32_t security_to_akms(enum security security);
\ No newline at end of file
--
2.34.1
next prev parent reply other threads:[~2026-03-24 19:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 19:20 [PATCH v2 1/4] pmksa: add pmksa_cache_flush_ssid James Prestwood
2026-03-24 19:20 ` James Prestwood [this message]
2026-03-24 19:20 ` [PATCH v2 3/4] network: remove PMKSA entries on known network removal James Prestwood
2026-03-24 19:20 ` [PATCH v2 4/4] auto-t: add test for known network removal of a PMKSA network James Prestwood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260324192051.801196-2-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox