nm-connection.h 11.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */

/*
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 *
19 20
 * Copyright 2007 - 2013 Red Hat, Inc.
 * Copyright 2007 - 2008 Novell, Inc.
21
 */
22

23 24 25 26
#ifndef NM_CONNECTION_H
#define NM_CONNECTION_H

#include <glib.h>
27
#include <glib-object.h>
28
#include "nm-setting.h"
29

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#include "nm-setting-8021x.h"
#include "nm-setting-bluetooth.h"
#include "nm-setting-bond.h"
#include "nm-setting-team.h"
#include "nm-setting-team-port.h"
#include "nm-setting-bridge.h"
#include "nm-setting-bridge-port.h"
#include "nm-setting-cdma.h"
#include "nm-setting-connection.h"
#include "nm-setting-dcb.h"
#include "nm-setting-generic.h"
#include "nm-setting-gsm.h"
#include "nm-setting-infiniband.h"
#include "nm-setting-ip4-config.h"
#include "nm-setting-ip6-config.h"
#include "nm-setting-olpc-mesh.h"
#include "nm-setting-ppp.h"
#include "nm-setting-pppoe.h"
#include "nm-setting-serial.h"
#include "nm-setting-vpn.h"
#include "nm-setting-wimax.h"
#include "nm-setting-wired.h"
#include "nm-setting-adsl.h"
#include "nm-setting-wireless.h"
#include "nm-setting-wireless-security.h"
#include "nm-setting-vlan.h"
56

57 58
G_BEGIN_DECLS

59 60 61 62
#define NM_TYPE_CONNECTION            (nm_connection_get_type ())
#define NM_CONNECTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION, NMConnection))
#define NM_CONNECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CONNECTION, NMConnectionClass))
#define NM_IS_CONNECTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION))
63
#define NM_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_CONNECTION))
64 65
#define NM_CONNECTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTION, NMConnectionClass))

66 67 68 69 70 71 72
/* Signals */
#define NM_CONNECTION_SECRETS_UPDATED "secrets-updated"
#define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared"
#define NM_CONNECTION_CHANGED         "changed"

/* Properties */
#define NM_CONNECTION_PATH "path"
Dan Williams's avatar
Dan Williams committed
73 74 75 76 77 78 79

/**
 * NMConnectionError:
 * @NM_CONNECTION_ERROR_UNKNOWN: unknown or unclassified error
 * @NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND: the #NMConnection object
 *   did not contain the required #NMSettingConnection object, which must be
 *   present for all connections
80 81 82 83
 * @NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID: the 'type' property of the
 *   'connection' setting did not point to a valid connection base type; ie
 *   it was not a hardware-related setting like #NMSettingWired or
 *   #NMSettingWireless.
84 85
 * @NM_CONNECTION_ERROR_SETTING_NOT_FOUND: the #NMConnection object
 *   did not contain the specified #NMSetting object
86 87
 *@NM_CONNECTION_ERROR_INVALID_SETTING: the #NMConnection object contains
 *   a conflicting setting object
Dan Williams's avatar
Dan Williams committed
88 89 90 91
 *
 * Describes errors that may result from operations involving a #NMConnection.
 *
 **/
92 93
typedef enum
{
94 95 96
	NM_CONNECTION_ERROR_UNKNOWN = 0,                  /*< nick=UnknownError >*/
	NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND, /*< nick=ConnectionSettingNotFound >*/
	NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID,      /*< nick=ConnectionTypeInvalid >*/
97 98
	NM_CONNECTION_ERROR_SETTING_NOT_FOUND,            /*< nick=SettingNotFound >*/
	NM_CONNECTION_ERROR_INVALID_SETTING,              /*< nick=InvalidSetting >*/
99 100
} NMConnectionError;

101 102 103 104 105 106 107
/*
 * NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD: overwrite the ip6 method
 * when normalizing ip6 configuration. If omited, this defaults to
 * @NM_SETTING_IP6_CONFIG_METHOD_AUTO.
 */
