1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2007 - 2008 Novell, Inc.
4 * Copyright (C) 2007 - 2013 Red Hat, Inc.
5 */
6
7#ifndef __NM_DEVICE_H__
8#define __NM_DEVICE_H__
9
10#if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION)
11#error "Only <NetworkManager.h> can be included directly."
12#endif
13
14#include "nm-object.h"
15
16G_BEGIN_DECLS
17
18#define NM_TYPE_DEVICE (nm_device_get_type())
19#define NM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DEVICE, NMDevice))
20#define NM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_DEVICE, NMDeviceClass))
21#define NM_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_DEVICE))
22#define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_DEVICE))
23#define NM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DEVICE, NMDeviceClass))
24
25#define NM_DEVICE_DEVICE_TYPE "device-type"
26#define NM_DEVICE_UDI "udi"
27#define NM_DEVICE_PATH "path"
28#define NM_DEVICE_INTERFACE "interface"
29#define NM_DEVICE_IP_INTERFACE "ip-interface"
30#define NM_DEVICE_DRIVER "driver"
31#define NM_DEVICE_DRIVER_VERSION "driver-version"
32#define NM_DEVICE_FIRMWARE_VERSION "firmware-version"
33#define NM_DEVICE_CAPABILITIES "capabilities"
34#define NM_DEVICE_REAL "real"
35#define NM_DEVICE_MANAGED "managed"
36
37_NM_DEPRECATED_SYNC_WRITABLE_PROPERTY
38#define NM_DEVICE_AUTOCONNECT "autoconnect"
39
40#define NM_DEVICE_FIRMWARE_MISSING "firmware-missing"
41#define NM_DEVICE_NM_PLUGIN_MISSING "nm-plugin-missing"
42#define NM_DEVICE_IP4_CONFIG "ip4-config"
43#define NM_DEVICE_DHCP4_CONFIG "dhcp4-config"
44#define NM_DEVICE_IP6_CONFIG "ip6-config"
45#define NM_DEVICE_DHCP6_CONFIG "dhcp6-config"
46#define NM_DEVICE_STATE "state"
47#define NM_DEVICE_STATE_REASON "state-reason"
48#define NM_DEVICE_ACTIVE_CONNECTION "active-connection"
49#define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
50#define NM_DEVICE_VENDOR "vendor"
51#define NM_DEVICE_PRODUCT "product"
52#define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id"
53#define NM_DEVICE_MTU "mtu"
54#define NM_DEVICE_METERED "metered"
55#define NM_DEVICE_LLDP_NEIGHBORS "lldp-neighbors"
56#define NM_DEVICE_IP4_CONNECTIVITY "ip4-connectivity"
57#define NM_DEVICE_IP6_CONNECTIVITY "ip6-connectivity"
58#define NM_DEVICE_INTERFACE_FLAGS "interface-flags"
59#define NM_DEVICE_HW_ADDRESS "hw-address"
60#define NM_DEVICE_PORTS "ports"
61
62/**
63 * NMDevice:
64 */
65typedef struct _NMDevice NMDevice;
66typedef struct _NMDeviceClass NMDeviceClass;
67
68/**
69 * NMLldpNeighbor:
70 *
71 * Supported attributes are:
72 *
73 * - #NM_LLDP_ATTR_CHASSIS_ID_TYPE (type: 'u')
74 * - #NM_LLDP_ATTR_CHASSIS_ID (type: 's')
75 * - #NM_LLDP_ATTR_DESTINATION (type: 's')
76 * - #NM_LLDP_ATTR_IEEE_802_1_PPVID (type: 'u'). This attribute only reports the first PPVID
77 * and therefore it is deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_PPVIDS which reports
78 * all the PPVID.
79 * - #NM_LLDP_ATTR_IEEE_802_1_PPVID_FLAGS (type: 'u'). This attribute only reports the first PPVID
80 * and therefore it is deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_PPVIDS which reports
81 * all the PPVID.
82 * - #NM_LLDP_ATTR_IEEE_802_1_PPVIDS (type: 'aa{sv}')
83 *
84 * An array of dictionaries where each element has keys:
85 * - flags (type: 'u')
86 * - ppvid (type: 'u')
87 * - #NM_LLDP_ATTR_IEEE_802_1_PVID (type: 'u')
88 * - #NM_LLDP_ATTR_IEEE_802_1_VID (type: 'u'). This attribute only reports the first VLAN
89 * and therefore it is deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_VLANS which reports
90 * all the VLANs.
91 * - #NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME (type: 's'). This attribute only reports the first VLAN
92 * and therefore it is deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_VLANS which reports
93 * all the VLANs.
94 * - #NM_LLDP_ATTR_IEEE_802_1_VLANS (type: 'aa{sv}')
95 *
96 * An array of dictionaries where each element has keys:
97 * - name (type: 's')
98 * - vid (type: 'u')
99 * - #NM_LLDP_ATTR_IEEE_802_3_MAC_PHY_CONF (type: 'a{sv}')
100 *
101 * Dictionary where each element has keys:
102 * - autoneg (type: 'u')
103 * - operational-mau-type (type: 'u')
104 * - pmd-autoneg-cap (type: 'u')
105 * - #NM_LLDP_ATTR_IEEE_802_3_MAX_FRAME_SIZE (type: 'u')
106 * - #NM_LLDP_ATTR_IEEE_802_3_POWER_VIA_MDI (type: 'a{sv}')
107 *
108 * Dictionary where each element has keys:
109 * - mdi-power-support (type: 'u')
110 * - power-class (type: 'u')
111 * - pse-power-pair (type: 'u')
112 * - #NM_LLDP_ATTR_MANAGEMENT_ADDRESSES (type: 'aa{sv}')
113 *
114 * An array of dictionaries where each element has keys:
115 * - address (type: 'ay')
116 * - address-subtype (type: 'u')
117 * - interface-number (type: 'u')
118 * - interface-number-subtype (type: 'u')
119 * - object-id (type: 'ay')
120 * - #NM_LLDP_ATTR_PORT_DESCRIPTION (type: 's')
121 * - #NM_LLDP_ATTR_PORT_ID_TYPE (type: 'u')
122 * - #NM_LLDP_ATTR_PORT_ID (type: 's')
123 * - #NM_LLDP_ATTR_RAW (type: 'ay')
124 * - #NM_LLDP_ATTR_SYSTEM_CAPABILITIES (type: 'u')
125 * - #NM_LLDP_ATTR_SYSTEM_DESCRIPTION (type: 's')
126 * - #NM_LLDP_ATTR_SYSTEM_NAME (type: 's')
127 **/
128typedef struct _NMLldpNeighbor NMLldpNeighbor;
129
130GType nm_device_get_type(void);
131
132const char *nm_device_get_iface(NMDevice *device);
133const char *nm_device_get_ip_iface(NMDevice *device);
134NMDeviceType nm_device_get_device_type(NMDevice *device);
135const char *nm_device_get_udi(NMDevice *device);
136NM_AVAILABLE_IN_1_26
137const char *nm_device_get_path(NMDevice *device);
138const char *nm_device_get_driver(NMDevice *device);
139const char *nm_device_get_driver_version(NMDevice *device);
140const char *nm_device_get_firmware_version(NMDevice *device);
141const char *nm_device_get_type_description(NMDevice *device);
142const char *nm_device_get_hw_address(NMDevice *device);
143NMDeviceCapabilities nm_device_get_capabilities(NMDevice *device);
144gboolean nm_device_get_managed(NMDevice *device);
145
146NM_AVAILABLE_IN_1_34
147const GPtrArray *nm_device_get_ports(NMDevice *device);
148
149NM_AVAILABLE_IN_1_2
150NM_DEPRECATED_IN_1_22
151_NM_DEPRECATED_SYNC_METHOD
152void nm_device_set_managed(NMDevice *device, gboolean managed);
153
154gboolean nm_device_get_autoconnect(NMDevice *device);
155
156NM_DEPRECATED_IN_1_22
157_NM_DEPRECATED_SYNC_METHOD
158void nm_device_set_autoconnect(NMDevice *device, gboolean autoconnect);
159
160gboolean nm_device_get_firmware_missing(NMDevice *device);
161NM_AVAILABLE_IN_1_2
162gboolean nm_device_get_nm_plugin_missing(NMDevice *device);
163NMIPConfig *nm_device_get_ip4_config(NMDevice *device);
164NMDhcpConfig *nm_device_get_dhcp4_config(NMDevice *device);
165NMIPConfig *nm_device_get_ip6_config(NMDevice *device);
166NMDhcpConfig *nm_device_get_dhcp6_config(NMDevice *device);
167NM_AVAILABLE_IN_1_16
168NMConnectivityState nm_device_get_connectivity(NMDevice *device, int addr_family);
169NMDeviceState nm_device_get_state(NMDevice *device);
170NMDeviceStateReason nm_device_get_state_reason(NMDevice *device);
171NMActiveConnection *nm_device_get_active_connection(NMDevice *device);
172const GPtrArray *nm_device_get_available_connections(NMDevice *device);
173const char *nm_device_get_physical_port_id(NMDevice *device);
174guint32 nm_device_get_mtu(NMDevice *device);
175NM_AVAILABLE_IN_1_2
176gboolean nm_device_is_real(NMDevice *device);
177gboolean nm_device_is_software(NMDevice *device);
178
179const char *nm_device_get_product(NMDevice *device);
180const char *nm_device_get_vendor(NMDevice *device);
181const char *nm_device_get_description(NMDevice *device);
182NM_AVAILABLE_IN_1_2
183NMMetered nm_device_get_metered(NMDevice *device);
184NM_AVAILABLE_IN_1_2
185GPtrArray *nm_device_get_lldp_neighbors(NMDevice *device);
186NM_AVAILABLE_IN_1_22
187NMDeviceInterfaceFlags nm_device_get_interface_flags(NMDevice *device);
188
189char **nm_device_disambiguate_names(NMDevice **devices, int num_devices);
190NM_AVAILABLE_IN_1_2
191_NM_DEPRECATED_SYNC_METHOD
192gboolean nm_device_reapply(NMDevice *device,
193 NMConnection *connection,
194 guint64 version_id,
195 guint32 flags,
196 GCancellable *cancellable,
197 GError **error);
198NM_AVAILABLE_IN_1_2
199void nm_device_reapply_async(NMDevice *device,
200 NMConnection *connection,
201 guint64 version_id,
202 guint32 flags,
203 GCancellable *cancellable,
204 GAsyncReadyCallback callback,
205 gpointer user_data);
206NM_AVAILABLE_IN_1_2
207gboolean nm_device_reapply_finish(NMDevice *device, GAsyncResult *result, GError **error);
208
209NM_AVAILABLE_IN_1_2
210_NM_DEPRECATED_SYNC_METHOD
211NMConnection *nm_device_get_applied_connection(NMDevice *device,
212 guint32 flags,
213 guint64 *version_id,
214 GCancellable *cancellable,
215 GError **error);
216NM_AVAILABLE_IN_1_2
217void nm_device_get_applied_connection_async(NMDevice *device,
218 guint32 flags,
219 GCancellable *cancellable,
220 GAsyncReadyCallback callback,
221 gpointer user_data);
222NM_AVAILABLE_IN_1_2
223NMConnection *nm_device_get_applied_connection_finish(NMDevice *device,
224 GAsyncResult *result,
225 guint64 *version_id,
226 GError **error);
227
228_NM_DEPRECATED_SYNC_METHOD
229gboolean nm_device_disconnect(NMDevice *device, GCancellable *cancellable, GError **error);
230void nm_device_disconnect_async(NMDevice *device,
231 GCancellable *cancellable,
232 GAsyncReadyCallback callback,
233 gpointer user_data);
234gboolean nm_device_disconnect_finish(NMDevice *device, GAsyncResult *result, GError **error);
235
236_NM_DEPRECATED_SYNC_METHOD
237gboolean nm_device_delete(NMDevice *device, GCancellable *cancellable, GError **error);
238void nm_device_delete_async(NMDevice *device,
239 GCancellable *cancellable,
240 GAsyncReadyCallback callback,
241 gpointer user_data);
242gboolean nm_device_delete_finish(NMDevice *device, GAsyncResult *result, GError **error);
243
244GPtrArray *nm_device_filter_connections(NMDevice *device, const GPtrArray *connections);
245
246gboolean nm_device_connection_valid(NMDevice *device, NMConnection *connection);
247
248gboolean
249nm_device_connection_compatible(NMDevice *device, NMConnection *connection, GError **error);
250
251GType nm_device_get_setting_type(NMDevice *device);
252
253NM_AVAILABLE_IN_1_2
254GType nm_lldp_neighbor_get_type(void);
255NM_AVAILABLE_IN_1_2
256void nm_lldp_neighbor_ref(NMLldpNeighbor *neighbor);
257NM_AVAILABLE_IN_1_2
258void nm_lldp_neighbor_unref(NMLldpNeighbor *neighbor);
259NM_AVAILABLE_IN_1_2
260char **nm_lldp_neighbor_get_attr_names(NMLldpNeighbor *neighbor);
261NM_AVAILABLE_IN_1_18
262GVariant *nm_lldp_neighbor_get_attr_value(NMLldpNeighbor *neighbor, const char *name);
263
264NM_AVAILABLE_IN_1_2
265NMLldpNeighbor *nm_lldp_neighbor_new(void);
266NM_AVAILABLE_IN_1_2
267gboolean nm_lldp_neighbor_get_attr_string_value(NMLldpNeighbor *neighbor,
268 const char *name,
269 const char **out_value);
270NM_AVAILABLE_IN_1_2
271gboolean
272nm_lldp_neighbor_get_attr_uint_value(NMLldpNeighbor *neighbor, const char *name, guint *out_value);
273NM_AVAILABLE_IN_1_2
274const GVariantType *nm_lldp_neighbor_get_attr_type(NMLldpNeighbor *neighbor, const char *name);
275
276G_END_DECLS
277
278#endif /* __NM_DEVICE_H__ */
279

source code of include/libnm/nm-device.h