device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm / 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 #if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
26 #error "Only <NetworkManager.h> can be included directly."
27 #endif
28
29 #include <nm-object.h>
30
31 G_BEGIN_DECLS
32
33 #define NM_TYPE_DEVICE            (nm_device_get_type ())
34 #define NM_DEVICE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice))
35 #define NM_DEVICE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE, NMDeviceClass))
36 #define NM_IS_DEVICE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE))
37 #define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE))
38 #define NM_DEVICE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE, NMDeviceClass))
39
40 #define NM_DEVICE_DEVICE_TYPE "device-type"
41 #define NM_DEVICE_UDI "udi"
42 #define NM_DEVICE_INTERFACE "interface"
43 #define NM_DEVICE_IP_INTERFACE "ip-interface"
44 #define NM_DEVICE_DRIVER "driver"
45 #define NM_DEVICE_DRIVER_VERSION "driver-version"
46 #define NM_DEVICE_FIRMWARE_VERSION "firmware-version"
47 #define NM_DEVICE_CAPABILITIES "capabilities"
48 #define NM_DEVICE_REAL "real"
49 #define NM_DEVICE_MANAGED "managed"
50 #define NM_DEVICE_AUTOCONNECT "autoconnect"
51 #define NM_DEVICE_FIRMWARE_MISSING "firmware-missing"
52 #define NM_DEVICE_NM_PLUGIN_MISSING "nm-plugin-missing"
53 #define NM_DEVICE_IP4_CONFIG "ip4-config"
54 #define NM_DEVICE_DHCP4_CONFIG "dhcp4-config"
55 #define NM_DEVICE_IP6_CONFIG "ip6-config"
56 #define NM_DEVICE_DHCP6_CONFIG "dhcp6-config"
57 #define NM_DEVICE_STATE "state"
58 #define NM_DEVICE_STATE_REASON "state-reason"
59 #define NM_DEVICE_ACTIVE_CONNECTION "active-connection"
60 #define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
61 #define NM_DEVICE_VENDOR "vendor"
62 #define NM_DEVICE_PRODUCT "product"
63 #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
64 #define NM_DEVICE_MTU "mtu"
65 #define NM_DEVICE_METERED "metered"
66 #define NM_DEVICE_LLDP_NEIGHBORS "lldp-neighbors"
67
68 struct _NMDevice {
69         NMObject parent;
70 };
71
72 typedef struct {
73         NMObjectClass parent;
74
75         /* Signals */
76         void (*state_changed) (NMDevice *device,
77                                NMDeviceState new_state,
78                                NMDeviceState old_state,
79                                NMDeviceStateReason reason);
80
81         /* Methods */
82         gboolean (*connection_compatible) (NMDevice *device,
83                                            NMConnection *connection,
84                                            GError **error);
85
86         const char * (*get_type_description) (NMDevice *device);
87         const char * (*get_hw_address) (NMDevice *device);
88
89         GType (*get_setting_type) (NMDevice *device);
90
91         /*< private >*/
92         gpointer padding[8];
93 } NMDeviceClass;
94
95 typedef struct _NMLldpNeighbor NMLldpNeighbor;
96
97 GType nm_device_get_type (void);
98
99 const char *         nm_device_get_iface            (NMDevice *device);
100 const char *         nm_device_get_ip_iface         (NMDevice *device);
101 NMDeviceType         nm_device_get_device_type      (NMDevice *device);
102 const char *         nm_device_get_udi              (NMDevice *device);
103 const char *         nm_device_get_driver           (NMDevice *device);
104 const char *         nm_device_get_driver_version   (NMDevice *device);
105 const char *         nm_device_get_firmware_version (NMDevice *device);
106 const char *         nm_device_get_type_description (NMDevice *device);
107 const char *         nm_device_get_hw_address       (NMDevice *device);
108 NMDeviceCapabilities nm_device_get_capabilities     (NMDevice *device);
109 gboolean             nm_device_get_managed          (NMDevice *device);
110 NM_AVAILABLE_IN_1_2
111 void                 nm_device_set_managed          (NMDevice *device, gboolean managed);
112 gboolean             nm_device_get_autoconnect      (NMDevice *device);
113 void                 nm_device_set_autoconnect      (NMDevice *device, gboolean autoconnect);
114 gboolean             nm_device_get_firmware_missing (NMDevice *device);
115 NM_AVAILABLE_IN_1_2
116 gboolean             nm_device_get_nm_plugin_missing (NMDevice *device);
117 NMIPConfig *         nm_device_get_ip4_config       (NMDevice *device);
118 NMDhcpConfig *       nm_device_get_dhcp4_config     (NMDevice *device);
119 NMIPConfig *         nm_device_get_ip6_config       (NMDevice *device);
120 NMDhcpConfig *       nm_device_get_dhcp6_config     (NMDevice *device);
121 NMDeviceState        nm_device_get_state            (NMDevice *device);
122 NMDeviceStateReason  nm_device_get_state_reason     (NMDevice *device);
123 NMActiveConnection * nm_device_get_active_connection(NMDevice *device);
124 const GPtrArray *    nm_device_get_available_connections(NMDevice *device);
125 const char *         nm_device_get_physical_port_id (NMDevice *device);
126 guint32              nm_device_get_mtu              (NMDevice *device);
127 NM_AVAILABLE_IN_1_2
128 gboolean             nm_device_is_real              (NMDevice *device);
129 gboolean             nm_device_is_software          (NMDevice *device);
130
131 const char *         nm_device_get_product           (NMDevice  *device);
132 const char *         nm_device_get_vendor            (NMDevice  *device);
133 const char *         nm_device_get_description       (NMDevice  *device);
134 NM_AVAILABLE_IN_1_2
135 NMMetered            nm_device_get_metered           (NMDevice  *device);
136 NM_AVAILABLE_IN_1_2
137 GPtrArray *          nm_device_get_lldp_neighbors    (NMDevice *device);
138 char **              nm_device_disambiguate_names    (NMDevice **devices,
139                                                       int        num_devices);
140 NM_AVAILABLE_IN_1_2
141 gboolean             nm_device_reapply              (NMDevice *device,
142                                                      NMConnection *connection,
143                                                      guint64 version_id,
144                                                      guint32 flags,
145                                                      GCancellable *cancellable,
146                                                      GError **error);
147 NM_AVAILABLE_IN_1_2
148 void                 nm_device_reapply_async        (NMDevice *device,
149                                                      NMConnection *connection,
150                                                      guint64 version_id,
151                                                      guint32 flags,
152                                                      GCancellable *cancellable,
153                                                      GAsyncReadyCallback callback,
154                                                      gpointer user_data);
155 NM_AVAILABLE_IN_1_2
156 gboolean             nm_device_reapply_finish       (NMDevice *device,
157                                                      GAsyncResult *result,
158                                                      GError **error);
159
160 NM_AVAILABLE_IN_1_2
161 NMConnection        *nm_device_get_applied_connection (NMDevice *device,
162                                                        guint32 flags,
163                                                        guint64 *version_id,
164                                                        GCancellable *cancellable,
165                                                        GError **error);
166 NM_AVAILABLE_IN_1_2
167 void                 nm_device_get_applied_connection_async  (NMDevice *device,
168                                                               guint32 flags,
169                                                               GCancellable *cancellable,
170                                                               GAsyncReadyCallback callback,
171                                                               gpointer user_data);
172 NM_AVAILABLE_IN_1_2
173 NMConnection        *nm_device_get_applied_connection_finish (NMDevice *device,
174                                                               GAsyncResult *result,
175                                                               guint64 *version_id,
176                                                               GError **error);
177
178 gboolean             nm_device_disconnect           (NMDevice *device,
179                                                      GCancellable *cancellable,
180                                                      GError **error);
181 void                 nm_device_disconnect_async     (NMDevice *device,
182                                                      GCancellable *cancellable,
183                                                      GAsyncReadyCallback callback,
184                                                      gpointer user_data);
185 gboolean             nm_device_disconnect_finish    (NMDevice *device,
186                                                      GAsyncResult *result,
187                                                      GError **error);
188
189 gboolean             nm_device_delete               (NMDevice *device,
190                                                      GCancellable *cancellable,
191                                                      GError **error);
192 void                 nm_device_delete_async         (NMDevice *device,
193                                                      GCancellable *cancellable,
194                                                      GAsyncReadyCallback callback,
195                                                      gpointer user_data);
196 gboolean             nm_device_delete_finish        (NMDevice *device,
197                                                      GAsyncResult *result,
198                                                      GError **error);
199
200 GPtrArray *          nm_device_filter_connections   (NMDevice *device,
201                                                      const GPtrArray *connections);
202
203 gboolean             nm_device_connection_valid     (NMDevice *device,
204                                                      NMConnection *connection);
205
206 gboolean             nm_device_connection_compatible (NMDevice *device,
207                                                       NMConnection *connection,
208                                                       GError **error);
209
210 GType                nm_device_get_setting_type     (NMDevice *device);
211
212 NM_AVAILABLE_IN_1_2
213 GType nm_lldp_neighbor_get_type (void);
214 NM_AVAILABLE_IN_1_2
215 NMLldpNeighbor *nm_lldp_neighbor_new (void);
216 NM_AVAILABLE_IN_1_2
217 void nm_lldp_neighbor_ref (NMLldpNeighbor *neighbor);
218 NM_AVAILABLE_IN_1_2
219 void nm_lldp_neighbor_unref (NMLldpNeighbor *neighbor);
220 NM_AVAILABLE_IN_1_2
221 char **nm_lldp_neighbor_get_attr_names (NMLldpNeighbor *neighbor);
222 NM_AVAILABLE_IN_1_2
223 gboolean nm_lldp_neighbor_get_attr_string_value (NMLldpNeighbor *neighbor, char *name,
224                                                  const char **out_value);
225 NM_AVAILABLE_IN_1_2
226 gboolean nm_lldp_neighbor_get_attr_uint_value (NMLldpNeighbor *neighbor, char *name,
227                                                guint *out_value);
228 NM_AVAILABLE_IN_1_2
229 const GVariantType *nm_lldp_neighbor_get_attr_type (NMLldpNeighbor *neighbor, char *name);
230
231 G_END_DECLS
232
233 #endif /* __NM_DEVICE_H__ */