diff options
Diffstat (limited to 'libnm')
71 files changed, 2515 insertions, 519 deletions
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 <string.h> - #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 <string.h> +#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 <string.h> +#include "nm-client.h" + #include <libudev.h> #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 <string.h> - #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 <string.h> - #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 <string.h> +#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 <string.h> +#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 <string.h> +#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 <string.h> - #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 <string.h> +#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 <string.h> - #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 <string.h> +#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 <string.h> +#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 <string.h> - #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 <string.h> +#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 <string.h> +#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 <string.h> +#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 <string.h> - #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 <string.h> - #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 <string.h> - #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 <string.h> +#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 <string.h> +#include "nm-device-tun.h" + #include <arpa/inet.h> #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 <string.h> +#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 <string.h> +#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 <NetworkManager.h> 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 <string.h> - #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 <string.h> +#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 <string.h> - #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 <string.h> #include <libudev.h> #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; @@ -701,6 +715,36 @@ nm_device_class_init (NMDeviceClass *device_class) 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: * * The state of the device. @@ -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); } /** @@ -1231,6 +1275,36 @@ nm_device_get_dhcp6_config (NMDevice *device) } /** + * 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 <string.h> - #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 <string.h> - #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 <string.h> - #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 [<string>] 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 <string.h> - #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 <string.h> #include <stdlib.h> #include <stdio.h> @@ -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 @@ <property name="read-only" name_upper="READ_ONLY" type="boolean" default="FALSE" description="FALSE if the connection can be modified using the provided settings service's D-Bus interface with the right privileges, or TRUE if the connection is read-only and cannot be modified." /> <property name="secondaries" name_upper="SECONDARIES" type="array of string" default="[]" description="List of connection UUIDs that should be activated when the base connection itself is activated. Currently only VPN connections are supported." /> <property name="slave-type" name_upper="SLAVE_TYPE" type="string" description="Setting name of the device type of this slave's master connection (eg, "bond"), or NULL if this connection is not a slave." /> - <property name="stable-id" name_upper="STABLE_ID" type="string" description="This represents the identity of the connection used for various purposes. It allows to configure multiple profiles to share the identity. Also, the stable-id can contain placeholders that are substituted dynamically and deterministically depending on the context. The stable-id is used for generating IPv6 stable private addresses with ipv6.addr-gen-mode=stable-privacy. It is also used to seed the generated cloned MAC address for ethernet.cloned-mac-address=stable and wifi.cloned-mac-address=stable. It is also used as DHCP client identifier with ipv4.dhcp-client-id=stable and to derive the DHCP DUID with ipv6.dhcp-duid=stable-[llt,ll,uuid]. Note that depending on the context where it is used, other parameters are also seeded into the generation algorithm. For example, a per-host key is commonly also included, so that different systems end up generating different IDs. Or with ipv6.addr-gen-mode=stable-privacy, also the device's name is included, so that different interfaces yield different addresses. The '$' character is treated special to perform dynamic substitutions at runtime. Currently supported are "${CONNECTION}", "${DEVICE}", "${MAC}", "${BOOT}", "${RANDOM}". These effectively create unique IDs per-connection, per-device, per-boot, or every time. Note that "${DEVICE}" corresponds the the interface name of the device and "${MAC}" is the permanent MAC address of the device. Any unrecognized patterns following '$' are treated verbatim, however are reserved for future use. You are thus advised to avoid '$' or escape it as "$$". For example, set it to "${CONNECTION}-${BOOT}-${DEVICE}" to create a unique id for this connection that changes with every reboot and differs depending on the interface where the profile activates. If the value is unset, a global connection default is consulted. If the value is still unset, the default is similar to "${CONNECTION}" and uses a unique, fixed ID for the connection." /> + <property name="stable-id" name_upper="STABLE_ID" type="string" description="This represents the identity of the connection used for various purposes. It allows to configure multiple profiles to share the identity. Also, the stable-id can contain placeholders that are substituted dynamically and deterministically depending on the context. The stable-id is used for generating IPv6 stable private addresses with ipv6.addr-gen-mode=stable-privacy. It is also used to seed the generated cloned MAC address for ethernet.cloned-mac-address=stable and wifi.cloned-mac-address=stable. It is also used as DHCP client identifier with ipv4.dhcp-client-id=stable and to derive the DHCP DUID with ipv6.dhcp-duid=stable-[llt,ll,uuid]. Note that depending on the context where it is used, other parameters are also seeded into the generation algorithm. For example, a per-host key is commonly also included, so that different systems end up generating different IDs. Or with ipv6.addr-gen-mode=stable-privacy, also the device's name is included, so that different interfaces yield different addresses. The '$' character is treated special to perform dynamic substitutions at runtime. Currently supported are "${CONNECTION}", "${DEVICE}", "${MAC}", "${BOOT}", "${RANDOM}". These effectively create unique IDs per-connection, per-device, per-boot, or every time. Note that "${DEVICE}" corresponds to the interface name of the device and "${MAC}" is the permanent MAC address of the device. Any unrecognized patterns following '$' are treated verbatim, however are reserved for future use. You are thus advised to avoid '$' or escape it as "$$". For example, set it to "${CONNECTION}-${BOOT}-${DEVICE}" to create a unique id for this connection that changes with every reboot and differs depending on the interface where the profile activates. If the value is unset, a global connection default is consulted. If the value is still unset, the default is similar to "${CONNECTION}" and uses a unique, fixed ID for the connection." /> <property name="timestamp" name_upper="TIMESTAMP" type="uint64" default="0" description="The time, in seconds since the Unix Epoch, that the connection was last _successfully_ fully activated. NetworkManager updates the connection timestamp periodically when the connection is active to ensure that an active connection has the latest timestamp. The property is only meant for reading (changes to this property will not be preserved)." /> <property name="type" name_upper="TYPE" type="string" description="Base type of the connection. For hardware-dependent connections, should contain the setting name of the hardware-type specific setting (ie, "802-3-ethernet" or "802-11-wireless" or "bluetooth", etc), and for non-hardware dependent connections like VPN or otherwise, should contain the setting name of that setting type (ie, "vpn" or "bridge", etc)." /> <property name="uuid" name_upper="UUID" type="string" description="A universally unique identifier for the connection, for example generated with libuuid. It should be assigned when the connection is created, and never changed as long as the connection still applies to the same network. For example, it should not be changed when the "id" property or NMSettingIP4Config changes, but might need to be re-created when the Wi-Fi SSID, mobile broadband network provider, or "type" property changes. The UUID must be in the format "2815492f-7e56-435e-b2e9-246bd7cdc664" (ie, contains only hexadecimal characters and "-")." /> @@ -145,7 +145,7 @@ <property name="home-only" name_upper="HOME_ONLY" type="boolean" default="FALSE" description="When TRUE, only connections to the home network will be allowed. Connections to roaming networks will not be made." /> <property name="mtu" name_upper="MTU" type="uint32" default="0" description="If non-zero, only transmit packets of the specified size or smaller, breaking larger packets up into multiple frames." /> <property name="network-id" name_upper="NETWORK_ID" type="string" description="The Network ID (GSM LAI format, ie MCC-MNC) to force specific network registration. If the Network ID is specified, NetworkManager will attempt to force the device to register only on the specified network. This can be used to ensure that the device does not roam when direct roaming control of the device is not otherwise possible." /> - <property name="number" name_upper="NUMBER" type="string" description="Number to dial when establishing a PPP data session with the GSM-based mobile broadband network. Many modems do not require PPP for connections to the mobile network and thus this property should be left blank, which allows NetworkManager to select the appropriate settings automatically." /> + <property name="number" name_upper="NUMBER" type="string" description="Legacy setting that used to help establishing PPP data sessions for GSM-based modems. Deprecated: 1" /> <property name="password" name_upper="PASSWORD" type="string" description="The password used to authenticate with the network, if required. Many providers do not require a password, or accept any password. But if a password is required, it is specified here." /> <property name="password-flags" name_upper="PASSWORD_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "password" property." /> <property name="pin" name_upper="PIN" type="string" description="If the SIM is locked with a PIN it must be unlocked before any other operations are requested. Specify the PIN here to allow operation of the device." /> @@ -171,7 +171,7 @@ <property name="dhcp-timeout" name_upper="DHCP_TIMEOUT" type="int32" default="0" description="A timeout for a DHCP transaction in seconds." /> <property name="dns" name_upper="DNS" type="array of uint32" default="[]" description="Array of IP addresses of DNS servers." /> <property name="dns-options" name_upper="DNS_OPTIONS" type="array of string" default="[]" description="Array of DNS options as described in man 5 resolv.conf. NULL means that the options are unset and left at the default. In this case NetworkManager will use default options. This is distinct from an empty list of properties." /> - <property name="dns-priority" name_upper="DNS_PRIORITY" type="int32" default="0" description="DNS servers priority. The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects the default value, which is 50 for VPNs and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, the one with an active default route will be preferred. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least a negative priority, only DNS servers from connections with the lowest priority value will be used. When using a DNS resolver that supports split-DNS as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored." /> + <property name="dns-priority" name_upper="DNS_PRIORITY" type="int32" default="0" description="DNS servers priority. The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to 50 for VPNs and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, the one with an active default route will be preferred. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least a negative priority, only DNS servers from connections with the lowest priority value will be used. When using a DNS resolver that supports split-DNS as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored." /> <property name="dns-search" name_upper="DNS_SEARCH" type="array of string" default="[]" description="Array of DNS search domains. Domains starting with a tilde ('~') are considered 'routing' domains and are used only to decide the interface over which a query must be forwarded; they are not used to complete unqualified host names." /> <property name="gateway" name_upper="GATEWAY" type="string" description="The gateway associated with this configuration. This is only meaningful if "addresses" is also set." /> <property name="ignore-auto-dns" name_upper="IGNORE_AUTO_DNS" type="boolean" default="FALSE" description="When "method" is set to "auto" and this property to TRUE, automatically configured nameservers and search domains are ignored and only nameservers and search domains specified in the "dns" and "dns-search" properties, if any, are used." /> @@ -193,7 +193,7 @@ <property name="dhcp-timeout" name_upper="DHCP_TIMEOUT" type="int32" default="0" description="A timeout for a DHCP transaction in seconds." /> <property name="dns" name_upper="DNS" type="array of byte array" default="[]" description="Array of IP addresses of DNS servers." /> <property name="dns-options" name_upper="DNS_OPTIONS" type="array of string" default="[]" description="Array of DNS options as described in man 5 resolv.conf. NULL means that the options are unset and left at the default. In this case NetworkManager will use default options. This is distinct from an empty list of properties." /> - <property name="dns-priority" name_upper="DNS_PRIORITY" type="int32" default="0" description="DNS servers priority. The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects the default value, which is 50 for VPNs and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, the one with an active default route will be preferred. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least a negative priority, only DNS servers from connections with the lowest priority value will be used. When using a DNS resolver that supports split-DNS as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored." /> + <property name="dns-priority" name_upper="DNS_PRIORITY" type="int32" default="0" description="DNS servers priority. The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to 50 for VPNs and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, the one with an active default route will be preferred. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least a negative priority, only DNS servers from connections with the lowest priority value will be used. When using a DNS resolver that supports split-DNS as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored." /> <property name="dns-search" name_upper="DNS_SEARCH" type="array of string" default="[]" description="Array of DNS search domains. Domains starting with a tilde ('~') are considered 'routing' domains and are used only to decide the interface over which a query must be forwarded; they are not used to complete unqualified host names." /> <property name="gateway" name_upper="GATEWAY" type="string" description="The gateway associated with this configuration. This is only meaningful if "addresses" is also set." /> <property name="ignore-auto-dns" name_upper="IGNORE_AUTO_DNS" type="boolean" default="FALSE" description="When "method" is set to "auto" and this property to TRUE, automatically configured nameservers and search domains are ignored and only nameservers and search domains specified in the "dns" and "dns-search" properties, if any, are used." /> @@ -318,7 +318,7 @@ </setting> <setting name="team" description="Teaming Settings" name_upper="TEAM" > <property name="config" name_upper="CONFIG" type="string" description="The JSON configuration for the team network interface. The property should contain raw JSON configuration data suitable for teamd, because the value is passed directly to teamd. If not specified, the default configuration is used. See man teamd.conf for the format details." /> - <property name="link-watchers" name_upper="LINK_WATCHERS" type="array of vardict" default="[]" description="Link watchers configuration for the connection: each link watcher is defined by a dictionary, whose keys depend upon the selected link watcher. Available link watchers are 'ethtool', 'nsna_ping' and 'arp_ping' and it is specified in the dictionary with the key 'name'. Available keys are: ethtool: 'delay-up', 'delay-down', 'init-wait'; nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host'; arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active', 'validate-incative', 'send-always'. See teamd.conf man for more details." /> + <property name="link-watchers" name_upper="LINK_WATCHERS" type="array of vardict" default="[]" description="Link watchers configuration for the connection: each link watcher is defined by a dictionary, whose keys depend upon the selected link watcher. Available link watchers are 'ethtool', 'nsna_ping' and 'arp_ping' and it is specified in the dictionary with the key 'name'. Available keys are: ethtool: 'delay-up', 'delay-down', 'init-wait'; nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host'; arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active', 'validate-inactive', 'send-always'. See teamd.conf man for more details." /> <property name="mcast-rejoin-count" name_upper="MCAST_REJOIN_COUNT" type="int32" default="0" description="Corresponds to the teamd mcast_rejoin.count." /> <property name="mcast-rejoin-interval" name_upper="MCAST_REJOIN_INTERVAL" type="int32" default="0" description="Corresponds to the teamd mcast_rejoin.interval." /> <property name="notify-peers-count" name_upper="NOTIFY_PEERS_COUNT" type="int32" default="0" description="Corresponds to the teamd notify_peers.count." /> @@ -338,7 +338,7 @@ <property name="config" name_upper="CONFIG" type="string" description="The JSON configuration for the team port. The property should contain raw JSON configuration data suitable for teamd, because the value is passed directly to teamd. If not specified, the default configuration is used. See man teamd.conf for the format details." /> <property name="lacp-key" name_upper="LACP_KEY" type="int32" default="0" description="Corresponds to the teamd ports.PORTIFNAME.lacp_key." /> <property name="lacp-prio" name_upper="LACP_PRIO" type="int32" default="255" description="Corresponds to the teamd ports.PORTIFNAME.lacp_prio." /> - <property name="link-watchers" name_upper="LINK_WATCHERS" type="array of vardict" default="[]" description="Link watchers configuration for the connection: each link watcher is defined by a dictionary, whose keys depend upon the selected link watcher. Available link watchers are 'ethtool', 'nsna_ping' and 'arp_ping' and it is specified in the dictionary with the key 'name'. Available keys are: ethtool: 'delay-up', 'delay-down', 'init-wait'; nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host'; arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active', 'validate-incative', 'send-always'. See teamd.conf man for more details." /> + <property name="link-watchers" name_upper="LINK_WATCHERS" type="array of vardict" default="[]" description="Link watchers configuration for the connection: each link watcher is defined by a dictionary, whose keys depend upon the selected link watcher. Available link watchers are 'ethtool', 'nsna_ping' and 'arp_ping' and it is specified in the dictionary with the key 'name'. Available keys are: ethtool: 'delay-up', 'delay-down', 'init-wait'; nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host'; arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active', 'validate-inactive', 'send-always'. See teamd.conf man for more details." /> <property name="prio" name_upper="PRIO" type="int32" default="0" description="Corresponds to the teamd ports.PORTIFNAME.prio." /> <property name="queue-id" name_upper="QUEUE_ID" type="int32" default="-1" description="Corresponds to the teamd ports.PORTIFNAME.queue_id. When set to -1 means the parameter is skipped from the json config." /> <property name="sticky" name_upper="STICKY" type="boolean" default="FALSE" description="Corresponds to the teamd ports.PORTIFNAME.sticky." /> @@ -387,6 +387,11 @@ <property name="tos" name_upper="TOS" type="uint32" default="0" description="Specifies the TOS value to use in outgoing packets." /> <property name="ttl" name_upper="TTL" type="uint32" default="0" description="Specifies the time-to-live value to use in outgoing packets." /> </setting> + <setting name="wifi-p2p" description="Wi-Fi P2P Settings" name_upper="WIFI_P2P" > + <property name="peer" name_upper="PEER" type="string" description="The P2P device that should be connected to. Currently this is the only way to create or join a group." /> + <property name="wfd-ies" name_upper="WFD_IES" type="byte array" description="The Wi-Fi Display (WFD) Information Elements (IEs) to set. Wi-Fi Display requires a protocol specific information element to be set in certain Wi-Fi frames. These can be specified here for the purpose of establishing a connection. This setting is only useful when implementing a Wi-Fi Display client." /> + <property name="wps-method" name_upper="WPS_METHOD" type="uint32" default="0" description="Flags indicating which mode of WPS is to be used. There's little point in changing the default setting as NetworkManager will automatically determine the best method to use." /> + </setting> <setting name="wimax" description="WiMax Settings" name_upper="WIMAX" > <property name="mac-address" name_upper="MAC_ADDRESS" type="byte array" description="If specified, this connection will only apply to the WiMAX device whose MAC address matches. This property does not change the MAC address of the device (known as MAC spoofing). Deprecated: 1" /> <property name="network-name" name_upper="NETWORK_NAME" type="string" description="Network Service Provider (NSP) name of the WiMAX network this connection should use. Deprecated: 1" /> @@ -407,6 +412,14 @@ <property name="wake-on-lan" name_upper="WAKE_ON_LAN" type="uint32" default="1" description="The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40) or the special values NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT (0x1) (to use global settings) and NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE (0x8000) (to disable management of Wake-on-LAN in NetworkManager)." /> <property name="wake-on-lan-password" name_upper="WAKE_ON_LAN_PASSWORD" type="string" description="If specified, the password used with magic-packet-based Wake-on-LAN, represented as an Ethernet MAC address. If NULL, no password will be required." /> </setting> + <setting name="wireguard" description="WireGuard Ethernet Settings" name_upper="WIREGUARD" > + <property name="fwmark" name_upper="FWMARK" type="uint32" default="0" description="The use of fwmark is optional and is by default off. Setting it to 0 disables it. Otherwise it is a 32-bit fwmark for outgoing packets." /> + <property name="listen-port" name_upper="LISTEN_PORT" type="uint32" default="0" description="The listen-port. If listen-port is not specified, the port will be chosen randomly when the interface comes up." /> + <property name="mtu" name_upper="MTU" type="uint32" default="0" description="If non-zero, only transmit packets of the specified size or smaller, breaking larger packets up into multiple fragments. If zero a default MTU is used. Note that contrary to wg-quick's MTU setting, this does not take into account the current routes at the time of activation." /> + <property name="peer-routes" name_upper="PEER_ROUTES" type="boolean" default="TRUE" description="Whether to automatically add routes for the AllowedIPs ranges of the peers. If TRUE (the default), NetworkManager will automatically add routes in the routing tables according to ipv4.route-table and ipv6.route-table. If FALSE, no such routes are added automatically. In this case, the user may want to configure static routes in ipv4.routes and ipv6.routes, respectively." /> + <property name="private-key" name_upper="PRIVATE_KEY" type="string" description="The 256 bit private-key in base64 encoding." /> + <property name="private-key-flags" name_upper="PRIVATE_KEY_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "private-key" property." /> + </setting> <setting name="802-11-wireless" description="Wi-Fi Settings" name_upper="WIRELESS" > <property name="band" name_upper="BAND" type="string" description="802.11 frequency band of the network. One of "a" for 5GHz 802.11a or "bg" for 2.4GHz 802.11. This will lock associations to the Wi-Fi network to the specific band, i.e. if "a" is specified, the device will not associate with the same network in the 2.4GHz band even if the network's settings are compatible. This setting depends on specific driver capability and may not work with all drivers." /> <property name="bssid" name_upper="BSSID" type="byte array" description="If specified, directs the device to only associate with the given access point. This capability is highly driver dependent and not supported by all devices. Note: this property does not control the BSSID used when creating an Ad-Hoc network and is unlikely to in the future." /> @@ -430,14 +443,14 @@ <property name="auth-alg" name_upper="AUTH_ALG" type="string" description="When WEP is used (ie, key-mgmt = "none" or "ieee8021x") indicate the 802.11 authentication algorithm required by the AP here. One of "open" for Open System, "shared" for Shared Key, or "leap" for Cisco LEAP. When using Cisco LEAP (ie, key-mgmt = "ieee8021x" and auth-alg = "leap") the "leap-username" and "leap-password" properties must be specified." /> <property name="fils" name_upper="FILS" type="int32" default="0" description="Indicates whether Fast Initial Link Setup (802.11ai) must be enabled for the connection. One of NM_SETTING_WIRELESS_SECURITY_FILS_DEFAULT (0) (use global default value), NM_SETTING_WIRELESS_SECURITY_FILS_DISABLE (1) (disable FILS), NM_SETTING_WIRELESS_SECURITY_FILS_OPTIONAL (2) (enable FILS if the supplicant and the access point support it) or NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED (3) (enable FILS and fail if not supported). When set to NM_SETTING_WIRELESS_SECURITY_FILS_DEFAULT (0) and no global default is set, FILS will be optionally enabled." /> <property name="group" name_upper="GROUP" type="array of string" default="[]" description="A list of group/broadcast encryption algorithms which prevents connections to Wi-Fi networks that do not utilize one of the algorithms in the list. For maximum compatibility leave this property empty. Each list element may be one of "wep40", "wep104", "tkip", or "ccmp"." /> - <property name="key-mgmt" name_upper="KEY_MGMT" type="string" description="Key management used for the connection. One of "none" (WEP), "ieee8021x" (Dynamic WEP), "wpa-none" (Ad-Hoc WPA-PSK), "wpa-psk" (infrastructure WPA-PSK), or "wpa-eap" (WPA-Enterprise). This property must be set for any Wi-Fi connection that uses security." /> + <property name="key-mgmt" name_upper="KEY_MGMT" type="string" description="Key management used for the connection. One of "none" (WEP), "ieee8021x" (Dynamic WEP), "wpa-none" (Ad-Hoc WPA-PSK), "wpa-psk" (infrastructure WPA-PSK), "sae" (SAE) or "wpa-eap" (WPA-Enterprise). This property must be set for any Wi-Fi connection that uses security." /> <property name="leap-password" name_upper="LEAP_PASSWORD" type="string" description="The login password for legacy LEAP connections (ie, key-mgmt = "ieee8021x" and auth-alg = "leap")." /> <property name="leap-password-flags" name_upper="LEAP_PASSWORD_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "leap-password" property." /> <property name="leap-username" name_upper="LEAP_USERNAME" type="string" description="The login username for legacy LEAP connections (ie, key-mgmt = "ieee8021x" and auth-alg = "leap")." /> <property name="pairwise" name_upper="PAIRWISE" type="array of string" default="[]" description="A list of pairwise encryption algorithms which prevents connections to Wi-Fi networks that do not utilize one of the algorithms in the list. For maximum compatibility leave this property empty. Each list element may be one of "tkip" or "ccmp"." /> <property name="pmf" name_upper="PMF" type="int32" default="0" description="Indicates whether Protected Management Frames (802.11w) must be enabled for the connection. One of NM_SETTING_WIRELESS_SECURITY_PMF_DEFAULT (0) (use global default value), NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE (1) (disable PMF), NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL (2) (enable PMF if the supplicant and the access point support it) or NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED (3) (enable PMF and fail if not supported). When set to NM_SETTING_WIRELESS_SECURITY_PMF_DEFAULT (0) and no global default is set, PMF will be optionally enabled." /> <property name="proto" name_upper="PROTO" type="array of string" default="[]" description="List of strings specifying the allowed WPA protocol versions to use. Each element may be one "wpa" (allow WPA) or "rsn" (allow WPA2/RSN). If not specified, both WPA and RSN connections are allowed." /> - <property name="psk" name_upper="PSK" type="string" description="Pre-Shared-Key for WPA networks. If the key is 64-characters long, it must contain only hexadecimal characters and is interpreted as a hexadecimal WPA key. Otherwise, the key must be between 8 and 63 ASCII characters (as specified in the 802.11i standard) and is interpreted as a WPA passphrase, and is hashed to derive the actual WPA-PSK used when connecting to the Wi-Fi network." /> + <property name="psk" name_upper="PSK" type="string" description="Pre-Shared-Key for WPA networks. For WPA-PSK, it's either an ASCII passphrase of 8 to 63 characters that is (as specified in the 802.11i standard) hashed to derive the actual key, or the key in form of 64 hexadecimal character. The WPA3-Personal networks use a passphrase of any length for SAE authentication." /> <property name="psk-flags" name_upper="PSK_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "psk" property." /> <property name="wep-key-flags" name_upper="WEP_KEY_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "wep-key0", "wep-key1", "wep-key2", and "wep-key3" properties." /> <property name="wep-key-type" name_upper="WEP_KEY_TYPE" type="NMWepKeyType (uint32)" description="Controls the interpretation of WEP keys. Allowed values are NM_WEP_KEY_TYPE_KEY (1), in which case the key is either a 10- or 26-character hexadecimal string, or a 5- or 13-character ASCII password; or NM_WEP_KEY_TYPE_PASSPHRASE (2), in which case the passphrase is provided as a string and will be hashed using the de-facto MD5 method to derive the actual WEP key." /> @@ -449,7 +462,9 @@ <property name="wps-method" name_upper="WPS_METHOD" type="uint32" default="0" description="Flags indicating which mode of WPS is to be used if any. There's little point in changing the default setting as NetworkManager will automatically determine whether it's feasible to start WPS enrollment from the Access Point capabilities. WPS can be disabled by setting this property to a value of 1." /> </setting> <setting name="wpan" description="IEEE 802.15.4 (WPAN) MAC Settings" name_upper="WPAN" > + <property name="channel" name_upper="CHANNEL" type="int32" default="-1" description="IEEE 802.15.4 channel. A positive integer or -1, meaning "do not set, use whatever the device is already set to"." /> <property name="mac-address" name_upper="MAC_ADDRESS" type="string" description="If specified, this connection will only apply to the IEEE 802.15.4 (WPAN) MAC layer device whose permanent MAC address matches." /> + <property name="page" name_upper="PAGE" type="int32" default="-1" description="IEEE 802.15.4 channel page. A positive integer or -1, meaning "do not set, use whatever the device is already set to"." /> <property name="pan-id" name_upper="PAN_ID" type="uint32" default="65535" description="IEEE 802.15.4 Personal Area Network (PAN) identifier." /> <property name="short-address" name_upper="SHORT_ADDRESS" type="uint32" default="65535" description="Short IEEE 802.15.4 address to be used within a restricted environment." /> </setting> 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 <string.h> +#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 <string.h> - #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 <string.h> +#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."/> </setting> <setting name="vxlan"> </setting> +<setting name="wifi-p2p"> +</setting> <setting name="wimax"> </setting> <setting name="802-3-ethernet"> @@ -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"."/> </setting> +<setting name="wireguard"> +<property name="peers" variable="peers" format="array of 'a{sv}'" values="" default="" example="" description="Array of dictionaries for the WireGuard peers."/> +</setting> <setting name="802-11-wireless-security"> </setting> <setting name="802-11-wireless"> @@ -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"."/> <property name="security" variable="security" format="" values="" default="" example="" description="This property is deprecated, but can be set to the value diff --git a/libnm/nm-settings-docs.xml b/libnm/nm-settings-docs.xml index f3dca3fb..ee5f3641 100644 --- a/libnm/nm-settings-docs.xml +++ b/libnm/nm-settings-docs.xml @@ -22,7 +22,7 @@ <property name="read-only" name_upper="READ_ONLY" type="boolean" default="FALSE" description="FALSE if the connection can be modified using the provided settings service's D-Bus interface with the right privileges, or TRUE if the connection is read-only and cannot be modified." /> <property name="secondaries" name_upper="SECONDARIES" type="array of string" default="[]" description="List of connection UUIDs that should be activated when the base connection itself is activated. Currently only VPN connections are supported." /> <property name="slave-type" name_upper="SLAVE_TYPE" type="string" description="Setting name of the device type of this slave's master connection (eg, "bond"), or NULL if this connection is not a slave." /> - <property name="stable-id" name_upper="STABLE_ID" type="string" description="This represents the identity of the connection used for various purposes. It allows to configure multiple profiles to share the identity. Also, the stable-id can contain placeholders that are substituted dynamically and deterministically depending on the context. The stable-id is used for generating IPv6 stable private addresses with ipv6.addr-gen-mode=stable-privacy. It is also used to seed the generated cloned MAC address for ethernet.cloned-mac-address=stable and wifi.cloned-mac-address=stable. It is also used as DHCP client identifier with ipv4.dhcp-client-id=stable and to derive the DHCP DUID with ipv6.dhcp-duid=stable-[llt,ll,uuid]. Note that depending on the context where it is used, other parameters are also seeded into the generation algorithm. For example, a per-host key is commonly also included, so that different systems end up generating different IDs. Or with ipv6.addr-gen-mode=stable-privacy, also the device's name is included, so that different interfaces yield different addresses. The '$' character is treated special to perform dynamic substitutions at runtime. Currently supported are "${CONNECTION}", "${DEVICE}", "${MAC}", "${BOOT}", "${RANDOM}". These effectively create unique IDs per-connection, per-device, per-boot, or every time. Note that "${DEVICE}" corresponds the the interface name of the device and "${MAC}" is the permanent MAC address of the device. Any unrecognized patterns following '$' are treated verbatim, however are reserved for future use. You are thus advised to avoid '$' or escape it as "$$". For example, set it to "${CONNECTION}-${BOOT}-${DEVICE}" to create a unique id for this connection that changes with every reboot and differs depending on the interface where the profile activates. If the value is unset, a global connection default is consulted. If the value is still unset, the default is similar to "${CONNECTION}" and uses a unique, fixed ID for the connection." /> + <property name="stable-id" name_upper="STABLE_ID" type="string" description="This represents the identity of the connection used for various purposes. It allows to configure multiple profiles to share the identity. Also, the stable-id can contain placeholders that are substituted dynamically and deterministically depending on the context. The stable-id is used for generating IPv6 stable private addresses with ipv6.addr-gen-mode=stable-privacy. It is also used to seed the generated cloned MAC address for ethernet.cloned-mac-address=stable and wifi.cloned-mac-address=stable. It is also used as DHCP client identifier with ipv4.dhcp-client-id=stable and to derive the DHCP DUID with ipv6.dhcp-duid=stable-[llt,ll,uuid]. Note that depending on the context where it is used, other parameters are also seeded into the generation algorithm. For example, a per-host key is commonly also included, so that different systems end up generating different IDs. Or with ipv6.addr-gen-mode=stable-privacy, also the device's name is included, so that different interfaces yield different addresses. The '$' character is treated special to perform dynamic substitutions at runtime. Currently supported are "${CONNECTION}", "${DEVICE}", "${MAC}", "${BOOT}", "${RANDOM}". These effectively create unique IDs per-connection, per-device, per-boot, or every time. Note that "${DEVICE}" corresponds to the interface name of the device and "${MAC}" is the permanent MAC address of the device. Any unrecognized patterns following '$' are treated verbatim, however are reserved for future use. You are thus advised to avoid '$' or escape it as "$$". For example, set it to "${CONNECTION}-${BOOT}-${DEVICE}" to create a unique id for this connection that changes with every reboot and differs depending on the interface where the profile activates. If the value is unset, a global connection default is consulted. If the value is still unset, the default is similar to "${CONNECTION}" and uses a unique, fixed ID for the connection." /> <property name="timestamp" name_upper="TIMESTAMP" type="uint64" default="0" description="The time, in seconds since the Unix Epoch, that the connection was last _successfully_ fully activated. NetworkManager updates the connection timestamp periodically when the connection is active to ensure that an active connection has the latest timestamp. The property is only meant for reading (changes to this property will not be preserved)." /> <property name="type" name_upper="TYPE" type="string" description="Base type of the connection. For hardware-dependent connections, should contain the setting name of the hardware-type specific setting (ie, "802-3-ethernet" or "802-11-wireless" or "bluetooth", etc), and for non-hardware dependent connections like VPN or otherwise, should contain the setting name of that setting type (ie, "vpn" or "bridge", etc)." /> <property name="uuid" name_upper="UUID" type="string" description="A universally unique identifier for the connection, for example generated with libuuid. It should be assigned when the connection is created, and never changed as long as the connection still applies to the same network. For example, it should not be changed when the "id" property or NMSettingIP4Config changes, but might need to be re-created when the Wi-Fi SSID, mobile broadband network provider, or "type" property changes. The UUID must be in the format "2815492f-7e56-435e-b2e9-246bd7cdc664" (ie, contains only hexadecimal characters and "-")." /> @@ -147,7 +147,7 @@ <property name="home-only" name_upper="HOME_ONLY" type="boolean" default="FALSE" description="When TRUE, only connections to the home network will be allowed. Connections to roaming networks will not be made." /> <property name="mtu" name_upper="MTU" type="uint32" default="0" description="If non-zero, only transmit packets of the specified size or smaller, breaking larger packets up into multiple frames." /> <property name="network-id" name_upper="NETWORK_ID" type="string" description="The Network ID (GSM LAI format, ie MCC-MNC) to force specific network registration. If the Network ID is specified, NetworkManager will attempt to force the device to register only on the specified network. This can be used to ensure that the device does not roam when direct roaming control of the device is not otherwise possible." /> - <property name="number" name_upper="NUMBER" type="string" description="Number to dial when establishing a PPP data session with the GSM-based mobile broadband network. Many modems do not require PPP for connections to the mobile network and thus this property should be left blank, which allows NetworkManager to select the appropriate settings automatically." /> + <property name="number" name_upper="NUMBER" type="string" description="Legacy setting that used to help establishing PPP data sessions for GSM-based modems. Deprecated: 1" /> <property name="password" name_upper="PASSWORD" type="string" description="The password used to authenticate with the network, if required. Many providers do not require a password, or accept any password. But if a password is required, it is specified here." /> <property name="password-flags" name_upper="PASSWORD_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "password" property." /> <property name="pin" name_upper="PIN" type="string" description="If the SIM is locked with a PIN it must be unlocked before any other operations are requested. Specify the PIN here to allow operation of the device." /> @@ -174,7 +174,7 @@ <property name="dhcp-timeout" name_upper="DHCP_TIMEOUT" type="int32" default="0" description="A timeout for a DHCP transaction in seconds." /> <property name="dns" name_upper="DNS" type="array of uint32" default="[]" description="Array of IP addresses of DNS servers (as network-byte-order integers)" /> <property name="dns-options" name_upper="DNS_OPTIONS" type="array of string" default="[]" description="Array of DNS options as described in man 5 resolv.conf. NULL means that the options are unset and left at the default. In this case NetworkManager will use default options. This is distinct from an empty list of properties." /> - <property name="dns-priority" name_upper="DNS_PRIORITY" type="int32" default="0" description="DNS servers priority. The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects the default value, which is 50 for VPNs and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, the one with an active default route will be preferred. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least a negative priority, only DNS servers from connections with the lowest priority value will be used. When using a DNS resolver that supports split-DNS as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored." /> + <property name="dns-priority" name_upper="DNS_PRIORITY" type="int32" default="0" description="DNS servers priority. The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to 50 for VPNs and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, the one with an active default route will be preferred. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least a negative priority, only DNS servers from connections with the lowest priority value will be used. When using a DNS resolver that supports split-DNS as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored." /> <property name="dns-search" name_upper="DNS_SEARCH" type="array of string" default="[]" description="Array of DNS search domains. Domains starting with a tilde ('~') are considered 'routing' domains and are used only to decide the interface over which a query must be forwarded; they are not used to complete unqualified host names." /> <property name="gateway" name_upper="GATEWAY" type="string" description="The gateway associated with this configuration. This is only meaningful if "addresses" is also set." /> <property name="ignore-auto-dns" name_upper="IGNORE_AUTO_DNS" type="boolean" default="FALSE" description="When "method" is set to "auto" and this property to TRUE, automatically configured nameservers and search domains are ignored and only nameservers and search domains specified in the "dns" and "dns-search" properties, if any, are used." /> @@ -198,7 +198,7 @@ <property name="dhcp-timeout" name_upper="DHCP_TIMEOUT" type="int32" default="0" description="A timeout for a DHCP transaction in seconds." /> <property name="dns" name_upper="DNS" type="array of byte array" default="[]" description="Array of IP addresses of DNS servers (in network byte order)" /> <property name="dns-options" name_upper="DNS_OPTIONS" type="array of string" default="[]" description="Array of DNS options as described in man 5 resolv.conf. NULL means that the options are unset and left at the default. In this case NetworkManager will use default options. This is distinct from an empty list of properties." /> - <property name="dns-priority" name_upper="DNS_PRIORITY" type="int32" default="0" description="DNS servers priority. The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects the default value, which is 50 for VPNs and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, the one with an active default route will be preferred. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least a negative priority, only DNS servers from connections with the lowest priority value will be used. When using a DNS resolver that supports split-DNS as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored." /> + <property name="dns-priority" name_upper="DNS_PRIORITY" type="int32" default="0" description="DNS servers priority. The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to 50 for VPNs and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, the one with an active default route will be preferred. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least a negative priority, only DNS servers from connections with the lowest priority value will be used. When using a DNS resolver that supports split-DNS as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored." /> <property name="dns-search" name_upper="DNS_SEARCH" type="array of string" default="[]" description="Array of DNS search domains. Domains starting with a tilde ('~') are considered 'routing' domains and are used only to decide the interface over which a query must be forwarded; they are not used to complete unqualified host names." /> <property name="gateway" name_upper="GATEWAY" type="string" description="The gateway associated with this configuration. This is only meaningful if "addresses" is also set." /> <property name="ignore-auto-dns" name_upper="IGNORE_AUTO_DNS" type="boolean" default="FALSE" description="When "method" is set to "auto" and this property to TRUE, automatically configured nameservers and search domains are ignored and only nameservers and search domains specified in the "dns" and "dns-search" properties, if any, are used." /> @@ -325,7 +325,7 @@ <setting name="team" description="Teaming Settings" name_upper="TEAM" > <property name="config" name_upper="CONFIG" type="string" description="The JSON configuration for the team network interface. The property should contain raw JSON configuration data suitable for teamd, because the value is passed directly to teamd. If not specified, the default configuration is used. See man teamd.conf for the format details." /> <property name="interface-name" name_upper="INTERFACE_NAME" type="string" description="Deprecated in favor of connection.interface-name, but can be used for backward-compatibility with older daemons, to set the team's interface name." /> - <property name="link-watchers" name_upper="LINK_WATCHERS" type="array of vardict" default="[]" description="Link watchers configuration for the connection: each link watcher is defined by a dictionary, whose keys depend upon the selected link watcher. Available link watchers are 'ethtool', 'nsna_ping' and 'arp_ping' and it is specified in the dictionary with the key 'name'. Available keys are: ethtool: 'delay-up', 'delay-down', 'init-wait'; nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host'; arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active', 'validate-incative', 'send-always'. See teamd.conf man for more details." /> + <property name="link-watchers" name_upper="LINK_WATCHERS" type="array of vardict" default="[]" description="Link watchers configuration for the connection: each link watcher is defined by a dictionary, whose keys depend upon the selected link watcher. Available link watchers are 'ethtool', 'nsna_ping' and 'arp_ping' and it is specified in the dictionary with the key 'name'. Available keys are: ethtool: 'delay-up', 'delay-down', 'init-wait'; nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host'; arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active', 'validate-inactive', 'send-always'. See teamd.conf man for more details." /> <property name="mcast-rejoin-count" name_upper="MCAST_REJOIN_COUNT" type="int32" default="0" description="Corresponds to the teamd mcast_rejoin.count." /> <property name="mcast-rejoin-interval" name_upper="MCAST_REJOIN_INTERVAL" type="int32" default="0" description="Corresponds to the teamd mcast_rejoin.interval." /> <property name="notify-peers-count" name_upper="NOTIFY_PEERS_COUNT" type="int32" default="0" description="Corresponds to the teamd notify_peers.count." /> @@ -345,7 +345,7 @@ <property name="config" name_upper="CONFIG" type="string" description="The JSON configuration for the team port. The property should contain raw JSON configuration data suitable for teamd, because the value is passed directly to teamd. If not specified, the default configuration is used. See man teamd.conf for the format details." /> <property name="lacp-key" name_upper="LACP_KEY" type="int32" default="0" description="Corresponds to the teamd ports.PORTIFNAME.lacp_key." /> <property name="lacp-prio" name_upper="LACP_PRIO" type="int32" default="255" description="Corresponds to the teamd ports.PORTIFNAME.lacp_prio." /> - <property name="link-watchers" name_upper="LINK_WATCHERS" type="array of vardict" default="[]" description="Link watchers configuration for the connection: each link watcher is defined by a dictionary, whose keys depend upon the selected link watcher. Available link watchers are 'ethtool', 'nsna_ping' and 'arp_ping' and it is specified in the dictionary with the key 'name'. Available keys are: ethtool: 'delay-up', 'delay-down', 'init-wait'; nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host'; arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active', 'validate-incative', 'send-always'. See teamd.conf man for more details." /> + <property name="link-watchers" name_upper="LINK_WATCHERS" type="array of vardict" default="[]" description="Link watchers configuration for the connection: each link watcher is defined by a dictionary, whose keys depend upon the selected link watcher. Available link watchers are 'ethtool', 'nsna_ping' and 'arp_ping' and it is specified in the dictionary with the key 'name'. Available keys are: ethtool: 'delay-up', 'delay-down', 'init-wait'; nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host'; arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active', 'validate-inactive', 'send-always'. See teamd.conf man for more details." /> <property name="prio" name_upper="PRIO" type="int32" default="0" description="Corresponds to the teamd ports.PORTIFNAME.prio." /> <property name="queue-id" name_upper="QUEUE_ID" type="int32" default="-1" description="Corresponds to the teamd ports.PORTIFNAME.queue_id. When set to -1 means the parameter is skipped from the json config." /> <property name="sticky" name_upper="STICKY" type="boolean" default="FALSE" description="Corresponds to the teamd ports.PORTIFNAME.sticky." /> @@ -395,12 +395,17 @@ <property name="tos" name_upper="TOS" type="uint32" default="0" description="Specifies the TOS value to use in outgoing packets." /> <property name="ttl" name_upper="TTL" type="uint32" default="0" description="Specifies the time-to-live value to use in outgoing packets." /> </setting> + <setting name="wifi-p2p" description="Wi-Fi P2P Settings" name_upper="WIFI_P2P" > + <property name="peer" name_upper="PEER" type="string" description="The P2P device that should be connected to. Currently this is the only way to create or join a group." /> + <property name="wfd-ies" name_upper="WFD_IES" type="byte array" description="The Wi-Fi Display (WFD) Information Elements (IEs) to set. Wi-Fi Display requires a protocol specific information element to be set in certain Wi-Fi frames. These can be specified here for the purpose of establishing a connection. This setting is only useful when implementing a Wi-Fi Display client." /> + <property name="wps-method" name_upper="WPS_METHOD" type="uint32" default="0" description="Flags indicating which mode of WPS is to be used. There's little point in changing the default setting as NetworkManager will automatically determine the best method to use." /> + </setting> <setting name="wimax" description="WiMax Settings" name_upper="WIMAX" > <property name="mac-address" name_upper="MAC_ADDRESS" type="byte array" description="If specified, this connection will only apply to the WiMAX device whose MAC address matches. This property does not change the MAC address of the device (known as MAC spoofing). Deprecated: 1" /> <property name="network-name" name_upper="NETWORK_NAME" type="string" description="Network Service Provider (NSP) name of the WiMAX network this connection should use. Deprecated: 1" /> </setting> <setting name="802-3-ethernet" description="Wired Ethernet Settings" name_upper="WIRED" > - <property name="assigned-mac-address" name_upper="ASSIGNED_MAC_ADDRESS" type="string" description="The new field for the cloned MAC address. It can be either 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 only exists in D-Bus API. libnm and nmcli continue to call this property "cloned-mac-address"." /> + <property name="assigned-mac-address" name_upper="ASSIGNED_MAC_ADDRESS" type="string" description="The new field for the cloned MAC address. It can be either 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 explicit hardware addresses. Note that this property only exists in D-Bus API. libnm and nmcli continue to call this property "cloned-mac-address"." /> <property name="auto-negotiate" name_upper="AUTO_NEGOTIATE" type="boolean" default="FALSE" description="When TRUE, enforce auto-negotiation of speed and duplex mode. If "speed" and "duplex" properties are both specified, only that single mode will be advertised and accepted during the link auto-negotiation process: this works only for BASE-T 802.3 specifications and is useful for enforcing gigabits modes, as in these cases link negotiation is mandatory. When FALSE, "speed" and "duplex" properties should be both set or link configuration will be skipped." /> <property name="cloned-mac-address" name_upper="CLONED_MAC_ADDRESS" type="byte array" description="This D-Bus field is deprecated in favor of "assigned-mac-address" which is more flexible and allows specifying special variants like "random". For libnm and nmcli, this field is called "cloned-mac-address"." /> <property name="duplex" name_upper="DUPLEX" type="string" description="When a value is set, either "half" or "full", configures the device to use the specified duplex mode. If "auto-negotiate" is "yes" the specified duplex mode will be the only one advertised during link negotiation: this works only for BASE-T 802.3 specifications and is useful for enforcing gigabits modes, as in these cases link negotiation is mandatory. If the value is unset (the default), the link configuration will be either skipped (if "auto-negotiate" is "no", the default) or will be auto-negotiated (if "auto-negotiate" is "yes") and the local device will advertise all the supported duplex modes. Must be set together with the "speed" property if specified. Before specifying a duplex mode be sure your device supports it." /> @@ -416,8 +421,17 @@ <property name="wake-on-lan" name_upper="WAKE_ON_LAN" type="uint32" default="1" description="The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40) or the special values NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT (0x1) (to use global settings) and NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE (0x8000) (to disable management of Wake-on-LAN in NetworkManager)." /> <property name="wake-on-lan-password" name_upper="WAKE_ON_LAN_PASSWORD" type="string" description="If specified, the password used with magic-packet-based Wake-on-LAN, represented as an Ethernet MAC address. If NULL, no password will be required." /> </setting> + <setting name="wireguard" description="WireGuard Ethernet Settings" name_upper="WIREGUARD" > + <property name="fwmark" name_upper="FWMARK" type="uint32" default="0" description="The use of fwmark is optional and is by default off. Setting it to 0 disables it. Otherwise it is a 32-bit fwmark for outgoing packets." /> + <property name="listen-port" name_upper="LISTEN_PORT" type="uint32" default="0" description="The listen-port. If listen-port is not specified, the port will be chosen randomly when the interface comes up." /> + <property name="mtu" name_upper="MTU" type="uint32" default="0" description="If non-zero, only transmit packets of the specified size or smaller, breaking larger packets up into multiple fragments. If zero a default MTU is used. Note that contrary to wg-quick's MTU setting, this does not take into account the current routes at the time of activation." /> + <property name="peer-routes" name_upper="PEER_ROUTES" type="boolean" default="TRUE" description="Whether to automatically add routes for the AllowedIPs ranges of the peers. If TRUE (the default), NetworkManager will automatically add routes in the routing tables according to ipv4.route-table and ipv6.route-table. If FALSE, no such routes are added automatically. In this case, the user may want to configure static routes in ipv4.routes and ipv6.routes, respectively." /> + <property name="peers" name_upper="PEERS" type="array of 'a{sv}'" description="Array of dictionaries for the WireGuard peers." /> + <property name="private-key" name_upper="PRIVATE_KEY" type="string" description="The 256 bit private-key in base64 encoding." /> + <property name="private-key-flags" name_upper="PRIVATE_KEY_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "private-key" property." /> + </setting> <setting name="802-11-wireless" description="Wi-Fi Settings" name_upper="WIRELESS" > - <property name="assigned-mac-address" name_upper="ASSIGNED_MAC_ADDRESS" type="string" description="The new field for the cloned MAC address. It can be either 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 only exists in D-Bus API. libnm and nmcli continue to call this property "cloned-mac-address"." /> + <property name="assigned-mac-address" name_upper="ASSIGNED_MAC_ADDRESS" type="string" description="The new field for the cloned MAC address. It can be either 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 explicit hardware addresses. Note that this property only exists in D-Bus API. libnm and nmcli continue to call this property "cloned-mac-address"." /> <property name="band" name_upper="BAND" type="string" description="802.11 frequency band of the network. One of "a" for 5GHz 802.11a or "bg" for 2.4GHz 802.11. This will lock associations to the Wi-Fi network to the specific band, i.e. if "a" is specified, the device will not associate with the same network in the 2.4GHz band even if the network's settings are compatible. This setting depends on specific driver capability and may not work with all drivers." /> <property name="bssid" name_upper="BSSID" type="byte array" description="If specified, directs the device to only associate with the given access point. This capability is highly driver dependent and not supported by all devices. Note: this property does not control the BSSID used when creating an Ad-Hoc network and is unlikely to in the future." /> <property name="channel" name_upper="CHANNEL" type="uint32" default="0" description="Wireless channel to use for the Wi-Fi connection. The device will only join (or create for Ad-Hoc networks) a Wi-Fi network on the specified channel. Because channel numbers overlap between bands, this property also requires the "band" property to be set." /> @@ -441,14 +455,14 @@ <property name="auth-alg" name_upper="AUTH_ALG" type="string" description="When WEP is used (ie, key-mgmt = "none" or "ieee8021x") indicate the 802.11 authentication algorithm required by the AP here. One of "open" for Open System, "shared" for Shared Key, or "leap" for Cisco LEAP. When using Cisco LEAP (ie, key-mgmt = "ieee8021x" and auth-alg = "leap") the "leap-username" and "leap-password" properties must be specified." /> <property name="fils" name_upper="FILS" type="int32" default="0" description="Indicates whether Fast Initial Link Setup (802.11ai) must be enabled for the connection. One of NM_SETTING_WIRELESS_SECURITY_FILS_DEFAULT (0) (use global default value), NM_SETTING_WIRELESS_SECURITY_FILS_DISABLE (1) (disable FILS), NM_SETTING_WIRELESS_SECURITY_FILS_OPTIONAL (2) (enable FILS if the supplicant and the access point support it) or NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED (3) (enable FILS and fail if not supported). When set to NM_SETTING_WIRELESS_SECURITY_FILS_DEFAULT (0) and no global default is set, FILS will be optionally enabled." /> <property name="group" name_upper="GROUP" type="array of string" default="[]" description="A list of group/broadcast encryption algorithms which prevents connections to Wi-Fi networks that do not utilize one of the algorithms in the list. For maximum compatibility leave this property empty. Each list element may be one of "wep40", "wep104", "tkip", or "ccmp"." /> - <property name="key-mgmt" name_upper="KEY_MGMT" type="string" description="Key management used for the connection. One of "none" (WEP), "ieee8021x" (Dynamic WEP), "wpa-none" (Ad-Hoc WPA-PSK), "wpa-psk" (infrastructure WPA-PSK), or "wpa-eap" (WPA-Enterprise). This property must be set for any Wi-Fi connection that uses security." /> + <property name="key-mgmt" name_upper="KEY_MGMT" type="string" description="Key management used for the connection. One of "none" (WEP), "ieee8021x" (Dynamic WEP), "wpa-none" (Ad-Hoc WPA-PSK), "wpa-psk" (infrastructure WPA-PSK), "sae" (SAE) or "wpa-eap" (WPA-Enterprise). This property must be set for any Wi-Fi connection that uses security." /> <property name="leap-password" name_upper="LEAP_PASSWORD" type="string" description="The login password for legacy LEAP connections (ie, key-mgmt = "ieee8021x" and auth-alg = "leap")." /> <property name="leap-password-flags" name_upper="LEAP_PASSWORD_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "leap-password" property." /> <property name="leap-username" name_upper="LEAP_USERNAME" type="string" description="The login username for legacy LEAP connections (ie, key-mgmt = "ieee8021x" and auth-alg = "leap")." /> <property name="pairwise" name_upper="PAIRWISE" type="array of string" default="[]" description="A list of pairwise encryption algorithms which prevents connections to Wi-Fi networks that do not utilize one of the algorithms in the list. For maximum compatibility leave this property empty. Each list element may be one of "tkip" or "ccmp"." /> <property name="pmf" name_upper="PMF" type="int32" default="0" description="Indicates whether Protected Management Frames (802.11w) must be enabled for the connection. One of NM_SETTING_WIRELESS_SECURITY_PMF_DEFAULT (0) (use global default value), NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE (1) (disable PMF), NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL (2) (enable PMF if the supplicant and the access point support it) or NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED (3) (enable PMF and fail if not supported). When set to NM_SETTING_WIRELESS_SECURITY_PMF_DEFAULT (0) and no global default is set, PMF will be optionally enabled." /> <property name="proto" name_upper="PROTO" type="array of string" default="[]" description="List of strings specifying the allowed WPA protocol versions to use. Each element may be one "wpa" (allow WPA) or "rsn" (allow WPA2/RSN). If not specified, both WPA and RSN connections are allowed." /> - <property name="psk" name_upper="PSK" type="string" description="Pre-Shared-Key for WPA networks. If the key is 64-characters long, it must contain only hexadecimal characters and is interpreted as a hexadecimal WPA key. Otherwise, the key must be between 8 and 63 ASCII characters (as specified in the 802.11i standard) and is interpreted as a WPA passphrase, and is hashed to derive the actual WPA-PSK used when connecting to the Wi-Fi network." /> + <property name="psk" name_upper="PSK" type="string" description="Pre-Shared-Key for WPA networks. For WPA-PSK, it's either an ASCII passphrase of 8 to 63 characters that is (as specified in the 802.11i standard) hashed to derive the actual key, or the key in form of 64 hexadecimal character. The WPA3-Personal networks use a passphrase of any length for SAE authentication." /> <property name="psk-flags" name_upper="PSK_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "psk" property." /> <property name="wep-key-flags" name_upper="WEP_KEY_FLAGS" type="NMSettingSecretFlags (uint32)" description="Flags indicating how to handle the "wep-key0", "wep-key1", "wep-key2", and "wep-key3" properties." /> <property name="wep-key-type" name_upper="WEP_KEY_TYPE" type="NMWepKeyType (uint32)" description="Controls the interpretation of WEP keys. Allowed values are NM_WEP_KEY_TYPE_KEY (1), in which case the key is either a 10- or 26-character hexadecimal string, or a 5- or 13-character ASCII password; or NM_WEP_KEY_TYPE_PASSPHRASE (2), in which case the passphrase is provided as a string and will be hashed using the de-facto MD5 method to derive the actual WEP key." /> @@ -460,7 +474,9 @@ <property name="wps-method" name_upper="WPS_METHOD" type="uint32" default="0" description="Flags indicating which mode of WPS is to be used if any. There's little point in changing the default setting as NetworkManager will automatically determine whether it's feasible to start WPS enrollment from the Access Point capabilities. WPS can be disabled by setting this property to a value of 1." /> </setting> <setting name="wpan" description="IEEE 802.15.4 (WPAN) MAC Settings" name_upper="WPAN" > + <property name="channel" name_upper="CHANNEL" type="int32" default="-1" description="IEEE 802.15.4 channel. A positive integer or -1, meaning "do not set, use whatever the device is already set to"." /> <property name="mac-address" name_upper="MAC_ADDRESS" type="string" description="If specified, this connection will only apply to the IEEE 802.15.4 (WPAN) MAC layer device whose permanent MAC address matches." /> + <property name="page" name_upper="PAGE" type="int32" default="-1" description="IEEE 802.15.4 channel page. A positive integer or -1, meaning "do not set, use whatever the device is already set to"." /> <property name="pan-id" name_upper="PAN_ID" type="uint32" default="65535" description="IEEE 802.15.4 Personal Area Network (PAN) identifier." /> <property name="short-address" name_upper="SHORT_ADDRESS" type="uint32" default="65535" description="Short IEEE 802.15.4 address to be used within a restricted environment." /> </setting> 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."/> <property name="priority-strict-bandwidth" variable="DCB_PG_STRICT" format="" values="" default="" example="DCB_PG_STRICT=01101110" description="Priority values. String of eight "0" or "1", where "0" means "may not utilize all bandwidth", "1" means "may utilize all bandwidth"."/> -<property name="priority-traffic-class" variable="DCB_PG_UP2TC" format="" values="" default="" example="DCB_PG_UP2TC=01623701" description="Priority values. String of eight trafic class values (0 - 7)."/> +<property name="priority-traffic-class" variable="DCB_PG_UP2TC" format="" values="" default="" example="DCB_PG_UP2TC=01623701" description="Priority values. String of eight traffic class values (0 - 7)."/> </setting> <setting name="dummy"> </setting> @@ -297,6 +297,8 @@ but VLAN id from DEVICE takes precedence over VLAN_ID."/> </setting> <setting name="vxlan"> </setting> +<setting name="wifi-p2p"> +</setting> <setting name="wimax"> </setting> <setting name="802-3-ethernet"> @@ -325,6 +327,8 @@ is listed."/> <property name="s390-options" variable="OPTIONS and PORTNAME, CTCPROTO," format="" values="" default="" example="" description="S390 device options. All options go to OPTIONS, except for "portname" and "ctcprot" that have their own variables."/> </setting> +<setting name="wireguard"> +</setting> <setting name="802-11-wireless-security"> <property name="key-mgmt" variable="KEY_MGMT(+)" format="" values="IEEE8021X, WPA-PSK, WPA-EAP" default="" example="" description="Key management menthod."/> <property name="wep-tx-keyidx" variable="DEFAULTKEY" format="" values="1, 2, 3, 4" default="1" example="" description="Index of active WEP key."/> 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."/> </setting> <setting name="vxlan"> </setting> +<setting name="wifi-p2p"> +<property name="peer" variable="peer" format="usual hex-digits-and-colons notation" values="" default="" example="" description="MAC address in traditional hex-digits-and-colons notation +(e.g. 00:22:68:12:79:A2), or semicolon separated list of 6 bytes (obsolete) +(e.g. 0;34;104;18;121;162)."/> +</setting> <setting name="wimax"> </setting> <setting name="802-3-ethernet"> @@ -113,6 +118,8 @@ under [vpn-secrets] section."/> (e.g. 0;34;104;18;121;178)."/> <property name="mac-address-blacklist" variable="mac-address-blacklist" format="list of MACs (separated with semicolons)" values="" default="" example="mac-address-blacklist= 00:22:68:12:79:A6;00:22:68:12:79:78" description="MAC address blacklist."/> </setting> +<setting name="wireguard"> +</setting> <setting name="802-11-wireless-security"> </setting> <setting name="802-11-wireless"> 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 <string.h> - #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 <errno.h> #include <signal.h> #include <stdlib.h> 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 <errno.h> #include <signal.h> #include <stdlib.h> @@ -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 <NetworkManager.h> 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 <string.h> +#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 <linux/memfd.h> +#endif + +#include <sys/mman.h> + #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 <string.h> #include <sys/types.h> #include <signal.h> 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 <string.h> #include <sys/types.h> #include <signal.h> 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 <string.h> #include <sys/types.h> #include <signal.h> |