summary refs log tree commit diff
path: root/src/devices/nm-device.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/nm-device.h')
-rw-r--r--src/devices/nm-device.h205
1 files changed, 150 insertions, 55 deletions
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 49cef8e1..e173b2db 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -22,13 +22,11 @@
 #ifndef __NETWORKMANAGER_DEVICE_H__
 #define __NETWORKMANAGER_DEVICE_H__
 
-#include <glib-object.h>
-#include <gio/gio.h>
-#include <dbus/dbus-glib.h>
 #include <netinet/in.h>
 
+#include "nm-exported-object.h"
 #include "nm-dbus-interface.h"
-#include "nm-types.h"
+#include "nm-default.h"
 #include "nm-connection.h"
 #include "nm-rfkill-manager.h"
 #include "NetworkManagerUtils.h"
@@ -51,14 +49,23 @@
 #define NM_DEVICE_STATE_REASON     "state-reason"
 #define NM_DEVICE_ACTIVE_CONNECTION "active-connection"
 #define NM_DEVICE_DEVICE_TYPE      "device-type" /* ugh */
+#define NM_DEVICE_LINK_TYPE        "link-type"
 #define NM_DEVICE_MANAGED          "managed"
 #define NM_DEVICE_AUTOCONNECT      "autoconnect"
 #define NM_DEVICE_FIRMWARE_MISSING "firmware-missing"
+#define NM_DEVICE_NM_PLUGIN_MISSING "nm-plugin-missing"
 #define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
 #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
 #define NM_DEVICE_MTU              "mtu"
 #define NM_DEVICE_HW_ADDRESS       "hw-address"
 #define NM_DEVICE_METERED          "metered"
+#define NM_DEVICE_LLDP_NEIGHBORS  "lldp-neighbors"
+#define NM_DEVICE_REAL             "real"
+
+/* the "slaves" property is internal in the parent class, but exposed
+ * by the derived classes NMDeviceBond, NMDeviceBridge and NMDeviceTeam.
+ * It is thus important that the property name matches. */
+#define NM_DEVICE_SLAVES           "slaves"         /* partially internal */
 
 #define NM_DEVICE_TYPE_DESC        "type-desc"      /* Internal only */
 #define NM_DEVICE_RFKILL_TYPE      "rfkill-type"    /* Internal only */
@@ -74,6 +81,7 @@
 #define NM_DEVICE_REMOVED               "removed"
 #define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate"
 #define NM_DEVICE_RECHECK_ASSUME        "recheck-assume"
+#define NM_DEVICE_STATE_CHANGED         "state-changed"
 #define NM_DEVICE_LINK_INITIALIZED      "link-initialized"
 
 G_BEGIN_DECLS
@@ -100,28 +108,34 @@ typedef enum { /*< skip >*/
 	NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST                      = _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER
 	                                                                    | _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP,
 
-	__NM_DEVICE_CHECK_CON_AVAILABLE_ALL,
-	NM_DEVICE_CHECK_CON_AVAILABLE_ALL                                   = (((__NM_DEVICE_CHECK_CON_AVAILABLE_ALL - 1) << 1) - 1),
+	NM_DEVICE_CHECK_CON_AVAILABLE_ALL                                   = (1L << 2) - 1,
 } NMDeviceCheckConAvailableFlags;
 
