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/meson.build | 2 +- libnm/nm-access-point.c | 2 +- libnm/nm-device-tun.c | 1 + libnm/nm-device.c | 2 +- libnm/nm-manager.c | 16 ++++++++-------- libnm/nm-property-docs.xml | 10 +++++----- libnm/nm-remote-connection.c | 2 +- libnm/nm-settings-docs.xml | 10 +++++----- libnm/nm-wimax-nsp.c | 2 +- 9 files changed, 24 insertions(+), 23 deletions(-) (limited to 'libnm') diff --git a/libnm/meson.build b/libnm/meson.build index 62e3e9d7..62e37993 100644 --- a/libnm/meson.build +++ b/libnm/meson.build @@ -184,7 +184,7 @@ pkg.generate( requires: 'gio-2.0', variables: [ 'exec_prefix=${prefix}', - 'vpnservicedir=' + join_paths(nm_pkglibdir, 'VPN') + 'vpnservicedir=' + join_paths('${prefix}', 'lib', nm_name, 'VPN') ] ) diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index 1cac12f9..25281c92 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -367,7 +367,7 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection) * #NMDevice using nm_device_filter_connections() and finally filter that list * with this function. * - * 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 @ap. The array should * be freed with g_ptr_array_unref() when it is no longer required. **/ diff --git a/libnm/nm-device-tun.c b/libnm/nm-device-tun.c index 2c88bf33..b5721350 100644 --- a/libnm/nm-device-tun.c +++ b/libnm/nm-device-tun.c @@ -268,6 +268,7 @@ finalize (GObject *object) NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (object); g_free (priv->mode); + g_free (priv->hw_address); G_OBJECT_CLASS (nm_device_tun_parent_class)->finalize (object); } 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. **/ diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index aac120c6..e108f2b0 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -885,22 +885,20 @@ activate_info_complete (ActivateInfo *info, NMActiveConnection *active, GError *error) { + nm_clear_g_signal_handler (info->cancellable, &info->cancelled_id); + + c_list_unlink_stale (&info->lst); + if (active) g_simple_async_result_set_op_res_gpointer (info->simple, g_object_ref (active), g_object_unref); else g_simple_async_result_set_from_error (info->simple, error); g_simple_async_result_complete (info->simple); - c_list_unlink_stale (&info->lst); - g_free (info->active_path); g_free (info->new_connection_path); g_object_unref (info->simple); - if (info->cancellable) { - if (info->cancelled_id) - g_signal_handler_disconnect (info->cancellable, info->cancelled_id); - g_object_unref (info->cancellable); - } + nm_g_object_unref (info->cancellable); g_slice_free (ActivateInfo, info); } @@ -1538,7 +1536,7 @@ nm_manager_checkpoint_rollback_finish (NMManager *manager, if (g_simple_async_result_propagate_error (simple, error)) return NULL; else - return g_simple_async_result_get_op_res_gpointer (simple); + return g_hash_table_ref (g_simple_async_result_get_op_res_gpointer (simple)); } static void @@ -1732,6 +1730,8 @@ dispose (GObject *object) priv->all_devices = NULL; } + nm_clear_pointer (&priv->checkpoints, g_ptr_array_unref); + free_active_connections (manager); g_clear_object (&priv->primary_connection); g_clear_object (&priv->activating_connection); diff --git a/libnm/nm-property-docs.xml b/libnm/nm-property-docs.xml index 22aed0ea..4016bc07 100644 --- a/libnm/nm-property-docs.xml +++ b/libnm/nm-property-docs.xml @@ -22,7 +22,7 @@ - + @@ -164,7 +164,7 @@ - + @@ -187,7 +187,7 @@ - + @@ -309,8 +309,8 @@ - - + + diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index 6c1e0924..08faa77e 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -918,7 +918,7 @@ get_property (GObject *object, guint prop_id, g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->unsaved); break; case PROP_FLAGS: - g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->flags); + g_value_set_uint (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->flags); break; case PROP_FILENAME: g_value_set_string (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->filename); diff --git a/libnm/nm-settings-docs.xml b/libnm/nm-settings-docs.xml index 258d3558..f3dca3fb 100644 --- a/libnm/nm-settings-docs.xml +++ b/libnm/nm-settings-docs.xml @@ -22,7 +22,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -192,7 +192,7 @@ - + @@ -315,8 +315,8 @@ - - + + diff --git a/libnm/nm-wimax-nsp.c b/libnm/nm-wimax-nsp.c index f8c8ca42..90c2c2bb 100644 --- a/libnm/nm-wimax-nsp.c +++ b/libnm/nm-wimax-nsp.c @@ -151,7 +151,7 @@ nm_wimax_nsp_connection_valid (NMWimaxNsp *nsp, NMConnection *connection) * return connections which may be activated with the NSP. Any returned * connections will match the @nsp's network name and other attributes. * - * 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 @nsp. 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/NetworkManager.h | 6 +- libnm/fake-typelib/meson.build | 8 +- libnm/generate-plugin-docs.pl | 2 +- libnm/libnm.ver | 74 ++++ libnm/meson.build | 79 ++-- libnm/nm-access-point.c | 2 - libnm/nm-active-connection.c | 10 +- libnm/nm-autoptr.h | 4 +- libnm/nm-checkpoint.c | 2 +- libnm/nm-client.c | 181 +++++++-- libnm/nm-client.h | 19 +- libnm/nm-dbus-helpers.c | 4 +- libnm/nm-device-adsl.c | 3 - libnm/nm-device-bond.c | 4 +- libnm/nm-device-bridge.c | 4 +- libnm/nm-device-bt.c | 4 +- libnm/nm-device-dummy.c | 3 +- libnm/nm-device-ethernet.c | 4 +- libnm/nm-device-generic.c | 3 +- libnm/nm-device-infiniband.c | 4 +- libnm/nm-device-ip-tunnel.c | 4 +- libnm/nm-device-macsec.c | 3 +- libnm/nm-device-macvlan.c | 4 +- libnm/nm-device-modem.c | 4 +- libnm/nm-device-olpc-mesh.c | 4 +- libnm/nm-device-ovs-bridge.c | 3 +- libnm/nm-device-ovs-interface.c | 3 +- libnm/nm-device-ovs-port.c | 4 +- libnm/nm-device-team.c | 4 +- libnm/nm-device-tun.c | 5 +- libnm/nm-device-vlan.c | 4 +- libnm/nm-device-vxlan.c | 6 +- libnm/nm-device-wifi-p2p.c | 502 +++++++++++++++++++++++++ libnm/nm-device-wifi-p2p.h | 80 ++++ libnm/nm-device-wifi.c | 7 +- libnm/nm-device-wimax.c | 4 +- libnm/nm-device-wpan.c | 3 +- libnm/nm-device.c | 88 ++++- libnm/nm-device.h | 4 + libnm/nm-dhcp-config.c | 3 +- libnm/nm-dhcp4-config.c | 1 + libnm/nm-dhcp6-config.c | 1 + libnm/nm-dns-manager.c | 3 - libnm/nm-ip-config.c | 3 +- libnm/nm-ip4-config.c | 1 + libnm/nm-ip6-config.c | 1 + libnm/nm-libnm-utils.c | 2 +- libnm/nm-manager.c | 154 ++++++-- libnm/nm-manager.h | 17 + libnm/nm-object.c | 3 +- libnm/nm-object.h | 2 +- libnm/nm-property-docs.xml | 31 +- libnm/nm-remote-connection.c | 4 +- libnm/nm-remote-settings.c | 3 - libnm/nm-secret-agent-old.c | 524 +++++++++++++------------- libnm/nm-settings-docs-overrides.xml | 9 +- libnm/nm-settings-docs.xml | 36 +- libnm/nm-settings-ifcfg-rh-docs.xml | 6 +- libnm/nm-settings-keyfile-docs.xml | 7 + libnm/nm-types.h | 4 +- libnm/nm-vpn-connection.c | 3 +- libnm/nm-vpn-plugin-old.c | 1 - libnm/nm-vpn-service-plugin.c | 82 ++-- libnm/nm-wifi-p2p-peer.c | 600 ++++++++++++++++++++++++++++++ libnm/nm-wifi-p2p-peer.h | 89 +++++ libnm/nm-wimax-nsp.c | 4 +- libnm/tests/meson.build | 7 +- libnm/tests/test-general.c | 274 ++++++++++++++ libnm/tests/test-nm-client.c | 1 - libnm/tests/test-remote-settings-client.c | 1 - libnm/tests/test-secret-agent.c | 1 - 71 files changed, 2515 insertions(+), 519 deletions(-) create mode 100644 libnm/nm-device-wifi-p2p.c create mode 100644 libnm/nm-device-wifi-p2p.h create mode 100644 libnm/nm-wifi-p2p-peer.c create mode 100644 libnm/nm-wifi-p2p-peer.h (limited to 'libnm') diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h index 759a4131..7c70a226 100644 --- a/libnm/NetworkManager.h +++ b/libnm/NetworkManager.h @@ -43,14 +43,15 @@ #include "nm-device-macvlan.h" #include "nm-device-modem.h" #include "nm-device-olpc-mesh.h" +#include "nm-device-ovs-bridge.h" #include "nm-device-ovs-interface.h" #include "nm-device-ovs-port.h" -#include "nm-device-ovs-bridge.h" #include "nm-device-ppp.h" #include "nm-device-team.h" #include "nm-device-tun.h" #include "nm-device-vlan.h" #include "nm-device-vxlan.h" +#include "nm-device-wifi-p2p.h" #include "nm-device-wifi.h" #include "nm-device-wimax.h" #include "nm-device-wireguard.h" @@ -88,6 +89,7 @@ #include "nm-setting-ovs-interface.h" #include "nm-setting-ovs-patch.h" #include "nm-setting-ovs-port.h" +#include "nm-setting-wifi-p2p.h" #include "nm-setting-ppp.h" #include "nm-setting-pppoe.h" #include "nm-setting-proxy.h" @@ -103,6 +105,7 @@ #include "nm-setting-vxlan.h" #include "nm-setting-wimax.h" #include "nm-setting-wired.h" +#include "nm-setting-wireguard.h" #include "nm-setting-wireless.h" #include "nm-setting-wireless-security.h" #include "nm-setting-wpan.h" @@ -116,6 +119,7 @@ #include "nm-vpn-editor-plugin.h" #include "nm-vpn-plugin-info.h" #include "nm-vpn-service-plugin.h" +#include "nm-wifi-p2p-peer.h" #include "nm-wimax-nsp.h" #include "nm-autoptr.h" diff --git a/libnm/fake-typelib/meson.build b/libnm/fake-typelib/meson.build index c0a779a2..fdbb2920 100644 --- a/libnm/fake-typelib/meson.build +++ b/libnm/fake-typelib/meson.build @@ -2,7 +2,7 @@ g_ir_compiler = find_program('g-ir-compiler') girs = [ 'NetworkManager', - 'NMClient' + 'NMClient', ] resource_data = [] @@ -14,17 +14,17 @@ foreach gir: girs gir_typelib, input: gir + '.gir', output: gir_typelib, - command: [g_ir_compiler, '@INPUT@', '-o', '@OUTPUT@'] + command: [g_ir_compiler, '@INPUT@', '-o', '@OUTPUT@'], ) endforeach resource = 'typelibs' -sources += gnome.compile_resources( +libnm_utils_sources += gnome.compile_resources( resource, resource + '.gresource.xml', source_dir: '.', dependencies: resource_data, extra_args: '--manual-register', - export: true + export: true, ) diff --git a/libnm/generate-plugin-docs.pl b/libnm/generate-plugin-docs.pl index e4963b7c..74e2126c 100755 --- a/libnm/generate-plugin-docs.pl +++ b/libnm/generate-plugin-docs.pl @@ -60,7 +60,7 @@ open $fo, '>', $output or die "Can't open $output: $!"; # write XML header write_header(); -# write generated documenation for each setting +# write generated documentation for each setting foreach my $c_file (@source_files) { my $setting_name = get_setting_name($c_file); if ($setting_name) { diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 1f76dc0f..ece9686e 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1444,3 +1444,77 @@ global: nm_utils_sriov_vf_from_str; nm_utils_sriov_vf_to_str; } libnm_1_12_0; + +libnm_1_16_0 { +global: + nm_client_add_and_activate_connection2; + nm_client_add_and_activate_connection2_finish; + nm_device_get_connectivity; + nm_device_wifi_p2p_get_hw_address; + nm_device_wifi_p2p_get_peers; + nm_device_wifi_p2p_get_type; + nm_device_wifi_p2p_start_find; + nm_device_wifi_p2p_start_find_finish; + nm_device_wifi_p2p_stop_find; + nm_device_wifi_p2p_stop_find_finish; + nm_setting_wifi_p2p_get_peer; + nm_setting_wifi_p2p_get_type; + nm_setting_wifi_p2p_get_wfd_ies; + nm_setting_wifi_p2p_get_wps_method; + nm_setting_wifi_p2p_new; + nm_setting_wireguard_append_peer; + nm_setting_wireguard_clear_peers; + nm_setting_wireguard_get_fwmark; + nm_setting_wireguard_get_listen_port; + nm_setting_wireguard_get_mtu; + nm_setting_wireguard_get_peer; + nm_setting_wireguard_get_peer_by_public_key; + nm_setting_wireguard_get_peer_routes; + nm_setting_wireguard_get_peers_len; + nm_setting_wireguard_get_private_key; + nm_setting_wireguard_get_private_key_flags; + nm_setting_wireguard_get_type; + nm_setting_wireguard_new; + nm_setting_wireguard_remove_peer; + nm_setting_wireguard_set_peer; + nm_team_link_watcher_get_vlanid; + nm_team_link_watcher_new_arp_ping2; + nm_utils_base64secret_decode; + nm_wifi_p2p_peer_connection_valid; + nm_wifi_p2p_peer_filter_connections; + nm_wifi_p2p_peer_get_flags; + nm_wifi_p2p_peer_get_hw_address; + nm_wifi_p2p_peer_get_last_seen; + nm_wifi_p2p_peer_get_manufacturer; + nm_wifi_p2p_peer_get_model; + nm_wifi_p2p_peer_get_model_number; + nm_wifi_p2p_peer_get_name; + nm_wifi_p2p_peer_get_serial; + nm_wifi_p2p_peer_get_strength; + nm_wifi_p2p_peer_get_type; + nm_wifi_p2p_peer_get_wfd_ies; + nm_wireguard_peer_append_allowed_ip; + nm_wireguard_peer_clear_allowed_ips; + nm_wireguard_peer_cmp; + nm_wireguard_peer_get_allowed_ip; + nm_wireguard_peer_get_allowed_ips_len; + nm_wireguard_peer_get_endpoint; + nm_wireguard_peer_get_persistent_keepalive; + nm_wireguard_peer_get_preshared_key; + nm_wireguard_peer_get_preshared_key_flags; + nm_wireguard_peer_get_public_key; + nm_wireguard_peer_get_type; + nm_wireguard_peer_is_sealed; + nm_wireguard_peer_is_valid; + nm_wireguard_peer_new; + nm_wireguard_peer_new_clone; + nm_wireguard_peer_ref; + nm_wireguard_peer_remove_allowed_ip; + nm_wireguard_peer_seal; + nm_wireguard_peer_set_endpoint; + nm_wireguard_peer_set_persistent_keepalive; + nm_wireguard_peer_set_preshared_key; + nm_wireguard_peer_set_preshared_key_flags; + nm_wireguard_peer_set_public_key; + nm_wireguard_peer_unref; +} libnm_1_14_0; diff --git a/libnm/meson.build b/libnm/meson.build index 62e37993..558a587b 100644 --- a/libnm/meson.build +++ b/libnm/meson.build @@ -1,17 +1,18 @@ libnm_inc = include_directories('.') -sources = files('nm-libnm-utils.c') - -deps = [ - libnmdbus_dep, - shared_dep -] - cflags = [ '-DG_LOG_DOMAIN="@0@"'.format(libnm_name), '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM', ] +libnm_utils_sources = files('nm-libnm-utils.c') + +deps = [ + libnmdbus_dep, + shared_nm_utils_base_dep, + nm_core_dep, +] + if have_fake_typelibs deps += gir_dep subdir('fake-typelib') @@ -19,10 +20,10 @@ endif libnm_utils = static_library( 'nm-utils', - sources: sources, + sources: libnm_utils_sources, include_directories: libnm_core_inc, dependencies: deps, - c_args: cflags + c_args: cflags, ) libnm_headers = files( @@ -40,25 +41,26 @@ libnm_headers = files( 'nm-device-dummy.h', 'nm-device-ethernet.h', 'nm-device-generic.h', - 'nm-device.h', 'nm-device-infiniband.h', 'nm-device-ip-tunnel.h', 'nm-device-macsec.h', 'nm-device-macvlan.h', 'nm-device-modem.h', 'nm-device-olpc-mesh.h', + 'nm-device-ovs-bridge.h', 'nm-device-ovs-interface.h', 'nm-device-ovs-port.h', - 'nm-device-ovs-bridge.h', 'nm-device-ppp.h', 'nm-device-team.h', 'nm-device-tun.h', 'nm-device-vlan.h', 'nm-device-vxlan.h', + 'nm-device-wifi-p2p.h', 'nm-device-wifi.h', 'nm-device-wimax.h', 'nm-device-wireguard.h', 'nm-device-wpan.h', + 'nm-device.h', 'nm-dhcp-config.h', 'nm-ip-config.h', 'nm-object.h', @@ -69,12 +71,13 @@ libnm_headers = files( 'nm-vpn-editor.h', 'nm-vpn-plugin-old.h', 'nm-vpn-service-plugin.h', - 'nm-wimax-nsp.h' + 'nm-wifi-p2p-peer.h', + 'nm-wimax-nsp.h', ) install_headers( libnm_core_headers + libnm_headers + [version_header], - subdir: libnm_name + subdir: libnm_name, ) enum_headers = libnm_headers + [version_header] @@ -87,7 +90,7 @@ libnm_enum = gnome.mkenums( c_template: enum_types + '.c.template', h_template: enum_types + '.h.template', install_header: true, - install_dir: libnm_pkgincludedir + install_dir: libnm_pkgincludedir, ) libnm_sources = files( @@ -101,7 +104,6 @@ libnm_sources = files( 'nm-device-bond.c', 'nm-device-bridge.c', 'nm-device-bt.c', - 'nm-device.c', 'nm-device-dummy.c', 'nm-device-ethernet.c', 'nm-device-generic.c', @@ -111,18 +113,20 @@ libnm_sources = files( 'nm-device-macvlan.c', 'nm-device-modem.c', 'nm-device-olpc-mesh.c', + 'nm-device-ovs-bridge.c', 'nm-device-ovs-interface.c', 'nm-device-ovs-port.c', - 'nm-device-ovs-bridge.c', 'nm-device-ppp.c', 'nm-device-team.c', 'nm-device-tun.c', 'nm-device-vlan.c', 'nm-device-vxlan.c', + 'nm-device-wifi-p2p.c', 'nm-device-wifi.c', 'nm-device-wimax.c', 'nm-device-wireguard.c', 'nm-device-wpan.c', + 'nm-device.c', 'nm-dhcp-config.c', 'nm-dhcp4-config.c', 'nm-dhcp6-config.c', @@ -136,19 +140,13 @@ libnm_sources = files( 'nm-remote-settings.c', 'nm-secret-agent-old.c', 'nm-vpn-connection.c', - 'nm-vpn-plugin-old.c', 'nm-vpn-editor.c', + 'nm-vpn-plugin-old.c', 'nm-vpn-service-plugin.c', - 'nm-wimax-nsp.c' + 'nm-wifi-p2p-peer.c', + 'nm-wimax-nsp.c', ) -deps = [ - dl_dep, - libudev_dep, - shared_dep, - uuid_dep -] - linker_script = join_paths(meson.current_source_dir(), 'libnm.ver') @@ -157,7 +155,14 @@ libnm = shared_library( sources: libnm_sources + libnm_enum, version: libnm_version, include_directories: libnm_core_inc, - dependencies: deps, + dependencies: [ + dl_dep, + libudev_dep, + shared_nm_utils_base_dep, + nm_core_dep, + uuid_dep, + libnm_systemd_shared_no_logging_dep, + ], c_args: cflags, link_with: libnm_utils, link_whole: libnm_core, @@ -165,13 +170,13 @@ libnm = shared_library( '-Wl,--version-script,@0@'.format(linker_script), ], link_depends: linker_script, - install: true + install: true, ) libnm_dep = declare_dependency( sources: libnm_enum[1], include_directories: libnm_inc, - link_with: libnm + link_with: libnm, ) pkg.generate( @@ -184,8 +189,8 @@ pkg.generate( requires: 'gio-2.0', variables: [ 'exec_prefix=${prefix}', - 'vpnservicedir=' + join_paths('${prefix}', 'lib', nm_name, 'VPN') - ] + 'vpnservicedir=' + join_paths('${prefix}', 'lib', nm_name, 'VPN'), + ], ) test( @@ -208,7 +213,7 @@ if enable_introspection includes: 'Gio-2.0', extra_args: cflags, header: 'NetworkManager.h', - install: true + install: true, ) generate_plugin_docs = join_paths(meson.current_source_dir(), 'generate-plugin-docs.pl') @@ -218,7 +223,7 @@ if enable_introspection name, input: libnm_core_settings_sources, output: name, - command: [perl, generate_plugin_docs, 'keyfile', '@OUTPUT@', '@INPUT@'] + command: [perl, generate_plugin_docs, 'keyfile', '@OUTPUT@', '@INPUT@'], ) name = 'nm-settings-docs-overrides.xml' @@ -226,7 +231,7 @@ if enable_introspection name, input: libnm_core_settings_sources, output: name, - command: [perl, generate_plugin_docs, 'dbus', '@OUTPUT@', '@INPUT@'] + command: [perl, generate_plugin_docs, 'dbus', '@OUTPUT@', '@INPUT@'], ) if enable_ifcfg_rh @@ -235,7 +240,7 @@ if enable_introspection name, input: libnm_core_settings_sources, output: name, - command: [perl, generate_plugin_docs, 'ifcfg-rh', '@OUTPUT@', '@INPUT@'] + command: [perl, generate_plugin_docs, 'ifcfg-rh', '@OUTPUT@', '@INPUT@'], ) endif @@ -256,7 +261,7 @@ if enable_introspection generate_setting_docs_env = [ 'env', '-i', 'GI_TYPELIB_PATH=' + gi_typelib_path, - 'LD_LIBRARY_PATH=' + ld_library_path + 'LD_LIBRARY_PATH=' + ld_library_path, ] name = 'nm-property-docs.xml' @@ -265,7 +270,7 @@ if enable_introspection input: libnm_gir[0], output: name, command: [generate_setting_docs_env, generate_setting_docs, '--lib-path', meson.current_build_dir(), '--gir', '@INPUT@', '--output', '@OUTPUT@'], - depends: libnm_gir + depends: libnm_gir, ) name = 'nm-settings-docs.xml' @@ -274,7 +279,7 @@ if enable_introspection input: libnm_gir[0], output: name, command: [generate_setting_docs_env, generate_setting_docs, '--lib-path', meson.current_build_dir(), '--gir', '@INPUT@', '--overrides', nm_settings_docs_overrides, '--output', '@OUTPUT@'], - depends: libnm_gir + depends: libnm_gir, ) endif diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index 25281c92..ac00d6e1 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -23,8 +23,6 @@ #include "nm-access-point.h" -#include - #include "nm-connection.h" #include "nm-setting-connection.h" #include "nm-setting-wireless.h" diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 0314667f..fdade4bc 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -21,10 +21,9 @@ #include "nm-default.h" -#include +#include "nm-active-connection.h" #include "nm-dbus-interface.h" -#include "nm-active-connection.h" #include "nm-object-private.h" #include "nm-core-internal.h" #include "nm-device.h" @@ -795,7 +794,12 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - /* signals */ + /** + * NMActiveConnection::state-changed: + * @active_connection: the source #NMActiveConnection + * @state: the new state number (#NMActiveConnectionState) + * @reason: the state change reason (#NMActiveConnectionStateReason) + */ signals[STATE_CHANGED] = g_signal_new ("state-changed", G_OBJECT_CLASS_TYPE (object_class), diff --git a/libnm/nm-autoptr.h b/libnm/nm-autoptr.h index e96a03a0..40248dcd 100644 --- a/libnm/nm-autoptr.h +++ b/libnm/nm-autoptr.h @@ -51,11 +51,11 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingDummy, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingEthtool, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingGeneric, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingGsm, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingInfiniband, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingIP4Config, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingIP6Config, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingIPConfig, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingIPTunnel, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingInfiniband, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingMacsec, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingMacvlan, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingMatch, g_object_unref) @@ -77,8 +77,10 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingUser, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingVlan, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingVpn, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingVxlan, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingWifiP2P, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingWimax, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingWired, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingWireGuard, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingWireless, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingWirelessSecurity, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (NMSettingWpan, g_object_unref) diff --git a/libnm/nm-checkpoint.c b/libnm/nm-checkpoint.c index ce15d087..0dde238e 100644 --- a/libnm/nm-checkpoint.c +++ b/libnm/nm-checkpoint.c @@ -91,7 +91,7 @@ nm_checkpoint_get_created (NMCheckpoint *checkpoint) * nm_checkpoint_get_rollback_timeout: * @checkpoint: a #NMCheckpoint * - * Gets the the timeout in seconds for automatic rollback. + * Gets the timeout in seconds for automatic rollback. * * Returns: the rollback timeout. * diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 1da22540..14bca3c3 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -21,11 +21,11 @@ #include "nm-default.h" -#include +#include "nm-client.h" + #include #include "nm-utils.h" -#include "nm-client.h" #include "nm-manager.h" #include "nm-dns-manager.h" #include "nm-remote-settings.h" @@ -41,6 +41,7 @@ #include "introspection/org.freedesktop.NetworkManager.h" #include "introspection/org.freedesktop.NetworkManager.Device.Wireless.h" +#include "introspection/org.freedesktop.NetworkManager.Device.WifiP2P.h" #include "introspection/org.freedesktop.NetworkManager.Device.h" #include "introspection/org.freedesktop.NetworkManager.DnsManager.h" #include "introspection/org.freedesktop.NetworkManager.Settings.h" @@ -65,24 +66,26 @@ #include "nm-device-macvlan.h" #include "nm-device-modem.h" #include "nm-device-olpc-mesh.h" +#include "nm-device-ovs-bridge.h" #include "nm-device-ovs-interface.h" #include "nm-device-ovs-port.h" -#include "nm-device-ovs-bridge.h" #include "nm-device-ppp.h" #include "nm-device-team.h" #include "nm-device-tun.h" #include "nm-device-vlan.h" #include "nm-device-vxlan.h" +#include "nm-device-wifi-p2p.h" #include "nm-device-wifi.h" #include "nm-device-wimax.h" #include "nm-device-wireguard.h" #include "nm-device-wpan.h" +#include "nm-dhcp-config.h" #include "nm-dhcp4-config.h" #include "nm-dhcp6-config.h" -#include "nm-dhcp-config.h" #include "nm-ip4-config.h" #include "nm-ip6-config.h" #include "nm-manager.h" +#include "nm-wifi-p2p-peer.h" #include "nm-remote-connection.h" #include "nm-remote-settings.h" #include "nm-vpn-connection.h" @@ -1163,18 +1166,20 @@ add_activate_cb (GObject *object, GAsyncResult *result, gpointer user_data) { - GSimpleAsyncResult *simple = user_data; - NMActiveConnection *ac; + gs_unref_object GSimpleAsyncResult *simple = user_data; + gs_unref_variant GVariant *result_data = NULL; + gs_unref_object NMActiveConnection *ac = NULL; GError *error = NULL; - ac = nm_manager_add_and_activate_connection_finish (NM_MANAGER (object), result, &error); - if (ac) - g_simple_async_result_set_op_res_gpointer (simple, ac, g_object_unref); - else + ac = nm_manager_add_and_activate_connection_finish (NM_MANAGER (object), result, &result_data, &error); + if (ac) { + g_simple_async_result_set_op_res_gpointer (simple, + _nm_activate_result_new (ac, result_data), + (GDestroyNotify) _nm_activate_result_free); + } else g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); - g_object_unref (simple); } /** @@ -1233,8 +1238,14 @@ nm_client_add_and_activate_connection_async (NMClient *client, if (cancellable) g_simple_async_result_set_check_cancellable (simple, cancellable); nm_manager_add_and_activate_connection_async (NM_CLIENT_GET_PRIVATE (client)->manager, - partial, device, specific_object, - cancellable, add_activate_cb, simple); + partial, + device, + specific_object, + NULL, + FALSE, + cancellable, + add_activate_cb, + simple); } /** @@ -1257,6 +1268,7 @@ nm_client_add_and_activate_connection_finish (NMClient *client, GError **error) { GSimpleAsyncResult *simple; + _NMActivateResult *r; g_return_val_if_fail (NM_IS_CLIENT (client), NULL); g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL); @@ -1264,8 +1276,128 @@ nm_client_add_and_activate_connection_finish (NMClient *client, simple = G_SIMPLE_ASYNC_RESULT (result); if (g_simple_async_result_propagate_error (simple, error)) return NULL; - else - return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple)); + r = g_simple_async_result_get_op_res_gpointer (simple); + return g_object_ref (r->active); +} + +/** + * nm_client_add_and_activate_connection2: + * @client: a #NMClient + * @partial: (allow-none): an #NMConnection to add; the connection may be + * partially filled (or even %NULL) and will be completed by NetworkManager + * using the given @device and @specific_object before being added + * @device: the #NMDevice + * @specific_object: (allow-none): the object path of a connection-type-specific + * object this activation should use. This parameter is currently ignored for + * wired and mobile broadband connections, and the value of %NULL should be used + * (ie, no specific object). For Wi-Fi or WiMAX connections, pass the object + * path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can + * get using nm_object_get_path(), and which will be used to complete the + * details of the newly added connection. + * @options: a #GVariant containing a dictionary with options, or %NULL + * @cancellable: a #GCancellable, or %NULL + * @callback: callback to be called when the activation has started + * @user_data: caller-specific data passed to @callback + * + * Adds a new connection using the given details (if any) as a template, + * automatically filling in missing settings with the capabilities of the given + * device and specific object. The new connection is then asynchronously + * activated as with nm_client_activate_connection_async(). Cannot be used for + * VPN connections at this time. + * + * Note that the callback is invoked when NetworkManager has started activating + * the new connection, not when it finishes. You can used the returned + * #NMActiveConnection object (in particular, #NMActiveConnection:state) to + * track the activation to its completion. + * + * This is identitcal to nm_client_add_and_activate_connection_async() but takes + * a further @options parameter. Currently the following options are supported + * by the daemon: + * * "persist": A string describing how the connection should be stored. + * The default is "disk", but it can be modified to "memory" (until + * the daemon quits) or "volatile" (will be deleted on disconnect). + * * "bind-activation": Bind the connection lifetime to something. The default is "none", + * meaning an explicit disconnect is needed. The value "dbus-client" + * means the connection will automatically be deactivated when the calling + * DBus client disappears from the system bus. + * + * Since: 1.16 + **/ +void +nm_client_add_and_activate_connection2 (NMClient *client, + NMConnection *partial, + NMDevice *device, + const char *specific_object, + GVariant *options, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *simple; + GError *error = NULL; + + g_return_if_fail (NM_IS_CLIENT (client)); + g_return_if_fail (NM_IS_DEVICE (device)); + if (partial) + g_return_if_fail (NM_IS_CONNECTION (partial)); + + if (!_nm_client_check_nm_running (client, &error)) { + g_simple_async_report_take_gerror_in_idle (G_OBJECT (client), callback, user_data, error); + return; + } + + simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data, + nm_client_add_and_activate_connection2); + if (cancellable) + g_simple_async_result_set_check_cancellable (simple, cancellable); + nm_manager_add_and_activate_connection_async (NM_CLIENT_GET_PRIVATE (client)->manager, + partial, + device, + specific_object, + options, + TRUE, + cancellable, + add_activate_cb, + simple); +} + +/** + * nm_client_add_and_activate_connection2_finish: + * @client: an #NMClient + * @result: the result passed to the #GAsyncReadyCallback + * @error: location for a #GError, or %NULL + * @out_result: (allow-none) (transfer full): the output result + * of type "a{sv}" returned by D-Bus' AddAndActivate2 call. Currently no + * output is implemented yet. + * + * Gets the result of a call to nm_client_add_and_activate_connection2(). + * + * You can call nm_active_connection_get_connection() on the returned + * #NMActiveConnection to find the path of the created #NMConnection. + * + * Returns: (transfer full): the new #NMActiveConnection on success, %NULL on + * failure, in which case @error will be set. + **/ +NMActiveConnection * +nm_client_add_and_activate_connection2_finish (NMClient *client, + GAsyncResult *result, + GVariant **out_result, + GError **error) +{ + GSimpleAsyncResult *simple; + _NMActivateResult *r; + + g_return_val_if_fail (NM_IS_CLIENT (client), NULL); + g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL); + + simple = G_SIMPLE_ASYNC_RESULT (result); + if (g_simple_async_result_propagate_error (simple, error)) { + NM_SET_OUT (out_result, NULL); + return NULL; + } + r = g_simple_async_result_get_op_res_gpointer (simple); + NM_SET_OUT (out_result, nm_g_variant_ref (r->add_and_activate_output)); + return g_object_ref (r->active); } /** @@ -2470,7 +2602,7 @@ proxy_type (GDBusObjectManagerClient *manager, const char *interface_name, gpointer user_data) { - /* ObjectManager asks us for an object proxy. Unfortunatelly, we can't + /* ObjectManager asks us for an object proxy. Unfortunately, we can't * decide that by interface name and GDBusObjectManager doesn't allow * us to look at the known interface list. Thus we need to create a * generic GDBusObject and only couple a NMObject subclass later. */ @@ -2482,6 +2614,8 @@ proxy_type (GDBusObjectManagerClient *manager, return NMDBUS_TYPE_MANAGER_PROXY; else if (strcmp (interface_name, NM_DBUS_INTERFACE_DEVICE_WIRELESS) == 0) return NMDBUS_TYPE_DEVICE_WIFI_PROXY; + else if (strcmp (interface_name, NM_DBUS_INTERFACE_DEVICE_WIFI_P2P) == 0) + return NMDBUS_TYPE_DEVICE_WIFI_P2P_PROXY; else if (strcmp (interface_name, NM_DBUS_INTERFACE_DEVICE) == 0) return NMDBUS_TYPE_DEVICE_PROXY; else if (strcmp (interface_name, NM_DBUS_INTERFACE_SETTINGS_CONNECTION) == 0) @@ -2560,6 +2694,8 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager type = NM_TYPE_DEVICE_OVS_PORT; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE) == 0) type = NM_TYPE_DEVICE_OVS_BRIDGE; + else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WIFI_P2P) == 0) + type = NM_TYPE_DEVICE_WIFI_P2P; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_PPP) == 0) type = NM_TYPE_DEVICE_PPP; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_TEAM) == 0) @@ -2586,6 +2722,8 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager type = NM_TYPE_IP4_CONFIG; else if (strcmp (ifname, NM_DBUS_INTERFACE_IP6_CONFIG) == 0) type = NM_TYPE_IP6_CONFIG; + else if (strcmp (ifname, NM_DBUS_INTERFACE_WIFI_P2P_PEER) == 0) + type = NM_TYPE_WIFI_P2P_PEER; else if (strcmp (ifname, NM_DBUS_INTERFACE_SETTINGS_CONNECTION) == 0) type = NM_TYPE_REMOTE_CONNECTION; else if (strcmp (ifname, NM_DBUS_INTERFACE_SETTINGS) == 0) @@ -3563,15 +3701,10 @@ nm_client_class_init (NMClientClass *client_class) G_PARAM_STATIC_STRINGS)); /** - * NMClient:dns-configuration: (type GPtrArray(GVariant)) + * NMClient:dns-configuration: (type GPtrArray(NMDnsEntry)) * - * The current DNS configuration represented as an array of - * dictionaries. Each dictionary has the "nameservers", - * "priority" keys and, optionally, "interface" and "vpn". - * "nameservers" is the list of DNS servers, "priority" their - * relative priority, "interface" the interface on which these - * servers are contacted, "vpn" a boolean telling whether the - * configuration was obtained from a VPN connection. + * The current DNS configuration, represented as an array + * of #NMDnsEntry objects. * * Since: 1.6 **/ diff --git a/libnm/nm-client.h b/libnm/nm-client.h index 6259b122..edb3ed78 100644 --- a/libnm/nm-client.h +++ b/libnm/nm-client.h @@ -107,6 +107,7 @@ G_BEGIN_DECLS * statistics can be globally enabled or disabled * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK: controls whether * connectivity check can be enabled or disabled + * @NM_CLIENT_PERMISSION_WIFI_SCAN: controls whether wifi scans can be performed * @NM_CLIENT_PERMISSION_LAST: a reserved boundary value * * #NMClientPermission values indicate various permissions that NetworkManager @@ -130,8 +131,9 @@ typedef enum { NM_CLIENT_PERMISSION_CHECKPOINT_ROLLBACK = 14, NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS = 15, NM_CLIENT_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK = 16, + NM_CLIENT_PERMISSION_WIFI_SCAN = 17, - NM_CLIENT_PERMISSION_LAST = 16, + NM_CLIENT_PERMISSION_LAST = 17, } NMClientPermission; /** @@ -339,6 +341,21 @@ NMActiveConnection *nm_client_add_and_activate_connection_finish (NMClient *clie GAsyncResult *result, GError **error); +NM_AVAILABLE_IN_1_16 +void nm_client_add_and_activate_connection2 (NMClient *client, + NMConnection *partial, + NMDevice *device, + const char *specific_object, + GVariant *options, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +NM_AVAILABLE_IN_1_16 +NMActiveConnection *nm_client_add_and_activate_connection2_finish (NMClient *client, + GAsyncResult *result, + GVariant **out_result, + GError **error); + gboolean nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active, GCancellable *cancellable, diff --git a/libnm/nm-dbus-helpers.c b/libnm/nm-dbus-helpers.c index 33c68191..a507c658 100644 --- a/libnm/nm-dbus-helpers.c +++ b/libnm/nm-dbus-helpers.c @@ -22,8 +22,6 @@ #include "nm-dbus-helpers.h" -#include - #include "nm-dbus-interface.h" static GBusType nm_bus = G_BUS_TYPE_SYSTEM; @@ -105,7 +103,7 @@ _nm_dbus_is_connection_private (GDBusConnection *connection) * rule the proxy added and ensure a less granular rule is present instead. * * Also, don't do this immediately since it has a performance penalty. - * Still better than loosing the signals altogether. + * Still better than losing the signals altogether. * * Ideally, we should be able to tell glib not to hook its rules: * https://bugzilla.gnome.org/show_bug.cgi?id=758749 diff --git a/libnm/nm-device-adsl.c b/libnm/nm-device-adsl.c index a82aa8d0..f63468aa 100644 --- a/libnm/nm-device-adsl.c +++ b/libnm/nm-device-adsl.c @@ -23,10 +23,7 @@ #include "nm-device-adsl.h" -#include - #include "nm-object-private.h" - #include "nm-setting-adsl.h" #include "nm-setting-connection.h" diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index 83b7c3b4..4cc47b5c 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -20,12 +20,10 @@ #include "nm-default.h" -#include +#include "nm-setting-bond.h" #include "nm-setting-connection.h" -#include "nm-setting-bond.h" #include "nm-utils.h" - #include "nm-device-bond.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index 39c48d2a..2db3a238 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -20,12 +20,10 @@ #include "nm-default.h" -#include +#include "nm-setting-bridge.h" #include "nm-setting-connection.h" -#include "nm-setting-bridge.h" #include "nm-utils.h" - #include "nm-device-bridge.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index a47e3958..d0af0ff6 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -21,13 +21,11 @@ #include "nm-default.h" -#include +#include "nm-device-bt.h" #include "nm-setting-connection.h" #include "nm-setting-bluetooth.h" #include "nm-utils.h" - -#include "nm-device-bt.h" #include "nm-object-private.h" #include "nm-enum-types.h" diff --git a/libnm/nm-device-dummy.c b/libnm/nm-device-dummy.c index 4c202025..8a372143 100644 --- a/libnm/nm-device-dummy.c +++ b/libnm/nm-device-dummy.c @@ -20,9 +20,8 @@ #include "nm-default.h" -#include - #include "nm-device-dummy.h" + #include "nm-object-private.h" #include "nm-setting-dummy.h" #include "nm-setting-connection.h" diff --git a/libnm/nm-device-ethernet.c b/libnm/nm-device-ethernet.c index ebb019dc..5d2acdb2 100644 --- a/libnm/nm-device-ethernet.c +++ b/libnm/nm-device-ethernet.c @@ -21,14 +21,12 @@ #include "nm-default.h" -#include +#include "nm-device-ethernet.h" #include "nm-setting-connection.h" #include "nm-setting-wired.h" #include "nm-setting-pppoe.h" #include "nm-utils.h" - -#include "nm-device-ethernet.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-generic.c b/libnm/nm-device-generic.c index 62cb89eb..c0bf4d70 100644 --- a/libnm/nm-device-generic.c +++ b/libnm/nm-device-generic.c @@ -20,9 +20,8 @@ #include "nm-default.h" -#include - #include "nm-device-generic.h" + #include "nm-object-private.h" #include "nm-setting-generic.h" #include "nm-setting-connection.h" diff --git a/libnm/nm-device-infiniband.c b/libnm/nm-device-infiniband.c index 1ed942b5..aaf5ff86 100644 --- a/libnm/nm-device-infiniband.c +++ b/libnm/nm-device-infiniband.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-device-infiniband.h" #include "nm-setting-connection.h" #include "nm-setting-infiniband.h" #include "nm-utils.h" - -#include "nm-device-infiniband.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-ip-tunnel.c b/libnm/nm-device-ip-tunnel.c index 2f7efe9d..150dc989 100644 --- a/libnm/nm-device-ip-tunnel.c +++ b/libnm/nm-device-ip-tunnel.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-device-ip-tunnel.h" #include "nm-setting-connection.h" #include "nm-setting-ip-tunnel.h" #include "nm-utils.h" - -#include "nm-device-ip-tunnel.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-macsec.c b/libnm/nm-device-macsec.c index 16bbbebb..493bff87 100644 --- a/libnm/nm-device-macsec.c +++ b/libnm/nm-device-macsec.c @@ -20,9 +20,8 @@ #include "nm-default.h" -#include - #include "nm-device-macsec.h" + #include "nm-device-private.h" #include "nm-object-private.h" #include "nm-utils.h" diff --git a/libnm/nm-device-macvlan.c b/libnm/nm-device-macvlan.c index 23c649cc..37484770 100644 --- a/libnm/nm-device-macvlan.c +++ b/libnm/nm-device-macvlan.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-setting-macvlan.h" #include "nm-setting-connection.h" -#include "nm-setting-macvlan.h" #include "nm-setting-wired.h" #include "nm-utils.h" - #include "nm-device-macvlan.h" #include "nm-object-private.h" diff --git a/libnm/nm-device-modem.c b/libnm/nm-device-modem.c index 7fc843f6..0373b3c0 100644 --- a/libnm/nm-device-modem.c +++ b/libnm/nm-device-modem.c @@ -21,13 +21,11 @@ #include "nm-default.h" -#include +#include "nm-device-modem.h" #include "nm-setting-connection.h" #include "nm-setting-gsm.h" #include "nm-setting-cdma.h" - -#include "nm-device-modem.h" #include "nm-object-private.h" #include "nm-enum-types.h" diff --git a/libnm/nm-device-olpc-mesh.c b/libnm/nm-device-olpc-mesh.c index 875f11a9..62589164 100644 --- a/libnm/nm-device-olpc-mesh.c +++ b/libnm/nm-device-olpc-mesh.c @@ -20,12 +20,10 @@ #include "nm-default.h" -#include +#include "nm-device-olpc-mesh.h" #include "nm-setting-connection.h" #include "nm-setting-olpc-mesh.h" - -#include "nm-device-olpc-mesh.h" #include "nm-object-private.h" #include "nm-device-wifi.h" diff --git a/libnm/nm-device-ovs-bridge.c b/libnm/nm-device-ovs-bridge.c index 27ee97cf..4671c8a9 100644 --- a/libnm/nm-device-ovs-bridge.c +++ b/libnm/nm-device-ovs-bridge.c @@ -19,9 +19,8 @@ #include "nm-default.h" -#include - #include "nm-device-ovs-bridge.h" + #include "nm-object-private.h" #include "nm-setting-ovs-bridge.h" #include "nm-setting-ovs-port.h" diff --git a/libnm/nm-device-ovs-interface.c b/libnm/nm-device-ovs-interface.c index ed3dbd4c..b07373e1 100644 --- a/libnm/nm-device-ovs-interface.c +++ b/libnm/nm-device-ovs-interface.c @@ -19,9 +19,8 @@ #include "nm-default.h" -#include - #include "nm-device-ovs-interface.h" + #include "nm-object-private.h" #include "nm-setting-ovs-interface.h" #include "nm-setting-ovs-port.h" diff --git a/libnm/nm-device-ovs-port.c b/libnm/nm-device-ovs-port.c index 8be5549a..49cf11cc 100644 --- a/libnm/nm-device-ovs-port.c +++ b/libnm/nm-device-ovs-port.c @@ -19,9 +19,8 @@ #include "nm-default.h" -#include - #include "nm-device-ovs-port.h" + #include "nm-object-private.h" #include "nm-setting-ovs-port.h" #include "nm-setting-ovs-port.h" @@ -76,6 +75,7 @@ get_type_description (NMDevice *device) { return "ovs-port"; } + static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index 101e3160..749739ff 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-device-team.h" #include "nm-setting-connection.h" #include "nm-setting-team.h" #include "nm-utils.h" - -#include "nm-device-team.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-tun.c b/libnm/nm-device-tun.c index b5721350..62460244 100644 --- a/libnm/nm-device-tun.c +++ b/libnm/nm-device-tun.c @@ -20,14 +20,13 @@ #include "nm-default.h" -#include +#include "nm-device-tun.h" + #include #include "nm-setting-connection.h" #include "nm-setting-tun.h" #include "nm-utils.h" - -#include "nm-device-tun.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-vlan.c b/libnm/nm-device-vlan.c index 5728d404..e0437245 100644 --- a/libnm/nm-device-vlan.c +++ b/libnm/nm-device-vlan.c @@ -20,14 +20,12 @@ #include "nm-default.h" -#include +#include "nm-device-vlan.h" #include "nm-setting-connection.h" #include "nm-setting-vlan.h" #include "nm-setting-wired.h" #include "nm-utils.h" - -#include "nm-device-vlan.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-vxlan.c b/libnm/nm-device-vxlan.c index 27b9c981..8dbf1336 100644 --- a/libnm/nm-device-vxlan.c +++ b/libnm/nm-device-vxlan.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-device-vxlan.h" #include "nm-setting-connection.h" #include "nm-setting-vxlan.h" #include "nm-utils.h" - -#include "nm-device-vxlan.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE) @@ -361,7 +359,7 @@ nm_device_vxlan_get_l2miss (NMDeviceVxlan *device) * nm_device_vxlan_get_l3miss: * @device: a #NMDeviceVxlan * - * Returns: wether netlink IP ADDR miss notifications are generated + * Returns: whether netlink IP ADDR miss notifications are generated * * Since: 1.2 **/ diff --git a/libnm/nm-device-wifi-p2p.c b/libnm/nm-device-wifi-p2p.c new file mode 100644 index 00000000..01397738 --- /dev/null +++ b/libnm/nm-device-wifi-p2p.c @@ -0,0 +1,502 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2018 - 2019 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-device-wifi-p2p.h" + +#include "nm-setting-connection.h" +#include "nm-setting-wifi-p2p.h" +#include "nm-utils.h" +#include "nm-wifi-p2p-peer.h" +#include "nm-object-private.h" +#include "nm-core-internal.h" +#include "nm-dbus-helpers.h" + +#include "introspection/org.freedesktop.NetworkManager.Device.WifiP2P.h" + +/*****************************************************************************/ + +typedef struct { + NMDeviceWifiP2P *device; + GSimpleAsyncResult *simple; +} RequestScanInfo; + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_PEERS, +); + +enum { + PEER_ADDED, + PEER_REMOVED, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct { + NMDBusDeviceWifiP2P *proxy; + + char *hw_address; + + GPtrArray *peers; +} NMDeviceWifiP2PPrivate; + +/** + * NMDeviceWifiP2P: + * + * Since: 1.16 + */ +struct _NMDeviceWifiP2P { + NMDevice parent; + NMDeviceWifiP2PPrivate _priv; +}; + +struct _NMDeviceWifiP2PClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceWifiP2P, nm_device_wifi_p2p, NM_TYPE_DEVICE) + +#define NM_DEVICE_WIFI_P2P_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceWifiP2P, NM_IS_DEVICE_WIFI_P2P, NMDevice, NMObject) + +/*****************************************************************************/ + +/** + * nm_device_wifi_p2p_get_hw_address: + * @device: a #NMDeviceWifiP2P + * + * Gets the actual hardware (MAC) address of the #NMDeviceWifiP2P + * + * Returns: the actual hardware address. This is the internal string used by the + * device, and must not be modified. + * + * Since: 1.16 + **/ +const char * +nm_device_wifi_p2p_get_hw_address (NMDeviceWifiP2P *device) +{ + g_return_val_if_fail (NM_IS_DEVICE_WIFI_P2P (device), NULL); + + return nm_str_not_empty (NM_DEVICE_WIFI_P2P_GET_PRIVATE (device)->hw_address); +} + +/** + * nm_device_wifi_p2p_get_peers: + * @device: a #NMDeviceWifiP2P + * + * Gets all the found peers of the #NMDeviceWifiP2P. + * + * Returns: (element-type NMWifiP2PPeer): a #GPtrArray containing all the + * found #NMWifiP2PPeers. + * The returned array is owned by the client and should not be modified. + * + * Since: 1.16 + **/ +const GPtrArray * +nm_device_wifi_p2p_get_peers (NMDeviceWifiP2P *device) +{ + g_return_val_if_fail (NM_IS_DEVICE_WIFI_P2P (device), NULL); + + return NM_DEVICE_WIFI_P2P_GET_PRIVATE (device)->peers; +} + +/** + * nm_device_wifi_p2p_get_peer_by_path: + * @device: a #NMDeviceWifiP2P + * @path: the object path of the peer + * + * Gets a #NMWifiP2PPeer by path. + * + * Returns: (transfer none): the peer or %NULL if none is found. + * + * Since: 1.16 + **/ +NMWifiP2PPeer * +nm_device_wifi_p2p_get_peer_by_path (NMDeviceWifiP2P *device, + const char *path) +{ + const GPtrArray *peers; + int i; + NMWifiP2PPeer *peer = NULL; + + g_return_val_if_fail (NM_IS_DEVICE_WIFI_P2P (device), NULL); + g_return_val_if_fail (path != NULL, NULL); + + peers = nm_device_wifi_p2p_get_peers (device); + if (!peers) + return NULL; + + for (i = 0; i < peers->len; i++) { + NMWifiP2PPeer *candidate = g_ptr_array_index (peers, i); + if (!strcmp (nm_object_get_path (NM_OBJECT (candidate)), path)) { + peer = candidate; + break; + } + } + + return peer; +} + +static void +start_find_finished_cb (GObject *obj, + GAsyncResult *res, + gpointer user_data) +{ + NMDBusDeviceWifiP2P *proxy = (NMDBusDeviceWifiP2P*) obj; + gs_unref_object GTask *task = G_TASK (user_data); + GError *error = NULL; + gboolean success; + + success = nmdbus_device_wifi_p2p_call_start_find_finish (proxy, res, &error); + if (!success) + g_task_return_error (task, error); + else + g_task_return_boolean (task, TRUE); +} + +/** + * nm_device_wifi_p2p_start_find: + * @device: a #NMDeviceWifiP2P + * @options: (allow-none): optional options passed to StartFind. + * @cancellable: a #GCancellable, or %NULL + * @callback: a #GAsyncReadyCallback, or %NULL + * @user_data: user_data for @callback + * + * Request NM to search for Wi-Fi P2P peers on @device. Note that the call + * returns immediately after requesting the find, and it may take some time + * after that for peers to be found. + * + * The find operation will run for 30s by default. You can stop it earlier + * using nm_device_p2p_wifi_stop_find(). + * + * Since: 1.16 + **/ +void +nm_device_wifi_p2p_start_find (NMDeviceWifiP2P *device, + GVariant *options, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (device); + GTask *task; + + g_return_if_fail (NM_IS_DEVICE_WIFI_P2P (device)); + + task = g_task_new (device, cancellable, callback, user_data); + + if (!options) + options = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0); + nmdbus_device_wifi_p2p_call_start_find (priv->proxy, + options, + cancellable, + start_find_finished_cb, + task); +} + +/** + * nm_device_wifi_p2p_start_find_finish: + * @device: a #NMDeviceWifiP2P + * @result: the #GAsyncResult + * @error: #GError return address + * + * Finish an operation started by nm_device_wifi_p2p_start_find(). + * + * Returns: %TRUE if the call was successful + * + * Since: 1.16 + **/ +gboolean +nm_device_wifi_p2p_start_find_finish (NMDeviceWifiP2P *device, + GAsyncResult *result, + GError **error) +{ + return g_task_propagate_boolean (G_TASK (result), error); +} + +static void +stop_find_finished_cb (GObject *obj, + GAsyncResult *res, + gpointer user_data) +{ + NMDBusDeviceWifiP2P *proxy = (NMDBusDeviceWifiP2P*) obj; + gs_unref_object GTask *task = G_TASK (user_data); + GError *error = NULL; + gboolean success; + + success = nmdbus_device_wifi_p2p_call_stop_find_finish (proxy, res, &error); + if (!success) + g_task_return_error (task, error); + else + g_task_return_boolean (task, TRUE); +} + +/** + * nm_device_wifi_p2p_stop_find: + * @device: a #NMDeviceWifiP2P + * @cancellable: a #GCancellable, or %NULL + * @callback: a #GAsyncReadyCallback, or %NULL + * @user_data: user_data for @callback + * + * Request NM to stop any ongoing find operation for Wi-Fi P2P peers on @device. + * + * Since: 1.16 + **/ +void +nm_device_wifi_p2p_stop_find (NMDeviceWifiP2P *device, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (device); + GTask *task; + + g_return_if_fail (NM_IS_DEVICE_WIFI_P2P (device)); + + task = g_task_new (device, cancellable, callback, user_data); + + nmdbus_device_wifi_p2p_call_stop_find (priv->proxy, + cancellable, + stop_find_finished_cb, + task); +} + +/** + * nm_device_wifi_p2p_stop_find_finish: + * @device: a #NMDeviceWifiP2P + * @result: the #GAsyncResult + * @error: #GError return address + * + * Finish an operation started by nm_device_wifi_p2p_stop_find(). + * + * Returns: %TRUE if the call was successful + * + * Since: 1.16 + **/ +gboolean +nm_device_wifi_p2p_stop_find_finish (NMDeviceWifiP2P *device, + GAsyncResult *result, + GError **error) +{ + return g_task_propagate_boolean (G_TASK (result), error); +} + +static void +clean_up_peers (NMDeviceWifiP2P *self) +{ + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (self); + + while (priv->peers->len > 0) { + NMWifiP2PPeer *peer; + + peer = priv->peers->pdata[priv->peers->len - 1]; + g_ptr_array_remove_index (priv->peers, priv->peers->len - 1); + + g_signal_emit (self, signals[PEER_REMOVED], 0, peer); + } +} + +static gboolean +connection_compatible (NMDevice *device, NMConnection *connection, GError **error) +{ + if (!NM_DEVICE_CLASS (nm_device_wifi_p2p_parent_class)->connection_compatible (device, connection, error)) + return FALSE; + + if (!nm_connection_is_type (connection, NM_SETTING_WIFI_P2P_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a Wi-Fi P2P connection.")); + return FALSE; + } + + return TRUE; +} + +static GType +get_setting_type (NMDevice *device) +{ + return NM_TYPE_SETTING_WIRELESS; +} + +static const char * +get_hw_address (NMDevice *device) +{ + return nm_device_wifi_p2p_get_hw_address (NM_DEVICE_WIFI_P2P (device)); +} + +static const char * +get_type_description (NMDevice *device) +{ + return "wifi-p2p"; +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P (object); + + switch (prop_id) { + case PROP_HW_ADDRESS: + g_value_set_string (value, nm_device_wifi_p2p_get_hw_address (self)); + break; + case PROP_PEERS: + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_wifi_p2p_get_peers (self))); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_device_wifi_p2p_init (NMDeviceWifiP2P *device) +{ + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (device); + + priv->peers = g_ptr_array_new (); +} + +static void +init_dbus (NMObject *object) +{ + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (object); + const NMPropertiesInfo property_info[] = { + { NM_DEVICE_WIFI_P2P_HW_ADDRESS, &priv->hw_address }, + { NM_DEVICE_WIFI_P2P_PEERS, &priv->peers, NULL, NM_TYPE_WIFI_P2P_PEER, "peer" }, + { NULL }, + }; + + NM_OBJECT_CLASS (nm_device_wifi_p2p_parent_class)->init_dbus (object); + + priv->proxy = NMDBUS_DEVICE_WIFI_P2P (_nm_object_get_proxy (object, NM_DBUS_INTERFACE_DEVICE_WIFI_P2P)); + _nm_object_register_properties (object, + NM_DBUS_INTERFACE_DEVICE_WIFI_P2P, + property_info); +} + +static void +dispose (GObject *object) +{ + clean_up_peers (NM_DEVICE_WIFI_P2P (object)); + + G_OBJECT_CLASS (nm_device_wifi_p2p_parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (object); + + g_clear_object (&priv->proxy); + g_free (priv->hw_address); + if (priv->peers) + g_ptr_array_unref (priv->peers); + + G_OBJECT_CLASS (nm_device_wifi_p2p_parent_class)->finalize (object); +} + +static void +nm_device_wifi_p2p_class_init (NMDeviceWifiP2PClass *wifi_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (wifi_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wifi_class); + NMDeviceClass *device_class = NM_DEVICE_CLASS (wifi_class); + + object_class->get_property = get_property; + object_class->dispose = dispose; + object_class->finalize = finalize; + + device_class->connection_compatible = connection_compatible; + device_class->get_setting_type = get_setting_type; + device_class->get_hw_address = get_hw_address; + device_class->get_type_description = get_type_description; + + nm_object_class->init_dbus = init_dbus; + + /** + * NMDeviceWifiP2P:hw-address: + * + * The hardware (MAC) address of the device. + * + * Since: 1.16 + **/ + obj_properties[PROP_HW_ADDRESS] = + g_param_spec_string (NM_DEVICE_WIFI_P2P_HW_ADDRESS, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + /** + * NMDeviceWifiP2P:peers: (type GPtrArray(NMWifiP2PPeer)) + * + * List of all Wi-Fi P2P peers the device can see. + * + * Since: 1.16 + **/ + obj_properties[PROP_PEERS] = + g_param_spec_boxed (NM_DEVICE_WIFI_P2P_PEERS, "", "", + G_TYPE_PTR_ARRAY, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + /** + * NMDeviceWifiP2P::peer-added: + * @device: the Wi-Fi P2P device that received the signal + * @peer: the new access point + * + * Notifies that a #NMWifiP2PPeer is added to the Wi-Fi P2P device. + * + * Since: 1.16 + **/ + signals[PEER_ADDED] = + g_signal_new ("peer-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); + + /** + * NMDeviceWifiP2P::peer-removed: + * @device: the Wi-Fi P2P device that received the signal + * @peer: the removed access point + * + * Notifies that a #NMWifiP2PPeer is removed from the Wi-Fi P2P device. + * + * Since: 1.16 + **/ + signals[PEER_REMOVED] = + g_signal_new ("peer-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + G_TYPE_OBJECT); +} diff --git a/libnm/nm-device-wifi-p2p.h b/libnm/nm-device-wifi-p2p.h new file mode 100644 index 00000000..ddca122f --- /dev/null +++ b/libnm/nm-device-wifi-p2p.h @@ -0,0 +1,80 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2018 - 2019 Red Hat, Inc. + */ + +#ifndef __NM_DEVICE_WIFI_P2P_H__ +#define __NM_DEVICE_WIFI_P2P_H__ + +#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION) +#error "Only can be included directly." +#endif + +#include "nm-device.h" + +G_BEGIN_DECLS + +#define NM_TYPE_DEVICE_WIFI_P2P (nm_device_wifi_p2p_get_type ()) +#define NM_DEVICE_WIFI_P2P(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WIFI_P2P, NMDeviceWifiP2P)) +#define NM_DEVICE_WIFI_P2P_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_WIFI_P2P, NMDeviceWifiP2PClass)) +#define NM_IS_DEVICE_WIFI_P2P(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_WIFI_P2P)) +#define NM_IS_DEVICE_WIFI_P2P_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIFI_P2P)) +#define NM_DEVICE_WIFI_P2P_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIFI_P2P, NMDeviceWifiP2PClass)) + +#define NM_DEVICE_WIFI_P2P_HW_ADDRESS "hw-address" +#define NM_DEVICE_WIFI_P2P_PEERS "peers" +#define NM_DEVICE_WIFI_P2P_WFDIES "wfdies" + +typedef struct _NMDeviceWifiP2PClass NMDeviceWifiP2PClass; + +NM_AVAILABLE_IN_1_16 +GType nm_device_wifi_p2p_get_type (void); + +NM_AVAILABLE_IN_1_16 +const char * nm_device_wifi_p2p_get_hw_address (NMDeviceWifiP2P *device); + +NM_AVAILABLE_IN_1_16 +NMWifiP2PPeer * nm_device_wifi_p2p_get_peer_by_path (NMDeviceWifiP2P *device, + const char *path); + +NM_AVAILABLE_IN_1_16 +const GPtrArray * nm_device_wifi_p2p_get_peers (NMDeviceWifiP2P *device); + +NM_AVAILABLE_IN_1_16 +void nm_device_wifi_p2p_start_find (NMDeviceWifiP2P *device, + GVariant *options, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +NM_AVAILABLE_IN_1_16 +gboolean nm_device_wifi_p2p_start_find_finish (NMDeviceWifiP2P *device, + GAsyncResult *result, + GError **error); + +NM_AVAILABLE_IN_1_16 +void nm_device_wifi_p2p_stop_find (NMDeviceWifiP2P *device, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +NM_AVAILABLE_IN_1_16 +gboolean nm_device_wifi_p2p_stop_find_finish (NMDeviceWifiP2P *device, + GAsyncResult *result, + GError **error); + +G_END_DECLS + +#endif /* __NM_DEVICE_WIFI_P2P_H__ */ diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index 848e297c..9af3639d 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -23,13 +23,10 @@ #include "nm-device-wifi.h" -#include - #include "nm-setting-connection.h" #include "nm-setting-wireless.h" #include "nm-setting-wireless-security.h" #include "nm-utils.h" - #include "nm-access-point.h" #include "nm-object-private.h" #include "nm-core-internal.h" @@ -370,7 +367,7 @@ nm_device_wifi_request_scan (NMDeviceWifi *device, * after that for the scan to complete. * This is the same as @nm_device_wifi_request_scan except it accepts @options * for the scanning. The argument is the dictionary passed to RequestScan() - * D-Bus call. Valid otions inside the dictionary are: + * D-Bus call. Valid options inside the dictionary are: * 'ssids' => array of SSIDs (saay) * * Returns: %TRUE on success, %FALSE on error, in which case @error will be @@ -487,7 +484,7 @@ nm_device_wifi_request_scan_async (NMDeviceWifi *device, * that for the scan to complete. * This is the same as @nm_device_wifi_request_scan_async except it accepts @options * for the scanning. The argument is the dictionary passed to RequestScan() - * D-Bus call. Valid otions inside the dictionary are: + * D-Bus call. Valid options inside the dictionary are: * 'ssids' => array of SSIDs (saay) * * Since: 1.2 diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index 08624594..36cebcf2 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -21,13 +21,11 @@ #include "nm-default.h" -#include +#include "nm-device-wimax.h" #include "nm-setting-connection.h" #include "nm-setting-wimax.h" #include "nm-utils.h" - -#include "nm-device-wimax.h" #include "nm-wimax-nsp.h" #include "nm-object-private.h" #include "nm-core-internal.h" diff --git a/libnm/nm-device-wpan.c b/libnm/nm-device-wpan.c index 61183623..d6acda61 100644 --- a/libnm/nm-device-wpan.c +++ b/libnm/nm-device-wpan.c @@ -19,9 +19,8 @@ #include "nm-default.h" -#include - #include "nm-device-wpan.h" + #include "nm-object-private.h" #include "nm-setting-wpan.h" #include "nm-setting-connection.h" 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 diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 91f31b87..fcda93ab 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -64,6 +64,8 @@ G_BEGIN_DECLS #define NM_DEVICE_MTU "mtu" #define NM_DEVICE_METERED "metered" #define NM_DEVICE_LLDP_NEIGHBORS "lldp-neighbors" +#define NM_DEVICE_IP4_CONNECTIVITY "ip4-connectivity" +#define NM_DEVICE_IP6_CONNECTIVITY "ip6-connectivity" /** * NMDevice: @@ -121,6 +123,8 @@ NMIPConfig * nm_device_get_ip4_config (NMDevice *device); NMDhcpConfig * nm_device_get_dhcp4_config (NMDevice *device); NMIPConfig * nm_device_get_ip6_config (NMDevice *device); NMDhcpConfig * nm_device_get_dhcp6_config (NMDevice *device); +NM_AVAILABLE_IN_1_16 +NMConnectivityState nm_device_get_connectivity (NMDevice *device, int addr_family); NMDeviceState nm_device_get_state (NMDevice *device); NMDeviceStateReason nm_device_get_state_reason (NMDevice *device); NMActiveConnection * nm_device_get_active_connection(NMDevice *device); diff --git a/libnm/nm-dhcp-config.c b/libnm/nm-dhcp-config.c index 3f835670..e13bbd34 100644 --- a/libnm/nm-dhcp-config.c +++ b/libnm/nm-dhcp-config.c @@ -21,9 +21,8 @@ #include "nm-default.h" -#include - #include "nm-dhcp-config.h" + #include "nm-dhcp4-config.h" #include "nm-dhcp6-config.h" #include "nm-dbus-interface.h" diff --git a/libnm/nm-dhcp4-config.c b/libnm/nm-dhcp4-config.c index 0e783576..b01e1677 100644 --- a/libnm/nm-dhcp4-config.c +++ b/libnm/nm-dhcp4-config.c @@ -21,6 +21,7 @@ #include "nm-default.h" #include "nm-dhcp4-config.h" + #include "nm-object-private.h" G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_DHCP_CONFIG) diff --git a/libnm/nm-dhcp6-config.c b/libnm/nm-dhcp6-config.c index 9252e734..03dbcc30 100644 --- a/libnm/nm-dhcp6-config.c +++ b/libnm/nm-dhcp6-config.c @@ -21,6 +21,7 @@ #include "nm-default.h" #include "nm-dhcp6-config.h" + #include "nm-object-private.h" G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_DHCP_CONFIG) diff --git a/libnm/nm-dns-manager.c b/libnm/nm-dns-manager.c index 37117b72..a3c2bba3 100644 --- a/libnm/nm-dns-manager.c +++ b/libnm/nm-dns-manager.c @@ -22,11 +22,8 @@ #include "nm-dns-manager.h" -#include - #include "nm-dbus-interface.h" #include "nm-connection.h" - #include "nm-client.h" #include "nm-object-private.h" #include "nm-dbus-helpers.h" diff --git a/libnm/nm-ip-config.c b/libnm/nm-ip-config.c index c1e888be..618b05f1 100644 --- a/libnm/nm-ip-config.c +++ b/libnm/nm-ip-config.c @@ -21,9 +21,8 @@ #include "nm-default.h" -#include - #include "nm-ip-config.h" + #include "nm-ip4-config.h" #include "nm-ip6-config.h" #include "nm-setting-ip-config.h" diff --git a/libnm/nm-ip4-config.c b/libnm/nm-ip4-config.c index 322ea4e8..ac16ef6a 100644 --- a/libnm/nm-ip4-config.c +++ b/libnm/nm-ip4-config.c @@ -21,6 +21,7 @@ #include "nm-default.h" #include "nm-ip4-config.h" + #include "nm-object-private.h" G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_IP_CONFIG) diff --git a/libnm/nm-ip6-config.c b/libnm/nm-ip6-config.c index 93cdf332..773faf6a 100644 --- a/libnm/nm-ip6-config.c +++ b/libnm/nm-ip6-config.c @@ -21,6 +21,7 @@ #include "nm-default.h" #include "nm-ip6-config.h" + #include "nm-object-private.h" G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_IP_CONFIG) diff --git a/libnm/nm-libnm-utils.c b/libnm/nm-libnm-utils.c index 36219065..f740c37c 100644 --- a/libnm/nm-libnm-utils.c +++ b/libnm/nm-libnm-utils.c @@ -125,7 +125,7 @@ next: } if (square_brackets_sensible) { /* If there's a [] that survived the substitution, then the string - * is a short form that is generally preferrable. */ + * is a short form that is generally preferable. */ q = strchr (desc_full, ']'); if (p && q > p) { p++; diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index e108f2b0..7a169863 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -23,8 +23,6 @@ #include "nm-manager.h" -#include - #include "nm-utils.h" #include "nm-checkpoint.h" #include "nm-common-macros.h" @@ -312,6 +310,8 @@ nm_permission_to_client (const char *nm) return NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS; else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK)) return NM_CLIENT_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK; + else if (!strcmp (nm, NM_AUTH_PERMISSION_WIFI_SCAN)) + return NM_CLIENT_PERMISSION_WIFI_SCAN; return NM_CLIENT_PERMISSION_NONE; } @@ -870,31 +870,71 @@ nm_manager_get_activating_connection (NMManager *manager) return NM_MANAGER_GET_PRIVATE (manager)->activating_connection; } +typedef enum { + ACTIVATE_TYPE_ACTIVATE_CONNECTION, + ACTIVATE_TYPE_ADD_AND_ACTIVATE_CONNECTION, + ACTIVATE_TYPE_ADD_AND_ACTIVATE_CONNECTION2, +} ActivateType; + typedef struct { CList lst; NMManager *manager; GSimpleAsyncResult *simple; GCancellable *cancellable; - gulong cancelled_id; char *active_path; char *new_connection_path; + GVariant *add_and_activate_output; + gulong cancelled_id; + ActivateType activate_type; } ActivateInfo; +_NMActivateResult * +_nm_activate_result_new (NMActiveConnection *active, + GVariant *add_and_activate_output) +{ + _NMActivateResult *r; + + nm_assert (!add_and_activate_output || g_variant_is_of_type (add_and_activate_output, G_VARIANT_TYPE ("a{sv}"))); + nm_assert (!add_and_activate_output || !g_variant_is_floating (add_and_activate_output)); + + r = g_slice_new (_NMActivateResult); + *r = (_NMActivateResult) { + .active = g_object_ref (active), + .add_and_activate_output = nm_g_variant_ref (add_and_activate_output), + }; + return r; +} + +void +_nm_activate_result_free (_NMActivateResult *result) +{ + g_object_unref (result->active); + nm_g_variant_unref (result->add_and_activate_output); + g_slice_free (_NMActivateResult, result); +} + static void activate_info_complete (ActivateInfo *info, NMActiveConnection *active, GError *error) { + nm_assert ((!error) != (!active)); + nm_clear_g_signal_handler (info->cancellable, &info->cancelled_id); c_list_unlink_stale (&info->lst); - if (active) - g_simple_async_result_set_op_res_gpointer (info->simple, g_object_ref (active), g_object_unref); - else + if (active) { + g_simple_async_result_set_op_res_gpointer (info->simple, + _nm_activate_result_new (active, + info->add_and_activate_output), + (GDestroyNotify) _nm_activate_result_free); + } else g_simple_async_result_set_from_error (info->simple, error); + g_simple_async_result_complete (info->simple); + nm_g_variant_unref (info->add_and_activate_output); g_free (info->active_path); g_free (info->new_connection_path); g_object_unref (info->simple); @@ -1035,6 +1075,7 @@ nm_manager_activate_connection_async (NMManager *manager, priv = NM_MANAGER_GET_PRIVATE (manager); info = g_slice_new0 (ActivateInfo); + info->activate_type = ACTIVATE_TYPE_ACTIVATE_CONNECTION; info->manager = manager; info->simple = g_simple_async_result_new (G_OBJECT (manager), callback, user_data, nm_manager_activate_connection_async); @@ -1058,14 +1099,16 @@ nm_manager_activate_connection_finish (NMManager *manager, GError **error) { GSimpleAsyncResult *simple; + _NMActivateResult *r; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (manager), nm_manager_activate_connection_async), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); if (g_simple_async_result_propagate_error (simple, error)) return NULL; - else - return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple)); + + r = g_simple_async_result_get_op_res_gpointer (simple); + return g_object_ref (r->active); } static void @@ -1074,23 +1117,39 @@ add_activate_cb (GObject *object, gpointer user_data) { ActivateInfo *info = user_data; - GError *error = NULL; - - if (nmdbus_manager_call_add_and_activate_connection_finish (NMDBUS_MANAGER (object), - NULL, - &info->active_path, - result, &error)) { - if (info->cancellable) { - info->cancelled_id = g_signal_connect (info->cancellable, "cancelled", - G_CALLBACK (activation_cancelled), info); - } - - recheck_pending_activations (info->manager); + gs_free_error GError *error = NULL; + gboolean success; + + nm_assert (info); + nm_assert (!info->active_path); + nm_assert (!info->add_and_activate_output); + + if (info->activate_type == ACTIVATE_TYPE_ADD_AND_ACTIVATE_CONNECTION) { + success = nmdbus_manager_call_add_and_activate_connection_finish (NMDBUS_MANAGER (object), + NULL, + &info->active_path, + result, + &error); } else { + success = nmdbus_manager_call_add_and_activate_connection2_finish (NMDBUS_MANAGER (object), + NULL, + &info->active_path, + &info->add_and_activate_output, + result, + &error); + } + if (!success) { g_dbus_error_strip_remote_error (error); activate_info_complete (info, NULL, error); - g_clear_error (&error); + return; + } + + if (info->cancellable) { + info->cancelled_id = g_signal_connect (info->cancellable, "cancelled", + G_CALLBACK (activation_cancelled), info); } + + recheck_pending_activations (info->manager); } void @@ -1098,6 +1157,8 @@ nm_manager_add_and_activate_connection_async (NMManager *manager, NMConnection *partial, NMDevice *device, const char *specific_object, + GVariant *options, + gboolean force_v2, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -1105,6 +1166,7 @@ nm_manager_add_and_activate_connection_async (NMManager *manager, NMManagerPrivate *priv; GVariant *dict = NULL; ActivateInfo *info; + ActivateType activate_type = ACTIVATE_TYPE_ADD_AND_ACTIVATE_CONNECTION; g_return_if_fail (NM_IS_MANAGER (manager)); g_return_if_fail (NM_IS_DEVICE (device)); @@ -1127,29 +1189,61 @@ nm_manager_add_and_activate_connection_async (NMManager *manager, dict = nm_connection_to_dbus (partial, NM_CONNECTION_SERIALIZE_ALL); if (!dict) dict = g_variant_new_array (G_VARIANT_TYPE ("{sa{sv}}"), NULL, 0); + if (force_v2) { + if (!options) + options = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0); + activate_type = ACTIVATE_TYPE_ADD_AND_ACTIVATE_CONNECTION2; + } else { + if (options) { + if (g_variant_n_children (options) > 0) + activate_type = ACTIVATE_TYPE_ADD_AND_ACTIVATE_CONNECTION2; + else + nm_g_variant_unref_floating (options); + } + } - nmdbus_manager_call_add_and_activate_connection (priv->proxy, - dict, - nm_object_get_path (NM_OBJECT (device)), - specific_object ?: "/", - cancellable, - add_activate_cb, info); + info->activate_type = activate_type; + + if (activate_type == ACTIVATE_TYPE_ADD_AND_ACTIVATE_CONNECTION2) { + nmdbus_manager_call_add_and_activate_connection2 (priv->proxy, + dict, + nm_object_get_path (NM_OBJECT (device)), + specific_object ?: "/", + options, + cancellable, + add_activate_cb, + info); + } else { + nmdbus_manager_call_add_and_activate_connection (priv->proxy, + dict, + nm_object_get_path (NM_OBJECT (device)), + specific_object ?: "/", + cancellable, + add_activate_cb, + info); + } } NMActiveConnection * nm_manager_add_and_activate_connection_finish (NMManager *manager, GAsyncResult *result, + GVariant **out_result, GError **error) { GSimpleAsyncResult *simple; + _NMActivateResult *r; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (manager), nm_manager_add_and_activate_connection_async), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); - if (g_simple_async_result_propagate_error (simple, error)) + if (g_simple_async_result_propagate_error (simple, error)) { + NM_SET_OUT (out_result, NULL); return NULL; - else - return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple)); + } + + r = g_simple_async_result_get_op_res_gpointer (simple); + NM_SET_OUT (out_result, nm_g_variant_ref (r->add_and_activate_output)); + return g_object_ref (r->active); } static void diff --git a/libnm/nm-manager.h b/libnm/nm-manager.h index 0a278aee..04e12eb3 100644 --- a/libnm/nm-manager.h +++ b/libnm/nm-manager.h @@ -163,11 +163,14 @@ void nm_manager_add_and_activate_connection_async (NMManager *ma NMConnection *partial, NMDevice *device, const char *specific_object, + GVariant *options, + gboolean force_v2, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); NMActiveConnection *nm_manager_add_and_activate_connection_finish (NMManager *manager, GAsyncResult *result, + GVariant **out_result, GError **error); gboolean nm_manager_deactivate_connection (NMManager *manager, @@ -220,4 +223,18 @@ gboolean nm_manager_checkpoint_adjust_rollback_timeout_finish (NMManager *manage GAsyncResult *result, GError **error); +/*****************************************************************************/ + +typedef struct { + NMActiveConnection *active; + GVariant *add_and_activate_output; +} _NMActivateResult; + +_NMActivateResult *_nm_activate_result_new (NMActiveConnection *active, + GVariant *add_and_activate_output); + +void _nm_activate_result_free (_NMActivateResult *result); + +/*****************************************************************************/ + #endif /* __NM_MANAGER_H__ */ diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 70f90b63..f54dac5d 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -23,7 +23,6 @@ #include "nm-object.h" -#include #include #include @@ -612,7 +611,7 @@ handle_object_property (NMObject *self, const char *property_name, GVariant *val * * NOTE: We've ignored this before and the server hits the condition * more often that it should. Given we're able to recover from - * ther error, let's lower the severity of the log message to + * the error, let's lower the severity of the log message to * avoid unnecessarily bothering the user. This can be removed * once the issue is fixed on the server. */ #if NM_MORE_ASSERTS diff --git a/libnm/nm-object.h b/libnm/nm-object.h index 5b4580eb..1cc61a73 100644 --- a/libnm/nm-object.h +++ b/libnm/nm-object.h @@ -57,7 +57,7 @@ typedef struct { /* The "object-creation-failed" method is PRIVATE for libnm and * is not meant for any external usage. It indicates that an error - * occured during creation of an object. + * occurred during creation of an object. */ void (*object_creation_failed) (NMObject *master_object, const char *failed_path); diff --git a/libnm/nm-property-docs.xml b/libnm/nm-property-docs.xml index 4016bc07..6344f784 100644 --- a/libnm/nm-property-docs.xml +++ b/libnm/nm-property-docs.xml @@ -22,7 +22,7 @@ - + @@ -145,7 +145,7 @@ - + @@ -171,7 +171,7 @@ - + @@ -193,7 +193,7 @@ - + @@ -318,7 +318,7 @@ - + @@ -338,7 +338,7 @@ - + @@ -387,6 +387,11 @@ + + + + + @@ -407,6 +412,14 @@ + + + + + + + + @@ -430,14 +443,14 @@ - + - + @@ -449,7 +462,9 @@ + + diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index 08faa77e..a011ca87 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -21,14 +21,12 @@ #include "nm-default.h" -#include +#include "nm-remote-connection.h" #include "nm-dbus-interface.h" #include "nm-utils.h" #include "nm-setting-connection.h" #include "nm-core-internal.h" - -#include "nm-remote-connection.h" #include "nm-remote-connection-private.h" #include "nm-object-private.h" #include "nm-dbus-helpers.h" diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c index f2b26215..6b2d6e92 100644 --- a/libnm/nm-remote-settings.c +++ b/libnm/nm-remote-settings.c @@ -23,11 +23,8 @@ #include "nm-remote-settings.h" -#include - #include "nm-dbus-interface.h" #include "nm-connection.h" - #include "nm-client.h" #include "nm-remote-connection.h" #include "nm-remote-connection-private.h" diff --git a/libnm/nm-secret-agent-old.c b/libnm/nm-secret-agent-old.c index 1b9e8915..56a88b00 100644 --- a/libnm/nm-secret-agent-old.c +++ b/libnm/nm-secret-agent-old.c @@ -20,55 +20,63 @@ #include "nm-default.h" -#include +#include "nm-secret-agent-old.h" #include "nm-dbus-interface.h" -#include "nm-secret-agent-old.h" #include "nm-enum-types.h" #include "nm-dbus-helpers.h" #include "nm-simple-connection.h" #include "nm-core-internal.h" +#include "c-list/src/c-list.h" #include "introspection/org.freedesktop.NetworkManager.SecretAgent.h" #include "introspection/org.freedesktop.NetworkManager.AgentManager.h" -static void nm_secret_agent_old_initable_iface_init (GInitableIface *iface); -static void nm_secret_agent_old_async_initable_iface_init (GAsyncInitableIface *iface); -G_DEFINE_ABSTRACT_TYPE_WITH_CODE (NMSecretAgentOld, nm_secret_agent_old, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_secret_agent_old_initable_iface_init); - G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_secret_agent_old_async_initable_iface_init); - ) - -#define NM_SECRET_AGENT_OLD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SECRET_AGENT_OLD, NMSecretAgentOldPrivate)) +/*****************************************************************************/ typedef struct { - gboolean registered; - gboolean registering; - NMSecretAgentCapabilities capabilities; + char *path; + char *setting_name; + GDBusMethodInvocation *context; + CList gsi_lst; +} GetSecretsInfo; +NM_GOBJECT_PROPERTIES_DEFINE (NMSecretAgentOld, + PROP_IDENTIFIER, + PROP_AUTO_REGISTER, + PROP_REGISTERED, + PROP_CAPABILITIES, +); + +typedef struct { GDBusConnection *bus; - gboolean private_bus; - gboolean session_bus; NMDBusAgentManager *manager_proxy; NMDBusSecretAgent *dbus_secret_agent; /* GetSecretsInfo structs of in-flight GetSecrets requests */ - GSList *pending_gets; + CList gsi_lst_head; char *identifier; - gboolean auto_register; - gboolean suppress_auto; + + NMSecretAgentCapabilities capabilities; + + bool registered:1; + bool registering:1; + bool private_bus:1; + bool session_bus:1; + bool auto_register:1; + bool suppress_auto:1; } NMSecretAgentOldPrivate; -enum { - PROP_0, - PROP_IDENTIFIER, - PROP_AUTO_REGISTER, - PROP_REGISTERED, - PROP_CAPABILITIES, +static void nm_secret_agent_old_initable_iface_init (GInitableIface *iface); +static void nm_secret_agent_old_async_initable_iface_init (GAsyncInitableIface *iface); - LAST_PROP -}; +G_DEFINE_ABSTRACT_TYPE_WITH_CODE (NMSecretAgentOld, nm_secret_agent_old, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_secret_agent_old_initable_iface_init); + G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_secret_agent_old_async_initable_iface_init); + ) + +#define NM_SECRET_AGENT_OLD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SECRET_AGENT_OLD, NMSecretAgentOldPrivate)) /*****************************************************************************/ @@ -81,32 +89,23 @@ _internal_unregister (NMSecretAgentOld *self) g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (priv->dbus_secret_agent)); priv->registered = FALSE; priv->registering = FALSE; - g_object_notify (G_OBJECT (self), NM_SECRET_AGENT_OLD_REGISTERED); + _notify (self, PROP_REGISTERED); } } -typedef struct { - char *path; - char *setting_name; - GDBusMethodInvocation *context; -} GetSecretsInfo; - static void -get_secrets_info_finalize (NMSecretAgentOld *self, GetSecretsInfo *info) +get_secrets_info_free (GetSecretsInfo *info) { - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); - - g_return_if_fail (info != NULL); + nm_assert (info); - priv->pending_gets = g_slist_remove (priv->pending_gets, info); + c_list_unlink_stale (&info->gsi_lst); g_free (info->path); g_free (info->setting_name); - memset (info, 0, sizeof (*info)); - g_free (info); + g_slice_free (GetSecretsInfo, info); } -static inline gboolean +static gboolean should_auto_register (NMSecretAgentOld *self) { NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); @@ -124,25 +123,20 @@ name_owner_changed (GObject *proxy, { NMSecretAgentOld *self = NM_SECRET_AGENT_OLD (user_data); NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); - GSList *iter; - char *owner; + gs_free char *owner = NULL; + GetSecretsInfo *info; owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (proxy)); - if (owner != NULL) { + if (owner) { if (should_auto_register (self)) nm_secret_agent_old_register_async (self, NULL, NULL, NULL); - g_free (owner); } else { - /* Cancel any pending secrets requests */ - for (iter = priv->pending_gets; iter; iter = g_slist_next (iter)) { - GetSecretsInfo *info = iter->data; - + while ((info = c_list_first_entry (&priv->gsi_lst_head, GetSecretsInfo, gsi_lst))) { + c_list_unlink (&info->gsi_lst); NM_SECRET_AGENT_OLD_GET_CLASS (self)->cancel_get_secrets (self, - info->path, - info->setting_name); + info->path, + info->setting_name); } - g_slist_free (priv->pending_gets); - priv->pending_gets = NULL; _internal_unregister (self); } @@ -154,11 +148,11 @@ verify_sender (NMSecretAgentOld *self, GError **error) { NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); - char *nm_owner; + gs_free char *owner = NULL; const char *sender; guint32 sender_uid; - GVariant *ret; - GError *local = NULL; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *local = NULL; g_return_val_if_fail (context != NULL, FALSE); @@ -170,8 +164,8 @@ verify_sender (NMSecretAgentOld *self, /* Verify that the sender is the same as NetworkManager's bus name owner. */ - nm_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (priv->manager_proxy)); - if (!nm_owner) { + owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (priv->manager_proxy)); + if (!owner) { g_set_error_literal (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, @@ -185,20 +179,16 @@ verify_sender (NMSecretAgentOld *self, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, "Failed to get request sender."); - g_free (nm_owner); return FALSE; } - /* Check that the sender matches the current NM bus name owner */ - if (strcmp (sender, nm_owner) != 0) { + if (!nm_streq (sender, owner)) { g_set_error_literal (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, "Request sender does not match NetworkManager bus name owner."); - g_free (nm_owner); return FALSE; } - g_free (nm_owner); /* If we're connected to the session bus, then this must be a test program, * so skip the UID check. @@ -217,8 +207,9 @@ verify_sender (NMSecretAgentOld *self, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &local); if (!ret) { - char *remote_error = g_dbus_error_get_remote_error (local); + gs_free char *remote_error = NULL; + remote_error = g_dbus_error_get_remote_error (local); g_dbus_error_strip_remote_error (local); g_set_error (error, NM_SECRET_AGENT_ERROR, @@ -226,15 +217,12 @@ verify_sender (NMSecretAgentOld *self, "Failed to request unix user: (%s) %s.", remote_error ?: "", local->message); - g_free (remote_error); - g_error_free (local); return FALSE; } g_variant_get (ret, "(u)", &sender_uid); - g_variant_unref (ret); /* We only accept requests from NM, which always runs as root */ - if (0 != sender_uid) { + if (sender_uid != 0) { g_set_error_literal (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_PERMISSION_DENIED, @@ -253,8 +241,8 @@ verify_request (NMSecretAgentOld *self, NMConnection **out_connection, GError **error) { - NMConnection *connection = NULL; - GError *local = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_free_error GError *local = NULL; if (!verify_sender (self, context, error)) return FALSE; @@ -273,20 +261,18 @@ verify_request (NMSecretAgentOld *self, } /* Make sure the given connection is valid */ - g_assert (out_connection); connection = _nm_simple_connection_new_from_dbus (connection_dict, NM_SETTING_PARSE_FLAGS_BEST_EFFORT, &local); - if (connection) { - nm_connection_set_path (connection, connection_path); - *out_connection = connection; - } else { + if (!connection) { g_set_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, "Invalid connection: %s", local->message); - g_clear_error (&local); + return FALSE; } - return !!connection; + nm_connection_set_path (connection, connection_path); + NM_SET_OUT (out_connection, g_steal_pointer (&connection)); + return TRUE; } static void @@ -306,8 +292,7 @@ get_secrets_cb (NMSecretAgentOld *self, g_variant_new ("(@a{sa{sv}})", secrets)); } - /* Remove the request from internal tracking */ - get_secrets_info_finalize (self, info); + get_secrets_info_free (info); } static void @@ -322,7 +307,7 @@ impl_secret_agent_old_get_secrets (NMSecretAgentOld *self, { NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); GError *error = NULL; - NMConnection *connection = NULL; + gs_unref_object NMConnection *connection = NULL; GetSecretsInfo *info; /* Make sure the request comes from NetworkManager and is valid */ @@ -331,34 +316,35 @@ impl_secret_agent_old_get_secrets (NMSecretAgentOld *self, return; } - info = g_malloc0 (sizeof (GetSecretsInfo)); - info->path = g_strdup (connection_path); - info->setting_name = g_strdup (setting_name); - info->context = context; - priv->pending_gets = g_slist_append (priv->pending_gets, info); + info = g_slice_new (GetSecretsInfo); + *info = (GetSecretsInfo) { + .path = g_strdup (connection_path), + .setting_name = g_strdup (setting_name), + .context = context, + }; + c_list_link_tail (&priv->gsi_lst_head, &info->gsi_lst); NM_SECRET_AGENT_OLD_GET_CLASS (self)->get_secrets (self, - connection, - connection_path, - setting_name, - (const char **) hints, - flags, - get_secrets_cb, - info); - g_object_unref (connection); + connection, + connection_path, + setting_name, + (const char **) hints, + flags, + get_secrets_cb, + info); } static GetSecretsInfo * -find_get_secrets_info (GSList *list, const char *path, const char *setting_name) +find_get_secrets_info (NMSecretAgentOldPrivate *priv, + const char *path, + const char *setting_name) { - GSList *iter; - - for (iter = list; iter; iter = g_slist_next (iter)) { - GetSecretsInfo *candidate = iter->data; + GetSecretsInfo *info; - if ( g_strcmp0 (path, candidate->path) == 0 - && g_strcmp0 (setting_name, candidate->setting_name) == 0) - return candidate; + c_list_for_each_entry (info, &priv->gsi_lst_head, gsi_lst) { + if ( nm_streq0 (path, info->path) + && nm_streq0 (setting_name, info->setting_name)) + return info; } return NULL; } @@ -380,7 +366,7 @@ impl_secret_agent_old_cancel_get_secrets (NMSecretAgentOld *self, return; } - info = find_get_secrets_info (priv->pending_gets, connection_path, setting_name); + info = find_get_secrets_info (priv, connection_path, setting_name); if (!info) { g_dbus_method_invocation_return_error (context, NM_SECRET_AGENT_ERROR, @@ -389,10 +375,12 @@ impl_secret_agent_old_cancel_get_secrets (NMSecretAgentOld *self, return; } - /* Send the cancel request up to the subclass and finalize it */ + c_list_unlink (&info->gsi_lst); + NM_SECRET_AGENT_OLD_GET_CLASS (self)->cancel_get_secrets (self, - info->path, - info->setting_name); + info->path, + info->setting_name); + g_dbus_method_invocation_return_value (context, NULL); } @@ -417,8 +405,8 @@ impl_secret_agent_old_save_secrets (NMSecretAgentOld *self, const char *connection_path, gpointer user_data) { + gs_unref_object NMConnection *connection = NULL; GError *error = NULL; - NMConnection *connection = NULL; /* Make sure the request comes from NetworkManager and is valid */ if (!verify_request (self, context, connection_dict, connection_path, &connection, &error)) { @@ -427,11 +415,10 @@ impl_secret_agent_old_save_secrets (NMSecretAgentOld *self, } NM_SECRET_AGENT_OLD_GET_CLASS (self)->save_secrets (self, - connection, - connection_path, - save_secrets_cb, - context); - g_object_unref (connection); + connection, + connection_path, + save_secrets_cb, + context); } static void @@ -455,8 +442,8 @@ impl_secret_agent_old_delete_secrets (NMSecretAgentOld *self, const char *connection_path, gpointer user_data) { + gs_unref_object NMConnection *connection = NULL; GError *error = NULL; - NMConnection *connection = NULL; /* Make sure the request comes from NetworkManager and is valid */ if (!verify_request (self, context, connection_dict, connection_path, &connection, &error)) { @@ -465,11 +452,10 @@ impl_secret_agent_old_delete_secrets (NMSecretAgentOld *self, } NM_SECRET_AGENT_OLD_GET_CLASS (self)->delete_secrets (self, - connection, - connection_path, - delete_secrets_cb, - context); - g_object_unref (connection); + connection, + connection_path, + delete_secrets_cb, + context); } /*****************************************************************************/ @@ -478,15 +464,13 @@ static gboolean check_nm_running (NMSecretAgentOld *self, GError **error) { NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); - char *owner; + gs_free char *owner = NULL; if (priv->private_bus) return TRUE; owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (priv->manager_proxy)); - if (owner) { - g_free (owner); + if (owner) return TRUE; - } g_set_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_FAILED, "NetworkManager is not running"); @@ -568,7 +552,7 @@ nm_secret_agent_old_register (NMSecretAgentOld *self, success: priv->registering = FALSE; priv->registered = TRUE; - g_object_notify (G_OBJECT (self), NM_SECRET_AGENT_OLD_REGISTERED); + _notify (self, PROP_REGISTERED); return TRUE; } @@ -576,6 +560,7 @@ static void reg_result (NMSecretAgentOld *self, GSimpleAsyncResult *simple, GError *error) { NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); + _nm_unused gs_unref_object GSimpleAsyncResult *simple_free = simple; priv->registering = FALSE; @@ -587,13 +572,11 @@ reg_result (NMSecretAgentOld *self, GSimpleAsyncResult *simple, GError *error) _internal_unregister (self); } else { priv->registered = TRUE; - g_object_notify (G_OBJECT (self), NM_SECRET_AGENT_OLD_REGISTERED); + _notify (self, PROP_REGISTERED); g_simple_async_result_set_op_res_gboolean (simple, TRUE); g_simple_async_result_complete (simple); } - - g_object_unref (simple); } static void @@ -624,6 +607,7 @@ reg_with_caps_cb (GObject *proxy, self = NM_SECRET_AGENT_OLD (g_async_result_get_source_object (G_ASYNC_RESULT (simple))); g_object_unref (self); /* drop extra ref added by get_source_object() */ + priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); if (nmdbus_agent_manager_call_register_with_capabilities_finish (NMDBUS_AGENT_MANAGER (proxy), result, NULL)) { @@ -661,7 +645,7 @@ nm_secret_agent_old_register_async (NMSecretAgentOld *self, { NMSecretAgentOldPrivate *priv; NMSecretAgentOldClass *class; - GSimpleAsyncResult *simple; + gs_unref_object GSimpleAsyncResult *simple = NULL; GError *error = NULL; g_return_if_fail (NM_IS_SECRET_AGENT_OLD (self)); @@ -687,7 +671,6 @@ nm_secret_agent_old_register_async (NMSecretAgentOld *self, if (!check_nm_running (self, &error)) { g_simple_async_result_take_error (simple, error); g_simple_async_result_complete_in_idle (simple); - g_object_unref (simple); return; } @@ -698,7 +681,6 @@ nm_secret_agent_old_register_async (NMSecretAgentOld *self, &error)) { g_simple_async_result_take_error (simple, error); g_simple_async_result_complete_in_idle (simple); - g_object_unref (simple); return; } @@ -709,7 +691,8 @@ nm_secret_agent_old_register_async (NMSecretAgentOld *self, priv->identifier, priv->capabilities, NULL, - reg_with_caps_cb, simple); + reg_with_caps_cb, + g_steal_pointer (&simple)); } /** @@ -775,7 +758,7 @@ nm_secret_agent_old_unregister (NMSecretAgentOld *self, static void unregister_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) { - GSimpleAsyncResult *simple = user_data; + gs_unref_object GSimpleAsyncResult *simple = user_data; NMSecretAgentOld *self; GError *error = NULL; @@ -793,7 +776,6 @@ unregister_cb (GObject *proxy, GAsyncResult *result, gpointer user_data) } g_simple_async_result_complete (simple); - g_object_unref (simple); } /** @@ -814,7 +796,7 @@ nm_secret_agent_old_unregister_async (NMSecretAgentOld *self, gpointer user_data) { NMSecretAgentOldPrivate *priv; - GSimpleAsyncResult *simple; + gs_unref_object GSimpleAsyncResult *simple = NULL; GError *error = NULL; g_return_if_fail (NM_IS_SECRET_AGENT_OLD (self)); @@ -832,14 +814,15 @@ nm_secret_agent_old_unregister_async (NMSecretAgentOld *self, if (!check_nm_running (self, &error)) { g_simple_async_result_take_error (simple, error); g_simple_async_result_complete_in_idle (simple); - g_object_unref (simple); return; } priv->suppress_auto = TRUE; - nmdbus_agent_manager_call_unregister (priv->manager_proxy, cancellable, - unregister_cb, simple); + nmdbus_agent_manager_call_unregister (priv->manager_proxy, + cancellable, + unregister_cb, + g_steal_pointer (&simple)); } /** @@ -916,13 +899,13 @@ nm_secret_agent_old_get_secrets (NMSecretAgentOld *self, g_return_if_fail (callback != NULL); NM_SECRET_AGENT_OLD_GET_CLASS (self)->get_secrets (self, - connection, - nm_connection_get_path (connection), - setting_name, - hints, - flags, - callback, - user_data); + connection, + nm_connection_get_path (connection), + setting_name, + hints, + flags, + callback, + user_data); } /** @@ -946,10 +929,10 @@ nm_secret_agent_old_save_secrets (NMSecretAgentOld *self, g_return_if_fail (nm_connection_get_path (connection)); NM_SECRET_AGENT_OLD_GET_CLASS (self)->save_secrets (self, - connection, - nm_connection_get_path (connection), - callback, - user_data); + connection, + nm_connection_get_path (connection), + callback, + user_data); } /** @@ -973,10 +956,10 @@ nm_secret_agent_old_delete_secrets (NMSecretAgentOld *self, g_return_if_fail (nm_connection_get_path (connection)); NM_SECRET_AGENT_OLD_GET_CLASS (self)->delete_secrets (self, - connection, - nm_connection_get_path (connection), - callback, - user_data); + connection, + nm_connection_get_path (connection), + callback, + user_data); } /*****************************************************************************/ @@ -1007,20 +990,7 @@ validate_identifier (const char *identifier) return TRUE; } -static void -nm_secret_agent_old_init (NMSecretAgentOld *self) -{ - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); - - priv->dbus_secret_agent = nmdbus_secret_agent_skeleton_new (); - _nm_dbus_bind_properties (self, priv->dbus_secret_agent); - _nm_dbus_bind_methods (self, priv->dbus_secret_agent, - "GetSecrets", impl_secret_agent_old_get_secrets, - "CancelGetSecrets", impl_secret_agent_old_cancel_get_secrets, - "DeleteSecrets", impl_secret_agent_old_delete_secrets, - "SaveSecrets", impl_secret_agent_old_save_secrets, - NULL); -} +/*****************************************************************************/ static void init_common (NMSecretAgentOld *self) @@ -1037,42 +1007,14 @@ init_common (NMSecretAgentOld *self) } } -static gboolean -init_sync (GInitable *initable, GCancellable *cancellable, GError **error) -{ - NMSecretAgentOld *self = NM_SECRET_AGENT_OLD (initable); - NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); - - priv->bus = _nm_dbus_new_connection (cancellable, error); - if (!priv->bus) - return FALSE; - - priv->manager_proxy = nmdbus_agent_manager_proxy_new_sync (priv->bus, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES - | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, - NM_DBUS_SERVICE, - NM_DBUS_PATH_AGENT_MANAGER, - cancellable, - error); - if (!priv->manager_proxy) - return FALSE; - - init_common (self); - - if (priv->auto_register) - return nm_secret_agent_old_register (self, cancellable, error); - else - return TRUE; -} - typedef struct { NMSecretAgentOld *self; GCancellable *cancellable; GSimpleAsyncResult *simple; -} NMSecretAgentOldInitData; +} InitData; static void -init_async_complete (NMSecretAgentOldInitData *init_data, GError *error) +init_async_complete (InitData *init_data, GError *error) { if (!error) g_simple_async_result_set_op_res_gboolean (init_data->simple, TRUE); @@ -1083,14 +1025,14 @@ init_async_complete (NMSecretAgentOldInitData *init_data, GError *error) g_object_unref (init_data->simple); g_clear_object (&init_data->cancellable); - g_slice_free (NMSecretAgentOldInitData, init_data); + g_slice_free (InitData, init_data); } static void init_async_registered (GObject *object, GAsyncResult *result, gpointer user_data) { NMSecretAgentOld *self = NM_SECRET_AGENT_OLD (object); - NMSecretAgentOldInitData *init_data = user_data; + InitData *init_data = user_data; GError *error = NULL; nm_secret_agent_old_register_finish (self, result, &error); @@ -1100,7 +1042,7 @@ init_async_registered (GObject *object, GAsyncResult *result, gpointer user_data static void init_async_got_proxy (GObject *object, GAsyncResult *result, gpointer user_data) { - NMSecretAgentOldInitData *init_data = user_data; + InitData *init_data = user_data; NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (init_data->self); GError *error = NULL; @@ -1122,7 +1064,7 @@ init_async_got_proxy (GObject *object, GAsyncResult *result, gpointer user_data) static void init_async_got_bus (GObject *initable, GAsyncResult *result, gpointer user_data) { - NMSecretAgentOldInitData *init_data = user_data; + InitData *init_data = user_data; NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (init_data->self); GError *error = NULL; @@ -1141,36 +1083,7 @@ init_async_got_bus (GObject *initable, GAsyncResult *result, gpointer user_data) init_async_got_proxy, init_data); } -static void -init_async (GAsyncInitable *initable, int io_priority, - GCancellable *cancellable, GAsyncReadyCallback callback, - gpointer user_data) -{ - NMSecretAgentOld *self = NM_SECRET_AGENT_OLD (initable); - NMSecretAgentOldInitData *init_data; - - init_data = g_slice_new (NMSecretAgentOldInitData); - init_data->self = self; - init_data->cancellable = cancellable ? g_object_ref (cancellable) : NULL; - - init_data->simple = g_simple_async_result_new (G_OBJECT (initable), callback, - user_data, init_async); - if (cancellable) - g_simple_async_result_set_check_cancellable (init_data->simple, cancellable); - - _nm_dbus_new_connection_async (cancellable, init_async_got_bus, init_data); -} - -static gboolean -init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error) -{ - GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); - - if (g_simple_async_result_propagate_error (simple, error)) - return FALSE; - else - return TRUE; -} +/*****************************************************************************/ static void get_property (GObject *object, @@ -1229,23 +1142,109 @@ set_property (GObject *object, } } +/*****************************************************************************/ + +static void +nm_secret_agent_old_init (NMSecretAgentOld *self) +{ + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); + + c_list_init (&priv->gsi_lst_head); + priv->dbus_secret_agent = nmdbus_secret_agent_skeleton_new (); + _nm_dbus_bind_properties (self, priv->dbus_secret_agent); + _nm_dbus_bind_methods (self, priv->dbus_secret_agent, + "GetSecrets", impl_secret_agent_old_get_secrets, + "CancelGetSecrets", impl_secret_agent_old_cancel_get_secrets, + "DeleteSecrets", impl_secret_agent_old_delete_secrets, + "SaveSecrets", impl_secret_agent_old_save_secrets, + NULL); +} + +static gboolean +init_sync (GInitable *initable, GCancellable *cancellable, GError **error) +{ + NMSecretAgentOld *self = NM_SECRET_AGENT_OLD (initable); + NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); + + priv->bus = _nm_dbus_new_connection (cancellable, error); + if (!priv->bus) + return FALSE; + + priv->manager_proxy = nmdbus_agent_manager_proxy_new_sync (priv->bus, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES + | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NM_DBUS_SERVICE, + NM_DBUS_PATH_AGENT_MANAGER, + cancellable, + error); + if (!priv->manager_proxy) + return FALSE; + + init_common (self); + + if (priv->auto_register) + return nm_secret_agent_old_register (self, cancellable, error); + else + return TRUE; +} + +static void +init_async (GAsyncInitable *initable, int io_priority, + GCancellable *cancellable, GAsyncReadyCallback callback, + gpointer user_data) +{ + NMSecretAgentOld *self = NM_SECRET_AGENT_OLD (initable); + InitData *init_data; + + init_data = g_slice_new (InitData); + *init_data = (InitData) { + .self = self, + .cancellable = nm_g_object_ref (cancellable), + .simple = g_simple_async_result_new (G_OBJECT (initable), + callback, + user_data, + init_async), + }; + + if (cancellable) + g_simple_async_result_set_check_cancellable (init_data->simple, cancellable); + + _nm_dbus_new_connection_async (cancellable, init_async_got_bus, init_data); +} + +static gboolean +init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error) +{ + GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); + + if (g_simple_async_result_propagate_error (simple, error)) + return FALSE; + else + return TRUE; +} + static void dispose (GObject *object) { NMSecretAgentOld *self = NM_SECRET_AGENT_OLD (object); NMSecretAgentOldPrivate *priv = NM_SECRET_AGENT_OLD_GET_PRIVATE (self); + GetSecretsInfo *info; - if (priv->registered) + if (priv->registered) { + priv->registered = FALSE; nm_secret_agent_old_unregister_async (self, NULL, NULL, NULL); + } - g_clear_pointer (&priv->identifier, g_free); + nm_clear_g_free (&priv->identifier); - while (priv->pending_gets) - get_secrets_info_finalize (self, priv->pending_gets->data); + while ((info = c_list_first_entry (&priv->gsi_lst_head, GetSecretsInfo, gsi_lst))) + get_secrets_info_free (info); - g_signal_handlers_disconnect_matched (priv->dbus_secret_agent, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, self); - g_object_unref (priv->dbus_secret_agent); + if (priv->dbus_secret_agent) { + g_signal_handlers_disconnect_matched (priv->dbus_secret_agent, G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, self); + g_clear_object (&priv->dbus_secret_agent); + } g_clear_object (&priv->manager_proxy); g_clear_object (&priv->bus); @@ -1260,7 +1259,6 @@ nm_secret_agent_old_class_init (NMSecretAgentOldClass *class) g_type_class_add_private (class, sizeof (NMSecretAgentOldPrivate)); - /* Virtual methods */ object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; @@ -1276,13 +1274,12 @@ nm_secret_agent_old_class_init (NMSecretAgentOldClass *class) * of 3 characters. An example valid identifier is 'org.gnome.nm-applet' * (without quotes). **/ - g_object_class_install_property - (object_class, PROP_IDENTIFIER, - g_param_spec_string (NM_SECRET_AGENT_OLD_IDENTIFIER, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_IDENTIFIER] = + g_param_spec_string (NM_SECRET_AGENT_OLD_IDENTIFIER, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); /** * NMSecretAgentOld:auto-register: @@ -1305,39 +1302,38 @@ nm_secret_agent_old_class_init (NMSecretAgentOldClass *class) * auto-registration. This ensures that the agent remains un-registered when * you expect it to be unregistered. **/ - g_object_class_install_property - (object_class, PROP_AUTO_REGISTER, - g_param_spec_boolean (NM_SECRET_AGENT_OLD_AUTO_REGISTER, "", "", - TRUE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_AUTO_REGISTER] = + g_param_spec_boolean (NM_SECRET_AGENT_OLD_AUTO_REGISTER, "", "", + TRUE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS); /** * NMSecretAgentOld:registered: * * %TRUE if the agent is registered with NetworkManager, %FALSE if not. **/ - g_object_class_install_property - (object_class, PROP_REGISTERED, - g_param_spec_boolean (NM_SECRET_AGENT_OLD_REGISTERED, "", "", - FALSE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_REGISTERED] = + g_param_spec_boolean (NM_SECRET_AGENT_OLD_REGISTERED, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); /** * NMSecretAgentOld:capabilities: * * A bitfield of %NMSecretAgentCapabilities. **/ - g_object_class_install_property - (object_class, PROP_CAPABILITIES, - g_param_spec_flags (NM_SECRET_AGENT_OLD_CAPABILITIES, "", "", - NM_TYPE_SECRET_AGENT_CAPABILITIES, - NM_SECRET_AGENT_CAPABILITY_NONE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_CAPABILITIES] = + g_param_spec_flags (NM_SECRET_AGENT_OLD_CAPABILITIES, "", "", + NM_TYPE_SECRET_AGENT_CAPABILITIES, + NM_SECRET_AGENT_CAPABILITY_NONE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); } static void diff --git a/libnm/nm-settings-docs-overrides.xml b/libnm/nm-settings-docs-overrides.xml index 276253c6..8f14996d 100644 --- a/libnm/nm-settings-docs-overrides.xml +++ b/libnm/nm-settings-docs-overrides.xml @@ -162,6 +162,8 @@ vlan's interface name."/> + + @@ -172,10 +174,13 @@ For libnm and nmcli, this field is called "cloned-mac-address"."/> a hardware address in ASCII representation, or one of the special values "preserve", "permanent", "random" or "stable". This field replaces the deprecated "cloned-mac-address" on D-Bus, which -can only contain explict hardware addresses. Note that this property +can only contain explicit hardware addresses. Note that this property only exists in D-Bus API. libnm and nmcli continue to call this property "cloned-mac-address"."/> + + + @@ -186,7 +191,7 @@ For libnm and nmcli, this field is called "cloned-mac-address"."/> a hardware address in ASCII representation, or one of the special values "preserve", "permanent", "random" or "stable". This field replaces the deprecated "cloned-mac-address" on D-Bus, which -can only contain explict hardware addresses. Note that this property +can only contain explicit hardware addresses. Note that this property only exists in D-Bus API. libnm and nmcli continue to call this property "cloned-mac-address"."/> - + @@ -147,7 +147,7 @@ - + @@ -174,7 +174,7 @@ - + @@ -198,7 +198,7 @@ - + @@ -325,7 +325,7 @@ - + @@ -345,7 +345,7 @@ - + @@ -395,12 +395,17 @@ + + + + + - + @@ -416,8 +421,17 @@ + + + + + + + + + - + @@ -441,14 +455,14 @@ - + - + @@ -460,7 +474,9 @@ + + diff --git a/libnm/nm-settings-ifcfg-rh-docs.xml b/libnm/nm-settings-ifcfg-rh-docs.xml index 11f3115d..cec2d527 100644 --- a/libnm/nm-settings-ifcfg-rh-docs.xml +++ b/libnm/nm-settings-ifcfg-rh-docs.xml @@ -135,7 +135,7 @@ means "do not transmit priority pause", "1" means "tran The sum of the numbers must be 100."/> - + @@ -297,6 +297,8 @@ but VLAN id from DEVICE takes precedence over VLAN_ID."/> + + @@ -325,6 +327,8 @@ is listed."/> + + diff --git a/libnm/nm-settings-keyfile-docs.xml b/libnm/nm-settings-keyfile-docs.xml index 09b119a2..002d5609 100644 --- a/libnm/nm-settings-keyfile-docs.xml +++ b/libnm/nm-settings-keyfile-docs.xml @@ -102,6 +102,11 @@ under [vpn-secrets] section."/> + + + @@ -113,6 +118,8 @@ under [vpn-secrets] section."/> (e.g. 0;34;104;18;121;178)."/> + + diff --git a/libnm/nm-types.h b/libnm/nm-types.h index bb77e642..16a2ba18 100644 --- a/libnm/nm-types.h +++ b/libnm/nm-types.h @@ -39,8 +39,8 @@ typedef struct _NMDeviceBt NMDeviceBt; typedef struct _NMDeviceDummy NMDeviceDummy; typedef struct _NMDeviceEthernet NMDeviceEthernet; typedef struct _NMDeviceGeneric NMDeviceGeneric; -typedef struct _NMDeviceInfiniband NMDeviceInfiniband; typedef struct _NMDeviceIPTunnel NMDeviceIPTunnel; +typedef struct _NMDeviceInfiniband NMDeviceInfiniband; typedef struct _NMDeviceMacsec NMDeviceMacsec; typedef struct _NMDeviceMacvlan NMDeviceMacvlan; typedef struct _NMDeviceModem NMDeviceModem; @@ -54,6 +54,7 @@ typedef struct _NMDeviceTun NMDeviceTun; typedef struct _NMDeviceVlan NMDeviceVlan; typedef struct _NMDeviceVxlan NMDeviceVxlan; typedef struct _NMDeviceWifi NMDeviceWifi; +typedef struct _NMDeviceWifiP2P NMDeviceWifiP2P; typedef struct _NMDeviceWimax NMDeviceWimax; typedef struct _NMDeviceWireGuard NMDeviceWireGuard; typedef struct _NMDeviceWpan NMDeviceWpan; @@ -62,6 +63,7 @@ typedef struct _NMIPConfig NMIPConfig; typedef struct _NMObject NMObject; typedef struct _NMRemoteConnection NMRemoteConnection; typedef struct _NMVpnConnection NMVpnConnection; +typedef struct _NMWifiP2PPeer NMWifiP2PPeer; typedef struct _NMWimaxNsp NMWimaxNsp; #endif /* NM_TYPES_H */ diff --git a/libnm/nm-vpn-connection.c b/libnm/nm-vpn-connection.c index bc26d0b9..9fc32ed6 100644 --- a/libnm/nm-vpn-connection.c +++ b/libnm/nm-vpn-connection.c @@ -21,9 +21,8 @@ #include "nm-default.h" -#include - #include "nm-vpn-connection.h" + #include "nm-dbus-interface.h" #include "nm-utils.h" #include "nm-object-private.h" diff --git a/libnm/nm-vpn-plugin-old.c b/libnm/nm-vpn-plugin-old.c index bfafc7b7..80900cec 100644 --- a/libnm/nm-vpn-plugin-old.c +++ b/libnm/nm-vpn-plugin-old.c @@ -23,7 +23,6 @@ #include "nm-vpn-plugin-old.h" -#include #include #include diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index 2213824e..a2728342 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -23,7 +23,6 @@ #include "nm-vpn-service-plugin.h" -#include #include #include @@ -787,10 +786,13 @@ nm_vpn_service_plugin_read_vpn_details (int fd, gs_unref_hashtable GHashTable *data = NULL; gs_unref_hashtable GHashTable *secrets = NULL; gboolean success = FALSE; - char *key = NULL, *val = NULL; + GHashTable *hash = NULL; + GString *key = NULL, *val = NULL; nm_auto_free_gstring GString *line = NULL; char c; + GString *str = NULL; + if (out_data) g_return_val_if_fail (*out_data == NULL, FALSE); if (out_secrets) @@ -804,49 +806,79 @@ nm_vpn_service_plugin_read_vpn_details (int fd, /* Read stdin for data and secret items until we get a DONE */ while (1) { ssize_t nr; - GHashTable *hash = NULL; - errno = 0; nr = read (fd, &c, 1); - if (nr == -1) { + if (nr < 0) { if (errno == EAGAIN) { g_usleep (100); continue; } break; } - - if (c != '\n') { + if (nr > 0 && c != '\n') { g_string_append_c (line, c); continue; } - /* Check for the finish marker */ - if (strcmp (line->str, "DONE") == 0) - break; + if (str && *line->str == '=') { + /* continuation */ + g_string_append_c (str, '\n'); + g_string_append (str, line->str + 1); + } else if (key && val) { + /* done a line */ + g_return_val_if_fail (hash, FALSE); + g_hash_table_insert (hash, + g_string_free (key, FALSE), + g_string_free (val, FALSE)); + key = NULL; + val = NULL; + hash = NULL; + success = TRUE; /* Got at least one value */ + } - /* Otherwise it's a data/secret item */ - if (strncmp (line->str, DATA_KEY_TAG, strlen (DATA_KEY_TAG)) == 0) { + if (strcmp (line->str, "DONE") == 0) { + /* finish marker */ + break; + } else if (strncmp (line->str, DATA_KEY_TAG, strlen (DATA_KEY_TAG)) == 0) { + if (key != NULL) { + g_warning ("a value expected"); + g_string_free (key, TRUE); + } + key = g_string_new (line->str + strlen (DATA_KEY_TAG)); + str = key; hash = data; - key = g_strdup (line->str + strlen (DATA_KEY_TAG)); } else if (strncmp (line->str, DATA_VAL_TAG, strlen (DATA_VAL_TAG)) == 0) { - hash = data; - val = g_strdup (line->str + strlen (DATA_VAL_TAG)); + if (val != NULL) + g_string_free (val, TRUE); + if (val || !key || hash != data) { + g_warning ("%s not preceded by %s", DATA_VAL_TAG, DATA_KEY_TAG); + break; + } + val = g_string_new (line->str + strlen (DATA_VAL_TAG)); + str = val; } else if (strncmp (line->str, SECRET_KEY_TAG, strlen (SECRET_KEY_TAG)) == 0) { + if (key != NULL) { + g_warning ("a value expected"); + g_string_free (key, TRUE); + } + key = g_string_new (line->str + strlen (SECRET_KEY_TAG)); + str = key; hash = secrets; - key = g_strdup (line->str + strlen (SECRET_KEY_TAG)); } else if (strncmp (line->str, SECRET_VAL_TAG, strlen (SECRET_VAL_TAG)) == 0) { - hash = secrets; - val = g_strdup (line->str + strlen (SECRET_VAL_TAG)); + if (val != NULL) + g_string_free (val, TRUE); + if (val || !key || hash != secrets) { + g_warning ("%s not preceded by %s", SECRET_VAL_TAG, SECRET_KEY_TAG); + break; + } + val = g_string_new (line->str + strlen (SECRET_VAL_TAG)); + str = val; } + g_string_truncate (line, 0); - if (key && val && hash) { - g_hash_table_insert (hash, key, val); - key = NULL; - val = NULL; - success = TRUE; /* Got at least one value */ - } + if (nr == 0) + break; } if (success) { @@ -1325,7 +1357,7 @@ nm_vpn_service_plugin_initable_iface_init (GInitableIface *iface) /*****************************************************************************/ /* this header is intended to be copied to users of nm_vpn_editor_plugin_call(), - * to simplify invocation of generic functions. Include it here, to complile + * to simplify invocation of generic functions. Include it here, to compile * the code. */ #include "nm-utils/nm-vpn-editor-plugin-call.h" diff --git a/libnm/nm-wifi-p2p-peer.c b/libnm/nm-wifi-p2p-peer.c new file mode 100644 index 00000000..4dd8545d --- /dev/null +++ b/libnm/nm-wifi-p2p-peer.c @@ -0,0 +1,600 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2018 - 2019 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-wifi-p2p-peer.h" + +#include "nm-connection.h" +#include "nm-setting-connection.h" +#include "nm-setting-wifi-p2p.h" +#include "nm-utils.h" +#include "nm-dbus-interface.h" +#include "nm-object-private.h" + +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_FLAGS, + PROP_NAME, + PROP_MANUFACTURER, + PROP_MODEL, + PROP_MODEL_NUMBER, + PROP_SERIAL, + PROP_WFD_IES, + PROP_HW_ADDRESS, + PROP_STRENGTH, + PROP_LAST_SEEN, +); + +typedef struct { + char *name; + char *manufacturer; + char *model; + char *model_number; + char *serial; + + GBytes *wfd_ies; + + char *hw_address; + + int last_seen; + + NM80211ApFlags flags; + + guint8 strength; +} NMWifiP2PPeerPrivate; + +/** + * NMWifiP2PPeer: + */ +struct _NMWifiP2PPeer { + NMObject parent; + NMWifiP2PPeerPrivate _priv; +}; + +struct _NMWifiP2PPeerClass { + NMObjectClass parent; +}; + +G_DEFINE_TYPE (NMWifiP2PPeer, nm_wifi_p2p_peer, NM_TYPE_OBJECT) + +#define NM_WIFI_P2P_PEER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMWifiP2PPeer, NM_IS_WIFI_P2P_PEER, NMObject) + +/*****************************************************************************/ + +/** + * nm_wifi_p2p_peer_get_flags: + * @peer: a #NMWifiP2PPeer + * + * Gets the flags of the P2P peer. + * + * Returns: the flags + * + * Since: 1.16 + **/ +NM80211ApFlags +nm_wifi_p2p_peer_get_flags (NMWifiP2PPeer *peer) +{ + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), NM_802_11_AP_FLAGS_NONE); + + return NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->flags; +} + +/** + * nm_wifi_p2p_peer_get_name: + * @peer: a #NMWifiP2PPeer + * + * Gets the name of the P2P peer. + * + * Returns: the name + * + * Since: 1.16 + **/ +const char * +nm_wifi_p2p_peer_get_name (NMWifiP2PPeer *peer) +{ + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), NULL); + + return NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->name; +} + +/** + * nm_wifi_p2p_peer_get_manufacturer: + * @peer: a #NMWifiP2PPeer + * + * Gets the manufacturer of the P2P peer. + * + * Returns: the manufacturer + * + * Since: 1.16 + **/ +const char * +nm_wifi_p2p_peer_get_manufacturer (NMWifiP2PPeer *peer) +{ + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), NULL); + + return NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->manufacturer; +} + +/** + * nm_wifi_p2p_peer_get_model: + * @peer: a #NMWifiP2PPeer + * + * Gets the model of the P2P peer. + * + * Returns: the model + * + * Since: 1.16 + **/ +const char * +nm_wifi_p2p_peer_get_model (NMWifiP2PPeer *peer) +{ + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), NULL); + + return NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->model; +} + +/** + * nm_wifi_p2p_peer_get_model_number: + * @peer: a #NMWifiP2PPeer + * + * Gets the model number of the P2P peer. + * + * Returns: the model number + * + * Since: 1.16 + **/ +const char * +nm_wifi_p2p_peer_get_model_number (NMWifiP2PPeer *peer) +{ + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), NULL); + + return NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->model_number; +} + +/** + * nm_wifi_p2p_peer_get_serial: + * @peer: a #NMWifiP2PPeer + * + * Gets the serial number of the P2P peer. + * + * Returns: the serial number + * + * Since: 1.16 + **/ +const char * +nm_wifi_p2p_peer_get_serial (NMWifiP2PPeer *peer) +{ + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), NULL); + + return NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->serial; +} + +/** + * nm_wifi_p2p_peer_get_wfd_ies: + * @peer: a #NMWifiP2PPeer + * + * Gets the WFD information elements of the P2P peer. + * + * Returns: (transfer none): the #GBytes containing the WFD IEs, or %NULL. + * + * Since: 1.16 + **/ +GBytes * +nm_wifi_p2p_peer_get_wfd_ies (NMWifiP2PPeer *peer) +{ + NMWifiP2PPeerPrivate *priv; + + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), NULL); + + priv = NM_WIFI_P2P_PEER_GET_PRIVATE (peer); + if (!priv->wfd_ies || g_bytes_get_size (priv->wfd_ies) == 0) + return NULL; + + return priv->wfd_ies; +} + +/** + * nm_wifi_p2p_peer_get_hw_address: + * @peer: a #NMWifiP2PPeer + * + * Gets the hardware address of the P2P peer. + * + * Returns: the hardware address + * + * Since: 1.16 + **/ +const char * +nm_wifi_p2p_peer_get_hw_address (NMWifiP2PPeer *peer) +{ + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), NULL); + + return NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->hw_address; +} + +/** + * nm_wifi_p2p_peer_get_strength: + * @peer: a #NMWifiP2PPeer + * + * Gets the current signal strength of the P2P peer as a percentage. + * + * Returns: the signal strength (0 to 100) + * + * Since: 1.16 + **/ +guint8 +nm_wifi_p2p_peer_get_strength (NMWifiP2PPeer *peer) +{ + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), 0); + + return NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->strength; +} + +/** + * nm_wifi_p2p_peer_get_last_seen: + * @peer: a #NMWifiP2PPeer + * + * Returns the timestamp (in CLOCK_BOOTTIME seconds) for the last time the + * P2P peer was seen. A value of -1 means the P2P peer has never been seen. + * + * Returns: the last seen time in seconds + * + * Since: 1.16 + **/ +int +nm_wifi_p2p_peer_get_last_seen (NMWifiP2PPeer *peer) +{ + g_return_val_if_fail (NM_IS_WIFI_P2P_PEER (peer), -1); + + return NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->last_seen; +} + +/** + * nm_wifi_p2p_peer_connection_valid: + * @peer: an #NMWifiP2PPeer to validate @connection against + * @connection: an #NMConnection to validate against @peer + * + * Validates a given connection against a given Wi-Fi P2P peer to ensure that + * the connection may be activated with that peer. The connection must match the + * @peer's address and in the future possibly other attributes. + * + * Returns: %TRUE if the connection may be activated with this Wi-Fi P2P Peer, + * %FALSE if it cannot be. + * + * Since: 1.16 + **/ +gboolean +nm_wifi_p2p_peer_connection_valid (NMWifiP2PPeer *peer, NMConnection *connection) +{ + NMSettingConnection *s_con; + NMSettingWifiP2P *s_wifi_p2p; + const char *ctype; + const char *hw_address; + const char *setting_peer; + + s_wifi_p2p = (NMSettingWifiP2P *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIFI_P2P); + if (!s_wifi_p2p) + return FALSE; + + s_con = nm_connection_get_setting_connection (connection); + if (!s_con) + return FALSE; + + ctype = nm_setting_connection_get_connection_type (s_con); + if ( !ctype + || !nm_streq (ctype, NM_SETTING_WIFI_P2P_SETTING_NAME)) + return FALSE; + + /* HW Address check */ + hw_address = nm_wifi_p2p_peer_get_hw_address (peer); + if (!hw_address) + return FALSE; + + setting_peer = nm_setting_wifi_p2p_get_peer (s_wifi_p2p); + if ( !setting_peer + || !nm_streq (hw_address, setting_peer)) + return FALSE; + + return TRUE; +} + +/** + * nm_wifi_p2p_peer_filter_connections: + * @peer: an #NMWifiP2PPeer to filter connections for + * @connections: (element-type NMConnection): an array of #NMConnections to + * filter + * + * Filters a given array of connections for a given #NMWifiP2PPeer object and + * returns connections which may be activated with the P2P peer. Any + * returned connections will match the @peers's HW address and in the future + * possibly other attributes. + * + * To obtain the list of connections that are compatible with this P2P peer, + * use nm_client_get_connections() and then filter the returned list for a given + * #NMDevice using nm_device_filter_connections() and finally filter that list + * with this function. + * + * Returns: (transfer container) (element-type NMConnection): an array of + * #NMConnections that could be activated with the given @peer. The array should + * be freed with g_ptr_array_unref() when it is no longer required. + * + * Since: 1.16 + **/ +GPtrArray * +nm_wifi_p2p_peer_filter_connections (NMWifiP2PPeer *peer, const GPtrArray *connections) +{ + GPtrArray *filtered; + guint i; + + filtered = g_ptr_array_new_with_free_func (g_object_unref); + for (i = 0; i < connections->len; i++) { + NMConnection *candidate = connections->pdata[i]; + + if (nm_wifi_p2p_peer_connection_valid (peer, candidate)) + g_ptr_array_add (filtered, g_object_ref (candidate)); + } + + return filtered; +} + +/*****************************************************************************/ + +static void +init_dbus (NMObject *object) +{ + NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE (object); + const NMPropertiesInfo property_info[] = { + { NM_WIFI_P2P_PEER_FLAGS, &priv->flags }, + { NM_WIFI_P2P_PEER_NAME, &priv->name }, + { NM_WIFI_P2P_PEER_MANUFACTURER, &priv->manufacturer }, + { NM_WIFI_P2P_PEER_MODEL, &priv->model }, + { NM_WIFI_P2P_PEER_MODEL_NUMBER, &priv->model_number }, + { NM_WIFI_P2P_PEER_SERIAL, &priv->serial }, + { NM_WIFI_P2P_PEER_WFD_IES, &priv->wfd_ies }, + { NM_WIFI_P2P_PEER_HW_ADDRESS, &priv->hw_address }, + { NM_WIFI_P2P_PEER_STRENGTH, &priv->strength }, + { NM_WIFI_P2P_PEER_LAST_SEEN, &priv->last_seen }, + { NULL }, + }; + + NM_OBJECT_CLASS (nm_wifi_p2p_peer_parent_class)->init_dbus (object); + + _nm_object_register_properties (object, + NM_DBUS_INTERFACE_WIFI_P2P_PEER, + property_info); +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMWifiP2PPeer *peer = NM_WIFI_P2P_PEER (object); + + switch (prop_id) { + case PROP_FLAGS: + g_value_set_flags (value, nm_wifi_p2p_peer_get_flags (peer)); + break; + case PROP_NAME: + g_value_set_string (value, nm_wifi_p2p_peer_get_name (peer)); + break; + case PROP_MANUFACTURER: + g_value_set_string (value, nm_wifi_p2p_peer_get_manufacturer (peer)); + break; + case PROP_MODEL: + g_value_set_string (value, nm_wifi_p2p_peer_get_model (peer)); + break; + case PROP_MODEL_NUMBER: + g_value_set_string (value, nm_wifi_p2p_peer_get_model_number (peer)); + break; + case PROP_SERIAL: + g_value_set_string (value, nm_wifi_p2p_peer_get_serial (peer)); + break; + case PROP_WFD_IES: + g_value_set_boxed (value, nm_wifi_p2p_peer_get_wfd_ies (peer)); + break; + case PROP_HW_ADDRESS: + g_value_set_string (value, nm_wifi_p2p_peer_get_hw_address (peer)); + break; + case PROP_STRENGTH: + g_value_set_uchar (value, nm_wifi_p2p_peer_get_strength (peer)); + break; + case PROP_LAST_SEEN: + g_value_set_int (value, nm_wifi_p2p_peer_get_last_seen (peer)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nm_wifi_p2p_peer_init (NMWifiP2PPeer *peer) +{ + NM_WIFI_P2P_PEER_GET_PRIVATE (peer)->last_seen = -1; +} + +static void +finalize (GObject *object) +{ + NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE (object); + + g_free (priv->name); + g_free (priv->manufacturer); + g_free (priv->model); + g_free (priv->model_number); + g_free (priv->serial); + + g_free (priv->hw_address); + + g_bytes_unref (priv->wfd_ies); + + G_OBJECT_CLASS (nm_wifi_p2p_peer_parent_class)->finalize (object); +} + +static void +nm_wifi_p2p_peer_class_init (NMWifiP2PPeerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (klass); + + object_class->get_property = get_property; + object_class->finalize = finalize; + + nm_object_class->init_dbus = init_dbus; + + /** + * NMWifiP2PPeer:flags: + * + * The flags of the P2P peer. + * + * Since: 1.16 + **/ + obj_properties[PROP_FLAGS] = + g_param_spec_flags (NM_WIFI_P2P_PEER_FLAGS, "", "", + NM_TYPE_802_11_AP_FLAGS, + NM_802_11_AP_FLAGS_NONE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + /** + * NMWifiP2PPeer:name: + * + * The name of the P2P peer. + * + * Since: 1.16 + **/ + obj_properties[PROP_NAME] = + g_param_spec_string (NM_WIFI_P2P_PEER_NAME, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + /** + * NMWifiP2PPeer:manufacturer: + * + * The manufacturer of the P2P peer. + * + * Since: 1.16 + **/ + obj_properties[PROP_MANUFACTURER] = + g_param_spec_string (NM_WIFI_P2P_PEER_MANUFACTURER, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + /** + * NMWifiP2PPeer:model: + * + * The model of the P2P peer. + * + * Since: 1.16 + **/ + obj_properties[PROP_MODEL] = + g_param_spec_string (NM_WIFI_P2P_PEER_MODEL, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + /** + * NMWifiP2PPeer:model-number: + * + * The hardware address of the P2P peer. + * + * Since: 1.16 + **/ + obj_properties[PROP_MODEL_NUMBER] = + g_param_spec_string (NM_WIFI_P2P_PEER_MODEL_NUMBER, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + /** + * NMWifiP2PPeer:serial: + * + * The serial number of the P2P peer. + * + * Since: 1.16 + **/ + obj_properties[PROP_SERIAL] = + g_param_spec_string (NM_WIFI_P2P_PEER_SERIAL, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + /** + * NMWifiP2PPeer:wfd-ies: + * + * The WFD information elements of the P2P peer. + * + * Since: 1.16 + **/ + obj_properties[PROP_WFD_IES] = + g_param_spec_boxed (NM_WIFI_P2P_PEER_WFD_IES, "", "", + G_TYPE_BYTES, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + /** + * NMWifiP2PPeer:hw-address: + * + * The hardware address of the P2P peer. + * + * Since: 1.16 + **/ + obj_properties[PROP_HW_ADDRESS] = + g_param_spec_string (NM_WIFI_P2P_PEER_HW_ADDRESS, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + /** + * NMWifiP2PPeer:strength: + * + * The current signal strength of the P2P peer. + * + * Since: 1.16 + **/ + obj_properties[PROP_STRENGTH] = + g_param_spec_uchar (NM_WIFI_P2P_PEER_STRENGTH, "", "", + 0, G_MAXUINT8, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + /** + * NMWifiP2PPeer:last-seen: + * + * The timestamp (in CLOCK_BOOTTIME seconds) for the last time the + * P2P peer was found. A value of -1 means the peer has never been seen. + * + * Since: 1.16 + **/ + obj_properties[PROP_LAST_SEEN] = + g_param_spec_int (NM_WIFI_P2P_PEER_LAST_SEEN, "", "", + -1, G_MAXINT, -1, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); +} diff --git a/libnm/nm-wifi-p2p-peer.h b/libnm/nm-wifi-p2p-peer.h new file mode 100644 index 00000000..7d48883b --- /dev/null +++ b/libnm/nm-wifi-p2p-peer.h @@ -0,0 +1,89 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2018 - 2019 Red Hat, Inc. + */ + +#ifndef __NM_WIFI_P2P_PEER_H__ +#define __NM_WIFI_P2P_PEER_H__ + +#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION) +#error "Only can be included directly." +#endif + +#include "nm-object.h" + +G_BEGIN_DECLS + +#define NM_TYPE_WIFI_P2P_PEER (nm_wifi_p2p_peer_get_type ()) +#define NM_WIFI_P2P_PEER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_P2P_PEER, NMWifiP2PPeer)) +#define NM_WIFI_P2P_PEER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIFI_P2P_PEER, NMWifiP2PPeerClass)) +#define NM_IS_WIFI_P2P_PEER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIFI_P2P_PEER)) +#define NM_IS_WIFI_P2P_PEER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WIFI_P2P_PEER)) +#define NM_WIFI_P2P_PEER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIFI_P2P_PEER, NMWifiP2PPeerClass)) + +#define NM_WIFI_P2P_PEER_FLAGS "flags" +#define NM_WIFI_P2P_PEER_NAME "name" +#define NM_WIFI_P2P_PEER_MANUFACTURER "manufacturer" +#define NM_WIFI_P2P_PEER_MODEL "model" +#define NM_WIFI_P2P_PEER_MODEL_NUMBER "model-number" +#define NM_WIFI_P2P_PEER_SERIAL "serial" +#define NM_WIFI_P2P_PEER_WFD_IES "wfd-ies" +#define NM_WIFI_P2P_PEER_HW_ADDRESS "hw-address" +#define NM_WIFI_P2P_PEER_STRENGTH "strength" +#define NM_WIFI_P2P_PEER_LAST_SEEN "last-seen" + +typedef struct _NMWifiP2PPeerClass NMWifiP2PPeerClass; + +NM_AVAILABLE_IN_1_16 +GType nm_wifi_p2p_peer_get_type (void); + +NM_AVAILABLE_IN_1_16 +NM80211ApFlags nm_wifi_p2p_peer_get_flags (NMWifiP2PPeer *peer); + +NM_AVAILABLE_IN_1_16 +const char * nm_wifi_p2p_peer_get_name (NMWifiP2PPeer *peer); +NM_AVAILABLE_IN_1_16 +const char * nm_wifi_p2p_peer_get_manufacturer (NMWifiP2PPeer *peer); +NM_AVAILABLE_IN_1_16 +const char * nm_wifi_p2p_peer_get_model (NMWifiP2PPeer *peer); +NM_AVAILABLE_IN_1_16 +const char * nm_wifi_p2p_peer_get_model_number (NMWifiP2PPeer *peer); +NM_AVAILABLE_IN_1_16 +const char * nm_wifi_p2p_peer_get_serial (NMWifiP2PPeer *peer); + +NM_AVAILABLE_IN_1_16 +GBytes * nm_wifi_p2p_peer_get_wfd_ies (NMWifiP2PPeer *peer); + +NM_AVAILABLE_IN_1_16 +const char * nm_wifi_p2p_peer_get_hw_address (NMWifiP2PPeer *peer); + +NM_AVAILABLE_IN_1_16 +guint8 nm_wifi_p2p_peer_get_strength (NMWifiP2PPeer *peer); +NM_AVAILABLE_IN_1_16 +int nm_wifi_p2p_peer_get_last_seen (NMWifiP2PPeer *peer); + +NM_AVAILABLE_IN_1_16 +GPtrArray * nm_wifi_p2p_peer_filter_connections (NMWifiP2PPeer *peer, + const GPtrArray *connections); + +NM_AVAILABLE_IN_1_16 +gboolean nm_wifi_p2p_peer_connection_valid (NMWifiP2PPeer *peer, + NMConnection *connection); + +G_END_DECLS + +#endif /* __NM_WIFI_P2P_PEER_H__ */ diff --git a/libnm/nm-wimax-nsp.c b/libnm/nm-wimax-nsp.c index 90c2c2bb..7baf7f02 100644 --- a/libnm/nm-wimax-nsp.c +++ b/libnm/nm-wimax-nsp.c @@ -20,13 +20,11 @@ #include "nm-default.h" -#include +#include "nm-wimax-nsp.h" #include "nm-connection.h" #include "nm-setting-connection.h" #include "nm-setting-wimax.h" - -#include "nm-wimax-nsp.h" #include "nm-dbus-interface.h" #include "nm-object-private.h" #include "nm-enum-types.h" diff --git a/libnm/tests/meson.build b/libnm/tests/meson.build index ae2f7124..d0a2dd30 100644 --- a/libnm/tests/meson.build +++ b/libnm/tests/meson.build @@ -20,16 +20,17 @@ foreach test_unit: test_units dependencies: [ libnm_dep, nm_core_dep, + libnm_systemd_shared_no_logging_dep, ], c_args: cflags, - link_with: test_unit[1] + link_with: test_unit[1], ) test( 'libnm/' + test_unit[0], test_script, timeout: test_unit[2], - args: test_args + [exe.full_path()] + args: test_args + [exe.full_path()], ) endforeach @@ -39,5 +40,5 @@ libnm_vpn_plugin_utils_test = static_library( sources: shared_nm_utils_nm_vpn_plugin_utils_c + [libnm_enum[1]], include_directories: libnm_inc, dependencies: nm_core_dep, - c_args: cflags + c_args: cflags, ) diff --git a/libnm/tests/test-general.c b/libnm/tests/test-general.c index 5959a4e6..410087af 100644 --- a/libnm/tests/test-general.c +++ b/libnm/tests/test-general.c @@ -20,8 +20,16 @@ #include "nm-default.h" +#if defined (HAVE_DECL_MEMFD_CREATE) && HAVE_DECL_MEMFD_CREATE +#include +#endif + +#include + #include "nm-libnm-utils.h" +#include "nm-vpn-service-plugin.h" + #include "nm-utils/nm-test-utils.h" /*****************************************************************************/ @@ -2158,6 +2166,271 @@ test_fixup_product_string (void) /*****************************************************************************/ +static int +_memfd_create (const char *name) +{ +#if defined (HAVE_DECL_MEMFD_CREATE) && HAVE_DECL_MEMFD_CREATE + return memfd_create (name, MFD_CLOEXEC); +#endif + return -1; +} + +typedef struct { + const char *key; + const char *val; +} ReadVpnDetailData; + +#define READ_VPN_DETAIL_DATA(...) \ + ((ReadVpnDetailData []) { __VA_ARGS__ }) + +static gboolean +_do_read_vpn_details_impl1 (const char *file, + int line, + int memfd, + char *mem, + gsize len, + const ReadVpnDetailData *expected_data, + guint expected_data_len, + const ReadVpnDetailData *expected_secrets, + guint expected_secrets_len) +{ + gssize written; + off_t lseeked; + gs_unref_hashtable GHashTable *data = NULL; + gs_unref_hashtable GHashTable *secrets = NULL; + + written = write (memfd, mem, len); + g_assert_cmpint (written, ==, (gssize) len); + + lseeked = lseek (memfd, 0, SEEK_SET); + g_assert_cmpint (lseeked, ==, 0); + + if (!nm_vpn_service_plugin_read_vpn_details (memfd, + &data, + &secrets)) { + g_assert (!data); + g_assert (!secrets); + g_assert_cmpint (expected_data_len, ==, 0); + g_assert_cmpint (expected_secrets_len, ==, 0); + return TRUE; + } + +#define _assert_hash(hash, expected, expected_len) \ + G_STMT_START { \ + GHashTable *_hash = (hash); \ + guint _expected_len = (expected_len); \ + const ReadVpnDetailData *_expected = (expected); \ + GHashTableIter _iter; \ + const char *_k, *_v; \ + guint _i; \ + \ + g_assert (_hash); \ + \ + g_hash_table_iter_init (&_iter, _hash); \ + while (g_hash_table_iter_next (&_iter, (gpointer *) &_k, (gpointer *) &_v)) { \ + for (_i = 0; _i < _expected_len; _i++) { \ + if (nm_streq (_expected[_i].key, _k)) \ + break; \ + } \ + if (_i >= _expected_len) \ + g_error ("%s:%d: hash '%s' contains unexpected data key '%s' with value '%s'", file, line, G_STRINGIFY (hash), _k, _v); \ + } \ + \ + for (_i = 0; _i < _expected_len; _i++) { \ + const ReadVpnDetailData *_d = &_expected[_i]; \ + \ + g_assert (_d->key); \ + g_assert (_d->val); \ + _v = g_hash_table_lookup (_hash, _d->key); \ + if (!nm_streq0 (_v, _d->val)) \ + g_error ("%s:%d: hash '%s' contains data key '%s' with value %s%s%s but we expected '%s'", file, line, G_STRINGIFY (hash), _d->key, NM_PRINT_FMT_QUOTE_STRING (_v), _d->val); \ + } \ + \ + g_assert_cmpint (g_hash_table_size (_hash), ==, _expected_len); \ + } G_STMT_END + + _assert_hash (data, expected_data, expected_data_len); + _assert_hash (secrets, expected_secrets, expected_secrets_len); + +#undef _assert_hash + return TRUE; +} + +#define _do_read_vpn_details_impl0(str, expected_data, expected_data_len, expected_secrets, expected_secrets_len, pre_setup_cmd) \ + G_STMT_START { \ + nm_auto_close int _memfd = _memfd_create ("libnm-test-read-vpn-details"); \ + \ + if (_memfd < 0) \ + g_test_skip ("cannot create memfd"); \ + else { \ + { pre_setup_cmd ; } \ + _do_read_vpn_details_impl1 (__FILE__, \ + __LINE__, \ + _memfd, \ + ""str"", \ + NM_STRLEN (str), \ + expected_data, \ + expected_data_len, \ + expected_secrets, \ + expected_secrets_len); \ + } \ + } G_STMT_END + +#define _do_read_vpn_details_empty(str) \ + _do_read_vpn_details_impl0 (str, \ + NULL, \ + 0, \ + NULL, \ + 0, \ + { } ) + +#define _do_read_vpn_details(str, expected_data, expected_secrets, pre_setup_cmd) \ + _do_read_vpn_details_impl0 (str, \ + expected_data, \ + G_N_ELEMENTS (expected_data), \ + expected_secrets, \ + G_N_ELEMENTS (expected_secrets), \ + pre_setup_cmd) + +static void +test_nm_vpn_service_plugin_read_vpn_details (void) +{ + _do_read_vpn_details_empty (""); + _do_read_vpn_details_empty ("hallo"); + _do_read_vpn_details_empty ("DONE"); + _do_read_vpn_details_empty ("DONE\n"); + _do_read_vpn_details_empty ("DONE\0"); + _do_read_vpn_details_empty ("\0DONE\0"); + + _do_read_vpn_details ("" + "DATA_KEY=some-key\n" + "DATA_VAL=string\n" + "\n" + "DATA_KEY=some-other-key\n" + "DATA_VAL=val2\n" + "\n" + "SECRET_KEY=some-secret\n" + "SECRET_VAL=val3\n" + "\n" + "DONE\n" + "\n" + "", + READ_VPN_DETAIL_DATA ( + { "some-key", "string" }, + { "some-other-key", "val2" }, + ), + READ_VPN_DETAIL_DATA ( + { "some-secret", "val3" }, + ), + ); + + _do_read_vpn_details ("" + "DATA_KEY=some-key\n" + "DATA_VAL=string\n" + "DONE\n", + READ_VPN_DETAIL_DATA ( + { "some-key", "string" }, + ), + READ_VPN_DETAIL_DATA (), + ); + + _do_read_vpn_details ("" + "DATA_KEY=some-key\n" + "DATA_VAL=string\n" + "=continued after a line break\n" + "SECRET_KEY=key names\n" + "=can have\n" + "=continuations too\n" + "bogus1=\n" + "SECRET_VAL=value\n" + "bogus=value\n" + "bogus=\n" + "DATA_VAL=x\n" + "DATA_KEY=\n" + "DATA_VAL=\n" + "DATA_VAL=y\n" + "DATA_KEY=y\n" + "DATA_KEY=y\n" + "DATA_KEY=z\n" + "SECRET_KEY=s1\n" + "DATA_VAL=z\n" + "SECRET_VAL=S1\n" + "\n" + "DONE\n" + "", + READ_VPN_DETAIL_DATA ( + { "some-key", "string\ncontinued after a line break" }, + ), + READ_VPN_DETAIL_DATA ( + { "key names\ncan have\ncontinuations too", "value" }, + ), + NMTST_EXPECT_LIBNM_WARNING ("DATA_VAL= not preceded by DATA_KEY=") + ); + + _do_read_vpn_details ("" + "DATA_KEY=some-key\n" + "DATA_VAL=string\n" + "=continued after a line break\n" + "SECRET_KEY=key names\n" + "=can have\n" + "=continuations too\n" + "SECRET_VAL=value\n" + "", + READ_VPN_DETAIL_DATA ( + { "some-key", "string\ncontinued after a line break" }, + ), + READ_VPN_DETAIL_DATA ( + { "key names\ncan have\ncontinuations too", "value" }, + ), + ); + + _do_read_vpn_details ("" + "DATA_KEY=some-key\n" + "DATA_VAL=string\n" + "\n" + "DATA_KEY=some\n" + "=key-2\n" + "DATA_VAL=val2\n" + "\n" + "DATA_KEY=key3\0" + "=key-2\n" + "DATA_VAL=val3\n" + "\n" + "SECRET_KEY=some-secret\n" + "SECRET_VAL=val3\n" + "\n" + "SECRET_KEY=\n" + "SECRET_VAL=val3\n" + "\n" + "SECRET_KEY=keyx\n" + "SECRET_VAL=\n" + "\n" + "SECRET_KEY=ke\xc0yx\n" + "SECRET_VAL=inval\n" + "\n" + "SECRET_KEY=key-inval\n" + "SECRET_VAL=in\xc1val\n" + "\n" + "DONE\n" + "\n" + "", + READ_VPN_DETAIL_DATA ( + { "some\nkey-2", "val2" }, + { "some-key", "string" }, + { "key3", "val3" }, + ), + READ_VPN_DETAIL_DATA ( + { "some-secret", "val3" }, + { "", "val3" }, + { "keyx", "" }, + { "ke\xc0yx", "inval" }, + { "key-inval", "in\xc1val" }, + ), + ); +} + +/*****************************************************************************/ + NMTST_DEFINE (); int main (int argc, char **argv) @@ -2166,6 +2439,7 @@ int main (int argc, char **argv) g_test_add_func ("/libnm/general/fixup_product_string", test_fixup_product_string); g_test_add_func ("/libnm/general/fixup_vendor_string", test_fixup_vendor_string); + g_test_add_func ("/libnm/general/nm_vpn_service_plugin_read_vpn_details", test_nm_vpn_service_plugin_read_vpn_details); return g_test_run (); } diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index 21272e4d..35ae33be 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include diff --git a/libnm/tests/test-remote-settings-client.c b/libnm/tests/test-remote-settings-client.c index 45d60c06..1b211494 100644 --- a/libnm/tests/test-remote-settings-client.c +++ b/libnm/tests/test-remote-settings-client.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include diff --git a/libnm/tests/test-secret-agent.c b/libnm/tests/test-secret-agent.c index 53110be6..35a215ca 100644 --- a/libnm/tests/test-secret-agent.c +++ b/libnm/tests/test-secret-agent.c @@ -20,7 +20,6 @@ #include "nm-default.h" -#include #include #include -- 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/libnm.ver | 86 +++++++++++++++++++++++++++++++++++++ libnm/meson.build | 8 ++-- libnm/nm-dbus-helpers.h | 2 +- libnm/nm-device.c | 66 +++++++++++++++++++++------- libnm/nm-device.h | 8 ++-- libnm/nm-manager.c | 2 +- libnm/nm-property-docs.xml | 4 ++ libnm/nm-secret-agent-old.c | 3 +- libnm/nm-settings-docs.xml | 4 ++ libnm/nm-settings-ifcfg-rh-docs.xml | 4 ++ libnm/nm-vpn-service-plugin.c | 2 +- libnm/tests/meson.build | 4 +- 12 files changed, 163 insertions(+), 30 deletions(-) (limited to 'libnm') diff --git a/libnm/libnm.ver b/libnm/libnm.ver index ece9686e..8100f3b6 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1518,3 +1518,89 @@ global: nm_wireguard_peer_set_public_key; nm_wireguard_peer_unref; } libnm_1_14_0; + +libnm_1_18_0 { +global: + nm_bridge_vlan_cmp; + nm_bridge_vlan_from_str; + nm_bridge_vlan_get_type; + nm_bridge_vlan_get_vid_range; + nm_bridge_vlan_is_pvid; + nm_bridge_vlan_is_sealed; + nm_bridge_vlan_is_untagged; + nm_bridge_vlan_new; + nm_bridge_vlan_new_clone; + nm_bridge_vlan_ref; + nm_bridge_vlan_seal; + nm_bridge_vlan_set_pvid; + nm_bridge_vlan_set_untagged; + nm_bridge_vlan_to_str; + nm_bridge_vlan_unref; + nm_ip_routing_rule_as_string_flags_get_type; + nm_ip_routing_rule_cmp; + nm_ip_routing_rule_from_string; + nm_ip_routing_rule_get_action; + nm_ip_routing_rule_get_addr_family; + nm_ip_routing_rule_get_destination_port_end; + nm_ip_routing_rule_get_destination_port_start; + nm_ip_routing_rule_get_from; + nm_ip_routing_rule_get_from_len; + nm_ip_routing_rule_get_fwmark; + nm_ip_routing_rule_get_fwmask; + nm_ip_routing_rule_get_iifname; + nm_ip_routing_rule_get_invert; + nm_ip_routing_rule_get_ipproto; + nm_ip_routing_rule_get_oifname; + nm_ip_routing_rule_get_priority; + nm_ip_routing_rule_get_source_port_end; + nm_ip_routing_rule_get_source_port_start; + nm_ip_routing_rule_get_table; + nm_ip_routing_rule_get_to; + nm_ip_routing_rule_get_to_len; + nm_ip_routing_rule_get_tos; + nm_ip_routing_rule_get_type; + nm_ip_routing_rule_is_sealed; + nm_ip_routing_rule_new; + nm_ip_routing_rule_new_clone; + nm_ip_routing_rule_ref; + nm_ip_routing_rule_seal; + nm_ip_routing_rule_set_action; + nm_ip_routing_rule_set_destination_port; + nm_ip_routing_rule_set_from; + nm_ip_routing_rule_set_fwmark; + nm_ip_routing_rule_set_iifname; + nm_ip_routing_rule_set_invert; + nm_ip_routing_rule_set_ipproto; + nm_ip_routing_rule_set_oifname; + nm_ip_routing_rule_set_priority; + nm_ip_routing_rule_set_source_port; + nm_ip_routing_rule_set_table; + nm_ip_routing_rule_set_to; + nm_ip_routing_rule_set_tos; + nm_ip_routing_rule_to_string; + nm_ip_routing_rule_unref; + nm_ip_routing_rule_validate; + nm_lldp_neighbor_get_attr_value; + nm_setting_bridge_add_vlan; + nm_setting_bridge_clear_vlans; + nm_setting_bridge_get_num_vlans; + nm_setting_bridge_get_vlan; + nm_setting_bridge_get_vlan_default_pvid; + nm_setting_bridge_get_vlan_filtering; + nm_setting_bridge_port_add_vlan; + nm_setting_bridge_port_clear_vlans; + nm_setting_bridge_port_get_num_vlans; + nm_setting_bridge_port_get_vlan; + nm_setting_bridge_port_remove_vlan; + nm_setting_bridge_port_remove_vlan_by_vid; + nm_setting_bridge_remove_vlan; + nm_setting_bridge_remove_vlan_by_vid; + nm_setting_ip_config_add_routing_rule; + nm_setting_ip_config_clear_routing_rules; + nm_setting_ip_config_get_num_routing_rules; + nm_setting_ip_config_get_routing_rule; + nm_setting_ip_config_remove_routing_rule; + nm_tc_qdisc_get_attribute; + nm_tc_qdisc_get_attribute_names; + nm_tc_qdisc_set_attribute; +} libnm_1_16_0; diff --git a/libnm/meson.build b/libnm/meson.build index 558a587b..4b3df97f 100644 --- a/libnm/meson.build +++ b/libnm/meson.build @@ -9,8 +9,8 @@ libnm_utils_sources = files('nm-libnm-utils.c') deps = [ libnmdbus_dep, - shared_nm_utils_base_dep, - nm_core_dep, + shared_nm_glib_aux_dep, + libnm_core_dep, ] if have_fake_typelibs @@ -158,8 +158,8 @@ libnm = shared_library( dependencies: [ dl_dep, libudev_dep, - shared_nm_utils_base_dep, - nm_core_dep, + shared_nm_glib_aux_dep, + libnm_core_dep, uuid_dep, libnm_systemd_shared_no_logging_dep, ], diff --git a/libnm/nm-dbus-helpers.h b/libnm/nm-dbus-helpers.h index 0f2cabe8..eb5394f0 100644 --- a/libnm/nm-dbus-helpers.h +++ b/libnm/nm-dbus-helpers.h @@ -25,7 +25,7 @@ #error Cannot use this header. #endif -#include "nm-dbus-compat.h" +#include "nm-std-aux/nm-dbus-compat.h" GBusType _nm_dbus_bus_type (void); 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; - } diff --git a/libnm/nm-device.h b/libnm/nm-device.h index fcda93ab..62272297 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -227,13 +227,15 @@ void nm_lldp_neighbor_unref (NMLldpNeighbor *neighbor); NM_AVAILABLE_IN_1_2 char **nm_lldp_neighbor_get_attr_names (NMLldpNeighbor *neighbor); NM_AVAILABLE_IN_1_2 -gboolean nm_lldp_neighbor_get_attr_string_value (NMLldpNeighbor *neighbor, char *name, +gboolean nm_lldp_neighbor_get_attr_string_value (NMLldpNeighbor *neighbor, const char *name, const char **out_value); NM_AVAILABLE_IN_1_2 -gboolean nm_lldp_neighbor_get_attr_uint_value (NMLldpNeighbor *neighbor, char *name, +gboolean nm_lldp_neighbor_get_attr_uint_value (NMLldpNeighbor *neighbor, const char *name, guint *out_value); NM_AVAILABLE_IN_1_2 -const GVariantType *nm_lldp_neighbor_get_attr_type (NMLldpNeighbor *neighbor, char *name); +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 diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 7a169863..509586e0 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -25,7 +25,7 @@ #include "nm-utils.h" #include "nm-checkpoint.h" -#include "nm-common-macros.h" +#include "nm-libnm-core-intern/nm-common-macros.h" #include "nm-device-ethernet.h" #include "nm-device-wifi.h" #include "nm-core-internal.h" diff --git a/libnm/nm-property-docs.xml b/libnm/nm-property-docs.xml index 6344f784..f73ff6da 100644 --- a/libnm/nm-property-docs.xml +++ b/libnm/nm-property-docs.xml @@ -103,11 +103,15 @@ + + + + diff --git a/libnm/nm-secret-agent-old.c b/libnm/nm-secret-agent-old.c index 56a88b00..40485ab6 100644 --- a/libnm/nm-secret-agent-old.c +++ b/libnm/nm-secret-agent-old.c @@ -892,8 +892,7 @@ nm_secret_agent_old_get_secrets (NMSecretAgentOld *self, g_return_if_fail (NM_IS_SECRET_AGENT_OLD (self)); g_return_if_fail (NM_IS_CONNECTION (connection)); g_return_if_fail (nm_connection_get_path (connection)); - g_return_if_fail (setting_name != NULL); - g_return_if_fail (strlen (setting_name) > 0); + g_return_if_fail (setting_name && setting_name[0]); g_return_if_fail (!(flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM)); g_return_if_fail (!(flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS)); g_return_if_fail (callback != NULL); diff --git a/libnm/nm-settings-docs.xml b/libnm/nm-settings-docs.xml index ee5f3641..0f1d8c97 100644 --- a/libnm/nm-settings-docs.xml +++ b/libnm/nm-settings-docs.xml @@ -105,11 +105,15 @@ + + + + diff --git a/libnm/nm-settings-ifcfg-rh-docs.xml b/libnm/nm-settings-ifcfg-rh-docs.xml index cec2d527..ca5a8449 100644 --- a/libnm/nm-settings-ifcfg-rh-docs.xml +++ b/libnm/nm-settings-ifcfg-rh-docs.xml @@ -58,6 +58,7 @@ lookaside file, or it can be owned by a secret agent."/> + + + + diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index a2728342..abd02f18 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -26,7 +26,7 @@ #include #include -#include "nm-utils/nm-secret-utils.h" +#include "nm-glib-aux/nm-secret-utils.h" #include "nm-enum-types.h" #include "nm-utils.h" #include "nm-connection.h" diff --git a/libnm/tests/meson.build b/libnm/tests/meson.build index d0a2dd30..d76b9f5f 100644 --- a/libnm/tests/meson.build +++ b/libnm/tests/meson.build @@ -19,7 +19,7 @@ foreach test_unit: test_units ], dependencies: [ libnm_dep, - nm_core_dep, + libnm_core_dep, libnm_systemd_shared_no_logging_dep, ], c_args: cflags, @@ -39,6 +39,6 @@ libnm_vpn_plugin_utils_test = static_library( 'nm-vpn-plugin-utils-test', sources: shared_nm_utils_nm_vpn_plugin_utils_c + [libnm_enum[1]], include_directories: libnm_inc, - dependencies: nm_core_dep, + dependencies: libnm_core_dep, c_args: cflags, ) -- cgit 1.3.0-6-gf8a5