nm-active-connection.h 9.19 KB
Newer Older
1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 3 4 5 6 7 8 9 10 11 12 13
/* NetworkManager -- Network link manager
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
14 15 16
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
 *
18
 * Copyright (C) 2008 - 2012 Red Hat, Inc.
19 20
 */

21 22
#ifndef __NETWORKMANAGER_ACTIVE_CONNECTION_H__
#define __NETWORKMANAGER_ACTIVE_CONNECTION_H__
23

24
#include "c-list/src/c-list.h"
25 26
#include "nm-connection.h"
#include "nm-dbus-object.h"
27

28 29 30 31
#define NM_TYPE_ACTIVE_CONNECTION            (nm_active_connection_get_type ())
#define NM_ACTIVE_CONNECTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnection))
#define NM_ACTIVE_CONNECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))
#define NM_IS_ACTIVE_CONNECTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_ACTIVE_CONNECTION))
32
#define NM_IS_ACTIVE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_ACTIVE_CONNECTION))
33 34
#define NM_ACTIVE_CONNECTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))

35
/* D-Bus Exported Properties */
36
#define NM_ACTIVE_CONNECTION_CONNECTION      "connection"
37
#define NM_ACTIVE_CONNECTION_ID              "id"
38
#define NM_ACTIVE_CONNECTION_UUID            "uuid"
39
#define NM_ACTIVE_CONNECTION_TYPE            "type"
40
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
41 42
#define NM_ACTIVE_CONNECTION_DEVICES         "devices"
#define NM_ACTIVE_CONNECTION_STATE           "state"
43
#define NM_ACTIVE_CONNECTION_STATE_FLAGS     "state-flags"
44
#define NM_ACTIVE_CONNECTION_DEFAULT         "default"
45 46
#define NM_ACTIVE_CONNECTION_IP4_CONFIG      "ip4-config"
#define NM_ACTIVE_CONNECTION_DHCP4_CONFIG    "dhcp4-config"
47
#define NM_ACTIVE_CONNECTION_DEFAULT6        "default6"
48 49
#define NM_ACTIVE_CONNECTION_IP6_CONFIG      "ip6-config"
#define NM_ACTIVE_CONNECTION_DHCP6_CONFIG    "dhcp6-config"
50 51 52
#define NM_ACTIVE_CONNECTION_VPN             "vpn"
#define NM_ACTIVE_CONNECTION_MASTER          "master"

53
/* Internal non-exported properties */
54
#define NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION "int-settings-connection"
55
#define NM_ACTIVE_CONNECTION_INT_APPLIED_CONNECTION  "int-applied-connection"
56 57 58 59 60 61
#define NM_ACTIVE_CONNECTION_INT_DEVICE              "int-device"
#define NM_ACTIVE_CONNECTION_INT_SUBJECT             "int-subject"
#define NM_ACTIVE_CONNECTION_INT_MASTER              "int-master"
#define NM_ACTIVE_CONNECTION_INT_MASTER_READY        "int-master-ready"
#define NM_ACTIVE_CONNECTION_INT_ACTIVATION_TYPE     "int-activation-type"
#define NM_ACTIVE_CONNECTION_INT_ACTIVATION_REASON   "int-activation-reason"
62

63 64 65
/* Signals */
#define NM_ACTIVE_CONNECTION_STATE_CHANGED           "state-changed"

66
/* Internal signals*/
67 68
#define NM_ACTIVE_CONNECTION_DEVICE_CHANGED          "device-changed"
#define NM_ACTIVE_CONNECTION_DEVICE_METERED_CHANGED  "device-metered-changed"
69
#define NM_ACTIVE_CONNECTION_PARENT_ACTIVE           "parent-active"
70

71 72
struct _NMActiveConnectionPrivate;

73
struct _NMActiveConnection {
74
	NMDBusObject parent;
75
	struct _NMActiveConnectionPrivate *_priv;
76 77 78 79

	/* active connection can be tracked in a list by NMManager. This is
	 * the list node. */
	CList active_connections_lst;
80
};
81 82

typedef struct {
83
	NMDBusObjectClass parent;
84

85 86 87 88 89 90 91 92
	/* re-emits device state changes as a convenience for subclasses for
	 * device states >= DISCONNECTED.
	 */
	void (*device_state_changed) (NMActiveConnection *connection,
	                              NMDevice *device,
	                              NMDeviceState new_state,
	                              NMDeviceState old_state);
	void (*master_failed)  (NMActiveConnection *connection);
93 94 95 96

	void (*device_changed) (NMActiveConnection *connection,
	                        NMDevice *new_device,
	                        NMDevice *old_device);
97 98 99

	void (*device_metered_changed) (NMActiveConnection *connection,
	                                NMMetered new_value);
100 101

	void (*parent_active) (NMActiveConnection *connection);
102 103
} NMActiveConnectionClass;