#define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method"

108 109 110
#define NM_CONNECTION_ERROR nm_connection_error_quark ()
GQuark nm_connection_error_quark (void);

Dan Williams's avatar
Dan Williams committed
111 112 113 114 115 116
/**
 * NMConnection:
 *
 * The NMConnection struct contains only private data.
 * It should only be accessed through the functions described below.
 */
117
typedef struct {
118
	GObject parent;
119 120
} NMConnection;

121 122
typedef struct {
	GObjectClass parent;
123 124 125

	/* Signals */
	void (*secrets_updated) (NMConnection *connection, const char * setting);
126 127 128 129
} NMConnectionClass;

GType nm_connection_get_type (void);

130
NMConnection *nm_connection_new           (void);
131 132 133

NMConnection *nm_connection_new_from_hash (GHashTable *hash, GError **error);

134 135
NMConnection *nm_connection_duplicate     (NMConnection *connection);

Dan Williams's avatar
Dan Williams committed
136 137
NMSetting    *nm_connection_create_setting (const char *name);

138
void          nm_connection_add_setting   (NMConnection *connection,
Dan Williams's avatar
Dan Williams committed
139
                                           NMSetting    *setting);
140

141
void          nm_connection_remove_setting (NMConnection *connection,
142
                                            GType         setting_type);
143

144
NMSetting    *nm_connection_get_setting   (NMConnection *connection,
145
                                           GType         setting_type);
146 147

NMSetting    *nm_connection_get_setting_by_name (NMConnection *connection,
Dan Williams's avatar
Dan Williams committed
148
                                                 const char   *name);
149

150
gboolean      nm_connection_replace_settings (NMConnection *connection,
151 152
                                              GHashTable *new_settings,
                                              GError **error);
153

154
NM_AVAILABLE_IN_0_9_10
155 156 157 158
gboolean      nm_connection_replace_settings_from_connection (NMConnection *connection,
                                                              NMConnection *new_connection,
                                                              GError **error);

159 160
gboolean      nm_connection_compare       (NMConnection *a,
                                           NMConnection *b,
161
                                           NMSettingCompareFlags flags);
162

163 164 165 166 167
gboolean      nm_connection_diff          (NMConnection *a,
                                           NMConnection *b,
                                           NMSettingCompareFlags flags,
                                           GHashTable **out_settings);

168
gboolean      nm_connection_verify        (NMConnection *connection, GError **error);
169 170 171 172 173
NM_AVAILABLE_IN_1_0
gboolean      nm_connection_normalize     (NMConnection *connection,
                                           GHashTable *parameters,
                                           gboolean *modified,
                                           GError **error);
174

175 176
const char *  nm_connection_need_secrets  (NMConnection *connection,
                                           GPtrArray **hints);
177

178 179
void          nm_connection_clear_secrets (NMConnection *connection);

180 181 182 183
void          nm_connection_clear_secrets_with_flags (NMConnection *connection,
                                                      NMSettingClearSecretsWithFlagsFn func,
                                                      gpointer user_data);

184
gboolean      nm_connection_update_secrets (NMConnection *connection,
185
                                            const char *setting_name,
186
                                            GHashTable *secrets,
187
                                            GError **error);
188

Dan Williams's avatar
Dan Williams committed
189 190
void          nm_connection_set_path      (NMConnection *connection,
                                           const char *path);
191

Dan Williams's avatar
Dan Williams committed
192
const char *  nm_connection_get_path      (NMConnection *connection);
193

194 195
const char *  nm_connection_get_virtual_iface_name (NMConnection *connection);

196 197 198
NM_AVAILABLE_IN_1_0
const char *  nm_connection_get_interface_name (NMConnection *connection);

199 200
gboolean      nm_connection_is_type (NMConnection *connection, const char *type);