+struct _NMDevicePrivate;
+
 struct _NMDevice {
-	GObject parent;
+	NMExportedObject parent;
+
+	/* private */
+	struct _NMDevicePrivate *priv;
 };
 
 /* The flags have an relaxing meaning, that means, specifying more flags, can make
  * a device appear more available. It can never make a device less available. */
 typedef enum { /*< skip >*/
 	NM_DEVICE_CHECK_DEV_AVAILABLE_NONE                                  = 0,
-	NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER                        = (1L << 0),
 
-	__NM_DEVICE_CHECK_DEV_AVAILABLE_ALL,
-	NM_DEVICE_CHECK_DEV_AVAILABLE_ALL                                   = (((__NM_DEVICE_CHECK_DEV_AVAILABLE_ALL - 1) << 1) - 1),
+	_NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER                       = (1L << 0),
+	NM_DEVICE_CHECK_DEV_AVAILABLE_FOR_USER_REQUEST                      = _NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER,
+
+	NM_DEVICE_CHECK_DEV_AVAILABLE_ALL                                   = (1L << 1) - 1,
 } NMDeviceCheckDevAvailableFlags;
 
 typedef struct {
-	GObjectClass parent;
+	NMExportedObjectClass parent;
 
 	const char *connection_type;
+	const NMLinkType *link_types;
 
 	void (*state_changed) (NMDevice *device,
 	                       NMDeviceState new_state,
@@ -130,6 +144,48 @@ typedef struct {
 
 	void            (* link_changed) (NMDevice *self, NMPlatformLink *info);
 
+	/**
+	 * create_and_realize():
+	 * @self: the #NMDevice
+	 * @connection: the #NMConnection being activated
+	 * @parent: the parent #NMDevice, if any
+	 * @out_plink: on success, a backing kernel network device if one exists.
+	 *   The returned pointer is owned by platform and only valid until the
+	 *   next platform operation.
+	 * @error: location to store error, or %NULL
+	 *
+	 * Create any backing resources (kernel devices, etc) required for this
+	 * device to activate @connection.  If the device is backed by a kernel
+	 * network device, that device should be returned in @out_plink after
+	 * being created.
+	 *
+	 * Returns: %TRUE on success, %FALSE on error
+	 */
+	gboolean        (*create_and_realize) (NMDevice *self,
+	                                       NMConnection *connection,
+	                                       NMDevice *parent,
+	                                       const NMPlatformLink **out_plink,
+	                                       GError **error);
+
+	/**
+	 * realize_start_notify():
+	 * @self: the #NMDevice
+	 * @plink: the #NMPlatformLink if backed by a kernel netdevice
+	 *
+	 * Hook for derived classes to be notfied during realize_start_setup()
+	 * and perform additional setup.
+	 */
+	void        (*realize_start_notify) (NMDevice *self, const NMPlatformLink *plink);
+
+	/**
+	 * unrealize_notify():
+	 * @self: the #NMDevice
+	 *
+	 * Hook for derived classes to clear any properties that depend on backing resources
+	 * (kernel devices, etc). This is called by nm_device_unrealize() during unrealization.
+	 */
+	void            (*unrealize_notify)  (NMDevice *self);
+
 	/* Hardware state (IFF_UP) */
 	gboolean        (*can_unmanaged_external_down)  (NMDevice *self);
 	gboolean        (*is_up)                        (NMDevice *self);
@@ -155,7 +211,7 @@ typedef struct {
 
 	/* Checks whether the connection is compatible with the device using
 	 * only the devices type and characteristics.  Does not use any live
-	 * network information like WiFi/WiMAX scan lists etc.
+	 * network information like WiFi scan lists etc.
 	 */
 	gboolean    (* check_connection_compatible) (NMDevice *self, NMConnection *connection);
 
@@ -186,11 +242,11 @@ typedef struct {
 	NMActStageReturn	(* act_stage2_config)	(NMDevice *self,
 	                                             NMDeviceStateReason *reason);
 	NMActStageReturn	(* act_stage3_ip4_config_start) (NMDevice *self,
-														 NMIP4Config **out_config,
-														 NMDeviceStateReason *reason);
+	                                                     NMIP4Config **out_config,
+	                                                     NMDeviceStateReason *reason);
 	NMActStageReturn	(* act_stage3_ip6_config_start) (NMDevice *self,
-														 NMIP6Config **out_config,
-														 NMDeviceStateReason *reason);
+	                                                     NMIP6Config **out_config,
+	                                                     NMDeviceStateReason *reason);
 	NMActStageReturn	(* act_stage4_ip4_config_timeout)	(NMDevice *self,
 	                                                         NMDeviceStateReason *reason);
 	NMActStageReturn	(* act_stage4_ip6_config_timeout)	(NMDevice *self,
@@ -229,13 +285,15 @@ typedef struct {
 	                                   NMConnection *connection,
 	                                   gboolean configure);
 
-	gboolean        (* release_slave) (NMDevice *self,
+	void            (* release_slave) (NMDevice *self,
 	                                   NMDevice *slave,
 	                                   gboolean configure);
 
 	gboolean        (* have_any_ready_slaves) (NMDevice *self,
 	                                           const GSList *slaves);
 
+	void            (* notify_new_device_added) (NMDevice *self, NMDevice *new_device);
+
 	/**
 	 * component_added:
 	 * @self: the #NMDevice
@@ -258,23 +316,21 @@ typedef struct {
 	NMConnection *  (* new_default_connection) (NMDevice *self);
 } NMDeviceClass;
 
-
 typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
-                                         DBusGMethodInvocation *context,
+                                         GDBusMethodInvocation *context,
+                                         NMAuthSubject *subject,
                                          GError *error,
                                          gpointer user_data);
 
 GType nm_device_get_type (void);
 
-const char *    nm_device_get_path (NMDevice *dev);
-void            nm_device_dbus_export   (NMDevice *device);
-
 void            nm_device_finish_init   (NMDevice *device);
 
 const char *	nm_device_get_udi		(NMDevice *dev);
 const char *	nm_device_get_iface		(NMDevice *dev);
 int             nm_device_get_ifindex	(NMDevice *dev);
 gboolean        nm_device_is_software   (NMDevice *dev);
+gboolean        nm_device_is_real       (NMDevice *dev);
 const char *	nm_device_get_ip_iface	(NMDevice *dev);
 int             nm_device_get_ip_ifindex(NMDevice *dev);
 const char *	nm_device_get_driver	(NMDevice *dev);
@@ -282,6 +338,7 @@ const char *	nm_device_get_driver_version	(NMDevice *dev);
 const char *	nm_device_get_type_desc (NMDevice *dev);
 const char *	nm_device_get_type_description (NMDevice *dev);
 NMDeviceType	nm_device_get_device_type	(NMDevice *dev);
+NMLinkType	nm_device_get_link_type	(NMDevice *dev);
 NMMetered       nm_device_get_metered	(NMDevice *dev);
 
 int			nm_device_get_priority (NMDevice *dev);
@@ -296,21 +353,28 @@ NMDhcp4Config * nm_device_get_dhcp4_config (NMDevice *dev);
 NMDhcp6Config * nm_device_get_dhcp6_config (NMDevice *dev);
 
 NMIP4Config *	nm_device_get_ip4_config	(NMDevice *dev);
-void            nm_device_set_vpn4_config   (NMDevice *dev, NMIP4Config *config);
+void            nm_device_replace_vpn4_config   (NMDevice *dev,
+                                                 NMIP4Config *old,
+                                                 NMIP4Config *config);
 
 NMIP6Config *	nm_device_get_ip6_config	(NMDevice *dev);
-void            nm_device_set_vpn6_config   (NMDevice *dev, NMIP6Config *config);
+void            nm_device_replace_vpn6_config   (NMDevice *dev,
+                                                 NMIP6Config *old,
+                                                 NMIP6Config *config);
 
 void            nm_device_capture_initial_config (NMDevice *dev);
 
 /* Master */
-GSList *        nm_device_master_get_slaves (NMDevice *dev);
+gboolean        nm_device_is_master         (NMDevice *dev);
 
 /* Slave */
 NMDevice *      nm_device_get_master        (NMDevice *dev);
 
-NMActRequest *	nm_device_get_act_request	(NMDevice *dev);
-NMConnection *  nm_device_get_connection	(NMDevice *dev);
+NMActRequest *          nm_device_get_act_request               (NMDevice *dev);
+NMSettingsConnection *  nm_device_get_settings_connection       (NMDevice *dev);
+NMConnection *          nm_device_get_applied_connection        (NMDevice *dev);
+gboolean                nm_device_has_unmodified_applied_connection (NMDevice *self,
+                                                                     NMSettingCompareFlags compare_flags);
 
 void            nm_device_removed        (NMDevice *dev);
 
@@ -335,6 +399,7 @@ gboolean nm_device_complete_connection (NMDevice *device,
                                         GError **error);
 
 gboolean nm_device_check_connection_compatible (NMDevice *device, NMConnection *connection);
+gboolean nm_device_check_slave_connection_compatible (NMDevice *device, NMConnection *connection);
 
 gboolean nm_device_uses_assumed_connection (NMDevice *device);
 
@@ -356,23 +421,27 @@ RfKillType nm_device_get_rfkill_type (NMDevice *device);
 /**
  * NMUnmanagedFlags:
  * @NM_UNMANAGED_NONE: placeholder value
- * @NM_UNMANAGED_DEFAULT: %TRUE when unmanaged by default (ie, Generic devices)
  * @NM_UNMANAGED_INTERNAL: %TRUE when unmanaged by internal decision (ie,
  *   because NM is sleeping or not managed for some other reason)
- * @NM_UNMANAGED_USER: %TRUE when unmanaged by user decision (via unmanaged-specs)
  * @NM_UNMANAGED_PARENT: %TRUE when unmanaged due to parent device being unmanaged
- * @NM_UNMANAGED_EXTERNAL_DOWN: %TRUE when unmanaged because !IFF_UP and not created by NM
+ * @NM_UNMANAGED_LOOPBACK: %TRUE for unmanaging loopback device
  * @NM_UNMANAGED_PLATFORM_INIT: %TRUE when unmanaged because platform link not
  *   yet initialized
+ * @NM_UNMANAGED_USER: %TRUE when unmanaged by user decision (via unmanaged-specs)
+ * @NM_UNMANAGED_DEFAULT: %TRUE when unmanaged by default (ie, Generic devices)
+ * @NM_UNMANAGED_EXTERNAL_DOWN: %TRUE when unmanaged because !IFF_UP and not created by NM
  */
-typedef enum {
-	NM_UNMANAGED_NONE          = 0x00,
-	NM_UNMANAGED_DEFAULT       = 0x01,
-	NM_UNMANAGED_INTERNAL      = 0x02,
-	NM_UNMANAGED_USER          = 0x04,
-	NM_UNMANAGED_PARENT        = 0x08,
-	NM_UNMANAGED_EXTERNAL_DOWN = 0x10,
-	NM_UNMANAGED_PLATFORM_INIT = 0x20,
+typedef enum { /*< skip >*/
+	NM_UNMANAGED_NONE          = 0,
+
+	NM_UNMANAGED_INTERNAL      = (1LL <<  0),
+	NM_UNMANAGED_PARENT        = (1LL <<  1),
+	NM_UNMANAGED_LOOPBACK      = (1LL <<  2),
+	NM_UNMANAGED_PLATFORM_INIT = (1LL <<  3),
+	NM_UNMANAGED_USER          = (1LL <<  4),
+
+	NM_UNMANAGED_DEFAULT       = (1LL <<  8),
+	NM_UNMANAGED_EXTERNAL_DOWN = (1LL << 11),
 
 	/* Boundary value */
 	__NM_UNMANAGED_LAST,
@@ -381,26 +450,37 @@ typedef enum {
 } NMUnmanagedFlags;
 
 gboolean nm_device_get_managed (NMDevice *device);
-gboolean nm_device_get_unmanaged_flag (NMDevice *device, NMUnmanagedFlags flag);
-void nm_device_set_unmanaged (NMDevice *device,
-                              NMUnmanagedFlags flag,
-                              gboolean unmanaged,
-                              NMDeviceStateReason reason);
+NMUnmanagedFlags nm_device_get_unmanaged_flags (NMDevice *device, NMUnmanagedFlags flag);
+void nm_device_set_unmanaged_flags (NMDevice *device,
+                                    NMUnmanagedFlags flag,
+                                    gboolean unmanaged,
+                                    NMDeviceStateReason reason);
+void nm_device_set_unmanaged_flags_by_device_spec (NMDevice *self, const GSList *unmanaged_specs);
+void nm_device_set_unmanaged_flags_initial (NMDevice *device,
+                                            NMUnmanagedFlags flag,
+                                            gboolean unmanaged);
 void nm_device_set_unmanaged_quitting (NMDevice *device);
-void nm_device_set_initial_unmanaged_flag (NMDevice *device,
-                                           NMUnmanagedFlags flag,
-                                           gboolean unmanaged);
 
 gboolean nm_device_get_is_nm_owned (NMDevice *device);
-void     nm_device_set_nm_owned    (NMDevice *device);
 
 gboolean nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps);
 
-gboolean nm_device_get_autoconnect (NMDevice *device);
+gboolean nm_device_realize_start      (NMDevice *device,
+                                       const NMPlatformLink *plink,
+                                       gboolean *out_compatible,
+                                       GError **error);
+void     nm_device_realize_finish     (NMDevice *self,
+                                       const NMPlatformLink *plink);
+gboolean nm_device_create_and_realize (NMDevice *self,
+                                       NMConnection *connection,
+                                       NMDevice *parent,
+                                       GError **error);
+gboolean nm_device_unrealize          (NMDevice *device,
+                                       gboolean remove_resources,
+                                       GError **error);
 
-void nm_device_handle_autoip4_event (NMDevice *self,
-                                     const char *event,
-                                     const char *address);
+gboolean nm_device_get_autoconnect (NMDevice *device);
+void nm_device_set_autoconnect (NMDevice *device, gboolean autoconnect);
 
 void nm_device_state_changed (NMDevice *device,
                               NMDeviceState state,
@@ -411,8 +491,11 @@ void nm_device_queue_state   (NMDevice *self,
                               NMDeviceStateReason reason);
 
 gboolean nm_device_get_firmware_missing (NMDevice *self);
+gboolean nm_device_get_nm_plugin_missing (NMDevice *self);
+void     nm_device_set_nm_plugin_missing (NMDevice *self,
+                                          gboolean missing);
 
-void nm_device_steal_connection (NMDevice *device, NMConnection *connection);
+void nm_device_steal_connection (NMDevice *device, NMSettingsConnection *connection);
 
 void nm_device_queue_activation (NMDevice *device, NMActRequest *req);
 
@@ -430,6 +513,7 @@ gboolean   nm_device_check_connection_available (NMDevice *device,
                                                  NMDeviceCheckConAvailableFlags flags,
                                                  const char *specific_object);
 
+void     nm_device_notify_new_device_added (NMDevice *self, NMDevice *new_device);
 gboolean nm_device_notify_component_added (NMDevice *device, GObject *component);
 
 gboolean nm_device_owns_iface (NMDevice *device, const char *iface);
@@ -441,9 +525,20 @@ const NMPlatformIP6Route *nm_device_get_ip6_default_route (NMDevice *self, gbool
 
 void nm_device_spawn_iface_helper (NMDevice *self);
 
-G_END_DECLS
+void nm_device_reapply_settings_immediately (NMDevice *self);
+
+void nm_device_update_firewall_zone (NMDevice *self);
+void nm_device_update_metered (NMDevice *self);
+void nm_device_reactivate_ip4_config (NMDevice *device,
+                                      NMSettingIPConfig *s_ip4_old,
+                                      NMSettingIPConfig *s_ip4_new);
+void nm_device_reactivate_ip6_config (NMDevice *device,
+                                      NMSettingIPConfig *s_ip6_old,
+                                      NMSettingIPConfig *s_ip6_new);
 
-/* For testing only */
-extern const char* nm_device_autoipd_helper_path;
+void nm_device_update_hw_address (NMDevice *self);
+void nm_device_update_initial_hw_address (NMDevice *self);
+
+G_END_DECLS
 
 #endif	/* NM_DEVICE_H */