104 105 106
guint64 nm_active_connection_version_id_get (NMActiveConnection *self);
guint64 nm_active_connection_version_id_bump (NMActiveConnection *self);

107 108
GType         nm_active_connection_get_type (void);

109 110 111
typedef void (*NMActiveConnectionAuthResultFunc) (NMActiveConnection *self,
                                                  gboolean success,
                                                  const char *error_desc,
112
                                                  gpointer user_data);
113 114

void          nm_active_connection_authorize (NMActiveConnection *self,
115
                                              NMConnection *initial_connection,
116
                                              NMActiveConnectionAuthResultFunc result_func,
117
                                              gpointer user_data);
118

119 120
NMSettingsConnection *nm_active_connection_get_settings_connection (NMActiveConnection *self);
NMConnection *nm_active_connection_get_applied_connection (NMActiveConnection *self);
121

122
NMSettingsConnection *_nm_active_connection_get_settings_connection (NMActiveConnection *self);
123

124 125
void          nm_active_connection_set_settings_connection (NMActiveConnection *self,
                                                            NMSettingsConnection *connection);
126

127 128
gboolean      nm_active_connection_has_unmodified_applied_connection (NMActiveConnection *self,
                                                                      NMSettingCompareFlags compare_flags);
129

130
const char *  nm_active_connection_get_settings_connection_id         (NMActiveConnection *self);
131

132 133 134 135 136 137
const char *  nm_active_connection_get_specific_object (NMActiveConnection *self);

void          nm_active_connection_set_specific_object (NMActiveConnection *self,
                                                        const char *specific_object);

void          nm_active_connection_set_default (NMActiveConnection *self,
138
                                                int addr_family,
139 140
                                                gboolean is_default);

141
gboolean      nm_active_connection_get_default (NMActiveConnection *self, int addr_family);
142

143 144
NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *self);

145
void          nm_active_connection_set_state (NMActiveConnection *self,
146 147
                                              NMActiveConnectionState state,
                                              NMActiveConnectionStateReason reason);
148

149 150 151 152
void          nm_active_connection_set_state_fail (NMActiveConnection *active,
                                                   NMActiveConnectionStateReason reason,
                                                   const char *error_desc);

153 154 155 156 157 158 159 160 161 162 163 164 165
NMActivationStateFlags  nm_active_connection_get_state_flags (NMActiveConnection *self);

void          nm_active_connection_set_state_flags_full (NMActiveConnection *self,
                                                         NMActivationStateFlags state_flags,
                                                         NMActivationStateFlags mask);

static inline void
nm_active_connection_set_state_flags (NMActiveConnection *self,
                                      NMActivationStateFlags state_flags)
{
	nm_active_connection_set_state_flags_full (self, state_flags, state_flags);
}

166 167 168 169 170 171 172
static inline void
nm_active_connection_set_state_flags_clear (NMActiveConnection *self,
                                            NMActivationStateFlags state_flags)
{
	nm_active_connection_set_state_flags_full (self, NM_ACTIVATION_STATE_FLAG_NONE, state_flags);
}

173 174
NMDevice *    nm_active_connection_get_device (NMActiveConnection *self);

175 176
gboolean      nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device);

177 178
NMAuthSubject *nm_active_connection_get_subject (NMActiveConnection *self);

179 180
gboolean      nm_active_connection_get_user_requested (NMActiveConnection *self);

181
NMActiveConnection *nm_active_connection_get_master (NMActiveConnection *self);
182

183 184
gboolean      nm_active_connection_get_master_ready (NMActiveConnection *self);

185 186
void          nm_active_connection_set_master (NMActiveConnection *self,
                                               NMActiveConnection *master);
187

188 189 190
void          nm_active_connection_set_parent (NMActiveConnection *self,
                                               NMActiveConnection *parent);

191 192
NMActivationType nm_active_connection_get_activation_type (NMActiveConnection *self);

193 194
NMActivationReason nm_active_connection_get_activation_reason (NMActiveConnection *self);

195
NMKeepAlive  *nm_active_connection_get_keep_alive (NMActiveConnection *self);
196

197 198
void          nm_active_connection_clear_secrets (NMActiveConnection *self);

199
#endif /* __NETWORKMANAGER_ACTIVE_CONNECTION_H__ */