device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-core / nm-setting-wireless-security.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
3 /*
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301 USA.
18  *
19  * Copyright 2007 - 2014 Red Hat, Inc.
20  * Copyright 2007 - 2008 Novell, Inc.
21  */
22
23 #ifndef __NM_SETTING_WIRELESS_SECURITY_H__
24 #define __NM_SETTING_WIRELESS_SECURITY_H__
25
26 #if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
27 #error "Only <NetworkManager.h> can be included directly."
28 #endif
29
30 #include <nm-setting.h>
31
32 G_BEGIN_DECLS
33
34 #define NM_TYPE_SETTING_WIRELESS_SECURITY            (nm_setting_wireless_security_get_type ())
35 #define NM_SETTING_WIRELESS_SECURITY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurity))
36 #define NM_SETTING_WIRELESS_SECURITY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurityClass))
37 #define NM_IS_SETTING_WIRELESS_SECURITY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_WIRELESS_SECURITY))
38 #define NM_IS_SETTING_WIRELESS_SECURITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_WIRELESS_SECURITY))
39 #define NM_SETTING_WIRELESS_SECURITY_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurityClass))
40
41 #define NM_SETTING_WIRELESS_SECURITY_SETTING_NAME "802-11-wireless-security"
42
43 /**
44  * NMWepKeyType:
45  * @NM_WEP_KEY_TYPE_UNKNOWN: unknown WEP key type
46  * @NM_WEP_KEY_TYPE_KEY: indicates a hexadecimal or ASCII formatted WEP key.
47  * Hex keys are either 10 or 26 hexadecimal characters (ie "5f782f2f5f" or
48  * "732f2d712e4a394a375d366931"), while ASCII keys are either 5 or 13 ASCII
49  * characters (ie "abcde" or "blahblah99$*1").
50  * @NM_WEP_KEY_TYPE_PASSPHRASE: indicates a WEP passphrase (ex "I bought a duck
51  * on my way back from the market 235Q&^%^*%") instead of a hexadecimal or ASCII
52  * key.  Passphrases are between 8 and 64 characters inclusive and are hashed
53  * the actual WEP key using the MD5 hash algorithm.
54  * @NM_WEP_KEY_TYPE_LAST: placeholder value for bounds-checking
55  *
56  * The #NMWepKeyType values specify how any WEP keys present in the setting
57  * are intepreted.  There are no standards governing how to hash the various WEP
58  * key/passphrase formats into the actual WEP key.  Unfortunately some WEP keys
59  * can be interpreted in multiple ways, requring the setting to specify how to
60  * interpret the any WEP keys.  For example, the key "732f2d712e4a394a375d366931"
61  * is both a valid Hexadecimal WEP key and a WEP passphrase.  Further, many
62  * ASCII keys are also valid WEP passphrases, but since passphrases and ASCII
63  * keys are hashed differently to determine the actual WEP key the type must be
64  * specified.
65  */
66 typedef enum {
67         NM_WEP_KEY_TYPE_UNKNOWN = 0,
68         NM_WEP_KEY_TYPE_KEY = 1,          /* Hex or ASCII */
69         NM_WEP_KEY_TYPE_PASSPHRASE = 2,   /* 104/128-bit Passphrase */
70
71         NM_WEP_KEY_TYPE_LAST = NM_WEP_KEY_TYPE_PASSPHRASE
72 } NMWepKeyType;
73
74 #define NM_SETTING_WIRELESS_SECURITY_KEY_MGMT "key-mgmt"
75 #define NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX "wep-tx-keyidx"
76 #define NM_SETTING_WIRELESS_SECURITY_AUTH_ALG "auth-alg"
77 #define NM_SETTING_WIRELESS_SECURITY_PROTO "proto"
78 #define NM_SETTING_WIRELESS_SECURITY_PAIRWISE "pairwise"
79 #define NM_SETTING_WIRELESS_SECURITY_GROUP "group"
80 #define NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME "leap-username"
81 #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY0 "wep-key0"
82 #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY1 "wep-key1"
83 #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY2 "wep-key2"
84 #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY3 "wep-key3"
85 #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS "wep-key-flags"
86 #define NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE "wep-key-type"
87 #define NM_SETTING_WIRELESS_SECURITY_PSK "psk"
88 #define NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS "psk-flags"
89 #define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD "leap-password"
90 #define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS "leap-password-flags"
91
92 struct _NMSettingWirelessSecurity {
93         NMSetting parent;
94 };
95
96 typedef struct {
97         NMSettingClass parent;
98
99         /*< private >*/
100         gpointer padding[4];
101 } NMSettingWirelessSecurityClass;
102
103 GType nm_setting_wireless_security_get_type (void);
104
105 NMSetting * nm_setting_wireless_security_new               (void);
106
107 const char *nm_setting_wireless_security_get_key_mgmt      (NMSettingWirelessSecurity *setting);
108
109 guint32     nm_setting_wireless_security_get_num_protos        (NMSettingWirelessSecurity *setting);
110 const char *nm_setting_wireless_security_get_proto             (NMSettingWirelessSecurity *setting, guint32 i);
111 gboolean    nm_setting_wireless_security_add_proto             (NMSettingWirelessSecurity *setting, const char *proto);
112 void        nm_setting_wireless_security_remove_proto          (NMSettingWirelessSecurity *setting, guint32 i);
113 gboolean    nm_setting_wireless_security_remove_proto_by_value (NMSettingWirelessSecurity *setting, const char *proto);
114 void        nm_setting_wireless_security_clear_protos          (NMSettingWirelessSecurity *setting);
115
116 guint32     nm_setting_wireless_security_get_num_pairwise         (NMSettingWirelessSecurity *setting);
117 const char *nm_setting_wireless_security_get_pairwise             (NMSettingWirelessSecurity *setting, guint32 i);
118 gboolean    nm_setting_wireless_security_add_pairwise             (NMSettingWirelessSecurity *setting, const char *pairwise);
119 void        nm_setting_wireless_security_remove_pairwise          (NMSettingWirelessSecurity *setting, guint32 i);
120 gboolean    nm_setting_wireless_security_remove_pairwise_by_value (NMSettingWirelessSecurity *setting, const char *pairwise);
121 void        nm_setting_wireless_security_clear_pairwise           (NMSettingWirelessSecurity *setting);
122
123 guint32     nm_setting_wireless_security_get_num_groups        (NMSettingWirelessSecurity *setting);
124 const char *nm_setting_wireless_security_get_group             (NMSettingWirelessSecurity *setting, guint32 i);
125 gboolean    nm_setting_wireless_security_add_group             (NMSettingWirelessSecurity *setting, const char *group);
126 void        nm_setting_wireless_security_remove_group          (NMSettingWirelessSecurity *setting, guint32 i);
127 gboolean    nm_setting_wireless_security_remove_group_by_value (NMSettingWirelessSecurity *setting, const char *group);
128 void        nm_setting_wireless_security_clear_groups          (NMSettingWirelessSecurity *setting);
129
130 const char *nm_setting_wireless_security_get_psk           (NMSettingWirelessSecurity *setting);
131 NMSettingSecretFlags nm_setting_wireless_security_get_psk_flags (NMSettingWirelessSecurity *setting);
132
133 const char *nm_setting_wireless_security_get_leap_username (NMSettingWirelessSecurity *setting);
134 const char *nm_setting_wireless_security_get_leap_password (NMSettingWirelessSecurity *setting);
135 NMSettingSecretFlags nm_setting_wireless_security_get_leap_password_flags (NMSettingWirelessSecurity *setting);
136
137 const char *nm_setting_wireless_security_get_wep_key       (NMSettingWirelessSecurity *setting, guint32 idx);
138 void        nm_setting_wireless_security_set_wep_key       (NMSettingWirelessSecurity *setting, guint32 idx, const char *key);
139 guint32     nm_setting_wireless_security_get_wep_tx_keyidx (NMSettingWirelessSecurity *setting);
140 const char *nm_setting_wireless_security_get_auth_alg      (NMSettingWirelessSecurity *setting);
141
142 NMSettingSecretFlags nm_setting_wireless_security_get_wep_key_flags (NMSettingWirelessSecurity *setting);
143 NMWepKeyType nm_setting_wireless_security_get_wep_key_type (NMSettingWirelessSecurity *setting);
144
145 G_END_DECLS
146
147 #endif /* __NM_SETTING_WIRELESS_SECURITY_H__ */