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 _NMDeviceClass NMDeviceClass;
66
67/**
68 * NMLldpNeighbor:
69 *
70 * Supported attributes are:
71 *
72 * - #NM_LLDP_ATTR_CHASSIS_ID_TYPE (type: 'u')
73 * - #NM_LLDP_ATTR_CHASSIS_ID (type: 's')
74 * - #NM_LLDP_ATTR_DESTINATION (type: 's')
75 * - #NM_LLDP_ATTR_IEEE_802_1_PPVID (type: 'u'). This attribute only reports the first PPVID
76 * and therefore it is deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_PPVIDS which reports
77 * all the PPVID.
78 * - #NM_LLDP_ATTR_IEEE_802_1_PPVID_FLAGS (type: 'u'). This attribute only reports the first PPVID
79 * and therefore it is deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_PPVIDS which reports
80 * all the PPVID.
81 * - #NM_LLDP_ATTR_IEEE_802_1_PPVIDS (type: 'aa{sv}')
82 *
83 * An array of dictionaries where each element has keys:
84 * - flags (type: 'u')
85 * - ppvid (type: 'u')
86 * - #NM_LLDP_ATTR_IEEE_802_1_PVID (type: 'u')
87 * - #NM_LLDP_ATTR_IEEE_802_1_VID (type: 'u'). This attribute only reports the first VLAN
88 * and therefore it is deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_VLANS which reports
89 * all the VLANs.
90 * - #NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME (type: 's'). This attribute only reports the first VLAN
91 * and therefore it is deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_VLANS which reports
92 * all the VLANs.
93 * - #NM_LLDP_ATTR_IEEE_802_1_VLANS (type: 'aa{sv}')
94 *
95 * An array of dictionaries where each element has keys:
96 * - name (type: 's')
97 * - vid (type: 'u')
98 * - #NM_LLDP_ATTR_IEEE_802_3_MAC_PHY_CONF (type: 'a{sv}')
99 *
100 * Dictionary where each element has keys:
101 * - autoneg (type: 'u')
102 * - operational-mau-type (type: 'u')
103 * - pmd-autoneg-cap (type: 'u')
104 * - #NM_LLDP_ATTR_IEEE_802_3_MAX_FRAME_SIZE (type: 'u')
105 * - #NM_LLDP_ATTR_IEEE_802_3_POWER_VIA_MDI (type: 'a{sv}')
106 *
107 * Dictionary where each element has keys:
108 * - mdi-power-support (type: 'u')
109 * - power-class (type: 'u')
110 * - pse-power-pair (type: 'u')
111 * - #NM_LLDP_ATTR_MANAGEMENT_ADDRESSES (type: 'aa{sv}')
112 *
113 * An array of dictionaries where each element has keys:
114 * - address (type: 'ay')
115 * - address-subtype (type: 'u')
116 * - interface-number (type: 'u')
117 * - interface-number-subtype (type: 'u')
118 * - object-id (type: 'ay')
119 * - #NM_LLDP_ATTR_PORT_DESCRIPTION (type: 's')
120 * - #NM_LLDP_ATTR_PORT_ID_TYPE (type: 'u')
121 * - #NM_LLDP_ATTR_PORT_ID (type: 's')
122 * - #NM_LLDP_ATTR_RAW (type: 'ay')
123 * - #NM_LLDP_ATTR_SYSTEM_CAPABILITIES (type: 'u')
124 * - #NM_LLDP_ATTR_SYSTEM_DESCRIPTION (type: 's')
125 * - #NM_LLDP_ATTR_SYSTEM_NAME (type: 's')
126 **/
127typedef struct _NMLldpNeighbor NMLldpNeighbor;
128
129GType nm_device_get_type(void);
130
131const char *nm_device_get_iface(NMDevice *device);
132const char *nm_device_get_ip_iface(NMDevice *device);
133NMDeviceType nm_device_get_device_type(NMDevice *device);
134const char *nm_device_get_udi(NMDevice *device);
135NM_AVAILABLE_IN_1_26
136const char *nm_device_get_path(NMDevice *device);
137const char *nm_device_get_driver(NMDevice *device);
138const char *nm_device_get_driver_version(NMDevice *device);
139const char *nm_device_get_firmware_version(NMDevice *device);
140const char *nm_device_get_type_description(NMDevice *device);
141const char *nm_device_get_hw_address(NMDevice *device);
142NMDeviceCapabilities nm_device_get_capabilities(NMDevice *device);
143gboolean nm_device_get_managed(NMDevice *device);
144
145NM_AVAILABLE_IN_1_34
146const GPtrArray *nm_device_get_ports(NMDevice *device);
147
148NM_AVAILABLE_IN_1_2
149NM_DEPRECATED_IN_1_22
150_NM_DEPRECATED_SYNC_METHOD
151void nm_device_set_managed(NMDevice *device, gboolean managed);
152
153gboolean nm_device_get_autoconnect(NMDevice *device);
154
155NM_DEPRECATED_IN_1_22
156_NM_DEPRECATED_SYNC_METHOD
157void nm_device_set_autoconnect(NMDevice *device, gboolean autoconnect);
158
159gboolean nm_device_get_firmware_missing(NMDevice *device);
160NM_AVAILABLE_IN_1_2
161gboolean nm_device_get_nm_plugin_missing(NMDevice *device);
162NMIPConfig *nm_device_get_ip4_config(NMDevice *device);
163NMDhcpConfig *nm_device_get_dhcp4_config(NMDevice *device);
164NMIPConfig *nm_device_get_ip6_config(NMDevice *device);
165NMDhcpConfig *nm_device_get_dhcp6_config(NMDevice *device);
166NM_AVAILABLE_IN_1_16
167NMConnectivityState nm_device_get_connectivity(NMDevice *device, int addr_family);
168NMDeviceState nm_device_get_state(NMDevice *device);
169NMDeviceStateReason nm_device_get_state_reason(NMDevice *device);
170NMActiveConnection *nm_device_get_active_connection(NMDevice *device);
171const GPtrArray *nm_device_get_available_connections(NMDevice *device);
172const char *nm_device_get_physical_port_id(NMDevice *device);
173guint32 nm_device_get_mtu(NMDevice *device);
174NM_AVAILABLE_IN_1_2
175gboolean nm_device_is_real(NMDevice *device);
176gboolean nm_device_is_software(NMDevice *device);
177
178const char *nm_device_get_product(NMDevice *device);
179const char *nm_device_get_vendor(NMDevice *device);
180const char *nm_device_get_description(NMDevice *device);
181NM_AVAILABLE_IN_1_2
182NMMetered nm_device_get_metered(NMDevice *device);
183NM_AVAILABLE_IN_1_2
184GPtrArray *nm_device_get_lldp_neighbors(NMDevice *device);
185NM_AVAILABLE_IN_1_22
186NMDeviceInterfaceFlags nm_device_get_interface_flags(NMDevice *device);
187
188char **nm_device_disambiguate_names(NMDevice **devices, int num_devices);
189NM_AVAILABLE_IN_1_2
190_NM_DEPRECATED_SYNC_METHOD
191gboolean nm_device_reapply(NMDevice *device,
192 NMConnection *connection,
193 guint64 version_id,
194 guint32 flags,
195 GCancellable *cancellable,
196 GError **error);
197NM_AVAILABLE_IN_1_2
198void nm_device_reapply_async(NMDevice *device,
199 NMConnection *connection,
200 guint64 version_id,
201 guint32 flags,
202 GCancellable *cancellable,
203 GAsyncReadyCallback callback,
204 gpointer user_data);
205NM_AVAILABLE_IN_1_2
206gboolean nm_device_reapply_finish(NMDevice *device, GAsyncResult *result, GError **error);
207
208NM_AVAILABLE_IN_1_2
209_NM_DEPRECATED_SYNC_METHOD
210NMConnection *nm_device_get_applied_connection(NMDevice *device,
211 guint32 flags,
212 guint64 *version_id,
213 GCancellable *cancellable,
214 GError **error);
215NM_AVAILABLE_IN_1_2
216void nm_device_get_applied_connection_async(NMDevice *device,
217 guint32 flags,
218 GCancellable *cancellable,
219 GAsyncReadyCallback callback,
220 gpointer user_data);
221NM_AVAILABLE_IN_1_2
222NMConnection *nm_device_get_applied_connection_finish(NMDevice *device,
223 GAsyncResult *result,
224 guint64 *version_id,
225 GError **error);
226
227_NM_DEPRECATED_SYNC_METHOD
228gboolean nm_device_disconnect(NMDevice *device, GCancellable *cancellable, GError **error);
229void nm_device_disconnect_async(NMDevice *device,
230 GCancellable *cancellable,
231 GAsyncReadyCallback callback,
232 gpointer user_data);
233gboolean nm_device_disconnect_finish(NMDevice *device, GAsyncResult *result, GError **error);
234
235_NM_DEPRECATED_SYNC_METHOD
236gboolean nm_device_delete(NMDevice *device, GCancellable *cancellable, GError **error);
237void nm_device_delete_async(NMDevice *device,
238 GCancellable *cancellable,
239 GAsyncReadyCallback callback,
240 gpointer user_data);
241gboolean nm_device_delete_finish(NMDevice *device, GAsyncResult *result, GError **error);
242
243GPtrArray *nm_device_filter_connections(NMDevice *device, const GPtrArray *connections);
244
245gboolean nm_device_connection_valid(NMDevice *device, NMConnection *connection);
246
247gboolean
248nm_device_connection_compatible(NMDevice *device, NMConnection *connection, GError **error);
249
250GType nm_device_get_setting_type(NMDevice *device);
251
252NM_AVAILABLE_IN_1_2
253GType nm_lldp_neighbor_get_type(void);
254NM_AVAILABLE_IN_1_2
255void nm_lldp_neighbor_ref(NMLldpNeighbor *neighbor);
256NM_AVAILABLE_IN_1_2
257void nm_lldp_neighbor_unref(NMLldpNeighbor *neighbor);
258NM_AVAILABLE_IN_1_2
259char **nm_lldp_neighbor_get_attr_names(NMLldpNeighbor *neighbor);
260NM_AVAILABLE_IN_1_18
261GVariant *nm_lldp_neighbor_get_attr_value(NMLldpNeighbor *neighbor, const char *name);
262
263NM_AVAILABLE_IN_1_2
264NMLldpNeighbor *nm_lldp_neighbor_new(void);
265NM_AVAILABLE_IN_1_2
266gboolean nm_lldp_neighbor_get_attr_string_value(NMLldpNeighbor *neighbor,
267 const char *name,
268 const char **out_value);
269NM_AVAILABLE_IN_1_2
270gboolean
271nm_lldp_neighbor_get_attr_uint_value(NMLldpNeighbor *neighbor, const char *name, guint *out_value);
272NM_AVAILABLE_IN_1_2
273const GVariantType *nm_lldp_neighbor_get_attr_type(NMLldpNeighbor *neighbor, const char *name);
274
275G_END_DECLS
276
277#endif /* __NM_DEVICE_H__ */
278

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