From 937796f6ea78c320e90e909330799a56df56b911 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 21 Jan 2019 11:53:48 +0100 Subject: [PATCH] libnm: add nm_lldp_neighbor_get_attr_value() The function provides access to the GVariant representing a LLDP attribute. --- libnm/libnm.ver | 1 + libnm/nm-device.c | 21 +++++++++++++++++++++ libnm/nm-device.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/libnm/libnm.ver b/libnm/libnm.ver index b705ca4589..c2780cca81 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1536,6 +1536,7 @@ global: nm_bridge_vlan_set_untagged; nm_bridge_vlan_to_str; nm_bridge_vlan_unref; + nm_lldp_neighbor_get_attr_value; nm_setting_bridge_add_vlan; nm_setting_bridge_clear_vlans; nm_setting_bridge_get_num_vlans; diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 6586140f96..a09ecb5cbb 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -2812,6 +2812,27 @@ nm_lldp_neighbor_get_attr_uint_value (NMLldpNeighbor *neighbor, const 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 (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 diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 9d31d38a44..6227229782 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -234,6 +234,8 @@ gboolean nm_lldp_neighbor_get_attr_uint_value (NMLldpNeighbor *neighbor, const c guint *out_value); NM_AVAILABLE_IN_1_2 const GVariantType *nm_lldp_neighbor_get_attr_type (NMLldpNeighbor *neighbor, const char *name); +NM_AVAILABLE_IN_1_18 +GVariant *nm_lldp_neighbor_get_attr_value (NMLldpNeighbor *neighbor, const char *name); G_END_DECLS