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
16G_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 */
61typedef 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 * Since: 1.10
79 **/
80typedef enum {
81 NM_SETTING_WIRELESS_SECURITY_PMF_DEFAULT = 0,
82 NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE = 1,
83 NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL = 2,
84 NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED = 3,
85 _NM_SETTING_WIRELESS_SECURITY_PMF_NUM, /*< skip >*/
86 NM_SETTING_WIRELESS_SECURITY_PMF_LAST = _NM_SETTING_WIRELESS_SECURITY_PMF_NUM - 1, /*< skip >*/
87} NMSettingWirelessSecurityPmf;
88
89/**
90 * NMSettingWirelessSecurityWpsMethod:
91 * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT: Attempt whichever method AP supports
92 * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DISABLED: WPS can not be used.
93 * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_AUTO: Use WPS, any method
94 * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PBC: use WPS push-button method
95 * @NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PIN: use PIN method
96 *
97 * Configure the use of WPS by a connection while it activates.
98 *
99 * Note: prior to 1.16, this was a GEnum type instead of a GFlags type
100 * although, with the same numeric values.
101 *
102 * Since: 1.10
103 **/
104typedef enum /*< flags >*/ {
105 NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT = 0x00000000,
106 NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DISABLED = 0x00000001,
107 NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_AUTO = 0x00000002,
108 NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PBC = 0x00000004,
109 NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PIN = 0x00000008,
110} NMSettingWirelessSecurityWpsMethod;
111
112/**
113 * NMSettingWirelessSecurityFils:
114 * @NM_SETTING_WIRELESS_SECURITY_FILS_DEFAULT: use the default value
115 * @NM_SETTING_WIRELESS_SECURITY_FILS_DISABLE: disable FILS
116 * @NM_SETTING_WIRELESS_SECURITY_FILS_OPTIONAL: enable FILS if the supplicant and the AP support it
117 * @NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED: require FILS and fail if not available
118 * @_NM_SETTING_WIRELESS_SECURITY_FILS_NUM: placeholder value for bounds-checking
119 * @NM_SETTING_WIRELESS_SECURITY_FILS_LAST: placeholder value for bounds-checking
120 *
121 * These flags indicate whether FILS must be enabled.
122 *
123 * Since: 1.12
124 **/
125/* clang-format off */
126typedef enum {
127 NM_SETTING_WIRELESS_SECURITY_FILS_DEFAULT = 0,
128 NM_SETTING_WIRELESS_SECURITY_FILS_DISABLE = 1,
129 NM_SETTING_WIRELESS_SECURITY_FILS_OPTIONAL = 2,
130 NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED = 3,
131 _NM_SETTING_WIRELESS_SECURITY_FILS_NUM, /*< skip >*/
132 NM_SETTING_WIRELESS_SECURITY_FILS_LAST = _NM_SETTING_WIRELESS_SECURITY_FILS_NUM - 1, /*< skip >*/
133} NMSettingWirelessSecurityFils;
134/* clang-format on */
135
136#define NM_SETTING_WIRELESS_SECURITY_KEY_MGMT "key-mgmt"
137#define NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX "wep-tx-keyidx"
138#define NM_SETTING_WIRELESS_SECURITY_AUTH_ALG "auth-alg"
139#define NM_SETTING_WIRELESS_SECURITY_PROTO "proto"
140#define NM_SETTING_WIRELESS_SECURITY_PAIRWISE "pairwise"
141#define NM_SETTING_WIRELESS_SECURITY_GROUP "group"
142#define NM_SETTING_WIRELESS_SECURITY_PMF "pmf"
143#define NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME "leap-username"
144#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY0 "wep-key0"
145#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY1 "wep-key1"
146#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY2 "wep-key2"
147#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY3 "wep-key3"
148#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS "wep-key-flags"
149#define NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE "wep-key-type"
150#define NM_SETTING_WIRELESS_SECURITY_PSK "psk"
151#define NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS "psk-flags"
152#define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD "leap-password"
153#define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS "leap-password-flags"
154#define NM_SETTING_WIRELESS_SECURITY_WPS_METHOD "wps-method"
155#define NM_SETTING_WIRELESS_SECURITY_FILS "fils"
156
157typedef struct _NMSettingWirelessSecurityClass NMSettingWirelessSecurityClass;
158
159GType nm_setting_wireless_security_get_type(void);
160
161NMSetting *nm_setting_wireless_security_new(void);
162
163const char *nm_setting_wireless_security_get_key_mgmt(NMSettingWirelessSecurity *setting);
164
165guint32 nm_setting_wireless_security_get_num_protos(NMSettingWirelessSecurity *setting);
166const char *nm_setting_wireless_security_get_proto(NMSettingWirelessSecurity *setting, guint32 i);
167gboolean nm_setting_wireless_security_add_proto(NMSettingWirelessSecurity *setting,
168 const char *proto);
169void nm_setting_wireless_security_remove_proto(NMSettingWirelessSecurity *setting, guint32 i);
170gboolean nm_setting_wireless_security_remove_proto_by_value(NMSettingWirelessSecurity *setting,
171 const char *proto);
172void nm_setting_wireless_security_clear_protos(NMSettingWirelessSecurity *setting);
173
174guint32 nm_setting_wireless_security_get_num_pairwise(NMSettingWirelessSecurity *setting);
175const char *nm_setting_wireless_security_get_pairwise(NMSettingWirelessSecurity *setting,
176 guint32 i);
177gboolean nm_setting_wireless_security_add_pairwise(NMSettingWirelessSecurity *setting,
178 const char *pairwise);
179void nm_setting_wireless_security_remove_pairwise(NMSettingWirelessSecurity *setting, guint32 i);
180gboolean nm_setting_wireless_security_remove_pairwise_by_value(NMSettingWirelessSecurity *setting,
181 const char *pairwise);
182void nm_setting_wireless_security_clear_pairwise(NMSettingWirelessSecurity *setting);
183
184guint32 nm_setting_wireless_security_get_num_groups(NMSettingWirelessSecurity *setting);
185const char *nm_setting_wireless_security_get_group(NMSettingWirelessSecurity *setting, guint32 i);
186gboolean nm_setting_wireless_security_add_group(NMSettingWirelessSecurity *setting,
187 const char *group);
188void nm_setting_wireless_security_remove_group(NMSettingWirelessSecurity *setting, guint32 i);
189gboolean nm_setting_wireless_security_remove_group_by_value(NMSettingWirelessSecurity *setting,
190 const char *group);
191void nm_setting_wireless_security_clear_groups(NMSettingWirelessSecurity *setting);
192
193NM_AVAILABLE_IN_1_10
194NMSettingWirelessSecurityPmf
195nm_setting_wireless_security_get_pmf(NMSettingWirelessSecurity *setting);
196
197const char *nm_setting_wireless_security_get_psk(NMSettingWirelessSecurity *setting);
198NMSettingSecretFlags nm_setting_wireless_security_get_psk_flags(NMSettingWirelessSecurity *setting);
199
200const char *nm_setting_wireless_security_get_leap_username(NMSettingWirelessSecurity *setting);
201const char *nm_setting_wireless_security_get_leap_password(NMSettingWirelessSecurity *setting);
202NMSettingSecretFlags
203nm_setting_wireless_security_get_leap_password_flags(NMSettingWirelessSecurity *setting);
204
205const char *nm_setting_wireless_security_get_wep_key(NMSettingWirelessSecurity *setting,
206 guint32 idx);
207void nm_setting_wireless_security_set_wep_key(NMSettingWirelessSecurity *setting,
208 guint32 idx,
209 const char *key);
210guint32 nm_setting_wireless_security_get_wep_tx_keyidx(NMSettingWirelessSecurity *setting);
211const char *nm_setting_wireless_security_get_auth_alg(NMSettingWirelessSecurity *setting);
212
213NMSettingSecretFlags
214 nm_setting_wireless_security_get_wep_key_flags(NMSettingWirelessSecurity *setting);
215NMWepKeyType nm_setting_wireless_security_get_wep_key_type(NMSettingWirelessSecurity *setting);
216
217NM_AVAILABLE_IN_1_10
218NMSettingWirelessSecurityWpsMethod
219nm_setting_wireless_security_get_wps_method(NMSettingWirelessSecurity *setting);
220
221NM_AVAILABLE_IN_1_12
222NMSettingWirelessSecurityFils
223nm_setting_wireless_security_get_fils(NMSettingWirelessSecurity *setting);
224
225G_END_DECLS
226
227#endif /* __NM_SETTING_WIRELESS_SECURITY_H__ */
228

source code of include/libnm/nm-setting-wireless-security.h