device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-glib / nm-device.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /*
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA 02110-1301 USA.
17  *
18  * Copyright 2007 - 2008 Novell, Inc.
19  * Copyright 2007 - 2013 Red Hat, Inc.
20  */
21
22 #ifndef NM_DEVICE_H
23 #define NM_DEVICE_H
24
25 #include <glib.h>
26 #include <glib-object.h>
27 #include <dbus/dbus-glib.h>
28 #include "nm-object.h"
29 #include "NetworkManager.h"
30 #include "nm-ip4-config.h"
31 #include "nm-dhcp4-config.h"
32 #include "nm-ip6-config.h"
33 #include "nm-dhcp6-config.h"
34 #include "nm-connection.h"
35 #include "nm-active-connection.h"
36
37 G_BEGIN_DECLS
38
39 #define NM_TYPE_DEVICE            (nm_device_get_type ())
40 #define NM_DEVICE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice))
41 #define NM_DEVICE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE, NMDeviceClass))
42 #define NM_IS_DEVICE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE))
43 #define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE))
44 #define NM_DEVICE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE, NMDeviceClass))
45
46 /**
47  * NMDeviceError:
48  * @NM_DEVICE_ERROR_UNKNOWN: unknown or unclassified error
49  * @NM_DEVICE_ERROR_INTERFACE_MISMATCH: the interface names of the connection and the
50  *   device mismatched
51  */
52 typedef enum {
53         NM_DEVICE_ERROR_UNKNOWN = 0,        /*< nick=UnknownError >*/
54         NM_DEVICE_ERROR_INTERFACE_MISMATCH, /*< nick=InterfaceMismatch >*/
55 } NMDeviceError;
56
57 #define NM_DEVICE_ERROR nm_device_error_quark ()
58 NM_AVAILABLE_IN_0_9_10
59 GQuark nm_device_error_quark (void);
60
61 #define NM_DEVICE_DEVICE_TYPE "device-type"
62 #define NM_DEVICE_UDI "udi"
63 #define NM_DEVICE_INTERFACE "interface"
64 #define NM_DEVICE_IP_INTERFACE "ip-interface"
65 #define NM_DEVICE_DRIVER "driver"
66 #define NM_DEVICE_DRIVER_VERSION "driver-version"
67 #define NM_DEVICE_FIRMWARE_VERSION "firmware-version"
68 #define NM_DEVICE_CAPABILITIES "capabilities"
69 #define NM_DEVICE_REAL "real"
70 #define NM_DEVICE_MANAGED "managed"
71 #define NM_DEVICE_AUTOCONNECT "autoconnect"
72 #define NM_DEVICE_FIRMWARE_MISSING "firmware-missing"
73 #define NM_DEVICE_IP4_CONFIG "ip4-config"
74 #define NM_DEVICE_DHCP4_CONFIG "dhcp4-config"
75 #define NM_DEVICE_IP6_CONFIG "ip6-config"
76 #define NM_DEVICE_DHCP6_CONFIG "dhcp6-config"
77 #define NM_DEVICE_STATE "state"
78 #define NM_DEVICE_STATE_REASON "state-reason"
79 #define NM_DEVICE_ACTIVE_CONNECTION "active-connection"
80 #define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
81 #define NM_DEVICE_VENDOR "vendor"
82 #define NM_DEVICE_PRODUCT "product"
83 #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
84 #define NM_DEVICE_MTU "mtu"
85
86 typedef struct {
87         NMObject parent;
88 } NMDevice;
89
90 typedef struct {
91         NMObjectClass parent;
92
93         /* Signals */
94         void (*state_changed) (NMDevice *device,
95                                NMDeviceState new_state,
96                                NMDeviceState old_state,
97                                NMDeviceStateReason reason);
98
99         gboolean (*connection_compatible) (NMDevice *device,
100                                            NMConnection *connection,
101                                            GError **error);
102
103         const char * (*get_type_description) (NMDevice *device);
104         const char * (*get_hw_address) (NMDevice *device);
105
106         GType (*get_setting_type) (NMDevice *device);
107
108         /* Padding for future expansion */
109         void (*_reserved1) (void);
110         void (*_reserved2) (void);
111         void (*_reserved3) (void);
112 } NMDeviceClass;
113
114 GType nm_device_get_type (void);
115
116 GObject * nm_device_new (DBusGConnection *connection, const char *path);
117
118 const char *         nm_device_get_iface            (NMDevice *device);
119 const char *         nm_device_get_ip_iface         (NMDevice *device);
120 NMDeviceType         nm_device_get_device_type      (NMDevice *device);
121 const char *         nm_device_get_udi              (NMDevice *device);
122 const char *         nm_device_get_driver           (NMDevice *device);
123 const char *         nm_device_get_driver_version   (NMDevice *device);
124 const char *         nm_device_get_firmware_version (NMDevice *device);
125 NM_AVAILABLE_IN_0_9_10
126 const char *         nm_device_get_type_description (NMDevice *device);
127 NM_AVAILABLE_IN_0_9_10
128 const char *         nm_device_get_hw_address       (NMDevice *device);
129 NMDeviceCapabilities nm_device_get_capabilities     (NMDevice *device);
130 gboolean             nm_device_get_managed          (NMDevice *device);
131 NM_AVAILABLE_IN_1_2
132 void                 nm_device_set_managed          (NMDevice *device, gboolean managed);
133 gboolean             nm_device_get_autoconnect      (NMDevice *device);
134 void                 nm_device_set_autoconnect      (NMDevice *device, gboolean autoconnect);
135 gboolean             nm_device_get_firmware_missing (NMDevice *device);
136 NMIP4Config *        nm_device_get_ip4_config       (NMDevice *device);
137 NMDHCP4Config *      nm_device_get_dhcp4_config     (NMDevice *device);
138 NMIP6Config *        nm_device_get_ip6_config       (NMDevice *device);
139 NMDHCP6Config *      nm_device_get_dhcp6_config     (NMDevice *device);
140 NMDeviceState        nm_device_get_state            (NMDevice *device);
141 NMDeviceState        nm_device_get_state_reason     (NMDevice *device, NMDeviceStateReason *reason);
142 NMActiveConnection * nm_device_get_active_connection(NMDevice *device);
143 const GPtrArray *    nm_device_get_available_connections(NMDevice *device);
144 NM_AVAILABLE_IN_0_9_10
145 const char *         nm_device_get_physical_port_id (NMDevice *device);
146 NM_AVAILABLE_IN_0_9_10
147 guint32              nm_device_get_mtu              (NMDevice *device);
148 NM_AVAILABLE_IN_1_0
149 gboolean             nm_device_is_software          (NMDevice *device);
150 NM_AVAILABLE_IN_1_2
151 gboolean             nm_device_is_real              (NMDevice *device);
152
153 const char *         nm_device_get_product           (NMDevice  *device);
154 const char *         nm_device_get_vendor            (NMDevice  *device);
155 NM_AVAILABLE_IN_0_9_10
156 const char *         nm_device_get_description       (NMDevice  *device);
157 NM_AVAILABLE_IN_0_9_10
158 char **              nm_device_disambiguate_names    (NMDevice **devices,
159                                                       int        num_devices);
160
161 typedef void (*NMDeviceCallbackFn) (NMDevice *device, GError *error, gpointer user_data);
162
163 void                 nm_device_disconnect           (NMDevice *device,
164                                                      NMDeviceCallbackFn callback,
165                                                      gpointer user_data);
166
167 NM_AVAILABLE_IN_1_0
168 void                 nm_device_delete               (NMDevice *device,
169                                                      NMDeviceCallbackFn callback,
170                                                      gpointer user_data);
171
172 GSList *             nm_device_filter_connections   (NMDevice *device,
173                                                      const GSList *connections);
174
175 gboolean             nm_device_connection_valid     (NMDevice *device,
176                                                      NMConnection *connection);
177
178 gboolean             nm_device_connection_compatible (NMDevice *device,
179                                                       NMConnection *connection,
180                                                       GError **error);
181
182 NM_AVAILABLE_IN_0_9_10
183 GType                nm_device_get_setting_type     (NMDevice *device);
184
185 /* Deprecated */
186 NM_DEPRECATED_IN_1_0
187 typedef void (*NMDeviceDeactivateFn) (NMDevice *device, GError *error, gpointer user_data);
188
189 G_END_DECLS
190
191 #endif /* NM_DEVICE_H */