201
void          nm_connection_for_each_setting_value (NMConnection *connection,
202 203
                                                    NMSettingValueIterFn func,
                                                    gpointer user_data);
204

205 206 207
GHashTable   *nm_connection_to_hash       (NMConnection *connection,
                                           NMSettingHashFlags flags);

208
void          nm_connection_dump          (NMConnection *connection);
209

Dan Williams's avatar
Dan Williams committed
210
GType         nm_connection_lookup_setting_type (const char *name);
211

Dan Williams's avatar
Dan Williams committed
212
GType         nm_connection_lookup_setting_type_by_quark (GQuark error_quark);
213

214
/* Helpers */
215 216 217 218
const char *  nm_connection_get_uuid            (NMConnection *connection);
const char *  nm_connection_get_id              (NMConnection *connection);
NM_AVAILABLE_IN_0_9_10
const char *  nm_connection_get_connection_type (NMConnection *connection);
219

220
NM_AVAILABLE_IN_0_9_10
221
char *        nm_connection_get_virtual_device_description (NMConnection *connection);
222

223 224
NMSetting8021x *           nm_connection_get_setting_802_1x            (NMConnection *connection);
NMSettingBluetooth *       nm_connection_get_setting_bluetooth         (NMConnection *connection);
225
NMSettingBond *            nm_connection_get_setting_bond              (NMConnection *connection);
226
NM_AVAILABLE_IN_0_9_10
227
NMSettingTeam *            nm_connection_get_setting_team              (NMConnection *connection);
228
NM_AVAILABLE_IN_0_9_10
229
NMSettingTeamPort *        nm_connection_get_setting_team_port         (NMConnection *connection);
230
NMSettingBridge *          nm_connection_get_setting_bridge            (NMConnection *connection);
231
NMSettingBridgePort *      nm_connection_get_setting_bridge_port       (NMConnection *connection);
232 233
NMSettingCdma *            nm_connection_get_setting_cdma              (NMConnection *connection);
NMSettingConnection *      nm_connection_get_setting_connection        (NMConnection *connection);
234
NM_AVAILABLE_IN_0_9_10
235
NMSettingDcb *             nm_connection_get_setting_dcb               (NMConnection *connection);
236
NM_AVAILABLE_IN_0_9_10
237
NMSettingGeneric *         nm_connection_get_setting_generic           (NMConnection *connection);
238
NMSettingGsm *             nm_connection_get_setting_gsm               (NMConnection *connection);
239
NMSettingInfiniband *      nm_connection_get_setting_infiniband        (NMConnection *connection);
240 241 242 243 244
NMSettingIP4Config *       nm_connection_get_setting_ip4_config        (NMConnection *connection);
NMSettingIP6Config *       nm_connection_get_setting_ip6_config        (NMConnection *connection);
NMSettingOlpcMesh *        nm_connection_get_setting_olpc_mesh         (NMConnection *connection);
NMSettingPPP *             nm_connection_get_setting_ppp               (NMConnection *connection);
NMSettingPPPOE *           nm_connection_get_setting_pppoe             (NMConnection *connection);
245
NMSettingSerial *          nm_connection_get_setting_serial            (NMConnection *connection);
246 247
NMSettingVPN *             nm_connection_get_setting_vpn               (NMConnection *connection);
NMSettingWimax *           nm_connection_get_setting_wimax             (NMConnection *connection);
248
NMSettingAdsl *            nm_connection_get_setting_adsl              (NMConnection *connection);
249 250 251
NMSettingWired *           nm_connection_get_setting_wired             (NMConnection *connection);
NMSettingWireless *        nm_connection_get_setting_wireless          (NMConnection *connection);
NMSettingWirelessSecurity *nm_connection_get_setting_wireless_security (NMConnection *connection);
252
NMSettingVlan *            nm_connection_get_setting_vlan              (NMConnection *connection);
253

254 255
G_END_DECLS

256
#endif /* NM_CONNECTION_H */