From 964ae8cc391520440cf5aa13e2b9cc34850ea6c2 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 26 Feb 2019 19:01:41 +0100 Subject: New upstream version 1.14.6 --- libnm/nm-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libnm/nm-device.c') diff --git a/libnm/nm-device.c b/libnm/nm-device.c index aa45c4ad..3f1cc636 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -2533,7 +2533,7 @@ nm_device_connection_compatible (NMDevice *device, NMConnection *connection, GEr * incompatible with the device. To get the full list of connections see * nm_client_get_connections(). * - * Returns: (transfer container) (element-type NMConnection): an array of + * Returns: (transfer full) (element-type NMConnection): an array of * #NMConnections that could be activated with the given @device. The array * should be freed with g_ptr_array_unref() when it is no longer required. **/ -- cgit 1.3.0-6-gf8a5 From 9a6dcbf895f9da01768e64b73cec88c16157d91e Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 26 Mar 2019 23:25:23 +0100 Subject: New upstream version 1.16.0 --- libnm/nm-device.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 6 deletions(-) (limited to 'libnm/nm-device.c') diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 3f1cc636..5965cb3b 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -23,7 +23,6 @@ #include "nm-device.h" -#include #include #include "nm-libnm-utils.h" @@ -74,6 +73,8 @@ typedef struct { NMDhcpConfig *dhcp4_config; NMIPConfig *ip6_config; NMDhcpConfig *dhcp6_config; + NMConnectivityState ip4_connectivity; + NMConnectivityState ip6_connectivity; NMDeviceState state; NMDeviceState last_seen_state; NMDeviceStateReason reason; @@ -120,6 +121,8 @@ enum { PROP_MTU, PROP_METERED, PROP_LLDP_NEIGHBORS, + PROP_IP4_CONNECTIVITY, + PROP_IP6_CONNECTIVITY, LAST_PROP }; @@ -144,6 +147,8 @@ nm_device_init (NMDevice *device) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); + priv->ip4_connectivity = NM_CONNECTIVITY_UNKNOWN; + priv->ip6_connectivity = NM_CONNECTIVITY_UNKNOWN; priv->state = NM_DEVICE_STATE_UNKNOWN; priv->reason = NM_DEVICE_STATE_REASON_NONE; priv->lldp_neighbors = g_ptr_array_new (); @@ -216,6 +221,8 @@ init_dbus (NMObject *object) { NM_DEVICE_DHCP4_CONFIG, &priv->dhcp4_config, NULL, NM_TYPE_DHCP4_CONFIG }, { NM_DEVICE_IP6_CONFIG, &priv->ip6_config, NULL, NM_TYPE_IP6_CONFIG }, { NM_DEVICE_DHCP6_CONFIG, &priv->dhcp6_config, NULL, NM_TYPE_DHCP6_CONFIG }, + { NM_DEVICE_IP4_CONNECTIVITY, &priv->ip4_connectivity }, + { NM_DEVICE_IP6_CONNECTIVITY, &priv->ip6_connectivity }, { NM_DEVICE_STATE, &priv->state }, { NM_DEVICE_STATE_REASON, &priv->reason, demarshal_state_reason }, { NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION }, @@ -287,6 +294,7 @@ coerce_type (NMDeviceType type) case NM_DEVICE_TYPE_WPAN: case NM_DEVICE_TYPE_6LOWPAN: case NM_DEVICE_TYPE_WIREGUARD: + case NM_DEVICE_TYPE_WIFI_P2P: return type; } return NM_DEVICE_TYPE_UNKNOWN; @@ -348,7 +356,7 @@ get_property (GObject *object, switch (prop_id) { case PROP_DEVICE_TYPE: - g_value_set_enum (value, coerce_type (nm_device_get_device_type (device))); + g_value_set_enum (value, nm_device_get_device_type (device)); break; case PROP_UDI: g_value_set_string (value, nm_device_get_udi (device)); @@ -428,6 +436,12 @@ get_property (GObject *object, case PROP_LLDP_NEIGHBORS: g_value_set_boxed (value, nm_device_get_lldp_neighbors (device)); break; + case PROP_IP4_CONNECTIVITY: + g_value_set_enum (value, nm_device_get_connectivity (device, AF_INET)); + break; + case PROP_IP6_CONNECTIVITY: + g_value_set_enum (value, nm_device_get_connectivity (device, AF_INET6)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -700,6 +714,36 @@ nm_device_class_init (NMDeviceClass *device_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMDevice:ip4-connectivity: + * + * The IPv4 connectivity state of the device. + * + * Since: 1.16 + **/ + g_object_class_install_property + (object_class, PROP_IP4_CONNECTIVITY, + g_param_spec_enum (NM_DEVICE_IP4_CONNECTIVITY, "", "", + NM_TYPE_CONNECTIVITY_STATE, + NM_CONNECTIVITY_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + /** + * NMDevice:ip6-connectivity: + * + * The IPv6 connectivity state of the device. + * + * Since: 1.16 + **/ + g_object_class_install_property + (object_class, PROP_IP6_CONNECTIVITY, + g_param_spec_enum (NM_DEVICE_IP6_CONNECTIVITY, "", "", + NM_TYPE_CONNECTIVITY_STATE, + NM_CONNECTIVITY_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + /** * NMDevice:state: * @@ -893,7 +937,7 @@ nm_device_get_device_type (NMDevice *self) { g_return_val_if_fail (NM_IS_DEVICE (self), NM_DEVICE_TYPE_UNKNOWN); - return NM_DEVICE_GET_PRIVATE (self)->device_type; + return coerce_type (NM_DEVICE_GET_PRIVATE (self)->device_type); } /** @@ -1230,6 +1274,36 @@ nm_device_get_dhcp6_config (NMDevice *device) return NM_DEVICE_GET_PRIVATE (device)->dhcp6_config; } +/** + * nm_device_get_connectivity: + * @device: a #NMDevice + * @addr_family: network address family + * + * The connectivity state of the device for given address family. + * Supported address families are %AF_INET for IPv4, %AF_INET6 + * for IPv6 or %AF_UNSPEC for any. + * + * Returns: the current connectivity state + * + * Since: 1.16 + **/ +NMConnectivityState +nm_device_get_connectivity (NMDevice *device, int addr_family) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); + + switch (addr_family) { + case AF_INET: + return priv->ip4_connectivity; + case AF_INET6: + return priv->ip6_connectivity; + case AF_UNSPEC: + return NM_MAX (priv->ip4_connectivity, priv->ip6_connectivity); + default: + g_return_val_if_reached (NM_CONNECTIVITY_UNKNOWN); + } +} + /** * nm_device_get_state: * @device: a #NMDevice @@ -1354,6 +1428,8 @@ get_type_name (NMDevice *device) return _("6LoWPAN"); case NM_DEVICE_TYPE_WIREGUARD: return _("WireGuard"); + case NM_DEVICE_TYPE_WIFI_P2P: + return _("Wi-Fi P2P"); case NM_DEVICE_TYPE_GENERIC: case NM_DEVICE_TYPE_UNUSED1: case NM_DEVICE_TYPE_UNUSED2: @@ -2059,7 +2135,7 @@ nm_device_reapply_finish (NMDevice *device, * nm_device_get_applied_connection: * @device: a #NMDevice * @flags: the flags argument. Currently this value must always be zero. - * @version_id: (out): (allow-none): returns the current version id of + * @version_id: (out) (allow-none): returns the current version id of * the applied connection * @cancellable: a #GCancellable, or %NULL * @error: location for a #GError, or %NULL @@ -2193,7 +2269,7 @@ nm_device_get_applied_connection_async (NMDevice *device, * nm_device_get_applied_connection_finish: * @device: a #NMDevice * @result: the result passed to the #GAsyncReadyCallback - * @version_id: (out): (allow-none): the current version id of the applied + * @version_id: (out) (allow-none): the current version id of the applied * connection. * @error: location for a #GError, or %NULL * @@ -2392,7 +2468,7 @@ device_delete_cb (GObject *proxy, * @callback: callback to be called when delete operation completes * @user_data: caller-specific data passed to @callback * - * Asynchronously begins deleteing the software device. Hardware devices can't + * Asynchronously begins deleting the software device. Hardware devices can't * be deleted. **/ void -- cgit 1.3.0-6-gf8a5 From 85563b7fc7ec2cd21e38debb9b28db342e2e8e7c Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Sun, 21 Apr 2019 21:09:51 +0200 Subject: New upstream version 1.18.0 --- libnm/nm-device.c | 66 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 16 deletions(-) (limited to 'libnm/nm-device.c') diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 5965cb3b..aba4e5c4 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -40,7 +40,7 @@ #include "nm-dbus-helpers.h" #include "nm-device-tun.h" #include "nm-setting-connection.h" -#include "shared/nm-utils/nm-udev-utils.h" +#include "nm-udev-aux/nm-udev-utils.h" #include "introspection/org.freedesktop.NetworkManager.Device.h" @@ -2649,6 +2649,18 @@ nm_device_get_setting_type (NMDevice *device) return NM_DEVICE_GET_CLASS (device)->get_setting_type (device); } +/*****************************************************************************/ + +static gboolean +NM_IS_LLDP_NEIGHBOR (const NMLldpNeighbor *self) +{ + nm_assert ( !self + || ( self->refcount > 0 + && self->attrs)); + return self + && self->refcount > 0; +} + /** * nm_lldp_neighbor_new: * @@ -2675,9 +2687,15 @@ static NMLldpNeighbor * nm_lldp_neighbor_dup (NMLldpNeighbor *neighbor) { NMLldpNeighbor *copy; + GHashTableIter iter; + const char *key; + GVariant *value; copy = nm_lldp_neighbor_new (); - copy->attrs = g_hash_table_ref (neighbor->attrs); + + g_hash_table_iter_init (&iter, neighbor->attrs); + while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) + g_hash_table_insert (copy->attrs, g_strdup (key), g_variant_ref (value)); return copy; } @@ -2693,8 +2711,7 @@ nm_lldp_neighbor_dup (NMLldpNeighbor *neighbor) void nm_lldp_neighbor_ref (NMLldpNeighbor *neighbor) { - g_return_if_fail (neighbor); - g_return_if_fail (neighbor->refcount > 0); + g_return_if_fail (NM_IS_LLDP_NEIGHBOR (neighbor)); neighbor->refcount++; } @@ -2711,11 +2728,9 @@ nm_lldp_neighbor_ref (NMLldpNeighbor *neighbor) void nm_lldp_neighbor_unref (NMLldpNeighbor *neighbor) { - g_return_if_fail (neighbor); - g_return_if_fail (neighbor->refcount > 0); + g_return_if_fail (NM_IS_LLDP_NEIGHBOR (neighbor)); if (--neighbor->refcount == 0) { - g_return_if_fail (neighbor->attrs); g_hash_table_unref (neighbor->attrs); g_free (neighbor); } @@ -2738,8 +2753,7 @@ nm_lldp_neighbor_get_attr_names (NMLldpNeighbor *neighbor) const char *key; GPtrArray *names; - g_return_val_if_fail (neighbor, NULL); - g_return_val_if_fail (neighbor->attrs, NULL); + g_return_val_if_fail (NM_IS_LLDP_NEIGHBOR (neighbor), NULL); names = g_ptr_array_new (); @@ -2765,12 +2779,12 @@ nm_lldp_neighbor_get_attr_names (NMLldpNeighbor *neighbor) * Since: 1.2 **/ gboolean -nm_lldp_neighbor_get_attr_string_value (NMLldpNeighbor *neighbor, char *name, +nm_lldp_neighbor_get_attr_string_value (NMLldpNeighbor *neighbor, const char *name, const char **out_value) { GVariant *variant; - g_return_val_if_fail (neighbor, FALSE); + g_return_val_if_fail (NM_IS_LLDP_NEIGHBOR (neighbor), FALSE); g_return_val_if_fail (name && name[0], FALSE); variant = g_hash_table_lookup (neighbor->attrs, name); @@ -2795,12 +2809,12 @@ nm_lldp_neighbor_get_attr_string_value (NMLldpNeighbor *neighbor, char *name, * Since: 1.2 **/ gboolean -nm_lldp_neighbor_get_attr_uint_value (NMLldpNeighbor *neighbor, char *name, +nm_lldp_neighbor_get_attr_uint_value (NMLldpNeighbor *neighbor, const char *name, guint *out_value) { GVariant *variant; - g_return_val_if_fail (neighbor, FALSE); + g_return_val_if_fail (NM_IS_LLDP_NEIGHBOR (neighbor), FALSE); g_return_val_if_fail (name && name[0], FALSE); variant = g_hash_table_lookup (neighbor->attrs, name); @@ -2812,6 +2826,27 @@ nm_lldp_neighbor_get_attr_uint_value (NMLldpNeighbor *neighbor, char *name, return FALSE; } +/** + * nm_lldp_neighbor_get_attr_value: + * @neighbor: the #NMLldpNeighbor + * @name: the attribute name + * + * Gets the value (as a GVariant) of attribute with name @name on @neighbor + * + * Returns: (transfer none): the value or %NULL if the attribute with @name was + * not found. + * + * Since: 1.18 + **/ +GVariant * +nm_lldp_neighbor_get_attr_value (NMLldpNeighbor *neighbor, const char *name) +{ + g_return_val_if_fail (NM_IS_LLDP_NEIGHBOR (neighbor), FALSE); + g_return_val_if_fail (name && name[0], FALSE); + + return g_hash_table_lookup (neighbor->attrs, name); +} + /** * nm_lldp_neighbor_get_attr_type: * @neighbor: the #NMLldpNeighbor @@ -2824,11 +2859,11 @@ nm_lldp_neighbor_get_attr_uint_value (NMLldpNeighbor *neighbor, char *name, * Since: 1.2 **/ const GVariantType * -nm_lldp_neighbor_get_attr_type (NMLldpNeighbor *neighbor, char *name) +nm_lldp_neighbor_get_attr_type (NMLldpNeighbor *neighbor, const char *name) { GVariant *variant; - g_return_val_if_fail (neighbor, NULL); + g_return_val_if_fail (NM_IS_LLDP_NEIGHBOR (neighbor), NULL); g_return_val_if_fail (name && name[0], NULL); variant = g_hash_table_lookup (neighbor->attrs, name); @@ -2836,5 +2871,4 @@ nm_lldp_neighbor_get_attr_type (NMLldpNeighbor *neighbor, char *name) return g_variant_get_type (variant); else return NULL; - } -- cgit 1.3.0-6-gf8a5