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 | |
16 | G_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 | */ |
65 | typedef 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 | **/ |
127 | typedef struct _NMLldpNeighbor NMLldpNeighbor; |
128 | |
129 | GType nm_device_get_type(void); |
130 | |
131 | const char *nm_device_get_iface(NMDevice *device); |
132 | const char *nm_device_get_ip_iface(NMDevice *device); |
133 | NMDeviceType nm_device_get_device_type(NMDevice *device); |
134 | const char *nm_device_get_udi(NMDevice *device); |
135 | NM_AVAILABLE_IN_1_26 |
136 | const char *nm_device_get_path(NMDevice *device); |
137 | const char *nm_device_get_driver(NMDevice *device); |
138 | const char *nm_device_get_driver_version(NMDevice *device); |
139 | const char *nm_device_get_firmware_version(NMDevice *device); |
140 | const char *nm_device_get_type_description(NMDevice *device); |
141 | const char *nm_device_get_hw_address(NMDevice *device); |
142 | NMDeviceCapabilities nm_device_get_capabilities(NMDevice *device); |
143 | gboolean nm_device_get_managed(NMDevice *device); |
144 | |
145 | NM_AVAILABLE_IN_1_34 |
146 | const GPtrArray *nm_device_get_ports(NMDevice *device); |
147 | |
148 | NM_AVAILABLE_IN_1_2 |
149 | NM_DEPRECATED_IN_1_22 |
150 | _NM_DEPRECATED_SYNC_METHOD |
151 | void nm_device_set_managed(NMDevice *device, gboolean managed); |
152 | |
153 | gboolean nm_device_get_autoconnect(NMDevice *device); |
154 | |
155 | NM_DEPRECATED_IN_1_22 |
156 | _NM_DEPRECATED_SYNC_METHOD |
157 | void nm_device_set_autoconnect(NMDevice *device, gboolean autoconnect); |
158 | |
159 | gboolean nm_device_get_firmware_missing(NMDevice *device); |
160 | NM_AVAILABLE_IN_1_2 |
161 | gboolean nm_device_get_nm_plugin_missing(NMDevice *device); |
162 | NMIPConfig *nm_device_get_ip4_config(NMDevice *device); |
163 | NMDhcpConfig *nm_device_get_dhcp4_config(NMDevice *device); |
164 | NMIPConfig *nm_device_get_ip6_config(NMDevice *device); |
165 | NMDhcpConfig *nm_device_get_dhcp6_config(NMDevice *device); |
166 | NM_AVAILABLE_IN_1_16 |
167 | NMConnectivityState nm_device_get_connectivity(NMDevice *device, int addr_family); |
168 | NMDeviceState nm_device_get_state(NMDevice *device); |
169 | NMDeviceStateReason nm_device_get_state_reason(NMDevice *device); |
170 | NMActiveConnection *nm_device_get_active_connection(NMDevice *device); |
171 | const GPtrArray *nm_device_get_available_connections(NMDevice *device); |
172 | const char *nm_device_get_physical_port_id(NMDevice *device); |
173 | guint32 nm_device_get_mtu(NMDevice *device); |
174 | NM_AVAILABLE_IN_1_2 |
175 | gboolean nm_device_is_real(NMDevice *device); |
176 | gboolean nm_device_is_software(NMDevice *device); |
177 | |
178 | const char *nm_device_get_product(NMDevice *device); |
179 | const char *nm_device_get_vendor(NMDevice *device); |
180 | const char *nm_device_get_description(NMDevice *device); |
181 | NM_AVAILABLE_IN_1_2 |
182 | NMMetered nm_device_get_metered(NMDevice *device); |
183 | NM_AVAILABLE_IN_1_2 |
184 | GPtrArray *nm_device_get_lldp_neighbors(NMDevice *device); |
185 | NM_AVAILABLE_IN_1_22 |
186 | NMDeviceInterfaceFlags nm_device_get_interface_flags(NMDevice *device); |
187 | |
188 | char **nm_device_disambiguate_names(NMDevice **devices, int num_devices); |
189 | NM_AVAILABLE_IN_1_2 |
190 | _NM_DEPRECATED_SYNC_METHOD |
191 | gboolean nm_device_reapply(NMDevice *device, |
192 | NMConnection *connection, |
193 | guint64 version_id, |
194 | guint32 flags, |
195 | GCancellable *cancellable, |
196 | GError **error); |
197 | NM_AVAILABLE_IN_1_2 |
198 | void 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); |
205 | NM_AVAILABLE_IN_1_2 |
206 | gboolean nm_device_reapply_finish(NMDevice *device, GAsyncResult *result, GError **error); |
207 | |
208 | NM_AVAILABLE_IN_1_2 |
209 | _NM_DEPRECATED_SYNC_METHOD |
210 | NMConnection *nm_device_get_applied_connection(NMDevice *device, |
211 | guint32 flags, |
212 | guint64 *version_id, |
213 | GCancellable *cancellable, |
214 | GError **error); |
215 | NM_AVAILABLE_IN_1_2 |
216 | void nm_device_get_applied_connection_async(NMDevice *device, |
217 | guint32 flags, |
218 | GCancellable *cancellable, |
219 | GAsyncReadyCallback callback, |
220 | gpointer user_data); |
221 | NM_AVAILABLE_IN_1_2 |
222 | NMConnection *nm_device_get_applied_connection_finish(NMDevice *device, |
223 | GAsyncResult *result, |
224 | guint64 *version_id, |
225 | GError **error); |
226 | |
227 | _NM_DEPRECATED_SYNC_METHOD |
228 | gboolean nm_device_disconnect(NMDevice *device, GCancellable *cancellable, GError **error); |
229 | void nm_device_disconnect_async(NMDevice *device, |
230 | GCancellable *cancellable, |
231 | GAsyncReadyCallback callback, |
232 | gpointer user_data); |
233 | gboolean nm_device_disconnect_finish(NMDevice *device, GAsyncResult *result, GError **error); |
234 | |
235 | _NM_DEPRECATED_SYNC_METHOD |
236 | gboolean nm_device_delete(NMDevice *device, GCancellable *cancellable, GError **error); |
237 | void nm_device_delete_async(NMDevice *device, |
238 | GCancellable *cancellable, |
239 | GAsyncReadyCallback callback, |
240 | gpointer user_data); |
241 | gboolean nm_device_delete_finish(NMDevice *device, GAsyncResult *result, GError **error); |
242 | |
243 | GPtrArray *nm_device_filter_connections(NMDevice *device, const GPtrArray *connections); |
244 | |
245 | gboolean nm_device_connection_valid(NMDevice *device, NMConnection *connection); |
246 | |
247 | gboolean |
248 | nm_device_connection_compatible(NMDevice *device, NMConnection *connection, GError **error); |
249 | |
250 | GType nm_device_get_setting_type(NMDevice *device); |
251 | |
252 | NM_AVAILABLE_IN_1_2 |
253 | GType nm_lldp_neighbor_get_type(void); |
254 | NM_AVAILABLE_IN_1_2 |
255 | void nm_lldp_neighbor_ref(NMLldpNeighbor *neighbor); |
256 | NM_AVAILABLE_IN_1_2 |
257 | void nm_lldp_neighbor_unref(NMLldpNeighbor *neighbor); |
258 | NM_AVAILABLE_IN_1_2 |
259 | char **nm_lldp_neighbor_get_attr_names(NMLldpNeighbor *neighbor); |
260 | NM_AVAILABLE_IN_1_18 |
261 | GVariant *nm_lldp_neighbor_get_attr_value(NMLldpNeighbor *neighbor, const char *name); |
262 | |
263 | NM_AVAILABLE_IN_1_2 |
264 | NMLldpNeighbor *nm_lldp_neighbor_new(void); |
265 | NM_AVAILABLE_IN_1_2 |
266 | gboolean nm_lldp_neighbor_get_attr_string_value(NMLldpNeighbor *neighbor, |
267 | const char *name, |
268 | const char **out_value); |
269 | NM_AVAILABLE_IN_1_2 |
270 | gboolean |
271 | nm_lldp_neighbor_get_attr_uint_value(NMLldpNeighbor *neighbor, const char *name, guint *out_value); |
272 | NM_AVAILABLE_IN_1_2 |
273 | const GVariantType *nm_lldp_neighbor_get_attr_type(NMLldpNeighbor *neighbor, const char *name); |
274 | |
275 | G_END_DECLS |
276 | |
277 | #endif /* __NM_DEVICE_H__ */ |
278 | |