| 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 | /* |
| 3 | * Copyright (C) 2007 - 2017 Red Hat, Inc. |
| 4 | * Copyright (C) 2007 - 2008 Novell, Inc. |
| 5 | */ |
| 6 | |
| 7 | #ifndef __NM_SETTING_WIRELESS_SECURITY_H__ |
| 8 | #define __NM_SETTING_WIRELESS_SECURITY_H__ |
| 9 | |
| 10 | #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) |
| 11 | #error "Only <NetworkManager.h> can be included directly." |
| 12 | #endif |
| 13 | |
| 14 | #include "nm-setting.h" |
| 15 | |
| 16 | G_BEGIN_DECLS |
| 17 | |
| 18 | #define NM_TYPE_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_get_type()) |
| 19 | #define NM_SETTING_WIRELESS_SECURITY(obj) \ |
| 20 | (G_TYPE_CHECK_INSTANCE_CAST((obj), \ |
| 21 | NM_TYPE_SETTING_WIRELESS_SECURITY, \ |
| 22 | NMSettingWirelessSecurity)) |
| 23 | #define NM_SETTING_WIRELESS_SECURITY_CLASS(klass) \ |
| 24 | (G_TYPE_CHECK_CLASS_CAST((klass), \ |
| 25 | NM_TYPE_SETTING_WIRELESS_SECURITY, \ |
| 26 | NMSettingWirelessSecurityClass)) |
| 27 | #define NM_IS_SETTING_WIRELESS_SECURITY(obj) \ |
| 28 | (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_SETTING_WIRELESS_SECURITY)) |
| 29 | #define NM_IS_SETTING_WIRELESS_SECURITY_CLASS(klass) \ |
| 30 | (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_SETTING_WIRELESS_SECURITY)) |
| 31 | #define NM_SETTING_WIRELESS_SECURITY_GET_CLASS(obj) \ |
| 32 | (G_TYPE_INSTANCE_GET_CLASS((obj), \ |
| 33 | NM_TYPE_SETTING_WIRELESS_SECURITY, \ |
| 34 | NMSettingWirelessSecurityClass)) |
| 35 | |
| 36 | #define NM_SETTING_WIRELESS_SECURITY_SETTING_NAME "802-11-wireless-security" |
| 37 | |
| 38 | /** |
| 39 | * NMWepKeyType: |
| 40 | * @NM_WEP_KEY_TYPE_UNKNOWN: unknown WEP key type |
| 41 | * @NM_WEP_KEY_TYPE_KEY: indicates a hexadecimal or ASCII formatted WEP key. |
| 42 | * Hex keys are either 10 or 26 hexadecimal characters (ie "5f782f2f5f" or |
| 43 | * "732f2d712e4a394a375d366931"), while ASCII keys are either 5 or 13 ASCII |
| 44 | * characters (ie "abcde" or "blahblah99$*1"). |
| 45 | * @NM_WEP_KEY_TYPE_PASSPHRASE: indicates a WEP passphrase (ex "I bought a duck |
| 46 | * on my way back from the market 235Q&^%^*%") instead of a hexadecimal or ASCII |
| 47 | * key. Passphrases are between 8 and 64 characters inclusive and are hashed |
| 48 | * the actual WEP key using the MD5 hash algorithm. |
| 49 | * @NM_WEP_KEY_TYPE_LAST: placeholder value for bounds-checking |
| 50 | * |
| 51 | * The #NMWepKeyType values specify how any WEP keys present in the setting |
| 52 | * are interpreted. There are no standards governing how to hash the various WEP |
| 53 | * key/passphrase formats into the actual WEP key. Unfortunately some WEP keys |
| 54 | * can be interpreted in multiple ways, requiring the setting to specify how to |
| 55 | * interpret the any WEP keys. For example, the key "732f2d712e4a394a375d366931" |
| 56 | * is both a valid Hexadecimal WEP key and a WEP passphrase. Further, many |
| 57 | * ASCII keys are also valid WEP passphrases, but since passphrases and ASCII |
| 58 | * keys are hashed differently to determine the actual WEP key the type must be |
| 59 | * specified. |
| 60 | */ |
| 61 | typedef enum { |
| 62 | NM_WEP_KEY_TYPE_UNKNOWN = 0, |
| 63 | NM_WEP_KEY_TYPE_KEY = 1, /* Hex or ASCII */ |
| 64 | NM_WEP_KEY_TYPE_PASSPHRASE = 2, /* 104/128-bit Passphrase */ |
| 65 | |
| 66 | NM_WEP_KEY_TYPE_LAST = NM_WEP_KEY_TYPE_PASSPHRASE, /*< skip >*/ |
| 67 | } NMWepKeyType; |
| 68 | |
| 69 | /** |
| 70 | * NMSettingWirelessSecurityPmf: |
| 71 | * @NM_SETTING_WIRELESS_SECURITY_PMF_DEFAULT: use the default value |
| 72 | * @NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE: disable PMF |
| 73 | * @NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL: enable PMF if the supplicant and the AP support it |
| 74 | * @NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED: require PMF and fail if not available |
| 75 | * |
| 76 | * These flags indicate whether PMF must be enabled. |
| 77 | **/ |
| 78 | typedef enum { |
| 79 | NM_SETTING_WIRELESS_SECURITY_PMF_DEFAULT = 0, |
| 80 | NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE = 1, |
| 81 | NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL = 2, |
| 82 | NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED = 3, |
| 83 | _NM_SETTING_WIRELESS_SECURITY_PMF_NUM, /*< skip >*/ |
| 84 | NM_SETTING_WIRELESS_SECURITY_PMF_LAST = _NM_SETTING_WIRELESS_SECURITY_PMF_NUM - 1, /*< skip >*/ |
| 85 | } NMSettingWirelessSecurityPmf; |
| 86 | |
| 87 | /** |
| 88 | * NMSettingWirelessSecurityWpsMethod: |
| 89 | * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT: Attempt whichever method AP supports |
| 90 | * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DISABLED: WPS can not be used. |
| 91 | * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_AUTO: Use WPS, any method |
| 92 | * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PBC: use WPS push-button method |
| 93 | * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PIN: use PIN method |
| 94 | * |
| 95 | * Configure the use of WPS by a connection while it activates. |
| 96 | * |
| 97 | * Note: prior to 1.16, this was a GEnum type instead of a GFlags type |
| 98 | * although, with the same numeric values. |
| 99 | * |
| 100 | * Since: 1.10 |
| 101 | **/ |
| 102 | typedef enum { /*< flags >*/ |
| 103 | NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT = 0x00000000, |
| 104 | NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DISABLED = 0x00000001, |
| 105 | NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_AUTO = 0x00000002, |
| 106 | NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PBC = 0x00000004, |
| 107 | NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PIN = 0x00000008, |
| 108 | } NMSettingWirelessSecurityWpsMethod; |
| 109 | |
| 110 | /** |
| 111 | * NMSettingWirelessSecurityFils: |
| 112 | * @NM_SETTING_WIRELESS_SECURITY_FILS_DEFAULT: use the default value |
| 113 | * @NM_SETTING_WIRELESS_SECURITY_FILS_DISABLE: disable FILS |
| 114 | * @NM_SETTING_WIRELESS_SECURITY_FILS_OPTIONAL: enable FILS if the supplicant and the AP support it |
| 115 | * @NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED: require FILS and fail if not available |
| 116 | * @_NM_SETTING_WIRELESS_SECURITY_FILS_NUM: placeholder value for bounds-checking |
| 117 | * @NM_SETTING_WIRELESS_SECURITY_FILS_LAST: placeholder value for bounds-checking |
| 118 | * |
| 119 | * These flags indicate whether FILS must be enabled. |
| 120 | * |
| 121 | * Since: 1.12 |
| 122 | **/ |
| 123 | /* clang-format off */ |
| 124 | typedef enum { |
| 125 | NM_SETTING_WIRELESS_SECURITY_FILS_DEFAULT = 0, |
| 126 | NM_SETTING_WIRELESS_SECURITY_FILS_DISABLE = 1, |
| 127 | NM_SETTING_WIRELESS_SECURITY_FILS_OPTIONAL = 2, |
| 128 | NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED = 3, |
| 129 | _NM_SETTING_WIRELESS_SECURITY_FILS_NUM, /*< skip >*/ |
| 130 | NM_SETTING_WIRELESS_SECURITY_FILS_LAST = _NM_SETTING_WIRELESS_SECURITY_FILS_NUM - 1, /*< skip >*/ |
| 131 | } NMSettingWirelessSecurityFils; |
| 132 | /* clang-format on */ |
| 133 | |
| 134 | #define NM_SETTING_WIRELESS_SECURITY_KEY_MGMT "key-mgmt" |
| 135 | #define NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX "wep-tx-keyidx" |
| 136 | #define NM_SETTING_WIRELESS_SECURITY_AUTH_ALG "auth-alg" |
| 137 | #define NM_SETTING_WIRELESS_SECURITY_PROTO "proto" |
| 138 | #define NM_SETTING_WIRELESS_SECURITY_PAIRWISE "pairwise" |
| 139 | #define NM_SETTING_WIRELESS_SECURITY_GROUP "group" |
| 140 | #define NM_SETTING_WIRELESS_SECURITY_PMF "pmf" |
| 141 | #define NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME "leap-username" |
| 142 | #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY0 "wep-key0" |
| 143 | #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY1 "wep-key1" |
| 144 | #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY2 "wep-key2" |
| 145 | #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY3 "wep-key3" |
| 146 | #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS "wep-key-flags" |
| 147 | #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE "wep-key-type" |
| 148 | #define NM_SETTING_WIRELESS_SECURITY_PSK "psk" |
| 149 | #define NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS "psk-flags" |
| 150 | #define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD "leap-password" |
| 151 | #define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS "leap-password-flags" |
| 152 | #define NM_SETTING_WIRELESS_SECURITY_WPS_METHOD "wps-method" |
| 153 | #define NM_SETTING_WIRELESS_SECURITY_FILS "fils" |
| 154 | |
| 155 | typedef struct _NMSettingWirelessSecurityClass NMSettingWirelessSecurityClass; |
| 156 | |
| 157 | GType nm_setting_wireless_security_get_type(void); |
| 158 | |
| 159 | NMSetting *nm_setting_wireless_security_new(void); |
| 160 | |
| 161 | const char *nm_setting_wireless_security_get_key_mgmt(NMSettingWirelessSecurity *setting); |
| 162 | |
| 163 | guint32 nm_setting_wireless_security_get_num_protos(NMSettingWirelessSecurity *setting); |
| 164 | const char *nm_setting_wireless_security_get_proto(NMSettingWirelessSecurity *setting, guint32 i); |
| 165 | gboolean nm_setting_wireless_security_add_proto(NMSettingWirelessSecurity *setting, |
| 166 | const char *proto); |
| 167 | void nm_setting_wireless_security_remove_proto(NMSettingWirelessSecurity *setting, guint32 i); |
| 168 | gboolean nm_setting_wireless_security_remove_proto_by_value(NMSettingWirelessSecurity *setting, |
| 169 | const char *proto); |
| 170 | void nm_setting_wireless_security_clear_protos(NMSettingWirelessSecurity *setting); |
| 171 | |
| 172 | guint32 nm_setting_wireless_security_get_num_pairwise(NMSettingWirelessSecurity *setting); |
| 173 | const char *nm_setting_wireless_security_get_pairwise(NMSettingWirelessSecurity *setting, |
| 174 | guint32 i); |
| 175 | gboolean nm_setting_wireless_security_add_pairwise(NMSettingWirelessSecurity *setting, |
| 176 | const char *pairwise); |
| 177 | void nm_setting_wireless_security_remove_pairwise(NMSettingWirelessSecurity *setting, guint32 i); |
| 178 | gboolean nm_setting_wireless_security_remove_pairwise_by_value(NMSettingWirelessSecurity *setting, |
| 179 | const char *pairwise); |
| 180 | void nm_setting_wireless_security_clear_pairwise(NMSettingWirelessSecurity *setting); |
| 181 | |
| 182 | guint32 nm_setting_wireless_security_get_num_groups(NMSettingWirelessSecurity *setting); |
| 183 | const char *nm_setting_wireless_security_get_group(NMSettingWirelessSecurity *setting, guint32 i); |
| 184 | gboolean nm_setting_wireless_security_add_group(NMSettingWirelessSecurity *setting, |
| 185 | const char *group); |
| 186 | void nm_setting_wireless_security_remove_group(NMSettingWirelessSecurity *setting, guint32 i); |
| 187 | gboolean nm_setting_wireless_security_remove_group_by_value(NMSettingWirelessSecurity *setting, |
| 188 | const char *group); |
| 189 | void nm_setting_wireless_security_clear_groups(NMSettingWirelessSecurity *setting); |
| 190 | |
| 191 | NM_AVAILABLE_IN_1_10 |
| 192 | NMSettingWirelessSecurityPmf |
| 193 | nm_setting_wireless_security_get_pmf(NMSettingWirelessSecurity *setting); |
| 194 | |
| 195 | const char *nm_setting_wireless_security_get_psk(NMSettingWirelessSecurity *setting); |
| 196 | NMSettingSecretFlags nm_setting_wireless_security_get_psk_flags(NMSettingWirelessSecurity *setting); |
| 197 | |
| 198 | const char *nm_setting_wireless_security_get_leap_username(NMSettingWirelessSecurity *setting); |
| 199 | const char *nm_setting_wireless_security_get_leap_password(NMSettingWirelessSecurity *setting); |
| 200 | NMSettingSecretFlags |
| 201 | nm_setting_wireless_security_get_leap_password_flags(NMSettingWirelessSecurity *setting); |
| 202 | |
| 203 | const char *nm_setting_wireless_security_get_wep_key(NMSettingWirelessSecurity *setting, |
| 204 | guint32 idx); |
| 205 | void nm_setting_wireless_security_set_wep_key(NMSettingWirelessSecurity *setting, |
| 206 | guint32 idx, |
| 207 | const char *key); |
| 208 | guint32 nm_setting_wireless_security_get_wep_tx_keyidx(NMSettingWirelessSecurity *setting); |
| 209 | const char *nm_setting_wireless_security_get_auth_alg(NMSettingWirelessSecurity *setting); |
| 210 | |
| 211 | NMSettingSecretFlags |
| 212 | nm_setting_wireless_security_get_wep_key_flags(NMSettingWirelessSecurity *setting); |
| 213 | NMWepKeyType nm_setting_wireless_security_get_wep_key_type(NMSettingWirelessSecurity *setting); |
| 214 | |
| 215 | NM_AVAILABLE_IN_1_10 |
| 216 | NMSettingWirelessSecurityWpsMethod |
| 217 | nm_setting_wireless_security_get_wps_method(NMSettingWirelessSecurity *setting); |
| 218 | |
| 219 | NM_AVAILABLE_IN_1_12 |
| 220 | NMSettingWirelessSecurityFils |
| 221 | nm_setting_wireless_security_get_fils(NMSettingWirelessSecurity *setting); |
| 222 | |
| 223 | G_END_DECLS |
| 224 | |
| 225 | #endif /* __NM_SETTING_WIRELESS_SECURITY_H__ */ |
| 226 | |