device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-core / nm-connection.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 - 2013 Red Hat, Inc.
20  * Copyright 2007 - 2008 Novell, Inc.
21  */
22
23 #ifndef __NM_CONNECTION_H__
24 #define __NM_CONNECTION_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-core-types.h>
31 #include <nm-setting.h>
32 #include <nm-errors.h>
33
34 G_BEGIN_DECLS
35
36 #define NM_TYPE_CONNECTION                (nm_connection_get_type ())
37 #define NM_CONNECTION(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION, NMConnection))
38 #define NM_IS_CONNECTION(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION))
39 #define NM_CONNECTION_GET_INTERFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_CONNECTION, NMConnectionClass))
40
41 /* Signals */
42 #define NM_CONNECTION_SECRETS_UPDATED "secrets-updated"
43 #define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared"
44 #define NM_CONNECTION_CHANGED         "changed"
45
46 /*
47  * NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD: overwrite the ip6 method
48  * when normalizing ip6 configuration. If omited, this defaults to
49  * @NM_SETTING_IP6_CONFIG_METHOD_AUTO.
50  */
51 #define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method"
52
53 /**
54  * NMConnection:
55  *
56  * NMConnection is the interface implemented by #NMRemoteConnection on the
57  * client side, and #NMSettingsConnection on the daemon side.
58  */
59
60 /**
61  * NMConnectionInterface:
62  * @parent: the parent interace struct
63  * @secrets_updated: emitted when the connection's secrets are updated
64  * @secrets_cleared: emitted when the connection's secrets are cleared
65  * @changed: emitted when any change to the connection's settings occurs
66  */
67 typedef struct {
68         GTypeInterface parent;
69
70         /* Signals */
71         void (*secrets_updated) (NMConnection *connection,
72                                  const char   *setting);
73         void (*secrets_cleared) (NMConnection *connection);
74         void (*changed)         (NMConnection *connection);
75
76 } NMConnectionInterface;
77
78 GType nm_connection_get_type (void);
79
80 void          nm_connection_add_setting   (NMConnection *connection,
81                                            NMSetting    *setting);
82
83 void          nm_connection_remove_setting (NMConnection *connection,
84                                             GType         setting_type);
85
86 NMSetting    *nm_connection_get_setting   (NMConnection *connection,
87                                            GType         setting_type);
88
89 NMSetting    *nm_connection_get_setting_by_name (NMConnection *connection,
90                                                  const char   *name);
91
92 /**
93  * NM_VARIANT_TYPE_CONNECTION:
94  *
95  * #GVariantType for a dictionary mapping from setting names to
96  * %NM_VARIANT_TYPE_SETTING variants. This is used to represent an
97  * #NMConnection, and is the type taken by nm_simple_connection_new_from_dbus()
98  * and returned from nm_connection_to_dbus().
99  */
100 #define NM_VARIANT_TYPE_CONNECTION (G_VARIANT_TYPE ("a{sa{sv}}"))
101
102 /**
103  * NM_VARIANT_TYPE_SETTING:
104  *
105  * #GVariantType for a dictionary mapping from property names to values. This is
106  * an alias for %G_VARIANT_TYPE_VARDICT, and is the type of each element of
107  * an %NM_VARIANT_TYPE_CONNECTION dictionary.
108  */
109 #define NM_VARIANT_TYPE_SETTING G_VARIANT_TYPE_VARDICT
110
111 /**
112  * NMConnectionSerializationFlags:
113  * @NM_CONNECTION_SERIALIZE_ALL: serialize all properties (including secrets)
114  * @NM_CONNECTION_SERIALIZE_NO_SECRETS: do not include secrets
115  * @NM_CONNECTION_SERIALIZE_ONLY_SECRETS: only serialize secrets
116  *
117  * These flags determine which properties are serialized when calling when
118  * calling nm_connection_to_dbus().
119  **/
120 typedef enum { /*< flags >*/
121         NM_CONNECTION_SERIALIZE_ALL = 0x00000000,
122         NM_CONNECTION_SERIALIZE_NO_SECRETS = 0x00000001,
123         NM_CONNECTION_SERIALIZE_ONLY_SECRETS = 0x00000002,
124 } NMConnectionSerializationFlags;
125
126 GVariant     *nm_connection_to_dbus       (NMConnection *connection,
127                                            NMConnectionSerializationFlags flags);
128
129 gboolean      nm_connection_replace_settings (NMConnection *connection,
130                                               GVariant *new_settings,
131                                               GError **error);
132
133 void          nm_connection_replace_settings_from_connection (NMConnection *connection,
134                                                               NMConnection *new_connection);
135
136 void          nm_connection_clear_settings (NMConnection *connection);
137
138 gboolean      nm_connection_compare       (NMConnection *a,
139                                            NMConnection *b,
140                                            NMSettingCompareFlags flags);
141
142 gboolean      nm_connection_diff          (NMConnection *a,
143                                            NMConnection *b,
144                                            NMSettingCompareFlags flags,
145                                            GHashTable **out_settings);
146
147 gboolean      nm_connection_verify        (NMConnection *connection, GError **error);
148 NM_AVAILABLE_IN_1_2
149 gboolean      nm_connection_verify_secrets (NMConnection *connection, GError **error);
150 gboolean      nm_connection_normalize     (NMConnection *connection,
151                                            GHashTable *parameters,
152                                            gboolean *modified,
153                                            GError **error);
154
155 const char *  nm_connection_need_secrets  (NMConnection *connection,
156                                            GPtrArray **hints);
157
158 void          nm_connection_clear_secrets (NMConnection *connection);
159
160 void          nm_connection_clear_secrets_with_flags (NMConnection *connection,
161                                                       NMSettingClearSecretsWithFlagsFn func,
162                                                       gpointer user_data);
163
164 gboolean      nm_connection_update_secrets (NMConnection *connection,
165                                             const char *setting_name,
166                                             GVariant *secrets,
167                                             GError **error);
168
169 void          nm_connection_set_path      (NMConnection *connection,
170                                            const char *path);
171
172 const char *  nm_connection_get_path      (NMConnection *connection);
173
174 const char *  nm_connection_get_interface_name (NMConnection *connection);
175
176 gboolean      nm_connection_is_type (NMConnection *connection, const char *type);
177
178 void          nm_connection_for_each_setting_value (NMConnection *connection,
179                                                     NMSettingValueIterFn func,
180                                                     gpointer user_data);
181
182 void          nm_connection_dump          (NMConnection *connection);
183
184 /* Helpers */
185 const char *  nm_connection_get_uuid            (NMConnection *connection);
186 const char *  nm_connection_get_id              (NMConnection *connection);
187 const char *  nm_connection_get_connection_type (NMConnection *connection);
188
189 gboolean      nm_connection_is_virtual          (NMConnection *connection);
190 char *        nm_connection_get_virtual_device_description (NMConnection *connection);
191
192 NMSetting8021x *           nm_connection_get_setting_802_1x            (NMConnection *connection);
193 NMSettingBluetooth *       nm_connection_get_setting_bluetooth         (NMConnection *connection);
194 NMSettingBond *            nm_connection_get_setting_bond              (NMConnection *connection);
195 NMSettingTeam *            nm_connection_get_setting_team              (NMConnection *connection);
196 NMSettingTeamPort *        nm_connection_get_setting_team_port         (NMConnection *connection);
197 NMSettingBridge *          nm_connection_get_setting_bridge            (NMConnection *connection);
198 NMSettingBridgePort *      nm_connection_get_setting_bridge_port       (NMConnection *connection);
199 NMSettingCdma *            nm_connection_get_setting_cdma              (NMConnection *connection);
200 NMSettingConnection *      nm_connection_get_setting_connection        (NMConnection *connection);
201 NMSettingDcb *             nm_connection_get_setting_dcb               (NMConnection *connection);
202 NMSettingGeneric *         nm_connection_get_setting_generic           (NMConnection *connection);
203 NMSettingGsm *             nm_connection_get_setting_gsm               (NMConnection *connection);
204 NMSettingInfiniband *      nm_connection_get_setting_infiniband        (NMConnection *connection);
205 NM_AVAILABLE_IN_1_2
206 NMSettingIPTunnel *        nm_connection_get_setting_ip_tunnel         (NMConnection *connection);
207 NMSettingIPConfig *        nm_connection_get_setting_ip4_config        (NMConnection *connection);
208 NMSettingIPConfig *        nm_connection_get_setting_ip6_config        (NMConnection *connection);
209 NM_AVAILABLE_IN_1_2
210 NMSettingMacvlan *         nm_connection_get_setting_macvlan           (NMConnection *connection);
211 NMSettingOlpcMesh *        nm_connection_get_setting_olpc_mesh         (NMConnection *connection);
212 NMSettingPpp *             nm_connection_get_setting_ppp               (NMConnection *connection);
213 NMSettingPppoe *           nm_connection_get_setting_pppoe             (NMConnection *connection);
214 NMSettingSerial *          nm_connection_get_setting_serial            (NMConnection *connection);
215 NMSettingTun *             nm_connection_get_setting_tun               (NMConnection *connection);
216 NMSettingVpn *             nm_connection_get_setting_vpn               (NMConnection *connection);
217 NMSettingWimax *           nm_connection_get_setting_wimax             (NMConnection *connection);
218 NMSettingAdsl *            nm_connection_get_setting_adsl              (NMConnection *connection);
219 NMSettingWired *           nm_connection_get_setting_wired             (NMConnection *connection);
220 NMSettingWireless *        nm_connection_get_setting_wireless          (NMConnection *connection);
221 NMSettingWirelessSecurity *nm_connection_get_setting_wireless_security (NMConnection *connection);
222 NMSettingVlan *            nm_connection_get_setting_vlan              (NMConnection *connection);
223 NM_AVAILABLE_IN_1_2
224 NMSettingVxlan *           nm_connection_get_setting_vxlan             (NMConnection *connection);
225
226 G_END_DECLS
227
228 #endif /* __NM_CONNECTION_H__ */