summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-06-10 12:52:26 +0200
committerThomas Haller <thaller@redhat.com>2020-06-11 11:06:30 +0200
commit505aee6598af75e14229b6ee05512886dc9b9f32 (patch)
treed0f7ee43d96f3643051c29fde13871ec36acd2b0
parent4afd62246b34ca196817e53b4b04fcab61926b21 (diff)
downloadNetworkManager-505aee6598af75e14229b6ee05512886dc9b9f32.tar.gz
supplicant: use macros to initialize config options
-rw-r--r--src/supplicant/nm-supplicant-settings-verify.c273
1 files changed, 139 insertions, 134 deletions
diff --git a/src/supplicant/nm-supplicant-settings-verify.c b/src/supplicant/nm-supplicant-settings-verify.c
index a71677ccec..954a4649e2 100644
--- a/src/supplicant/nm-supplicant-settings-verify.c
+++ b/src/supplicant/nm-supplicant-settings-verify.c
@@ -12,148 +12,153 @@
struct Opt {
const char *key;
+ const char *const*str_allowed;
const NMSupplOptType type;
const guint32 int_low; /* Inclusive */
const guint32 int_high; /* Inclusive; max length for strings */
- const char *const*str_allowed;
};
typedef gboolean (*validate_func) (const struct Opt *, const char *, const guint32);
+#define OPT_INT( _key, _int_low, _int_high) { .key = _key, .type = NM_SUPPL_OPT_TYPE_INT, .int_high = _int_high, .int_low = _int_low, }
+#define OPT_BYTES( _key, _int_high) { .key = _key, .type = NM_SUPPL_OPT_TYPE_BYTES, .int_high = _int_high, }
+#define OPT_UTF8( _key, _int_high) { .key = _key, .type = NM_SUPPL_OPT_TYPE_UTF8, .int_high = _int_high, }
+#define OPT_KEYWORD(_key, _str_allowed) { .key = _key, .type = NM_SUPPL_OPT_TYPE_KEYWORD, .str_allowed = _str_allowed, }
+
static const struct Opt opt_table[] = {
- { "altsubject_match", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "altsubject_match2", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "anonymous_identity", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "auth_alg", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NM_MAKE_STRV (
- "OPEN",
- "SHARED",
- "LEAP",
- ) },
- { "bgscan", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "bssid", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NULL },
- { "ca_cert", NM_SUPPL_OPT_TYPE_BYTES, 0, 65536, NULL },
- { "ca_cert2", NM_SUPPL_OPT_TYPE_BYTES, 0, 65536, NULL },
- { "ca_path", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "ca_path2", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "client_cert", NM_SUPPL_OPT_TYPE_BYTES, 0, 65536, NULL },
- { "client_cert2", NM_SUPPL_OPT_TYPE_BYTES, 0, 65536, NULL },
- { "domain_match", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "domain_match2", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "domain_suffix_match", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "domain_suffix_match2", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "eap", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NM_MAKE_STRV (
- "LEAP",
- "MD5",
- "TLS",
- "PEAP",
- "TTLS",
- "SIM",
- "PSK",
- "FAST",
- "PWD",
- ) },
- { "eapol_flags", NM_SUPPL_OPT_TYPE_INT, 0, 3, NULL },
- { "eappsk", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "engine", NM_SUPPL_OPT_TYPE_INT, 0, 1, NULL },
- { "engine_id", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "fragment_size", NM_SUPPL_OPT_TYPE_INT, 1, 2000, NULL },
- { "freq_list", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NULL },
- { "frequency", NM_SUPPL_OPT_TYPE_INT, 2412, 5825, NULL },
- { "group", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NM_MAKE_STRV (
- "CCMP",
- "TKIP",
- "WEP104",
- "WEP40",
- ) },
- { "identity", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "ieee80211w", NM_SUPPL_OPT_TYPE_INT, 0, 2, NULL },
- { "ignore_broadcast_ssid", NM_SUPPL_OPT_TYPE_INT, 0, 2, NULL },
- { "key_id", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "key_mgmt", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NM_MAKE_STRV (
- "WPA-PSK",
- "WPA-PSK-SHA256",
- "FT-PSK",
- "WPA-EAP",
- "WPA-EAP-SHA256",
- "FT-EAP",
- "FT-EAP-SHA384",
- "FILS-SHA256",
- "FILS-SHA384",
- "FT-FILS-SHA256",
- "FT-FILS-SHA384",
- "IEEE8021X",
- "SAE",
- "FT-SAE",
- "OWE",
- "NONE",
- ) },
- { "macsec_integ_only", NM_SUPPL_OPT_TYPE_INT, 0, 1, NULL },
- { "macsec_policy", NM_SUPPL_OPT_TYPE_INT, 0, 1, NULL },
- { "macsec_port", NM_SUPPL_OPT_TYPE_INT, 1, 65534, NULL },
- { "mka_cak", NM_SUPPL_OPT_TYPE_BYTES, 0, 65536, NULL },
- { "mka_ckn", NM_SUPPL_OPT_TYPE_BYTES, 0, 65536, NULL },
- { "nai", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "pac_file", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "pairwise", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NM_MAKE_STRV (
- "CCMP",
- "TKIP",
- "NONE",
- ) },
- { "password", NM_SUPPL_OPT_TYPE_UTF8, 0, 0, NULL },
- { "pcsc", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "phase1", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NM_MAKE_STRV (
- "peapver=0",
- "peapver=1",
- "peaplabel=1",
- "peap_outer_success=0",
- "include_tls_length=1",
- "sim_min_num_chal=3",
- "fast_provisioning=0",
- "fast_provisioning=1",
- "fast_provisioning=2",
- "fast_provisioning=3",
- "tls_disable_tlsv1_0=0",
- "tls_disable_tlsv1_0=1",
- "tls_disable_tlsv1_1=0",
- "tls_disable_tlsv1_1=1",
- "tls_disable_tlsv1_2=0",
- "tls_disable_tlsv1_2=1",
- ) },
- { "phase2", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NM_MAKE_STRV (
- "auth=PAP",
- "auth=CHAP",
- "auth=MSCHAP",
- "auth=MSCHAPV2",
- "auth=GTC",
- "auth=OTP",
- "auth=MD5",
- "auth=TLS",
- "autheap=MD5",
- "autheap=MSCHAPV2",
- "autheap=OTP",
- "autheap=GTC",
- "autheap=TLS",
- ) },
- { "pin", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "private_key", NM_SUPPL_OPT_TYPE_BYTES, 0, 65536, NULL },
- { "private_key2", NM_SUPPL_OPT_TYPE_BYTES, 0, 65536, NULL },
- { "private_key2_passwd", NM_SUPPL_OPT_TYPE_BYTES, 0, 1024, NULL },
- { "private_key_passwd", NM_SUPPL_OPT_TYPE_BYTES, 0, 1024, NULL },
- { "proactive_key_caching", NM_SUPPL_OPT_TYPE_INT, 0, 1, NULL },
- { "proto", NM_SUPPL_OPT_TYPE_KEYWORD, 0, 0, NM_MAKE_STRV (
- "WPA",
- "RSN",
- ) },
- { "psk", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "scan_ssid", NM_SUPPL_OPT_TYPE_INT, 0, 1, NULL },
- { "ssid", NM_SUPPL_OPT_TYPE_BYTES, 0, 32, NULL },
- { "subject_match", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "subject_match2", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "wep_key0", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "wep_key1", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "wep_key2", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "wep_key3", NM_SUPPL_OPT_TYPE_BYTES, 0, 0, NULL },
- { "wep_tx_keyidx", NM_SUPPL_OPT_TYPE_INT, 0, 3, NULL },
+ OPT_BYTES ("altsubject_match", 0),
+ OPT_BYTES ("altsubject_match2", 0),
+ OPT_BYTES ("anonymous_identity", 0),
+ OPT_KEYWORD ("auth_alg", NM_MAKE_STRV (
+ "OPEN",
+ "SHARED",
+ "LEAP",
+ )),
+ OPT_BYTES ("bgscan", 0),
+ OPT_KEYWORD ("bssid", NULL),
+ OPT_BYTES ("ca_cert", 65536),
+ OPT_BYTES ("ca_cert2", 65536),
+ OPT_BYTES ("ca_path", 0),
+ OPT_BYTES ("ca_path2", 0),
+ OPT_BYTES ("client_cert", 65536),
+ OPT_BYTES ("client_cert2", 65536),
+ OPT_BYTES ("domain_match", 0),
+ OPT_BYTES ("domain_match2", 0),
+ OPT_BYTES ("domain_suffix_match", 0),
+ OPT_BYTES ("domain_suffix_match2", 0),
+ OPT_KEYWORD ("eap", NM_MAKE_STRV (
+ "LEAP",
+ "MD5",
+ "TLS",
+ "PEAP",
+ "TTLS",
+ "SIM",
+ "PSK",
+ "FAST",
+ "PWD",
+ )),
+ OPT_INT ("eapol_flags", 0, 3),
+ OPT_BYTES ("eappsk", 0),
+ OPT_INT ("engine", 0, 1),
+ OPT_BYTES ("engine_id", 0),
+ OPT_INT ("fragment_size", 1, 2000),
+ OPT_KEYWORD ("freq_list", NULL),
+ OPT_INT ("frequency", 2412, 5825),
+ OPT_KEYWORD ("group", NM_MAKE_STRV (
+ "CCMP",
+ "TKIP",
+ "WEP104",
+ "WEP40",
+ )),
+ OPT_BYTES ("identity", 0),
+ OPT_INT ("ieee80211w", 0, 2),
+ OPT_INT ("ignore_broadcast_ssid", 0, 2),
+ OPT_BYTES ("key_id", 0),
+ OPT_KEYWORD ("key_mgmt", NM_MAKE_STRV (
+ "WPA-PSK",
+ "WPA-PSK-SHA256",
+ "FT-PSK",
+ "WPA-EAP",
+ "WPA-EAP-SHA256",
+ "FT-EAP",
+ "FT-EAP-SHA384",
+ "FILS-SHA256",
+ "FILS-SHA384",
+ "FT-FILS-SHA256",
+ "FT-FILS-SHA384",
+ "IEEE8021X",
+ "SAE",
+ "FT-SAE",
+ "OWE",
+ "NONE",
+ )),
+ OPT_INT ("macsec_integ_only", 0, 1),
+ OPT_INT ("macsec_policy", 0, 1),
+ OPT_INT ("macsec_port", 1, 65534),
+ OPT_BYTES ("mka_cak", 65536),
+ OPT_BYTES ("mka_ckn", 65536),
+ OPT_BYTES ("nai", 0),
+ OPT_BYTES ("pac_file", 0),
+ OPT_KEYWORD ("pairwise", NM_MAKE_STRV (
+ "CCMP",
+ "TKIP",
+ "NONE",
+ )),
+ OPT_UTF8 ("password", 0),
+ OPT_BYTES ("pcsc", 0),
+ OPT_KEYWORD ("phase1", NM_MAKE_STRV (
+ "peapver=0",
+ "peapver=1",
+ "peaplabel=1",
+ "peap_outer_success=0",
+ "include_tls_length=1",
+ "sim_min_num_chal=3",
+ "fast_provisioning=0",
+ "fast_provisioning=1",
+ "fast_provisioning=2",
+ "fast_provisioning=3",
+ "tls_disable_tlsv1_0=0",
+ "tls_disable_tlsv1_0=1",
+ "tls_disable_tlsv1_1=0",
+ "tls_disable_tlsv1_1=1",
+ "tls_disable_tlsv1_2=0",
+ "tls_disable_tlsv1_2=1",
+ )),
+ OPT_KEYWORD ("phase2", NM_MAKE_STRV (
+ "auth=PAP",
+ "auth=CHAP",
+ "auth=MSCHAP",
+ "auth=MSCHAPV2",
+ "auth=GTC",
+ "auth=OTP",
+ "auth=MD5",
+ "auth=TLS",
+ "autheap=MD5",
+ "autheap=MSCHAPV2",
+ "autheap=OTP",
+ "autheap=GTC",
+ "autheap=TLS",
+ )),
+ OPT_BYTES ("pin", 0),
+ OPT_BYTES ("private_key", 65536),
+ OPT_BYTES ("private_key2", 65536),
+ OPT_BYTES ("private_key2_passwd", 1024),
+ OPT_BYTES ("private_key_passwd", 1024),
+ OPT_INT ("proactive_key_caching", 0, 1),
+ OPT_KEYWORD ("proto", NM_MAKE_STRV (
+ "WPA",
+ "RSN",
+ )),
+ OPT_BYTES ("psk", 0),
+ OPT_INT ("scan_ssid", 0, 1),
+ OPT_BYTES ("ssid", 32),
+ OPT_BYTES ("subject_match", 0),
+ OPT_BYTES ("subject_match2", 0),
+ OPT_BYTES ("wep_key0", 0),
+ OPT_BYTES ("wep_key1", 0),
+ OPT_BYTES ("wep_key2", 0),
+ OPT_BYTES ("wep_key3", 0),
+ OPT_INT ("wep_tx_keyidx", 0, 3),
};
static gboolean