1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
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.
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.
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.
19 * Copyright 2007 - 2013 Red Hat, Inc.
20 * Copyright 2007 - 2008 Novell, Inc.
23 #ifndef __NM_CONNECTION_H__
24 #define __NM_CONNECTION_H__
26 #if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
27 #error "Only <NetworkManager.h> can be included directly."
30 #include <nm-core-types.h>
31 #include <nm-setting.h>
32 #include <nm-errors.h>
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))
42 #define NM_CONNECTION_SECRETS_UPDATED "secrets-updated"
43 #define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared"
44 #define NM_CONNECTION_CHANGED "changed"
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.
51 #define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method"
56 * NMConnection is the interface implemented by #NMRemoteConnection on the
57 * client side, and #NMSettingsConnection on the daemon side.
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
68 GTypeInterface parent;
71 void (*secrets_updated) (NMConnection *connection,
73 void (*secrets_cleared) (NMConnection *connection);
74 void (*changed) (NMConnection *connection);
76 } NMConnectionInterface;
78 GType nm_connection_get_type (void);
80 void nm_connection_add_setting (NMConnection *connection,
83 void nm_connection_remove_setting (NMConnection *connection,
86 NMSetting *nm_connection_get_setting (NMConnection *connection,
89 NMSetting *nm_connection_get_setting_by_name (NMConnection *connection,
93 * NM_VARIANT_TYPE_CONNECTION:
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().
100 #define NM_VARIANT_TYPE_CONNECTION (G_VARIANT_TYPE ("a{sa{sv}}"))
103 * NM_VARIANT_TYPE_SETTING:
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.
109 #define NM_VARIANT_TYPE_SETTING G_VARIANT_TYPE_VARDICT
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
117 * These flags determine which properties are serialized when calling when
118 * calling nm_connection_to_dbus().
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;
126 GVariant *nm_connection_to_dbus (NMConnection *connection,
127 NMConnectionSerializationFlags flags);
129 gboolean nm_connection_replace_settings (NMConnection *connection,
130 GVariant *new_settings,
133 void nm_connection_replace_settings_from_connection (NMConnection *connection,
134 NMConnection *new_connection);
136 void nm_connection_clear_settings (NMConnection *connection);
138 gboolean nm_connection_compare (NMConnection *a,
140 NMSettingCompareFlags flags);
142 gboolean nm_connection_diff (NMConnection *a,
144 NMSettingCompareFlags flags,
145 GHashTable **out_settings);
147 gboolean nm_connection_verify (NMConnection *connection, GError **error);
149 gboolean nm_connection_verify_secrets (NMConnection *connection, GError **error);
150 gboolean nm_connection_normalize (NMConnection *connection,
151 GHashTable *parameters,
155 const char * nm_connection_need_secrets (NMConnection *connection,
158 void nm_connection_clear_secrets (NMConnection *connection);
160 void nm_connection_clear_secrets_with_flags (NMConnection *connection,
161 NMSettingClearSecretsWithFlagsFn func,
164 gboolean nm_connection_update_secrets (NMConnection *connection,
165 const char *setting_name,
169 void nm_connection_set_path (NMConnection *connection,
172 const char * nm_connection_get_path (NMConnection *connection);
174 const char * nm_connection_get_interface_name (NMConnection *connection);
176 gboolean nm_connection_is_type (NMConnection *connection, const char *type);
178 void nm_connection_for_each_setting_value (NMConnection *connection,
179 NMSettingValueIterFn func,
182 void nm_connection_dump (NMConnection *connection);
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);
189 gboolean nm_connection_is_virtual (NMConnection *connection);
190 char * nm_connection_get_virtual_device_description (NMConnection *connection);
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);
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);
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);
224 NMSettingVxlan * nm_connection_get_setting_vxlan (NMConnection *connection);
228 #endif /* __NM_CONNECTION_H__ */