diff options
Diffstat (limited to 'libnm-core')
146 files changed, 2354 insertions, 3426 deletions
diff --git a/libnm-core/meson.build b/libnm-core/meson.build index 9637afaa..4c72590e 100644 --- a/libnm-core/meson.build +++ b/libnm-core/meson.build @@ -1,5 +1,16 @@ libnm_core_inc = include_directories('.') +libnm_core_nm_default_dep = declare_dependency( + sources: nm_version_macro_header, + include_directories: libnm_core_inc, + dependencies: glib_nm_default_dep, +) + +common_c_flags = [ + '-DG_LOG_DOMAIN="@0@"'.format(libnm_name), + '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', +] + libnm_core_headers = files( 'nm-connection.h', 'nm-core-types.h', @@ -62,6 +73,42 @@ libnm_core_headers = files( 'nm-vpn-plugin-info.h', ) +enum_types = 'nm-core-enum-types' + +libnm_core_enum_sources = gnome.mkenums_simple( + enum_types, + sources: libnm_core_headers + [nm_version_macro_header], + identifier_prefix: nm_id_prefix, + install_header: true, + install_dir: libnm_pkgincludedir, +) + +libnm_libnm_core_intern = static_library( + 'nm-libnm-core-intern', + sources: nm_ethtool_utils_source + nm_libnm_core_utils_source + [libnm_core_enum_sources[1]], + dependencies: libnm_core_nm_default_dep, + c_args: common_c_flags, +) + +libnm_libnm_core_intern_dep = declare_dependency( + sources: [libnm_core_enum_sources[1], nm_version_macro_header], + include_directories: [libnm_core_inc, shared_inc], + dependencies: libnm_utils_base_dep, + link_with: libnm_libnm_core_intern, +) + +deps = [ + crypto_dep, + libnm_utils_base_dep, +] + +libnm_crypto = static_library( + 'nm-crypto', + sources: 'nm-crypto-@0@.c'.format(crypto), + dependencies: deps, + c_args: common_c_flags, +) + libnm_core_settings_sources = files( 'nm-setting-6lowpan.c', 'nm-setting-8021x.c', @@ -129,75 +176,16 @@ libnm_core_sources = libnm_core_settings_sources + files( 'nm-vpn-plugin-info.c', ) -enum_headers = libnm_core_headers + [version_header] -enum_types = 'nm-core-enum-types' - -libnm_core_enum = gnome.mkenums( - enum_types, - sources: enum_headers, - identifier_prefix: nm_id_prefix, - c_template: enum_types + '.c.template', - h_template: enum_types + '.h.template', - install_header: true, - install_dir: libnm_pkgincludedir, -) - -libnm_core_enum_dep = declare_dependency( - sources: libnm_core_enum[1], -) - -############################################################################### - -shared_nm_libnm_core_intern = static_library( - 'nm-libnm-core-intern', - sources: files('../shared/nm-libnm-core-intern/nm-ethtool-utils.c', - '../shared/nm-libnm-core-intern/nm-libnm-core-utils.c'), - c_args: [ - '-DG_LOG_DOMAIN="@0@"'.format(libnm_name), - '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', - ], - include_directories: [ - top_inc, - shared_inc, - libnm_core_inc, - ], - dependencies: [ - glib_dep, - shared_c_siphash_dep, - shared_nm_glib_aux_dep, - libnm_core_enum_dep, - ], -) - -shared_nm_libnm_core_intern_dep = declare_dependency( - link_with: shared_nm_libnm_core_intern, - include_directories: [ - top_inc, - shared_inc, - ], - dependencies: [ - glib_dep, - shared_nm_glib_aux_dep, - libnm_systemd_shared_dep, - ], -) - -############################################################################### - deps = [ dl_dep, - libudev_dep, + libnm_systemd_shared_dep, + libnm_utils_base_dep, uuid_dep, - glib_dep, - shared_c_siphash_dep, - shared_nm_glib_aux_dep, - shared_nm_udev_aux_dep, - shared_nm_libnm_core_intern_dep, ] -cflags = [ - '-DG_LOG_DOMAIN="@0@"'.format(libnm_name), - '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', +links = [ + libnm_crypto, + libnm_libnm_core_intern, ] if enable_json_validation @@ -205,95 +193,43 @@ if enable_json_validation deps += jansson_dep endif -if (crypto_gnutls_dep.found()) - libnm_crypto_gnutls = static_library( - 'nm-crypto-gnutls', - sources: [ 'nm-crypto-gnutls.c' ], - dependencies: deps + [ crypto_gnutls_dep ], - c_args: cflags, - ) -endif - -if (crypto_nss_dep.found()) - libnm_crypto_nss = static_library( - 'nm-crypto-nss', - sources: [ 'nm-crypto-nss.c' ], - dependencies: deps + [ crypto_nss_dep ], - c_args: cflags, - ) -endif - -if crypto == 'gnutls' - libnm_crypto = libnm_crypto_gnutls -elif crypto == 'nss' - libnm_crypto = libnm_crypto_nss -else - error('bug') -endif - -libnm_core_sources_all = libnm_core_sources -libnm_core_sources_all += libnm_core_enum -libnm_core_sources_all += shared_nm_meta_setting_c -libnm_core_sources_all += [version_header] - libnm_core = static_library( 'nm-core', - sources: libnm_core_sources_all, + sources: libnm_core_sources + libnm_core_enum_sources + nm_meta_setting_source + [nm_version_macro_header], + include_directories: top_inc, dependencies: deps, - link_with: libnm_crypto, - c_args: cflags, + c_args: common_c_flags, + link_with: links, ) libnm_core_dep = declare_dependency( - sources: libnm_core_enum[1], - include_directories: libnm_core_inc, - dependencies: [ - shared_nm_libnm_core_intern_dep, - shared_nm_glib_aux_dep, - shared_c_siphash_dep, - libnm_systemd_shared_dep, - ], + sources: [libnm_core_enum_sources[1], nm_version_macro_header], + include_directories: [libnm_core_inc, shared_inc], + dependencies: glib_dep, + link_with: libnm_core, ) -############################################################################### +c_flags = [ + '-DG_LOG_DOMAIN="@0@"'.format(libnm_name), + '-DNETWORKMANAGER_COMPILATION=(NM_NETWORKMANAGER_COMPILATION_WITH_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB)', +] -shared_nm_libnm_core_aux = static_library( - 'nm-libnm-core-aux', - sources: files('../shared/nm-libnm-core-aux/nm-libnm-core-aux.c'), - c_args: [ - '-DG_LOG_DOMAIN="@0@"'.format(libnm_name), - '-DNETWORKMANAGER_COMPILATION=(NM_NETWORKMANAGER_COMPILATION_WITH_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB)', - ], - include_directories: [ - top_inc, - shared_inc, - libnm_core_inc, - ], - dependencies: [ - glib_dep, - shared_c_siphash_dep, - shared_nm_glib_aux_dep, - libnm_core_dep, - ], +libnm_libnm_core_aux = static_library( + 'nm-libnm-core-aux', + sources: nm_libnm_core_aux_source + [libnm_core_enum_sources[1]], + dependencies: libnm_utils_base_dep, + c_args: c_flags, + link_with: libnm_libnm_core_intern, ) -shared_nm_libnm_core_aux_dep = declare_dependency( - link_with: shared_nm_libnm_core_aux, - include_directories: [ - top_inc, - shared_inc, - ], - dependencies: [ - libnm_core_dep, - glib_dep, - shared_nm_glib_aux_dep, - libnm_systemd_shared_dep, - ], +libnm_libnm_core_aux_dep = declare_dependency( + sources: [libnm_core_enum_sources[1], nm_version_macro_header], + include_directories: [libnm_core_inc, shared_inc], + dependencies: glib_dep, + link_with: libnm_libnm_core_aux, ) -############################################################################### - -enums_to_docbook = join_paths(meson.source_root(), 'tools', 'enums-to-docbook.pl') +enums_to_docbook = join_paths(source_root, 'tools', 'enums-to-docbook.pl') docbooks = [ ['nm-dbus-types', 'nm-dbus-interface.h', 'NetworkManager D-Bus API Types'], @@ -317,8 +253,6 @@ foreach docbook: docbooks content_files += xml.full_path() endforeach -############################################################################### - if enable_tests subdir('tests') endif diff --git a/libnm-core/nm-connection-private.h b/libnm-core/nm-connection-private.h index 6c747c76..ea7583e0 100644 --- a/libnm-core/nm-connection-private.h +++ b/libnm-core/nm-connection-private.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2014 Red Hat, Inc. + * Copyright (C) 2014 Red Hat, Inc. */ #ifndef __NM_CONNECTION_PRIVATE_H__ diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 2532b64a..307b9d62 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2018 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2018 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -1055,7 +1041,7 @@ _normalize_ip_config (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_infiniband_mtu (NMConnection *self, GHashTable *parameters) +_normalize_infiniband_mtu (NMConnection *self) { NMSettingInfiniband *s_infini = nm_connection_get_setting_infiniband (self); @@ -1070,7 +1056,7 @@ _normalize_infiniband_mtu (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_bond_mode (NMConnection *self, GHashTable *parameters) +_normalize_bond_mode (NMConnection *self) { NMSettingBond *s_bond = nm_connection_get_setting_bond (self); @@ -1091,7 +1077,7 @@ _normalize_bond_mode (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_bond_options (NMConnection *self, GHashTable *parameters) +_normalize_bond_options (NMConnection *self) { NMSettingBond *s_bond = nm_connection_get_setting_bond (self); gboolean changed = FALSE; @@ -1121,7 +1107,7 @@ again: } static gboolean -_normalize_wireless_mac_address_randomization (NMConnection *self, GHashTable *parameters) +_normalize_wireless_mac_address_randomization (NMConnection *self) { NMSettingWireless *s_wifi = nm_connection_get_setting_wireless (self); const char *cloned_mac_address; @@ -1167,7 +1153,7 @@ _normalize_wireless_mac_address_randomization (NMConnection *self, GHashTable *p } static gboolean -_normalize_macsec (NMConnection *self, GHashTable *parameters) +_normalize_macsec (NMConnection *self) { NMSettingMacsec *s_macsec = nm_connection_get_setting_macsec (self); gboolean changed = FALSE; @@ -1190,7 +1176,7 @@ _normalize_macsec (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_team_config (NMConnection *self, GHashTable *parameters) +_normalize_team_config (NMConnection *self) { NMSettingTeam *s_team = nm_connection_get_setting_team (self); @@ -1206,7 +1192,7 @@ _normalize_team_config (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_team_port_config (NMConnection *self, GHashTable *parameters) +_normalize_team_port_config (NMConnection *self) { NMSettingTeamPort *s_team_port = nm_connection_get_setting_team_port (self); @@ -1222,7 +1208,7 @@ _normalize_team_port_config (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_bluetooth_type (NMConnection *self, GHashTable *parameters) +_normalize_bluetooth_type (NMConnection *self) { const char *type = _nm_connection_detect_bluetooth_type (self); @@ -1236,7 +1222,7 @@ _normalize_bluetooth_type (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_ovs_interface_type (NMConnection *self, GHashTable *parameters) +_normalize_ovs_interface_type (NMConnection *self) { NMSettingOvsInterface *s_ovs_interface = nm_connection_get_setting_ovs_interface (self); gboolean modified; @@ -1257,7 +1243,7 @@ _normalize_ovs_interface_type (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_ip_tunnel_wired_setting (NMConnection *self, GHashTable *parameters) +_normalize_ip_tunnel_wired_setting (NMConnection *self) { NMSettingIPTunnel *s_ip_tunnel; @@ -1277,7 +1263,7 @@ _normalize_ip_tunnel_wired_setting (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_sriov_vf_order (NMConnection *self, GHashTable *parameters) +_normalize_sriov_vf_order (NMConnection *self) { NMSettingSriov *s_sriov; @@ -1289,7 +1275,7 @@ _normalize_sriov_vf_order (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_bridge_vlan_order (NMConnection *self, GHashTable *parameters) +_normalize_bridge_vlan_order (NMConnection *self) { NMSettingBridge *s_bridge; @@ -1301,7 +1287,7 @@ _normalize_bridge_vlan_order (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_bridge_port_vlan_order (NMConnection *self, GHashTable *parameters) +_normalize_bridge_port_vlan_order (NMConnection *self) { NMSettingBridgePort *s_port; @@ -1313,7 +1299,30 @@ _normalize_bridge_port_vlan_order (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_required_settings (NMConnection *self, GHashTable *parameters) +_normalize_gsm_auto_config (NMConnection *self) +{ + NMSettingGsm *s_gsm; + + s_gsm = nm_connection_get_setting_gsm (self); + if (!s_gsm) + return FALSE; + + if (!nm_setting_gsm_get_auto_config (s_gsm)) + return FALSE; + + if ( !nm_setting_gsm_get_apn (s_gsm) + && !nm_setting_gsm_get_username (s_gsm) + && !nm_setting_gsm_get_password (s_gsm)) + return FALSE; + + g_object_set (s_gsm, + NM_SETTING_GSM_AUTO_CONFIG, FALSE, + NULL); + return TRUE; +} + +static gboolean +_normalize_required_settings (NMConnection *self) { NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth (self); NMSetting *s_bridge; @@ -1337,7 +1346,7 @@ _normalize_required_settings (NMConnection *self, GHashTable *parameters) } static gboolean -_normalize_invalid_slave_port_settings (NMConnection *self, GHashTable *parameters) +_normalize_invalid_slave_port_settings (NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection (self); const char *slave_type; @@ -1611,23 +1620,24 @@ _connection_normalize (NMConnection *connection, was_modified |= _normalize_connection_uuid (connection); was_modified |= _normalize_connection_type (connection); was_modified |= _normalize_connection_slave_type (connection); - was_modified |= _normalize_required_settings (connection, parameters); - was_modified |= _normalize_invalid_slave_port_settings (connection, parameters); + was_modified |= _normalize_required_settings (connection); + was_modified |= _normalize_invalid_slave_port_settings (connection); was_modified |= _normalize_ip_config (connection, parameters); was_modified |= _normalize_ethernet_link_neg (connection); - was_modified |= _normalize_infiniband_mtu (connection, parameters); - was_modified |= _normalize_bond_mode (connection, parameters); - was_modified |= _normalize_bond_options (connection, parameters); - was_modified |= _normalize_wireless_mac_address_randomization (connection, parameters); - was_modified |= _normalize_macsec (connection, parameters); - was_modified |= _normalize_team_config (connection, parameters); - was_modified |= _normalize_team_port_config (connection, parameters); - was_modified |= _normalize_bluetooth_type (connection, parameters); - was_modified |= _normalize_ovs_interface_type (connection, parameters); - was_modified |= _normalize_ip_tunnel_wired_setting (connection, parameters); - was_modified |= _normalize_sriov_vf_order (connection, parameters); - was_modified |= _normalize_bridge_vlan_order (connection, parameters); - was_modified |= _normalize_bridge_port_vlan_order (connection, parameters); + was_modified |= _normalize_infiniband_mtu (connection); + was_modified |= _normalize_bond_mode (connection); + was_modified |= _normalize_bond_options (connection); + was_modified |= _normalize_wireless_mac_address_randomization (connection); + was_modified |= _normalize_macsec (connection); + was_modified |= _normalize_team_config (connection); + was_modified |= _normalize_team_port_config (connection); + was_modified |= _normalize_bluetooth_type (connection); + was_modified |= _normalize_ovs_interface_type (connection); + was_modified |= _normalize_ip_tunnel_wired_setting (connection); + was_modified |= _normalize_sriov_vf_order (connection); + was_modified |= _normalize_bridge_vlan_order (connection); + was_modified |= _normalize_bridge_port_vlan_order (connection); + was_modified |= _normalize_gsm_auto_config (connection); was_modified = !!was_modified; diff --git a/libnm-core/nm-connection.h b/libnm-core/nm-connection.h index 2c553e0e..86041f36 100644 --- a/libnm-core/nm-connection.h +++ b/libnm-core/nm-connection.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2018 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2018 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_CONNECTION_H__ diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index 868f7312..b7222df2 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. - * - * (C) Copyright 2014 - 2018 Red Hat, Inc. + * Copyright (C) 2014 - 2018 Red Hat, Inc. */ #ifndef NM_CORE_NM_INTERNAL_H @@ -145,6 +131,25 @@ _nm_setting_secret_flags_valid (NMSettingSecretFlags flags) /*****************************************************************************/ +const char *nm_bluetooth_capability_to_string (NMBluetoothCapabilities capabilities, char *buf, gsize len); + +/*****************************************************************************/ + +#define NM_DHCP_HOSTNAME_FLAGS_FQDN_MASK \ + ( NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED \ + | NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE \ + | NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE \ + | NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS) + +#define NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP4 \ + ( NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED \ + | NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE) + +#define NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP6 \ + NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE + +/*****************************************************************************/ + typedef enum { /*< skip >*/ NM_SETTING_PARSE_FLAGS_NONE = 0, NM_SETTING_PARSE_FLAGS_STRICT = 1LL << 0, @@ -720,10 +725,9 @@ typedef GVariant *(*NMSettInfoPropGPropToDBusFcn) (const GValue *from); typedef void (*NMSettInfoPropGPropFromDBusFcn) (GVariant *from, GValue *to); -struct _NMSettInfoProperty { - const char *name; - GParamSpec *param_spec; +const NMSettInfoSetting *nmtst_sett_info_settings (void); +typedef struct { const GVariantType *dbus_type; NMSettInfoPropToDBusFcn to_dbus_fcn; @@ -734,6 +738,14 @@ struct _NMSettInfoProperty { * on the GValue value of the GObject property. */ NMSettInfoPropGPropToDBusFcn gprop_to_dbus_fcn; NMSettInfoPropGPropFromDBusFcn gprop_from_dbus_fcn; +} NMSettInfoPropertType; + +struct _NMSettInfoProperty { + const char *name; + + GParamSpec *param_spec; + + const NMSettInfoPropertType *property_type; }; typedef struct { @@ -875,4 +887,18 @@ gboolean nm_utils_connection_is_adhoc_wpa (NMConnection *connection); const char *nm_utils_wifi_freq_to_band (guint32 freq); +gboolean _nm_utils_iaid_verify (const char *str, gint64 *out_value); + +gboolean _nm_utils_validate_dhcp_hostname_flags (NMDhcpHostnameFlags flags, + int addr_family, + GError **error); + +/*****************************************************************************/ + +gboolean _nmtst_variant_attribute_spec_assert_sorted (const NMVariantAttributeSpec *const*array, + gsize len); + +const NMVariantAttributeSpec *_nm_variant_attribute_spec_find_binary_search (const NMVariantAttributeSpec *const*array, + gsize len, + const char *name); #endif diff --git a/libnm-core/nm-core-types-internal.h b/libnm-core/nm-core-types-internal.h index f4b3ae0c..71d4d788 100644 --- a/libnm-core/nm-core-types-internal.h +++ b/libnm-core/nm-core-types-internal.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. - * - * (C) Copyright 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #ifndef NM_CORE_TYPES_INTERNAL_H diff --git a/libnm-core/nm-core-types.h b/libnm-core/nm-core-types.h index fa8b4c41..d7c1b5b5 100644 --- a/libnm-core/nm-core-types.h +++ b/libnm-core/nm-core-types.h @@ -1,20 +1,6 @@ -/* NetworkManager -- Network link manager - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2014 - 2018 Red Hat, Inc. +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2014 - 2018 Red Hat, Inc. */ #ifndef __NM_CORE_TYPES_H__ diff --git a/libnm-core/nm-crypto-gnutls.c b/libnm-core/nm-crypto-gnutls.c index 3288271d..5821e65f 100644 --- a/libnm-core/nm-crypto-gnutls.c +++ b/libnm-core/nm-crypto-gnutls.c @@ -1,23 +1,7 @@ -/* NetworkManager Wireless Applet -- Display wireless access points and allow user control - * +// SPDX-License-Identifier: LGPL-2.1+ +/* * Dan Williams <dcbw@redhat.com> - * - * 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 2007 - 2015 Red Hat, Inc. + * Copyright (C) 2007 - 2015 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-crypto-impl.h b/libnm-core/nm-crypto-impl.h index a745869e..e3d26de2 100644 --- a/libnm-core/nm-crypto-impl.h +++ b/libnm-core/nm-crypto-impl.h @@ -1,22 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* * Dan Williams <dcbw@redhat.com> - * - * 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 2007 - 2018 Red Hat, Inc. + * Copyright (C) 2007 - 2018 Red Hat, Inc. */ #ifndef __NM_CRYPTO_IMPL_H__ diff --git a/libnm-core/nm-crypto-nss.c b/libnm-core/nm-crypto-nss.c index 70d42682..60c8dfb5 100644 --- a/libnm-core/nm-crypto-nss.c +++ b/libnm-core/nm-crypto-nss.c @@ -1,22 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* * Dan Williams <dcbw@redhat.com> - * - * 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 2007 - 2009 Red Hat, Inc. + * Copyright (C) 2007 - 2009 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-crypto.c b/libnm-core/nm-crypto.c index e0c3b7fd..c8187017 100644 --- a/libnm-core/nm-crypto.c +++ b/libnm-core/nm-crypto.c @@ -1,22 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* * Dan Williams <dcbw@redhat.com> - * - * 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 2007 - 2018 Red Hat, Inc. + * Copyright (C) 2007 - 2018 Red Hat, Inc. */ #include "nm-default.h" @@ -444,7 +429,8 @@ file_read_contents (const char *filename, NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET, &out_contents->str, &out_contents->len, - error) >= 0; + NULL, + error); } GBytes * diff --git a/libnm-core/nm-crypto.h b/libnm-core/nm-crypto.h index 4b43d153..a96f0d05 100644 --- a/libnm-core/nm-crypto.h +++ b/libnm-core/nm-crypto.h @@ -1,22 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* * Dan Williams <dcbw@redhat.com> - * - * 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 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. */ #ifndef __NM_CRYPTO_H__ diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index d74ea2ba..35f2335f 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -1,19 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2004 - 2018 Red Hat, Inc. + * Copyright (C) 2004 - 2018 Red Hat, Inc. */ /* Definitions related to NetworkManager's D-Bus interfaces. @@ -293,6 +280,7 @@ typedef enum { /*< flags >*/ * @NM_WIFI_DEVICE_CAP_FREQ_2GHZ: device supports 2.4GHz frequencies * @NM_WIFI_DEVICE_CAP_FREQ_5GHZ: device supports 5GHz frequencies * @NM_WIFI_DEVICE_CAP_MESH: device supports acting as a mesh point. Since: 1.20. + * @NM_WIFI_DEVICE_CAP_IBSS_RSN: device supports WPA2/RSN in an IBSS network. Since: 1.22. * * 802.11 specific device encryption and authentication capabilities. **/ @@ -310,6 +298,7 @@ typedef enum { /*< flags >*/ NM_WIFI_DEVICE_CAP_FREQ_2GHZ = 0x00000200, NM_WIFI_DEVICE_CAP_FREQ_5GHZ = 0x00000400, NM_WIFI_DEVICE_CAP_MESH = 0x00001000, + NM_WIFI_DEVICE_CAP_IBSS_RSN = 0x00002000, } NMDeviceWifiCapabilities; /** @@ -653,11 +642,38 @@ typedef enum { /** * NMMetered: * @NM_METERED_UNKNOWN: The metered status is unknown - * @NM_METERED_YES: Metered, the value was statically set - * @NM_METERED_NO: Not metered, the value was statically set + * @NM_METERED_YES: Metered, the value was explicitly configured + * @NM_METERED_NO: Not metered, the value was explicitly configured * @NM_METERED_GUESS_YES: Metered, the value was guessed * @NM_METERED_GUESS_NO: Not metered, the value was guessed * + * The NMMetered enum has two different purposes: one is to configure + * "connection.metered" setting of a connection profile in #NMSettingConnection, and + * the other is to express the actual metered state of the #NMDevice at a given moment. + * + * For the connection profile only #NM_METERED_UNKNOWN, #NM_METERED_NO + * and #NM_METERED_YES are allowed. + * + * The device's metered state at runtime is determined by the profile + * which is currently active. If the profile explicitly specifies #NM_METERED_NO + * or #NM_METERED_YES, then the device's metered state is as such. + * If the connection profile leaves it undecided at #NM_METERED_UNKNOWN (the default), + * then NetworkManager tries to guess the metered state, for example based on the + * device type or on DHCP options (like Android devices exposing a "ANDROID_METERED" + * DHCP vendor option). This then leads to either #NM_METERED_GUESS_NO or #NM_METERED_GUESS_YES. + * + * Most applications probably should treat the runtime state #NM_METERED_GUESS_YES + * like #NM_METERED_YES, and all other states as not metered. + * + * Note that the per-device metered states are then combined to a global metered + * state. This is basically the metered state of the device with the best default + * route. However, that generalization of a global metered state may not be correct + * if the default routes for IPv4 and IPv6 are on different devices, or if policy + * routing is configured. In general, the global metered state tries to express whether + * the traffic is likely metered, but since that depends on the traffic itself, + * there is not one answer in all cases. Hence, an application may want to consider + * the per-device's metered states. + * * Since: 1.2 **/ NM_AVAILABLE_IN_1_2 @@ -1106,4 +1122,56 @@ typedef enum { NM_TERNARY_TRUE = 1, } NMTernary; +/** + * NMManagerReloadFlags: + * @NM_MANAGER_RELOAD_FLAG_NONE: an alias for numeric zero, no flags set. This + * reloads everything that is supported and is identical to a SIGHUP. + * @NM_MANAGER_RELOAD_FLAG_CONF: reload the NetworkManager.conf configuration + * from disk. Note that this does not include connections, which can be + * reloaded via Setting's ReloadConnections(). + * @NM_MANAGER_RELOAD_FLAG_DNS_RC: update DNS configuration, which usually + * involves writing /etc/resolv.conf anew. + * @NM_MANAGER_RELOAD_FLAG_DNS_FULL: means to restart the DNS plugin. This + * is for example useful when using dnsmasq plugin, which uses additional + * configuration in /etc/NetworkManager/dnsmasq.d. If you edit those files, + * you can restart the DNS plugin. This action shortly interrupts name + * resolution. + * @NM_MANAGER_RELOAD_FLAG_ALL: all flags. + * + * Flags for the manager Reload() call. + * + * Since: 1.22 + */ +typedef enum { /*< flags >*/ + NM_MANAGER_RELOAD_FLAG_NONE = 0, /*< skip >*/ + NM_MANAGER_RELOAD_FLAG_CONF = 0x1, + NM_MANAGER_RELOAD_FLAG_DNS_RC = 0x2, + NM_MANAGER_RELOAD_FLAG_DNS_FULL = 0x4, + NM_MANAGER_RELOAD_FLAG_ALL = 0x7, /*< skip >*/ +} NMManagerReloadFlags; + +/** + * NMDeviceInterfaceFlags: + * @NM_DEVICE_INTERFACE_FLAG_NONE: an alias for numeric zero, no flags set. + * @NM_DEVICE_INTERFACE_FLAG_UP: the interface is enabled from the + * administrative point of view. Corresponds to kernel IFF_UP. + * @NM_DEVICE_INTERFACE_FLAG_LOWER_UP: the physical link is up. Corresponds + * to kernel IFF_LOWER_UP. + * @NM_DEVICE_INTERFACE_FLAG_CARRIER: the interface has carrier. In most + * cases this is equal to the value of @NM_DEVICE_INTERFACE_FLAG_LOWER_UP. + * However some devices have a non-standard carrier detection mechanism. + * + * Flags for a network interface. + * + * Since: 1.22 + */ +typedef enum { /*< flags >*/ + /* kernel flags */ + NM_DEVICE_INTERFACE_FLAG_NONE = 0, /*< skip >*/ + NM_DEVICE_INTERFACE_FLAG_UP = 0x1, + NM_DEVICE_INTERFACE_FLAG_LOWER_UP = 0x2, + /* NM-specific flags */ + NM_DEVICE_INTERFACE_FLAG_CARRIER = 0x10000, +} NMDeviceInterfaceFlags; + #endif /* __NM_DBUS_INTERFACE_H__ */ diff --git a/libnm-core/nm-dbus-types.xml b/libnm-core/nm-dbus-types.xml index 309a88b7..b2190724 100644 --- a/libnm-core/nm-dbus-types.xml +++ b/libnm-core/nm-dbus-types.xml @@ -442,6 +442,11 @@ <entry role="enum_member_value"><para>= <literal>0x00001000</literal></para><para></para></entry> <entry role="enum_member_description"><para>device supports acting as a mesh point. Since: 1.20.</para><para></para></entry> </row> + <row role="constant"> + <entry role="enum_member_name"><para>NM_WIFI_DEVICE_CAP_IBSS_RSN</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0x00002000</literal></para><para></para></entry> + <entry role="enum_member_description"><para>device supports WPA2/RSN in an IBSS network. Since: 1.22.</para><para></para></entry> + </row> </tbody> </tgroup> </informaltable> @@ -1188,7 +1193,7 @@ <indexterm zone="NMMetered"> <primary>NMMetered</primary> </indexterm> - <para><para>Since: 1.2</para><para></para></para> + <para><para>The NMMetered enum has two different purposes: one is to configure "connection.metered" setting of a connection profile in <link linkend="NMSettingConnection,">NMSettingConnection,</link> and the other is to express the actual metered state of the <link linkend="NMDevice">NMDevice</link> at a given moment.</para><para>For the connection profile only <link linkend="NM_METERED_UNKNOWN,">NM_METERED_UNKNOWN,</link> <link linkend="NM_METERED_NO">NM_METERED_NO</link> and <link linkend="NM_METERED_YES">NM_METERED_YES</link> are allowed.</para><para>The device's metered state at runtime is determined by the profile which is currently active. If the profile explicitly specifies <link linkend="NM_METERED_NO">NM_METERED_NO</link> or <link linkend="NM_METERED_YES,">NM_METERED_YES,</link> then the device's metered state is as such. If the connection profile leaves it undecided at <link linkend="NM_METERED_UNKNOWN">NM_METERED_UNKNOWN</link> (the default), then NetworkManager tries to guess the metered state, for example based on the device type or on DHCP options (like Android devices exposing a "ANDROID_METERED" DHCP vendor option). This then leads to either <link linkend="NM_METERED_GUESS_NO">NM_METERED_GUESS_NO</link> or <link linkend="NM_METERED_GUESS_YES">NM_METERED_GUESS_YES</link>.</para><para>Most applications probably should treat the runtime state <link linkend="NM_METERED_GUESS_YES">NM_METERED_GUESS_YES</link> like <link linkend="NM_METERED_YES,">NM_METERED_YES,</link> and all other states as not metered.</para><para>Note that the per-device metered states are then combined to a global metered state. This is basically the metered state of the device with the best default route. However, that generalization of a global metered state may not be correct if the default routes for IPv4 and IPv6 are on different devices, or if policy routing is configured. In general, the global metered state tries to express whether the traffic is likely metered, but since that depends on the traffic itself, there is not one answer in all cases. Hence, an application may want to consider the per-device's metered states.</para><para>Since: 1.2</para><para></para></para> <refsect3 role="enum_members"> <title>Values</title> <informaltable role="enum_members_table" pgwide="1" frame="none"> @@ -1205,12 +1210,12 @@ <row role="constant"> <entry role="enum_member_name"><para>NM_METERED_YES</para><para></para></entry> <entry role="enum_member_value"><para>= <literal>1</literal></para><para></para></entry> - <entry role="enum_member_description"><para>Metered, the value was statically set</para><para></para></entry> + <entry role="enum_member_description"><para>Metered, the value was explicitly configured</para><para></para></entry> </row> <row role="constant"> <entry role="enum_member_name"><para>NM_METERED_NO</para><para></para></entry> <entry role="enum_member_value"><para>= <literal>2</literal></para><para></para></entry> - <entry role="enum_member_description"><para>Not metered, the value was statically set</para><para></para></entry> + <entry role="enum_member_description"><para>Not metered, the value was explicitly configured</para><para></para></entry> </row> <row role="constant"> <entry role="enum_member_name"><para>NM_METERED_GUESS_YES</para><para></para></entry> @@ -1893,4 +1898,89 @@ </refsect3> </refsect2> + <refsect2 id="NMManagerReloadFlags" role="enum"> + <title>enum NMManagerReloadFlags</title> + <indexterm zone="NMManagerReloadFlags"> + <primary>NMManagerReloadFlags</primary> + </indexterm> + <para><para>Flags for the manager Reload() call.</para><para>Since: 1.22</para><para></para></para> + <refsect3 role="enum_members"> + <title>Values</title> + <informaltable role="enum_members_table" pgwide="1" frame="none"> + <tgroup cols="4"> + <colspec colname="enum_members_name" colwidth="300px" /> + <colspec colname="enum_members_value" colwidth="100px"/> + <colspec colname="enum_members_description" /> + <tbody> + <row role="constant"> + <entry role="enum_member_name"><para>NM_MANAGER_RELOAD_FLAG_NONE</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0</literal></para><para></para></entry> + <entry role="enum_member_description"><para>an alias for numeric zero, no flags set. This reloads everything that is supported and is identical to a SIGHUP.</para><para></para></entry> + </row> + <row role="constant"> + <entry role="enum_member_name"><para>NM_MANAGER_RELOAD_FLAG_CONF</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0x1</literal></para><para></para></entry> + <entry role="enum_member_description"><para>reload the NetworkManager.conf configuration from disk. Note that this does not include connections, which can be reloaded via Setting's ReloadConnections().</para><para></para></entry> + </row> + <row role="constant"> + <entry role="enum_member_name"><para>NM_MANAGER_RELOAD_FLAG_DNS_RC</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0x2</literal></para><para></para></entry> + <entry role="enum_member_description"><para>update DNS configuration, which usually involves writing /etc/resolv.conf anew.</para><para></para></entry> + </row> + <row role="constant"> + <entry role="enum_member_name"><para>NM_MANAGER_RELOAD_FLAG_DNS_FULL</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0x4</literal></para><para></para></entry> + <entry role="enum_member_description"><para>means to restart the DNS plugin. This is for example useful when using dnsmasq plugin, which uses additional configuration in /etc/NetworkManager/dnsmasq.d. If you edit those files, you can restart the DNS plugin. This action shortly interrupts name resolution.</para><para></para></entry> + </row> + <row role="constant"> + <entry role="enum_member_name"><para>NM_MANAGER_RELOAD_FLAG_ALL</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0x7</literal></para><para></para></entry> + <entry role="enum_member_description"><para>all flags.</para><para></para></entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect3> + </refsect2> + + <refsect2 id="NMDeviceInterfaceFlags" role="enum"> + <title>enum NMDeviceInterfaceFlags</title> + <indexterm zone="NMDeviceInterfaceFlags"> + <primary>NMDeviceInterfaceFlags</primary> + </indexterm> + <para><para>Flags for a network interface.</para><para>Since: 1.22</para><para></para></para> + <refsect3 role="enum_members"> + <title>Values</title> + <informaltable role="enum_members_table" pgwide="1" frame="none"> + <tgroup cols="4"> + <colspec colname="enum_members_name" colwidth="300px" /> + <colspec colname="enum_members_value" colwidth="100px"/> + <colspec colname="enum_members_description" /> + <tbody> + <row role="constant"> + <entry role="enum_member_name"><para>NM_DEVICE_INTERFACE_FLAG_NONE</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0</literal></para><para></para></entry> + <entry role="enum_member_description"><para>an alias for numeric zero, no flags set.</para><para></para></entry> + </row> + <row role="constant"> + <entry role="enum_member_name"><para>NM_DEVICE_INTERFACE_FLAG_UP</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0x1</literal></para><para></para></entry> + <entry role="enum_member_description"><para>the interface is enabled from the administrative point of view. Corresponds to kernel IFF_UP.</para><para></para></entry> + </row> + <row role="constant"> + <entry role="enum_member_name"><para>NM_DEVICE_INTERFACE_FLAG_LOWER_UP</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0x2</literal></para><para></para></entry> + <entry role="enum_member_description"><para>the physical link is up. Corresponds to kernel IFF_LOWER_UP.</para><para></para></entry> + </row> + <row role="constant"> + <entry role="enum_member_name"><para>NM_DEVICE_INTERFACE_FLAG_CARRIER</para><para></para></entry> + <entry role="enum_member_value"><para>= <literal>0x10000</literal></para><para></para></entry> + <entry role="enum_member_description"><para>the interface has carrier. In most cases this is equal to the value of @NM_DEVICE_INTERFACE_FLAG_LOWER_UP. However some devices have a non-standard carrier detection mechanism.</para><para></para></entry> + </row> + </tbody> + </tgroup> + </informaltable> + </refsect3> + </refsect2> + </refentry> diff --git a/libnm-core/nm-dbus-utils.c b/libnm-core/nm-dbus-utils.c index 469773cf..83092948 100644 --- a/libnm-core/nm-dbus-utils.c +++ b/libnm-core/nm-dbus-utils.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-errors.c b/libnm-core/nm-errors.c index d6aa1ed3..9aa25ff8 100644 --- a/libnm-core/nm-errors.c +++ b/libnm-core/nm-errors.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2004 - 2014 Red Hat, Inc. + * Copyright (C) 2004 - 2014 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-errors.h b/libnm-core/nm-errors.h index 7350fe3b..0b54133d 100644 --- a/libnm-core/nm-errors.h +++ b/libnm-core/nm-errors.h @@ -1,19 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2004 - 2014 Red Hat, Inc. + * Copyright (C) 2004 - 2014 Red Hat, Inc. */ #ifndef __NM_ERRORS_H__ diff --git a/libnm-core/nm-json.c b/libnm-core/nm-json.c index aa181a4a..001d53db 100644 --- a/libnm-core/nm-json.c +++ b/libnm-core/nm-json.c @@ -1,19 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2017, 2018 Red Hat, Inc. + * Copyright (C) 2017, 2018 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-json.h b/libnm-core/nm-json.h index b75a4f8e..d857fe02 100644 --- a/libnm-core/nm-json.h +++ b/libnm-core/nm-json.h @@ -1,20 +1,8 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2017, 2018 Red Hat, Inc. + * Copyright (C) 2017, 2018 Red Hat, Inc. */ + #ifndef __NM_JSON_H__ #define __NM_JSON_H__ diff --git a/libnm-core/nm-keyfile-internal.h b/libnm-core/nm-keyfile-internal.h index ced4ed97..42003a5f 100644 --- a/libnm-core/nm-keyfile-internal.h +++ b/libnm-core/nm-keyfile-internal.h @@ -1,19 +1,5 @@ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Copyright (C) 2008 Novell, Inc. * Copyright (C) 2015 Red Hat, Inc. */ diff --git a/libnm-core/nm-keyfile-utils.c b/libnm-core/nm-keyfile-utils.c index 522d5b71..e18db20d 100644 --- a/libnm-core/nm-keyfile-utils.c +++ b/libnm-core/nm-keyfile-utils.c @@ -1,20 +1,6 @@ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2010 Red Hat, Inc. +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2010 Red Hat, Inc. */ #include "nm-default.h" @@ -49,18 +35,28 @@ * to detect parsing failures. * * Returns: either %TRUE or %FALSE if the key exists and is parsable as a boolean. - * Otherwise, @default_value. + * Otherwise, @default_value. Sets errno to ENODATA, EINVAL or 0, depending on whether + * the key exists, whether the value is invalid, or success. */ int nm_key_file_get_boolean (GKeyFile *kf, const char *group, const char *key, int default_value) { + int v; gs_free char *value = NULL; value = g_key_file_get_value (kf, group, key, NULL); - if (!value) + if (!value) { + errno = ENODATA; return default_value; - return _nm_utils_ascii_str_to_bool (value, default_value); + } + v = _nm_utils_ascii_str_to_bool (value, -1); + if (v != -1) { + errno = 0; + return v; + } + errno = EINVAL; + return default_value; } /*****************************************************************************/ diff --git a/libnm-core/nm-keyfile-utils.h b/libnm-core/nm-keyfile-utils.h index 9c5b0143..7fb80717 100644 --- a/libnm-core/nm-keyfile-utils.h +++ b/libnm-core/nm-keyfile-utils.h @@ -1,20 +1,6 @@ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2010-2015 Red Hat, Inc. +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2010 - 2015 Red Hat, Inc. */ #ifndef __NM_KEYFILE_UTILS_H__ diff --git a/libnm-core/nm-keyfile.c b/libnm-core/nm-keyfile.c index 43253acf..535acccf 100644 --- a/libnm-core/nm-keyfile.c +++ b/libnm-core/nm-keyfile.c @@ -1,19 +1,5 @@ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Copyright (C) 2008 - 2009 Novell, Inc. * Copyright (C) 2008 - 2017 Red Hat, Inc. */ @@ -248,15 +234,16 @@ static gpointer build_route (KeyfileReaderInfo *info, const char *property_name, int family, - const char *dest_str, guint32 plen, - const char *gateway_str, const char *metric_str) + const char *dest_str, + guint32 plen, + const char *gateway_str, + const char *metric_str) { NMIPRoute *route; guint32 u32; gint64 metric = -1; GError *error = NULL; - g_return_val_if_fail (plen, NULL); g_return_val_if_fail (dest_str, NULL); /* Next hop */ @@ -294,7 +281,10 @@ build_route (KeyfileReaderInfo *info, metric = u32; } - route = nm_ip_route_new (family, dest_str, plen, gateway_str, + route = nm_ip_route_new (family, + dest_str, + plen, + gateway_str, metric, &error); if (!route) { @@ -517,8 +507,7 @@ read_one_ip_address_or_route (KeyfileReaderInfo *info, /* parse plen, fallback to defaults */ if (plen_str) { - if ( !get_one_int (info, property_name, plen_str, ipv6 ? 128 : 32, &plen) - || (route && plen == 0)) { + if (!get_one_int (info, property_name, plen_str, ipv6 ? 128 : 32, &plen)) { plen = DEFAULT_PREFIX (route, ipv6); if ( info->error || !handle_warn (info, property_name, NM_KEYFILE_WARN_SEVERITY_WARN, @@ -536,12 +525,19 @@ read_one_ip_address_or_route (KeyfileReaderInfo *info, /* build the appropriate data structure for NetworkManager settings */ if (route) { - result = build_route (info, property_name, + result = build_route (info, + property_name, ipv6 ? AF_INET6 : AF_INET, - address_str, plen, gateway_str, metric_str); + address_str, + plen, + gateway_str, + metric_str); } else { - result = build_address (info, ipv6 ? AF_INET6 : AF_INET, - address_str, plen, property_name); + result = build_address (info, + ipv6 ? AF_INET6 : AF_INET, + address_str, + plen, + property_name); if (!result) return NULL; if (gateway_str) diff --git a/libnm-core/nm-property-compare.c b/libnm-core/nm-property-compare.c index cb3ee0c2..a5d07c4f 100644 --- a/libnm-core/nm-property-compare.c +++ b/libnm-core/nm-property-compare.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-property-compare.h b/libnm-core/nm-property-compare.h index 13046caa..37fdcf2f 100644 --- a/libnm-core/nm-property-compare.h +++ b/libnm-core/nm-property-compare.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_PROPERTY_COMPARE_H__ diff --git a/libnm-core/nm-setting-6lowpan.c b/libnm-core/nm-setting-6lowpan.c index 3a2b084e..d6aa5978 100644 --- a/libnm-core/nm-setting-6lowpan.c +++ b/libnm-core/nm-setting-6lowpan.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 Red Hat, Inc. + * Copyright (C) 2018 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-6lowpan.h b/libnm-core/nm-setting-6lowpan.h index 73f57b7c..778f472d 100644 --- a/libnm-core/nm-setting-6lowpan.h +++ b/libnm-core/nm-setting-6lowpan.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 Red Hat, Inc. + * Copyright (C) 2018 Red Hat, Inc. */ #ifndef __NM_SETTING_6LOWPAN_H__ diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index 50568474..8464100d 100644 --- a/libnm-core/nm-setting-8021x.c +++ b/libnm-core/nm-setting-8021x.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -2440,7 +2426,7 @@ nm_setting_802_1x_get_auth_timeout (NMSetting8021x *setting) * Returns: %TRUE if the activation should proceed even when the 802.1X * authentication fails; %FALSE otherwise * - * Since: 1.20.6 + * Since: 1.22 **/ gboolean nm_setting_802_1x_get_optional (NMSetting8021x *setting) @@ -3849,7 +3835,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) /** * NMSetting8021x:phase2-auth: * - * Specifies the allowed "phase 2" inner non-EAP authentication methods when + * Specifies the allowed "phase 2" inner non-EAP authentication method when * an EAP method that uses an inner TLS tunnel is specified in the * #NMSetting8021x:eap property. Recognized non-EAP "phase 2" methods are * "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", and "tls". @@ -3874,7 +3860,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) /** * NMSetting8021x:phase2-autheap: * - * Specifies the allowed "phase 2" inner EAP-based authentication methods + * Specifies the allowed "phase 2" inner EAP-based authentication method * when an EAP method that uses an inner TLS tunnel is specified in the * #NMSetting8021x:eap property. Recognized EAP-based "phase 2" methods are * "md5", "mschapv2", "otp", "gtc", and "tls". Each "phase 2" inner method @@ -4449,7 +4435,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) * If set to %FALSE, the activation can continue only after a successful * authentication. * - * Since: 1.20.6 + * Since: 1.22 **/ /* ---ifcfg-rh--- * property: optional diff --git a/libnm-core/nm-setting-8021x.h b/libnm-core/nm-setting-8021x.h index 394ea22b..1bcca30c 100644 --- a/libnm-core/nm-setting-8021x.h +++ b/libnm-core/nm-setting-8021x.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_8021X_H__ @@ -84,9 +70,12 @@ typedef enum { /*< underscore_name=nm_setting_802_1x_ck_scheme >*/ * #NMSetting8021xAuthFlags values indicate which authentication settings * should be used. * + * Before 1.22, this was wrongly marked as a enum and not as a flags + * type. + * * Since: 1.8 */ -typedef enum { /*< underscore_name=nm_setting_802_1x_auth_flags >*/ +typedef enum { /*< flags, underscore_name=nm_setting_802_1x_auth_flags >*/ NM_SETTING_802_1X_AUTH_FLAGS_NONE = 0, NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_DISABLE = 0x1, NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_1_DISABLE = 0x2, @@ -358,7 +347,7 @@ NM_AVAILABLE_IN_1_8 NMSetting8021xAuthFlags nm_setting_802_1x_get_phase1_auth_flags (NMSetting8021x *setting); NM_AVAILABLE_IN_1_8 int nm_setting_802_1x_get_auth_timeout (NMSetting8021x *setting); -NM_AVAILABLE_IN_1_20_6 +NM_AVAILABLE_IN_1_22 gboolean nm_setting_802_1x_get_optional (NMSetting8021x *setting); G_END_DECLS diff --git a/libnm-core/nm-setting-adsl.c b/libnm-core/nm-setting-adsl.c index bd29a988..e9b86669 100644 --- a/libnm-core/nm-setting-adsl.c +++ b/libnm-core/nm-setting-adsl.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 - 2013 Red Hat, Inc. + * Copyright (C) 2011 - 2013 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-adsl.h b/libnm-core/nm-setting-adsl.h index c92f04ab..e02083ca 100644 --- a/libnm-core/nm-setting-adsl.h +++ b/libnm-core/nm-setting-adsl.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2008 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Red Hat, Inc. */ #ifndef __NM_SETTING_ADSL_H__ diff --git a/libnm-core/nm-setting-bluetooth.c b/libnm-core/nm-setting-bluetooth.c index 06618740..f175e5c0 100644 --- a/libnm-core/nm-setting-bluetooth.c +++ b/libnm-core/nm-setting-bluetooth.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -309,12 +295,7 @@ nm_setting_bluetooth_class_init (NMSettingBluetoothClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_BDADDR], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_to_dbus, - _nm_utils_hwaddr_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_BDADDR], &nm_sett_info_propert_type_mac_addrees); /** * NMSettingBluetooth:type: diff --git a/libnm-core/nm-setting-bluetooth.h b/libnm-core/nm-setting-bluetooth.h index 407dfa76..bf78d217 100644 --- a/libnm-core/nm-setting-bluetooth.h +++ b/libnm-core/nm-setting-bluetooth.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2009 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2009 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_BLUETOOTH_H__ diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index ee32afb5..52da8ccf 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 - 2013 Red Hat, Inc. + * Copyright (C) 2011 - 2013 Red Hat, Inc. */ #include "nm-default.h" @@ -984,12 +970,7 @@ nm_setting_bond_class_init (NMSettingBondClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_OPTIONS], - G_VARIANT_TYPE ("a{ss}"), - _nm_utils_strdict_to_dbus, - _nm_utils_strdict_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_OPTIONS], &nm_sett_info_propert_type_strdict); /* ---dbus--- * property: interface-name @@ -999,11 +980,7 @@ nm_setting_bond_class_init (NMSettingBondClass *klass) * bond's interface name. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "interface-name", - G_VARIANT_TYPE_STRING, - _nm_setting_get_deprecated_virtual_interface_name, - NULL); + _nm_properties_override_dbus (properties_override, "interface-name", &nm_sett_info_propert_type_deprecated_interface_name); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-bond.h b/libnm-core/nm-setting-bond.h index 7b932ca9..c17babdc 100644 --- a/libnm-core/nm-setting-bond.h +++ b/libnm-core/nm-setting-bond.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 - 2013 Red Hat, Inc. + * Copyright (C) 2011 - 2013 Red Hat, Inc. */ #ifndef __NM_SETTING_BOND_H__ diff --git a/libnm-core/nm-setting-bridge-port.c b/libnm-core/nm-setting-bridge-port.c index e15f26a9..152ba944 100644 --- a/libnm-core/nm-setting-bridge-port.c +++ b/libnm-core/nm-setting-bridge-port.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2012 - 2013 Red Hat, Inc. + * Copyright (C) 2012 - 2013 Red Hat, Inc. */ #include "nm-default.h" @@ -587,17 +573,10 @@ nm_setting_bridge_port_class_init (NMSettingBridgePortClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_VLANS], - G_VARIANT_TYPE ("aa{sv}"), - _nm_utils_bridge_vlans_to_dbus, - _nm_utils_bridge_vlans_from_dbus, - NULL); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_VLANS], &nm_sett_info_propert_type_bridge_vlans); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); _nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_BRIDGE_PORT, NULL, properties_override); - } diff --git a/libnm-core/nm-setting-bridge-port.h b/libnm-core/nm-setting-bridge-port.h index 2d75ac0a..f86677ef 100644 --- a/libnm-core/nm-setting-bridge-port.h +++ b/libnm-core/nm-setting-bridge-port.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2012 Red Hat, Inc. + * Copyright (C) 2012 Red Hat, Inc. */ #ifndef __NM_SETTING_BRIDGE_PORT_H__ diff --git a/libnm-core/nm-setting-bridge.c b/libnm-core/nm-setting-bridge.c index d79e83ea..585f9ced 100644 --- a/libnm-core/nm-setting-bridge.c +++ b/libnm-core/nm-setting-bridge.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 - 2017 Red Hat, Inc. + * Copyright (C) 2011 - 2017 Red Hat, Inc. */ #include "nm-default.h" @@ -1223,12 +1209,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_MAC_ADDRESS], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_to_dbus, - _nm_utils_hwaddr_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_MAC_ADDRESS], &nm_sett_info_propert_type_mac_addrees); /** * NMSettingBridge:stp: @@ -1480,13 +1461,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_VLANS], - G_VARIANT_TYPE ("aa{sv}"), - _nm_utils_bridge_vlans_to_dbus, - _nm_utils_bridge_vlans_from_dbus, - NULL); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_VLANS], &nm_sett_info_propert_type_bridge_vlans); /* ---dbus--- * property: interface-name @@ -1496,11 +1471,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *klass) * bridge's interface name. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "interface-name", - G_VARIANT_TYPE_STRING, - _nm_setting_get_deprecated_virtual_interface_name, - NULL); + _nm_properties_override_dbus (properties_override, "interface-name", &nm_sett_info_propert_type_deprecated_interface_name); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-bridge.h b/libnm-core/nm-setting-bridge.h index 9d507d53..ee8b45f6 100644 --- a/libnm-core/nm-setting-bridge.h +++ b/libnm-core/nm-setting-bridge.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 - 2015 Red Hat, Inc. + * Copyright (C) 2011 - 2015 Red Hat, Inc. */ #ifndef __NM_SETTING_BRIDGE_H__ diff --git a/libnm-core/nm-setting-cdma.c b/libnm-core/nm-setting-cdma.c index d8c2f462..60be8c8f 100644 --- a/libnm-core/nm-setting-cdma.c +++ b/libnm-core/nm-setting-cdma.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2013 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-cdma.h b/libnm-core/nm-setting-cdma.h index 1c0d5947..fcc59766 100644 --- a/libnm-core/nm-setting-cdma.h +++ b/libnm-core/nm-setting-cdma.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2011 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_CDMA_H__ diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index 8c5fe941..a13e3f23 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -1749,13 +1735,13 @@ nm_setting_connection_class_init (NMSettingConnectionClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_INTERFACE_NAME], - G_VARIANT_TYPE_STRING, - NULL, - nm_setting_connection_set_interface_name, - nm_setting_connection_no_interface_name); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_INTERFACE_NAME], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_STRING, + .from_dbus_fcn = nm_setting_connection_set_interface_name, + .missing_from_dbus_fcn = nm_setting_connection_no_interface_name, + )); /** * NMSettingConnection:type: @@ -1934,13 +1920,12 @@ nm_setting_connection_class_init (NMSettingConnectionClass *klass) G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_TIMESTAMP], - G_VARIANT_TYPE_UINT64, - _to_dbus_fcn_timestamp, - NULL, - NULL); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_TIMESTAMP], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_UINT64, + .to_dbus_fcn = _to_dbus_fcn_timestamp, + )); /** * NMSettingConnection:read-only: diff --git a/libnm-core/nm-setting-connection.h b/libnm-core/nm-setting-connection.h index a3c1334d..b93e9b4d 100644 --- a/libnm-core/nm-setting-connection.h +++ b/libnm-core/nm-setting-connection.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_CONNECTION_H__ diff --git a/libnm-core/nm-setting-dcb.c b/libnm-core/nm-setting-dcb.c index 9feb4ea2..3c12abdf 100644 --- a/libnm-core/nm-setting-dcb.c +++ b/libnm-core/nm-setting-dcb.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2013 Red Hat, Inc. + * Copyright (C) 2013 Red Hat, Inc. */ #include "nm-default.h" @@ -757,6 +743,12 @@ _nm_setting_dcb_uint_array_from_dbus (GVariant *dbus_value, set_gvalue_from_array (prop_value, (guint *) array, length); } +static const NMSettInfoPropertType nm_sett_info_propert_type_dcb_au = { + .dbus_type = NM_G_VARIANT_TYPE ("au"), + .gprop_to_dbus_fcn = _nm_setting_dcb_uint_array_to_dbus, + .gprop_from_dbus_fcn = _nm_setting_dcb_uint_array_from_dbus, +}; + /*****************************************************************************/ static void @@ -1111,12 +1103,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *klass) G_TYPE_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_PRIORITY_FLOW_CONTROL], - G_VARIANT_TYPE ("au"), - _nm_setting_dcb_uint_array_to_dbus, - _nm_setting_dcb_uint_array_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_PRIORITY_FLOW_CONTROL], &nm_sett_info_propert_type_dcb_au); /** * NMSettingDcb:priority-group-flags: @@ -1159,12 +1146,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *klass) G_TYPE_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_PRIORITY_GROUP_ID], - G_VARIANT_TYPE ("au"), - _nm_setting_dcb_uint_array_to_dbus, - _nm_setting_dcb_uint_array_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_PRIORITY_GROUP_ID], &nm_sett_info_propert_type_dcb_au); /** * NMSettingDcb:priority-group-bandwidth: (type GArray(guint)) @@ -1186,12 +1168,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *klass) G_TYPE_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_PRIORITY_GROUP_BANDWIDTH], - G_VARIANT_TYPE ("au"), - _nm_setting_dcb_uint_array_to_dbus, - _nm_setting_dcb_uint_array_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_PRIORITY_GROUP_BANDWIDTH], &nm_sett_info_propert_type_dcb_au); /** * NMSettingDcb:priority-bandwidth: (type GArray(guint)) @@ -1215,12 +1192,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *klass) G_TYPE_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_PRIORITY_BANDWIDTH], - G_VARIANT_TYPE ("au"), - _nm_setting_dcb_uint_array_to_dbus, - _nm_setting_dcb_uint_array_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_PRIORITY_BANDWIDTH], &nm_sett_info_propert_type_dcb_au); /** * NMSettingDcb:priority-strict-bandwidth: (type GArray(gboolean)) @@ -1242,12 +1214,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *klass) G_TYPE_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_PRIORITY_STRICT_BANDWIDTH], - G_VARIANT_TYPE ("au"), - _nm_setting_dcb_uint_array_to_dbus, - _nm_setting_dcb_uint_array_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_PRIORITY_STRICT_BANDWIDTH], &nm_sett_info_propert_type_dcb_au); /** * NMSettingDcb:priority-traffic-class: (type GArray(guint)) @@ -1268,12 +1235,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *klass) G_TYPE_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_PRIORITY_TRAFFIC_CLASS], - G_VARIANT_TYPE ("au"), - _nm_setting_dcb_uint_array_to_dbus, - _nm_setting_dcb_uint_array_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_PRIORITY_TRAFFIC_CLASS], &nm_sett_info_propert_type_dcb_au); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-dcb.h b/libnm-core/nm-setting-dcb.h index 842f5303..b106ebd5 100644 --- a/libnm-core/nm-setting-dcb.h +++ b/libnm-core/nm-setting-dcb.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2013 Red Hat, Inc. + * Copyright (C) 2013 Red Hat, Inc. */ #ifndef __NM_SETTING_DCB_H__ diff --git a/libnm-core/nm-setting-dummy.c b/libnm-core/nm-setting-dummy.c index 6a2a5d0f..bb84a9fa 100644 --- a/libnm-core/nm-setting-dummy.c +++ b/libnm-core/nm-setting-dummy.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-dummy.h b/libnm-core/nm-setting-dummy.h index 1fe2bbf7..acdf68a6 100644 --- a/libnm-core/nm-setting-dummy.h +++ b/libnm-core/nm-setting-dummy.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #ifndef __NM_SETTING_DUMMY_H__ diff --git a/libnm-core/nm-setting-ethtool.c b/libnm-core/nm-setting-ethtool.c index 555ac34d..a8976b69 100644 --- a/libnm-core/nm-setting-ethtool.c +++ b/libnm-core/nm-setting-ethtool.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 Red Hat, Inc. + * Copyright (C) 2018 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-ethtool.h b/libnm-core/nm-setting-ethtool.h index 7b747be9..ba8c6a6e 100644 --- a/libnm-core/nm-setting-ethtool.h +++ b/libnm-core/nm-setting-ethtool.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 Red Hat, Inc. + * Copyright (C) 2018 Red Hat, Inc. */ #ifndef __NM_SETTING_ETHTOOL_H__ diff --git a/libnm-core/nm-setting-generic.c b/libnm-core/nm-setting-generic.c index 95f42de2..385ff6cb 100644 --- a/libnm-core/nm-setting-generic.c +++ b/libnm-core/nm-setting-generic.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2013 Red Hat, Inc. + * Copyright (C) 2013 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-generic.h b/libnm-core/nm-setting-generic.h index 15f40231..f764bc48 100644 --- a/libnm-core/nm-setting-generic.h +++ b/libnm-core/nm-setting-generic.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2013 Red Hat, Inc. + * Copyright (C) 2013 Red Hat, Inc. */ #ifndef __NM_SETTING_GENERIC_H__ diff --git a/libnm-core/nm-setting-gsm.c b/libnm-core/nm-setting-gsm.c index bf2e7b23..4bc957d3 100644 --- a/libnm-core/nm-setting-gsm.c +++ b/libnm-core/nm-setting-gsm.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -38,6 +24,7 @@ /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_AUTO_CONFIG, PROP_NUMBER, PROP_USERNAME, PROP_PASSWORD, @@ -54,6 +41,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( ); typedef struct { + gboolean auto_config; + char *number; /* For dialing, duh */ char *username; char *password; @@ -81,6 +70,22 @@ G_DEFINE_TYPE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING) /*****************************************************************************/ /** + * nm_setting_gsm_get_auto_config: + * @setting: the #NMSettingGsm + * + * Returns: the #NMSettingGsm:auto-config property of the setting + * + * Since: 1.22 + **/ +gboolean +nm_setting_gsm_get_auto_config (NMSettingGsm *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_GSM (setting), FALSE); + + return NM_SETTING_GSM_GET_PRIVATE (setting)->auto_config; +} + +/** * nm_setting_gsm_get_number: * @setting: the #NMSettingGsm * @@ -287,10 +292,10 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } if (priv->apn) { - guint32 apn_len = strlen (priv->apn); - guint32 i; + gsize apn_len = strlen (priv->apn); + gsize i; - if (apn_len < 1 || apn_len > 64) { + if (apn_len > 64) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -334,7 +339,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } } - if (priv->username && !strlen (priv->username)) { + if ( priv->username + && priv->username[0] == '\0') { g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -344,8 +350,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } if (priv->network_id) { - guint32 nid_len = strlen (priv->network_id); - guint32 i; + gsize nid_len = strlen (priv->network_id); + gsize i; /* Accept both 5 and 6 digit MCC/MNC codes */ if ((nid_len < 5) || (nid_len > 6)) { @@ -414,6 +420,16 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } } + if ( priv->auto_config + && (priv->apn || priv->username || priv->password)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("can't be enabled when manual configuration is present")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_AUTO_CONFIG); + return NM_SETTING_VERIFY_NORMALIZABLE_ERROR; + } + return TRUE; } @@ -454,6 +470,9 @@ get_property (GObject *object, guint prop_id, NMSettingGsm *setting = NM_SETTING_GSM (object); switch (prop_id) { + case PROP_AUTO_CONFIG: + g_value_set_boolean (value, nm_setting_gsm_get_auto_config (setting)); + break; case PROP_NUMBER: g_value_set_string (value, nm_setting_gsm_get_number (setting)); break; @@ -507,6 +526,9 @@ set_property (GObject *object, guint prop_id, char *tmp; switch (prop_id) { + case PROP_AUTO_CONFIG: + priv->auto_config = g_value_get_boolean (value); + break; case PROP_NUMBER: g_free (priv->number); priv->number = g_value_dup_string (value); @@ -623,6 +645,21 @@ nm_setting_gsm_class_init (NMSettingGsmClass *klass) setting_class->need_secrets = need_secrets; /** + * NMSettingGsm:auto-config: + * + * When %TRUE, the settings such as APN, username, or password will + * default to values that match the network the modem will register + * to in the Mobile Broadband Provider database. + * + * Since: 1.22 + **/ + obj_properties[PROP_AUTO_CONFIG] = + g_param_spec_boolean (NM_SETTING_GSM_AUTO_CONFIG, "", "", + FALSE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + + /** * NMSettingGsm:number: * * Legacy setting that used to help establishing PPP data sessions for @@ -810,17 +847,8 @@ nm_setting_gsm_class_init (NMSettingGsmClass *klass) G_PARAM_STATIC_STRINGS); /* Ignore incoming deprecated properties */ - _properties_override_add_dbus_only (properties_override, - "allowed-bands", - G_VARIANT_TYPE_UINT32, - NULL, - NULL); - - _properties_override_add_dbus_only (properties_override, - "network-type", - G_VARIANT_TYPE_INT32, - NULL, - NULL); + _nm_properties_override_dbus (properties_override, "allowed-bands", &nm_sett_info_propert_type_deprecated_ignore_u); + _nm_properties_override_dbus (properties_override, "network-type", &nm_sett_info_propert_type_deprecated_ignore_i); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-gsm.h b/libnm-core/nm-setting-gsm.h index 8dc0fb48..170040a7 100644 --- a/libnm-core/nm-setting-gsm.h +++ b/libnm-core/nm-setting-gsm.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2011 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_GSM_H__ @@ -38,6 +24,7 @@ G_BEGIN_DECLS #define NM_SETTING_GSM_SETTING_NAME "gsm" +#define NM_SETTING_GSM_AUTO_CONFIG "auto-config" #define NM_SETTING_GSM_USERNAME "username" #define NM_SETTING_GSM_PASSWORD "password" #define NM_SETTING_GSM_PASSWORD_FLAGS "password-flags" @@ -73,6 +60,10 @@ typedef struct { GType nm_setting_gsm_get_type (void); NMSetting *nm_setting_gsm_new (void); + +NM_AVAILABLE_IN_1_22 +gboolean nm_setting_gsm_get_auto_config (NMSettingGsm *setting); + const char *nm_setting_gsm_get_username (NMSettingGsm *setting); const char *nm_setting_gsm_get_password (NMSettingGsm *setting); const char *nm_setting_gsm_get_apn (NMSettingGsm *setting); diff --git a/libnm-core/nm-setting-infiniband.c b/libnm-core/nm-setting-infiniband.c index dc3bcdd5..d03a7a2a 100644 --- a/libnm-core/nm-setting-infiniband.c +++ b/libnm-core/nm-setting-infiniband.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 - 2013 Red Hat, Inc. + * Copyright (C) 2011 - 2013 Red Hat, Inc. */ #include "nm-default.h" @@ -428,12 +414,7 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_MAC_ADDRESS], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_to_dbus, - _nm_utils_hwaddr_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_MAC_ADDRESS], &nm_sett_info_propert_type_mac_addrees); /** * NMSettingInfiniband:mtu: diff --git a/libnm-core/nm-setting-infiniband.h b/libnm-core/nm-setting-infiniband.h index ea8ba47c..9fb1ee50 100644 --- a/libnm-core/nm-setting-infiniband.h +++ b/libnm-core/nm-setting-infiniband.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 Red Hat, Inc. + * Copyright (C) 2011 Red Hat, Inc. */ #ifndef __NM_SETTING_INFINIBAND_H__ diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c index 458d93b3..49a3efbd 100644 --- a/libnm-core/nm-setting-ip-config.c +++ b/libnm-core/nm-setting-ip-config.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2017 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2017 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -303,49 +289,62 @@ nm_ip_address_unref (NMIPAddress *address) } /** - * _nm_ip_address_equal: - * @address: the #NMIPAddress - * @other: the #NMIPAddress to compare @address to. - * @consider_attributes: whether to check for equality of attributes too. + * nm_ip_address_cmp_full: + * @a: the #NMIPAddress + * @b: the #NMIPAddress to compare @address to. + * @cmp_flags: the #NMIPAddressCmpFlags that indicate what to compare. * - * Determines if two #NMIPAddress objects are equal. + * Note that with @cmp_flags #NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS, there + * is no total order for comparing GVariant. That means, if the two addresses + * only differ by their attributes, the sort order is undefined and the return + * value only indicates equality. * - * Returns: %TRUE if the objects contain the same values, %FALSE if they do not. + * Returns: 0 if the two objects have the same values (according to their flags) + * or a integer indicating the compare order. **/ -static gboolean -_nm_ip_address_equal (NMIPAddress *address, NMIPAddress *other, gboolean consider_attributes) +int +nm_ip_address_cmp_full (const NMIPAddress *a, const NMIPAddress *b, NMIPAddressCmpFlags cmp_flags) { - g_return_val_if_fail (address != NULL, FALSE); - g_return_val_if_fail (address->refcount > 0, FALSE); + g_return_val_if_fail (!a || a->refcount > 0, 0); + g_return_val_if_fail (!b || b->refcount > 0, 0); + g_return_val_if_fail (!NM_FLAGS_ANY (cmp_flags, ~NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS), 0); - g_return_val_if_fail (other != NULL, FALSE); - g_return_val_if_fail (other->refcount > 0, FALSE); + NM_CMP_SELF (a, b); - if ( address->family != other->family - || address->prefix != other->prefix - || strcmp (address->address, other->address) != 0) - return FALSE; - if (consider_attributes) { + NM_CMP_FIELD (a, b, family); + NM_CMP_FIELD (a, b, prefix); + NM_CMP_FIELD_STR (a, b, address); + + if (NM_FLAGS_HAS (cmp_flags, NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS)) { GHashTableIter iter; const char *key; GVariant *value, *value2; guint n; - n = address->attributes ? g_hash_table_size (address->attributes) : 0; - if (n != (other->attributes ? g_hash_table_size (other->attributes) : 0)) - return FALSE; - if (n) { - g_hash_table_iter_init (&iter, address->attributes); + n = a->attributes ? g_hash_table_size (a->attributes) : 0u; + NM_CMP_DIRECT (n, (b->attributes ? g_hash_table_size (b->attributes) : 0u)); + + if (n > 0) { + g_hash_table_iter_init (&iter, a->attributes); while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) { - value2 = g_hash_table_lookup (other->attributes, key); + value2 = g_hash_table_lookup (b->attributes, key); + /* We cannot really compare GVariants, because g_variant_compare() does + * not work in general. So, don't bother. NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS is + * documented to not provide a total order for the attribute contents. + * + * Theoretically, we can implement also a total order. However we should + * not do that by default because it would require us to sort the keys + * first. Most callers don't care about total order, so they shouldn't + * pay the overhead. */ if (!value2) - return FALSE; + return -2; if (!g_variant_equal (value, value2)) - return FALSE; + return -2; } } } - return TRUE; + + return 0; } /** @@ -361,7 +360,7 @@ _nm_ip_address_equal (NMIPAddress *address, NMIPAddress *other, gboolean conside gboolean nm_ip_address_equal (NMIPAddress *address, NMIPAddress *other) { - return _nm_ip_address_equal (address, other, FALSE); + return nm_ip_address_cmp_full (address, other, NM_IP_ADDRESS_CMP_FLAGS_NONE) == 0; } /** @@ -792,8 +791,8 @@ nm_ip_route_equal_full (NMIPRoute *route, NMIPRoute *other, guint cmp_flags) GVariant *value, *value2; guint n; - n = route->attributes ? g_hash_table_size (route->attributes) : 0; - if (n != (other->attributes ? g_hash_table_size (other->attributes) : 0)) + n = route->attributes ? g_hash_table_size (route->attributes) : 0u; + if (n != (other->attributes ? g_hash_table_size (other->attributes) : 0u)) return FALSE; if (n) { g_hash_table_iter_init (&iter, route->attributes); @@ -1211,21 +1210,22 @@ nm_ip_route_set_attribute (NMIPRoute *route, const char *name, GVariant *value) } static const NMVariantAttributeSpec *const ip_route_attribute_spec[] = { - NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_TABLE, G_VARIANT_TYPE_UINT32, .v4 = TRUE, .v6 = TRUE, ), - NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_SRC, G_VARIANT_TYPE_STRING, .v4 = TRUE, .v6 = TRUE, .str_type = 'a', ), - NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_FROM, G_VARIANT_TYPE_STRING, .v6 = TRUE, .str_type = 'p', ), - NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_TOS, G_VARIANT_TYPE_BYTE, .v4 = TRUE, ), - NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_ONLINK, G_VARIANT_TYPE_BOOLEAN, .v4 = TRUE, .v6 = TRUE, ), - NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_WINDOW, G_VARIANT_TYPE_UINT32, .v4 = TRUE, .v6 = TRUE, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_CWND, G_VARIANT_TYPE_UINT32, .v4 = TRUE, .v6 = TRUE, ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_FROM, G_VARIANT_TYPE_STRING, .v6 = TRUE, .str_type = 'p', ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_INITCWND, G_VARIANT_TYPE_UINT32, .v4 = TRUE, .v6 = TRUE, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_INITRWND, G_VARIANT_TYPE_UINT32, .v4 = TRUE, .v6 = TRUE, ), - NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_MTU, G_VARIANT_TYPE_UINT32, .v4 = TRUE, .v6 = TRUE, ), - NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_LOCK_WINDOW, G_VARIANT_TYPE_BOOLEAN, .v4 = TRUE, .v6 = TRUE, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_LOCK_CWND, G_VARIANT_TYPE_BOOLEAN, .v4 = TRUE, .v6 = TRUE, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_LOCK_INITCWND, G_VARIANT_TYPE_BOOLEAN, .v4 = TRUE, .v6 = TRUE, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_LOCK_INITRWND, G_VARIANT_TYPE_BOOLEAN, .v4 = TRUE, .v6 = TRUE, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_LOCK_MTU, G_VARIANT_TYPE_BOOLEAN, .v4 = TRUE, .v6 = TRUE, ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_LOCK_WINDOW, G_VARIANT_TYPE_BOOLEAN, .v4 = TRUE, .v6 = TRUE, ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_MTU, G_VARIANT_TYPE_UINT32, .v4 = TRUE, .v6 = TRUE, ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_ONLINK, G_VARIANT_TYPE_BOOLEAN, .v4 = TRUE, .v6 = TRUE, ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_SCOPE, G_VARIANT_TYPE_BYTE, .v4 = TRUE, ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_SRC, G_VARIANT_TYPE_STRING, .v4 = TRUE, .v6 = TRUE, .str_type = 'a', ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_TABLE, G_VARIANT_TYPE_UINT32, .v4 = TRUE, .v6 = TRUE, ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_TOS, G_VARIANT_TYPE_BYTE, .v4 = TRUE, ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE (NM_IP_ROUTE_ATTRIBUTE_WINDOW, G_VARIANT_TYPE_UINT32, .v4 = TRUE, .v6 = TRUE, ), NULL, }; @@ -1264,21 +1264,16 @@ nm_ip_route_attribute_validate (const char *name, gboolean *known, GError **error) { - const NMVariantAttributeSpec *const *iter; - const NMVariantAttributeSpec *spec = NULL; + const NMVariantAttributeSpec *spec; g_return_val_if_fail (name, FALSE); g_return_val_if_fail (value, FALSE); g_return_val_if_fail (family == AF_INET || family == AF_INET6, FALSE); g_return_val_if_fail (!error || !*error, FALSE); - for (iter = ip_route_attribute_spec; *iter; iter++) { - if (nm_streq (name, (*iter)->name)) { - spec = *iter; - break; - } - } - + spec = _nm_variant_attribute_spec_find_binary_search (ip_route_attribute_spec, + G_N_ELEMENTS (ip_route_attribute_spec) - 1, + name); if (!spec) { NM_SET_OUT (known, FALSE); g_set_error_literal (error, @@ -1312,8 +1307,6 @@ nm_ip_route_attribute_validate (const char *name, if (g_variant_type_equal (spec->type, G_VARIANT_TYPE_STRING)) { const char *string = g_variant_get_string (value, NULL); - gs_free char *string_free = NULL; - char *sep; switch (spec->str_type) { case 'a': /* IP address */ @@ -1328,30 +1321,35 @@ nm_ip_route_attribute_validate (const char *name, return FALSE; } break; - case 'p': /* IP address + optional prefix */ - string_free = g_strdup (string); - sep = strchr (string_free, '/'); - if (sep) { - *sep = 0; - if (_nm_utils_ascii_str_to_int64 (sep + 1, 10, 1, family == AF_INET ? 32 : 128, -1) < 0) { + case 'p': /* IP address + optional prefix */ { + gs_free char *addr_free = NULL; + const char *addr = string; + const char *str; + + str = strchr (addr, '/'); + if (str) { + addr = nm_strndup_a (200, addr, str - addr, &addr_free); + str++; + if (_nm_utils_ascii_str_to_int64 (str, 10, 0, family == AF_INET ? 32 : 128, -1) < 0) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED, - _("invalid prefix %s"), sep + 1); + _("invalid prefix %s"), str); return FALSE; } } - if (!nm_utils_ipaddr_valid (family, string_free)) { + if (!nm_utils_ipaddr_valid (family, addr)) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED, family == AF_INET ? _("'%s' is not a valid IPv4 address") : _("'%s' is not a valid IPv6 address"), - string_free); + string); return FALSE; } break; + } default: break; } @@ -3110,7 +3108,8 @@ nm_ip_routing_rule_from_string (const char *str, goto next_words_consumed; } if (NM_IN_STRSET (word0, "not")) { - /* we accept multiple "not" specifiers. */ + /* we accept multiple "not" specifiers. "not not" still means + * not. */ val_invert = TRUE; goto next_words_consumed; } @@ -3460,15 +3459,15 @@ nm_ip_routing_rule_to_string (const NMIPRoutingRule *self, str = g_string_sized_new (30); - if (self->invert) - g_string_append (str, "not"); - if (self->priority_has) { g_string_append_printf (nm_gstring_add_space_delimiter (str), "priority %u", (guint) self->priority); } + if (self->invert) + g_string_append (nm_gstring_add_space_delimiter (str), "not"); + _rr_string_append_inet_addr (str, TRUE, ( !self->to_has @@ -3589,11 +3588,13 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingIPConfig, PROP_IGNORE_AUTO_ROUTES, PROP_IGNORE_AUTO_DNS, PROP_DHCP_HOSTNAME, + PROP_DHCP_HOSTNAME_FLAGS, PROP_DHCP_SEND_HOSTNAME, PROP_NEVER_DEFAULT, PROP_MAY_FAIL, PROP_DAD_TIMEOUT, PROP_DHCP_TIMEOUT, + PROP_DHCP_IAID, ); typedef struct { @@ -3616,6 +3617,8 @@ typedef struct { gboolean may_fail; int dad_timeout; int dhcp_timeout; + char *dhcp_iaid; + guint dhcp_hostname_flags; } NMSettingIPConfigPrivate; G_DEFINE_ABSTRACT_TYPE (NMSettingIPConfig, nm_setting_ip_config, NM_TYPE_SETTING) @@ -4851,6 +4854,25 @@ nm_setting_ip_config_get_dad_timeout (NMSettingIPConfig *setting) } /** + * nm_setting_ip_config_get_dhcp_hostname_flags: + * @setting: the #NMSettingIPConfig + * + * Returns the value contained in the #NMSettingIPConfig:dhcp-hostname-flags + * property. + * + * Returns: flags for the DHCP hostname and FQDN + * + * Since: 1.22 + */ +NMDhcpHostnameFlags +nm_setting_ip_config_get_dhcp_hostname_flags (NMSettingIPConfig *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_IP_CONFIG (setting), NM_DHCP_HOSTNAME_FLAG_NONE); + + return NM_SETTING_IP_CONFIG_GET_PRIVATE (setting)->dhcp_hostname_flags; +} + +/** * nm_setting_ip_config_get_dhcp_timeout: * @setting: the #NMSettingIPConfig * @@ -4870,6 +4892,25 @@ nm_setting_ip_config_get_dhcp_timeout (NMSettingIPConfig *setting) return NM_SETTING_IP_CONFIG_GET_PRIVATE (setting)->dhcp_timeout; } +/** + * nm_setting_ip_config_get_dhcp_iaid: + * @setting: the #NMSettingIPConfig + * + * Returns the value contained in the #NMSettingIPConfig:dhcp-iaid + * property. + * + * Returns: the configured DHCP IAID (Identity Association Identifier) + * + * Since: 1.22 + **/ +const char * +nm_setting_ip_config_get_dhcp_iaid (NMSettingIPConfig *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_IP_CONFIG (setting), NULL); + + return NM_SETTING_IP_CONFIG_GET_PRIVATE (setting)->dhcp_iaid; +} + static gboolean verify_label (const char *label) { @@ -5001,15 +5042,6 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), NM_SETTING_IP_CONFIG_ROUTES); return FALSE; } - if (nm_ip_route_get_prefix (route) == 0) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("%d. route cannot be a default route"), - (int) (i + 1)); - g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), NM_SETTING_IP_CONFIG_ROUTES); - return FALSE; - } } if (priv->routing_rules) { @@ -5039,6 +5071,43 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } } + if ( priv->dhcp_iaid + && !_nm_utils_iaid_verify (priv->dhcp_iaid, NULL)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not a valid IAID"), + priv->dhcp_iaid); + g_prefix_error (error, "%s.%s: ", + nm_setting_get_name (setting), + NM_SETTING_IP_CONFIG_DHCP_IAID); + return FALSE; + } + + /* Validate DHCP hostname flags */ + if ( priv->dhcp_hostname_flags != NM_DHCP_HOSTNAME_FLAG_NONE + && !priv->dhcp_send_hostname) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("the property cannot be set when '%s' is disabled"), + NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME); + g_prefix_error (error, "%s.%s: ", + nm_setting_get_name (setting), + NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS); + return FALSE; + } + + if (!_nm_utils_validate_dhcp_hostname_flags (priv->dhcp_hostname_flags, + NM_SETTING_IP_CONFIG_GET_FAMILY (setting), + error)) { + g_prefix_error (error, "%s.%s: ", + nm_setting_get_name (setting), + NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS); + return FALSE; + } + + /* Normalizable errors */ if (priv->gateway && priv->never_default) { g_set_error (error, NM_CONNECTION_ERROR, @@ -5073,7 +5142,9 @@ compare_property (const NMSettInfoSetting *sett_info, if (a_priv->addresses->len != b_priv->addresses->len) return FALSE; for (i = 0; i < a_priv->addresses->len; i++) { - if (!_nm_ip_address_equal (a_priv->addresses->pdata[i], b_priv->addresses->pdata[i], TRUE)) + if (nm_ip_address_cmp_full (a_priv->addresses->pdata[i], + b_priv->addresses->pdata[i], + NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS) != 0) return FALSE; } } @@ -5213,12 +5284,12 @@ _nm_sett_info_property_override_create_array_ip_config (void) { GArray *properties_override = _nm_sett_info_property_override_create_array (); - _properties_override_add_override (properties_override, - obj_properties[PROP_GATEWAY], - G_VARIANT_TYPE_STRING, - NULL, - ip_gateway_set, - NULL); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_GATEWAY], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_STRING, + .from_dbus_fcn = ip_gateway_set, + )); /* ---dbus--- * property: routing-rules @@ -5226,11 +5297,13 @@ _nm_sett_info_property_override_create_array_ip_config (void) * description: Array of dictionaries for routing rules. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - NM_SETTING_IP_CONFIG_ROUTING_RULES, - G_VARIANT_TYPE ("aa{sv}"), - _routing_rules_dbus_only_synth, - _routing_rules_dbus_only_set); + _nm_properties_override_dbus (properties_override, + NM_SETTING_IP_CONFIG_ROUTING_RULES, + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = _routing_rules_dbus_only_synth, + .from_dbus_fcn = _routing_rules_dbus_only_set, + )); return properties_override; } @@ -5303,6 +5376,12 @@ get_property (GObject *object, guint prop_id, case PROP_DHCP_TIMEOUT: g_value_set_int (value, nm_setting_ip_config_get_dhcp_timeout (setting)); break; + case PROP_DHCP_IAID: + g_value_set_string (value, nm_setting_ip_config_get_dhcp_iaid (setting)); + break; + case PROP_DHCP_HOSTNAME_FLAGS: + g_value_set_uint (value, nm_setting_ip_config_get_dhcp_hostname_flags (setting)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -5403,6 +5482,12 @@ set_property (GObject *object, guint prop_id, case PROP_DHCP_TIMEOUT: priv->dhcp_timeout = g_value_get_int (value); break; + case PROP_DHCP_IAID: + priv->dhcp_iaid = g_value_dup_string (value); + break; + case PROP_DHCP_HOSTNAME_FLAGS: + priv->dhcp_hostname_flags = g_value_get_uint (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -5432,6 +5517,7 @@ finalize (GObject *object) g_free (priv->method); g_free (priv->gateway); g_free (priv->dhcp_hostname); + g_free (priv->dhcp_iaid); g_ptr_array_unref (priv->dns); g_ptr_array_unref (priv->dns_search); @@ -5794,5 +5880,61 @@ nm_setting_ip_config_class_init (NMSettingIPConfigClass *klass) NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + /** + * NMSettingIPConfig:dhcp-iaid: + * + * A string containing the "Identity Association Identifier" (IAID) used + * by the DHCP client. The property is a 32-bit decimal value or a + * special value among "mac", "perm-mac", "ifname" and "stable". When + * set to "mac" (or "perm-mac"), the last 4 bytes of the current (or + * permanent) MAC address are used as IAID. When set to "ifname", the + * IAID is computed by hashing the interface name. The special value + * "stable" can be used to generate an IAID based on the stable-id (see + * connection.stable-id), a per-host key and the interface name. When + * the property is unset, the value from global configuration is used; + * if no global default is set then the IAID is assumed to be + * "ifname". Note that at the moment this property is ignored for IPv6 + * by dhclient, which always derives the IAID from the MAC address. + * + * Since: 1.22 + **/ + obj_properties[PROP_DHCP_IAID] = + g_param_spec_string (NM_SETTING_IP_CONFIG_DHCP_IAID, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + + /** + * NMSettingIPConfig:dhcp-hostname-flags: + * + * Flags for the DHCP hostname and FQDN. + * + * Currently this property only includes flags to control the FQDN flags + * set in the DHCP FQDN option. Supported FQDN flags are + * %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE, + * %NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED and + * %NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE. When no FQDN flag is set and + * %NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS is set, the DHCP FQDN option will + * contain no flag. Otherwise, if no FQDN flag is set and + * %NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS is not set, the standard FQDN flags + * are set in the request: + * %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE, + * %NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED for IPv4 and + * %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE for IPv6. + * + * When this property is set to the default value %NM_DHCP_HOSTNAME_FLAG_NONE, + * a global default is looked up in NetworkManager configuration. If that value + * is unset or also %NM_DHCP_HOSTNAME_FLAG_NONE, then the standard FQDN flags + * described above are sent in the DHCP requests. + * + * Since: 1.22 + */ + obj_properties[PROP_DHCP_HOSTNAME_FLAGS] = + g_param_spec_uint (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS, "", "", + 0, G_MAXUINT32, + NM_DHCP_HOSTNAME_FLAG_NONE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); } diff --git a/libnm-core/nm-setting-ip-config.h b/libnm-core/nm-setting-ip-config.h index 4a522367..ef3671c4 100644 --- a/libnm-core/nm-setting-ip-config.h +++ b/libnm-core/nm-setting-ip-config.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef NM_SETTING_IP_CONFIG_H @@ -32,6 +18,24 @@ G_BEGIN_DECLS #define NM_IP_ADDRESS_ATTRIBUTE_LABEL "label" +/** + * NMIPAddressCmpFlags: + * @NM_IP_ADDRESS_CMP_FLAGS_NONE: no flags. + * @NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS: when comparing two addresses, + * also consider their attributes. Warning: note that attributes are GVariants + * and they don't have a total order. In other words, if the address differs only + * by their attributes, the returned compare order is not total. In that case, + * the return value merely indicates equality (zero) or inequality. + * + * Compare flags for nm_ip_address_cmp_full(). + * + * Since: 1.22 + */ +typedef enum { /*< flags >*/ + NM_IP_ADDRESS_CMP_FLAGS_NONE = 0, + NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS = 0x1, +} NMIPAddressCmpFlags; + typedef struct NMIPAddress NMIPAddress; GType nm_ip_address_get_type (void); @@ -49,6 +53,10 @@ void nm_ip_address_ref (NMIPAddress *address); void nm_ip_address_unref (NMIPAddress *address); gboolean nm_ip_address_equal (NMIPAddress *address, NMIPAddress *other); +NM_AVAILABLE_IN_1_22 +int nm_ip_address_cmp_full (const NMIPAddress *a, + const NMIPAddress *b, + NMIPAddressCmpFlags cmp_flags); NMIPAddress *nm_ip_address_dup (NMIPAddress *address); int nm_ip_address_get_family (NMIPAddress *address); @@ -141,21 +149,22 @@ gboolean nm_ip_route_attribute_validate (const char *name, gboolean *known, GError **error); -#define NM_IP_ROUTE_ATTRIBUTE_TABLE "table" -#define NM_IP_ROUTE_ATTRIBUTE_SRC "src" -#define NM_IP_ROUTE_ATTRIBUTE_FROM "from" -#define NM_IP_ROUTE_ATTRIBUTE_TOS "tos" -#define NM_IP_ROUTE_ATTRIBUTE_ONLINK "onlink" -#define NM_IP_ROUTE_ATTRIBUTE_WINDOW "window" #define NM_IP_ROUTE_ATTRIBUTE_CWND "cwnd" +#define NM_IP_ROUTE_ATTRIBUTE_FROM "from" #define NM_IP_ROUTE_ATTRIBUTE_INITCWND "initcwnd" #define NM_IP_ROUTE_ATTRIBUTE_INITRWND "initrwnd" -#define NM_IP_ROUTE_ATTRIBUTE_MTU "mtu" -#define NM_IP_ROUTE_ATTRIBUTE_LOCK_WINDOW "lock-window" #define NM_IP_ROUTE_ATTRIBUTE_LOCK_CWND "lock-cwnd" #define NM_IP_ROUTE_ATTRIBUTE_LOCK_INITCWND "lock-initcwnd" #define NM_IP_ROUTE_ATTRIBUTE_LOCK_INITRWND "lock-initrwnd" #define NM_IP_ROUTE_ATTRIBUTE_LOCK_MTU "lock-mtu" +#define NM_IP_ROUTE_ATTRIBUTE_LOCK_WINDOW "lock-window" +#define NM_IP_ROUTE_ATTRIBUTE_MTU "mtu" +#define NM_IP_ROUTE_ATTRIBUTE_ONLINK "onlink" +#define NM_IP_ROUTE_ATTRIBUTE_SCOPE "scope" +#define NM_IP_ROUTE_ATTRIBUTE_SRC "src" +#define NM_IP_ROUTE_ATTRIBUTE_TABLE "table" +#define NM_IP_ROUTE_ATTRIBUTE_TOS "tos" +#define NM_IP_ROUTE_ATTRIBUTE_WINDOW "window" /*****************************************************************************/ @@ -320,24 +329,26 @@ char *nm_ip_routing_rule_to_string (const NMIPRoutingRule *self, #define NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX 30000 -#define NM_SETTING_IP_CONFIG_METHOD "method" -#define NM_SETTING_IP_CONFIG_DNS "dns" -#define NM_SETTING_IP_CONFIG_DNS_SEARCH "dns-search" -#define NM_SETTING_IP_CONFIG_DNS_OPTIONS "dns-options" -#define NM_SETTING_IP_CONFIG_DNS_PRIORITY "dns-priority" -#define NM_SETTING_IP_CONFIG_ADDRESSES "addresses" -#define NM_SETTING_IP_CONFIG_GATEWAY "gateway" -#define NM_SETTING_IP_CONFIG_ROUTES "routes" -#define NM_SETTING_IP_CONFIG_ROUTE_METRIC "route-metric" -#define NM_SETTING_IP_CONFIG_ROUTE_TABLE "route-table" -#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes" -#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns" -#define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME "dhcp-hostname" -#define NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname" -#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT "never-default" -#define NM_SETTING_IP_CONFIG_MAY_FAIL "may-fail" -#define NM_SETTING_IP_CONFIG_DAD_TIMEOUT "dad-timeout" -#define NM_SETTING_IP_CONFIG_DHCP_TIMEOUT "dhcp-timeout" +#define NM_SETTING_IP_CONFIG_METHOD "method" +#define NM_SETTING_IP_CONFIG_DNS "dns" +#define NM_SETTING_IP_CONFIG_DNS_SEARCH "dns-search" +#define NM_SETTING_IP_CONFIG_DNS_OPTIONS "dns-options" +#define NM_SETTING_IP_CONFIG_DNS_PRIORITY "dns-priority" +#define NM_SETTING_IP_CONFIG_ADDRESSES "addresses" +#define NM_SETTING_IP_CONFIG_GATEWAY "gateway" +#define NM_SETTING_IP_CONFIG_ROUTES "routes" +#define NM_SETTING_IP_CONFIG_ROUTE_METRIC "route-metric" +#define NM_SETTING_IP_CONFIG_ROUTE_TABLE "route-table" +#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes" +#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns" +#define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME "dhcp-hostname" +#define NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname" +#define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS "dhcp-hostname-flags" +#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT "never-default" +#define NM_SETTING_IP_CONFIG_MAY_FAIL "may-fail" +#define NM_SETTING_IP_CONFIG_DAD_TIMEOUT "dad-timeout" +#define NM_SETTING_IP_CONFIG_DHCP_TIMEOUT "dhcp-timeout" +#define NM_SETTING_IP_CONFIG_DHCP_IAID "dhcp-iaid" /* these are not real GObject properties. */ #define NM_SETTING_IP_CONFIG_ROUTING_RULES "routing-rules" @@ -372,6 +383,45 @@ typedef struct { gpointer padding[8]; } NMSettingIPConfigClass; +/** + * NMDhcpHostnameFlags: + * @NM_DHCP_HOSTNAME_FLAG_NONE: no flag set. The default value from + * Networkmanager global configuration is used. If such value is unset + * or still zero, the DHCP request will use standard FQDN flags, i.e. + * %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE and + * %NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED for IPv4 and + * %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE for IPv6. + * @NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE: whether the server should + * do the A RR (FQDN-to-address) DNS updates. + * @NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED: if set, the FQDN is encoded + * using canonical wire format. Otherwise it uses the deprecated + * ASCII encoding. This flag is allowed only for DHCPv4. + * @NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE: when not set, request the + * server to perform updates (the PTR RR and possibly the A RR + * based on the %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE flag). If + * this is set, the %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE flag + * should be cleared. + * @NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS: when set, no FQDN flags are + * sent in the DHCP FQDN option. When cleared and all other FQDN + * flags are zero, standard FQDN flags are sent. This flag is + * incompatible with any other FQDN flag. + * + * #NMDhcpHostnameFlags describe flags related to the DHCP hostname and + * FQDN. + * + * Since: 1.22 + */ +typedef enum { /*< flags >*/ + NM_DHCP_HOSTNAME_FLAG_NONE = 0x0, + + NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE = 0x1, + NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED = 0x2, + NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE = 0x4, + + NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS = 0x8, + +} NMDhcpHostnameFlags; + GType nm_setting_ip_config_get_type (void); const char *nm_setting_ip_config_get_method (NMSettingIPConfig *setting); @@ -470,6 +520,11 @@ NM_AVAILABLE_IN_1_2 int nm_setting_ip_config_get_dad_timeout (NMSettingIPConfig *setting); NM_AVAILABLE_IN_1_2 int nm_setting_ip_config_get_dhcp_timeout (NMSettingIPConfig *setting); +NM_AVAILABLE_IN_1_22 +const char *nm_setting_ip_config_get_dhcp_iaid (NMSettingIPConfig *setting); + +NM_AVAILABLE_IN_1_22 +NMDhcpHostnameFlags nm_setting_ip_config_get_dhcp_hostname_flags (NMSettingIPConfig *setting); G_END_DECLS diff --git a/libnm-core/nm-setting-ip-tunnel.c b/libnm-core/nm-setting-ip-tunnel.c index b4921fea..3df89cdd 100644 --- a/libnm-core/nm-setting-ip-tunnel.c +++ b/libnm-core/nm-setting-ip-tunnel.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-ip-tunnel.h b/libnm-core/nm-setting-ip-tunnel.h index fae62d0d..39a0d6d7 100644 --- a/libnm-core/nm-setting-ip-tunnel.h +++ b/libnm-core/nm-setting-ip-tunnel.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #ifndef __NM_SETTING_IP_TUNNEL_H__ diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c index 73ba4b74..31c82220 100644 --- a/libnm-core/nm-setting-ip4-config.c +++ b/libnm-core/nm-setting-ip4-config.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2014 Red Hat, Inc. + * Copyright (C) 2014 Red Hat, Inc. */ #include "nm-default.h" @@ -208,6 +194,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } + if ( NM_FLAGS_ANY (nm_setting_ip_config_get_dhcp_hostname_flags (s_ip), + NM_DHCP_HOSTNAME_FLAGS_FQDN_MASK) + && !priv->dhcp_fqdn) { + /* Currently we send a FQDN option only when ipv4.dhcp-fqdn is set */ + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("FQDN flags requires a FQDN set")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS); + return FALSE; + } + /* Failures from here on are NORMALIZABLE_ERROR... */ if ( nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) @@ -777,6 +775,13 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) * ---end--- */ + /* ---ifcfg-rh--- + * property: dhcp-hostname-flags + * variable: DHCP_HOSTNAME_FLAGS + * description: flags for the DHCP hostname and FQDN properties + * example: DHCP_HOSTNAME_FLAGS=5 + */ + /** * NMSettingIP4Config:dhcp-fqdn: * @@ -810,12 +815,14 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) * integers) * ---end--- */ - _properties_override_add_transform (properties_override, - g_object_class_find_property (G_OBJECT_CLASS (setting_class), - NM_SETTING_IP_CONFIG_DNS), - G_VARIANT_TYPE ("au"), - ip4_dns_to_dbus, - ip4_dns_from_dbus); + _nm_properties_override_gobj (properties_override, + g_object_class_find_property (G_OBJECT_CLASS (setting_class), + NM_SETTING_IP_CONFIG_DNS), + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("au"), + .gprop_to_dbus_fcn = ip4_dns_to_dbus, + .gprop_from_dbus_fcn = ip4_dns_from_dbus, + )); /* ---dbus--- * property: addresses @@ -832,19 +839,20 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) * for that subnet. * ---end--- */ - _properties_override_add_override (properties_override, - g_object_class_find_property (G_OBJECT_CLASS (setting_class), - NM_SETTING_IP_CONFIG_ADDRESSES), - G_VARIANT_TYPE ("aau"), - ip4_addresses_get, - ip4_addresses_set, - NULL); - - _properties_override_add_dbus_only (properties_override, - "address-labels", - G_VARIANT_TYPE_STRING_ARRAY, - ip4_address_labels_get, - NULL); + _nm_properties_override_gobj (properties_override, + g_object_class_find_property (G_OBJECT_CLASS (setting_class), + NM_SETTING_IP_CONFIG_ADDRESSES), + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aau"), + .to_dbus_fcn = ip4_addresses_get, + .from_dbus_fcn = ip4_addresses_set, + )); + _nm_properties_override_dbus (properties_override, + "address-labels", + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_STRING_ARRAY, + .to_dbus_fcn = ip4_address_labels_get, + )); /* ---dbus--- * property: address-data @@ -855,11 +863,13 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) * also exist on some addresses. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "address-data", - G_VARIANT_TYPE ("aa{sv}"), - ip4_address_data_get, - ip4_address_data_set); + _nm_properties_override_dbus (properties_override, + "address-data", + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = ip4_address_data_get, + .from_dbus_fcn = ip4_address_data_set, + )); /* ---dbus--- * property: routes @@ -878,13 +888,14 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) * property.) * ---end--- */ - _properties_override_add_override (properties_override, - g_object_class_find_property (G_OBJECT_CLASS (setting_class), - NM_SETTING_IP_CONFIG_ROUTES), - G_VARIANT_TYPE ("aau"), - ip4_routes_get, - ip4_routes_set, - NULL); + _nm_properties_override_gobj (properties_override, + g_object_class_find_property (G_OBJECT_CLASS (setting_class), + NM_SETTING_IP_CONFIG_ROUTES), + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aau"), + .to_dbus_fcn = ip4_routes_get, + .from_dbus_fcn = ip4_routes_set, + )); /* ---dbus--- * property: route-data @@ -899,11 +910,13 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass) * also exist on some routes. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "route-data", - G_VARIANT_TYPE ("aa{sv}"), - ip4_route_data_get, - ip4_route_data_set); + _nm_properties_override_dbus (properties_override, + "route-data", + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = ip4_route_data_get, + .from_dbus_fcn = ip4_route_data_set, + )); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-ip4-config.h b/libnm-core/nm-setting-ip4-config.h index bd6b6a2c..fedec334 100644 --- a/libnm-core/nm-setting-ip4-config.h +++ b/libnm-core/nm-setting-ip4-config.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_IP4_CONFIG_H__ diff --git a/libnm-core/nm-setting-ip6-config.c b/libnm-core/nm-setting-ip6-config.c index 44379ef7..4cbda830 100644 --- a/libnm-core/nm-setting-ip6-config.c +++ b/libnm-core/nm-setting-ip6-config.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. */ #include "nm-default.h" @@ -672,6 +658,13 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass) */ /* ---ifcfg-rh--- + * property: dhcp-hostname-flags + * variable: DHCPV6_HOSTNAME_FLAGS + * description: flags for the DHCP hostname property + * example: DHCPV6_HOSTNAME_FLAGS=5 + */ + + /* ---ifcfg-rh--- * property: never-default * variable: IPV6_DEFROUTE(+), (and IPV6_DEFAULTGW, IPV6_DEFAULTDEV in /etc/sysconfig/network) * default: IPV6_DEFROUTE=yes (when no variable specified) @@ -894,12 +887,14 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass) * description: Array of IP addresses of DNS servers (in network byte order) * ---end--- */ - _properties_override_add_transform (properties_override, - g_object_class_find_property (G_OBJECT_CLASS (setting_class), - NM_SETTING_IP_CONFIG_DNS), - G_VARIANT_TYPE ("aay"), - ip6_dns_to_dbus, - ip6_dns_from_dbus); + _nm_properties_override_gobj (properties_override, + g_object_class_find_property (G_OBJECT_CLASS (setting_class), + NM_SETTING_IP_CONFIG_DNS), + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aay"), + .gprop_to_dbus_fcn = ip6_dns_to_dbus, + .gprop_from_dbus_fcn = ip6_dns_from_dbus, + )); /* ---dbus--- * property: addresses @@ -915,13 +910,14 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass) * that subnet. * ---end--- */ - _properties_override_add_override (properties_override, - g_object_class_find_property (G_OBJECT_CLASS (setting_class), - NM_SETTING_IP_CONFIG_ADDRESSES), - G_VARIANT_TYPE ("a(ayuay)"), - ip6_addresses_get, - ip6_addresses_set, - NULL); + _nm_properties_override_gobj (properties_override, + g_object_class_find_property (G_OBJECT_CLASS (setting_class), + NM_SETTING_IP_CONFIG_ADDRESSES), + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("a(ayuay)"), + .to_dbus_fcn = ip6_addresses_get, + .from_dbus_fcn = ip6_addresses_set, + )); /* ---dbus--- * property: address-data @@ -932,11 +928,13 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass) * also exist on some addresses. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "address-data", - G_VARIANT_TYPE ("aa{sv}"), - ip6_address_data_get, - ip6_address_data_set); + _nm_properties_override_dbus (properties_override, + "address-data", + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = ip6_address_data_get, + .from_dbus_fcn = ip6_address_data_set, + )); /* ---dbus--- * property: routes @@ -952,13 +950,14 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass) * default metric for the device. * ---end--- */ - _properties_override_add_override (properties_override, - g_object_class_find_property (G_OBJECT_CLASS (setting_class), - NM_SETTING_IP_CONFIG_ROUTES), - G_VARIANT_TYPE ("a(ayuayu)"), - ip6_routes_get, - ip6_routes_set, - NULL); + _nm_properties_override_gobj (properties_override, + g_object_class_find_property (G_OBJECT_CLASS (setting_class), + NM_SETTING_IP_CONFIG_ROUTES), + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("a(ayuayu)"), + .to_dbus_fcn = ip6_routes_get, + .from_dbus_fcn = ip6_routes_set, + )); /* ---dbus--- * property: route-data @@ -973,11 +972,13 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass) * also exist on some routes. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "route-data", - G_VARIANT_TYPE ("aa{sv}"), - ip6_route_data_get, - ip6_route_data_set); + _nm_properties_override_dbus (properties_override, + "route-data", + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = ip6_route_data_get, + .from_dbus_fcn = ip6_route_data_set, + )); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-ip6-config.h b/libnm-core/nm-setting-ip6-config.h index 80449e0c..86a39a8e 100644 --- a/libnm-core/nm-setting-ip6-config.h +++ b/libnm-core/nm-setting-ip6-config.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. */ #ifndef __NM_SETTING_IP6_CONFIG_H__ diff --git a/libnm-core/nm-setting-macsec.c b/libnm-core/nm-setting-macsec.c index 792d3f20..62351eb5 100644 --- a/libnm-core/nm-setting-macsec.c +++ b/libnm-core/nm-setting-macsec.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-macsec.h b/libnm-core/nm-setting-macsec.h index 6a9dc7f8..56fb0d7c 100644 --- a/libnm-core/nm-setting-macsec.h +++ b/libnm-core/nm-setting-macsec.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #ifndef __NM_SETTING_MACSEC_H__ diff --git a/libnm-core/nm-setting-macvlan.c b/libnm-core/nm-setting-macvlan.c index 65a7e779..cb7778f1 100644 --- a/libnm-core/nm-setting-macvlan.c +++ b/libnm-core/nm-setting-macvlan.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-macvlan.h b/libnm-core/nm-setting-macvlan.h index 67aadb48..7e401994 100644 --- a/libnm-core/nm-setting-macvlan.h +++ b/libnm-core/nm-setting-macvlan.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #ifndef __NM_SETTING_MACVLAN_H__ diff --git a/libnm-core/nm-setting-match.c b/libnm-core/nm-setting-match.c index b1b8e55f..2fbd0716 100644 --- a/libnm-core/nm-setting-match.c +++ b/libnm-core/nm-setting-match.c @@ -1,14 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - * - * Copyright 2018 Red Hat, Inc. + * Copyright (C) 2018 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-match.h b/libnm-core/nm-setting-match.h index 31917d25..e15911ad 100644 --- a/libnm-core/nm-setting-match.h +++ b/libnm-core/nm-setting-match.h @@ -1,14 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - * - * Copyright 2018 Red Hat, Inc. + * Copyright (C) 2018 Red Hat, Inc. */ #ifndef NM_SETTING_MATCH_H diff --git a/libnm-core/nm-setting-olpc-mesh.c b/libnm-core/nm-setting-olpc-mesh.c index a5e9de73..0e1d27cf 100644 --- a/libnm-core/nm-setting-olpc-mesh.c +++ b/libnm-core/nm-setting-olpc-mesh.c @@ -1,22 +1,8 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. - * Copyright 2009 One Laptop per Child + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + * Copyright (C) 2009 One Laptop per Child */ #include "nm-default.h" @@ -264,12 +250,7 @@ nm_setting_olpc_mesh_class_init (NMSettingOlpcMeshClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_DHCP_ANYCAST_ADDRESS], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_to_dbus, - _nm_utils_hwaddr_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_DHCP_ANYCAST_ADDRESS], &nm_sett_info_propert_type_mac_addrees); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-olpc-mesh.h b/libnm-core/nm-setting-olpc-mesh.h index e781e75f..768734a8 100644 --- a/libnm-core/nm-setting-olpc-mesh.h +++ b/libnm-core/nm-setting-olpc-mesh.h @@ -1,22 +1,8 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2008 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. - * Copyright 2009 One Laptop per Child + * Copyright (C) 2007 - 2008 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + * Copyright (C) 2009 One Laptop per Child */ #ifndef __NM_SETTING_OLPC_MESH_H__ diff --git a/libnm-core/nm-setting-ovs-bridge.c b/libnm-core/nm-setting-ovs-bridge.c index 473bdb94..7f9ca1dc 100644 --- a/libnm-core/nm-setting-ovs-bridge.c +++ b/libnm-core/nm-setting-ovs-bridge.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-ovs-bridge.h b/libnm-core/nm-setting-ovs-bridge.h index b9f92c06..3210927c 100644 --- a/libnm-core/nm-setting-ovs-bridge.h +++ b/libnm-core/nm-setting-ovs-bridge.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #ifndef __NM_SETTING_OVS_BRIDGE_H__ diff --git a/libnm-core/nm-setting-ovs-dpdk.c b/libnm-core/nm-setting-ovs-dpdk.c index 4e831e6e..ed3c3255 100644 --- a/libnm-core/nm-setting-ovs-dpdk.c +++ b/libnm-core/nm-setting-ovs-dpdk.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2019 Red Hat, Inc. + * Copyright (C) 2019 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-ovs-dpdk.h b/libnm-core/nm-setting-ovs-dpdk.h index 75ec6752..e841ed1f 100644 --- a/libnm-core/nm-setting-ovs-dpdk.h +++ b/libnm-core/nm-setting-ovs-dpdk.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2019 Red Hat, Inc. + * Copyright (C) 2019 Red Hat, Inc. */ #ifndef __NM_SETTING_OVS_DPDK_H__ diff --git a/libnm-core/nm-setting-ovs-interface.c b/libnm-core/nm-setting-ovs-interface.c index 406c7b2b..ecefd6a5 100644 --- a/libnm-core/nm-setting-ovs-interface.c +++ b/libnm-core/nm-setting-ovs-interface.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-ovs-interface.h b/libnm-core/nm-setting-ovs-interface.h index 7261cfd8..64d2e65f 100644 --- a/libnm-core/nm-setting-ovs-interface.h +++ b/libnm-core/nm-setting-ovs-interface.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #ifndef __NM_SETTING_OVS_INTERFACE_H__ diff --git a/libnm-core/nm-setting-ovs-patch.c b/libnm-core/nm-setting-ovs-patch.c index dd0bdc71..e74a35ca 100644 --- a/libnm-core/nm-setting-ovs-patch.c +++ b/libnm-core/nm-setting-ovs-patch.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-ovs-patch.h b/libnm-core/nm-setting-ovs-patch.h index 091f0d43..486b073e 100644 --- a/libnm-core/nm-setting-ovs-patch.h +++ b/libnm-core/nm-setting-ovs-patch.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #ifndef __NM_SETTING_OVS_PATCH_H__ diff --git a/libnm-core/nm-setting-ovs-port.c b/libnm-core/nm-setting-ovs-port.c index 4a4d74af..ab4b63d8 100644 --- a/libnm-core/nm-setting-ovs-port.c +++ b/libnm-core/nm-setting-ovs-port.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-ovs-port.h b/libnm-core/nm-setting-ovs-port.h index 4c14f123..26409e64 100644 --- a/libnm-core/nm-setting-ovs-port.h +++ b/libnm-core/nm-setting-ovs-port.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #ifndef __NM_SETTING_OVS_PORT_H__ diff --git a/libnm-core/nm-setting-ppp.c b/libnm-core/nm-setting-ppp.c index eb4ef7ab..c42feb46 100644 --- a/libnm-core/nm-setting-ppp.c +++ b/libnm-core/nm-setting-ppp.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-ppp.h b/libnm-core/nm-setting-ppp.h index 30578a81..3d0abc5b 100644 --- a/libnm-core/nm-setting-ppp.h +++ b/libnm-core/nm-setting-ppp.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2008 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2008 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_PPP_H__ diff --git a/libnm-core/nm-setting-pppoe.c b/libnm-core/nm-setting-pppoe.c index 0f079279..d9ff2a80 100644 --- a/libnm-core/nm-setting-pppoe.c +++ b/libnm-core/nm-setting-pppoe.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-pppoe.h b/libnm-core/nm-setting-pppoe.h index ab319aa3..9b09feb5 100644 --- a/libnm-core/nm-setting-pppoe.h +++ b/libnm-core/nm-setting-pppoe.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2011 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_PPPOE_H__ diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h index c4c0bb48..326b05da 100644 --- a/libnm-core/nm-setting-private.h +++ b/libnm-core/nm-setting-private.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 Red Hat, Inc. + * Copyright (C) 2011 Red Hat, Inc. */ #ifndef __NM_SETTING_PRIVATE_H__ @@ -81,14 +67,16 @@ gboolean _nm_setting_clear_secrets (NMSetting *setting, */ #define NM_SETTING_PARAM_REAPPLY_IMMEDIATELY (1 << (6 + G_PARAM_USER_SHIFT)) -#define NM_SETTING_PARAM_GENDATA_BACKED (1 << (7 + G_PARAM_USER_SHIFT)) +/* property_to_dbus() should ignore the property flags, and instead always calls to_dbus_fcn() + */ +#define NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS (1 << (7 + G_PARAM_USER_SHIFT)) + +extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name; +extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i; +extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u; -GVariant *_nm_setting_get_deprecated_virtual_interface_name (const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection *connection, - NMSetting *setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options); +extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_i; +extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_u; NMSettingVerifyResult _nm_setting_verify (NMSetting *setting, NMConnection *connection, @@ -157,40 +145,44 @@ _nm_setting_class_commit (NMSettingClass *setting_class, __VA_ARGS__ \ })) +#define NM_SETT_INFO_PROPERT_TYPE(...) \ + ({ \ + static const NMSettInfoPropertType _g = { \ + __VA_ARGS__ \ + }; \ + \ + &_g; \ + }) + #define NM_SETT_INFO_PROPERTY(...) \ (&((const NMSettInfoProperty) { \ __VA_ARGS__ \ })) -void _properties_override_add_struct (GArray *properties_override, - const NMSettInfoProperty *prop_info); - -void _properties_override_add__helper (GArray *properties_override, - NMSettInfoProperty *prop_info); - -#define _properties_override_add(properties_override, \ - ...) \ - (_properties_override_add_struct (properties_override, \ - NM_SETT_INFO_PROPERTY (__VA_ARGS__))) - -void _properties_override_add_dbus_only (GArray *properties_override, - const char *property_name, - const GVariantType *dbus_type, - NMSettInfoPropToDBusFcn to_dbus_fcn, - NMSettInfoPropFromDBusFcn from_dbus_fcn); - -void _properties_override_add_override (GArray *properties_override, - GParamSpec *param_spec, - const GVariantType *dbus_type, - NMSettInfoPropToDBusFcn to_dbus_fcn, - NMSettInfoPropFromDBusFcn from_dbus_fcn, - NMSettInfoPropMissingFromDBusFcn missing_from_dbus_fcn); - -void _properties_override_add_transform (GArray *properties_override, - GParamSpec *param_spec, - const GVariantType *dbus_type, - NMSettInfoPropGPropToDBusFcn gprop_to_dbus_fcn, - NMSettInfoPropGPropFromDBusFcn gprop_from_dbus_fcn); +gboolean _nm_properties_override_assert (const NMSettInfoProperty *prop_info); + +static inline void +_nm_properties_override (GArray *properties_override, + const NMSettInfoProperty *prop_info) +{ + nm_assert (properties_override); + nm_assert (_nm_properties_override_assert (prop_info)); + g_array_append_vals (properties_override, prop_info, 1); +} + +#define _nm_properties_override_gobj(properties_override, p_param_spec, p_property_type) \ + _nm_properties_override ((properties_override), \ + NM_SETT_INFO_PROPERTY ( \ + .param_spec = (p_param_spec), \ + .property_type = (p_property_type), \ + )) + +#define _nm_properties_override_dbus(properties_override, p_name, p_property_type) \ + _nm_properties_override ((properties_override), \ + NM_SETT_INFO_PROPERTY ( \ + .name = (""p_name""), \ + .property_type = (p_property_type), \ + )) /*****************************************************************************/ diff --git a/libnm-core/nm-setting-proxy.c b/libnm-core/nm-setting-proxy.c index bbda0ba1..9e83339c 100644 --- a/libnm-core/nm-setting-proxy.c +++ b/libnm-core/nm-setting-proxy.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. - * - * (C) Copyright 2016 Atul Anand <atulhjp@gmail.com>. + * Copyright (C) 2016 Atul Anand <atulhjp@gmail.com>. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-proxy.h b/libnm-core/nm-setting-proxy.h index 3800ac76..d5913315 100644 --- a/libnm-core/nm-setting-proxy.h +++ b/libnm-core/nm-setting-proxy.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. - * - * (C) Copyright 2016 Atul Anand <atulhjp@gmail.com>. + * Copyright (C) 2016 Atul Anand <atulhjp@gmail.com>. */ #ifndef __NM_SETTING_PROXY_H__ diff --git a/libnm-core/nm-setting-serial.c b/libnm-core/nm-setting-serial.c index 9bdc887a..c050e238 100644 --- a/libnm-core/nm-setting-serial.c +++ b/libnm-core/nm-setting-serial.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2018 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2018 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -302,12 +288,13 @@ nm_setting_serial_class_init (NMSettingSerialClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_PARITY], - G_VARIANT_TYPE_BYTE, - parity_to_dbus, - parity_from_dbus); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_PARITY], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_BYTE, + .gprop_to_dbus_fcn = parity_to_dbus, + .gprop_from_dbus_fcn = parity_from_dbus, + )); /** * NMSettingSerial:stopbits: diff --git a/libnm-core/nm-setting-serial.h b/libnm-core/nm-setting-serial.h index bec9829a..f0b6a660 100644 --- a/libnm-core/nm-setting-serial.h +++ b/libnm-core/nm-setting-serial.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2008 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2008 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_SERIAL_H__ diff --git a/libnm-core/nm-setting-sriov.c b/libnm-core/nm-setting-sriov.c index 90ac44ab..4dd43ae1 100644 --- a/libnm-core/nm-setting-sriov.c +++ b/libnm-core/nm-setting-sriov.c @@ -1,14 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - * - * Copyright 2018 Red Hat, Inc. + * Copyright (C) 2018 Red Hat, Inc. */ #include "nm-default.h" @@ -1334,13 +1326,13 @@ nm_setting_sriov_class_init (NMSettingSriovClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_VFS], - G_VARIANT_TYPE ("aa{sv}"), - vfs_to_dbus, - vfs_from_dbus, - NULL); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_VFS], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = vfs_to_dbus, + .from_dbus_fcn = vfs_from_dbus, + )); /** * NMSettingSriov:autoprobe-drivers diff --git a/libnm-core/nm-setting-sriov.h b/libnm-core/nm-setting-sriov.h index a1ad726b..af15a0a0 100644 --- a/libnm-core/nm-setting-sriov.h +++ b/libnm-core/nm-setting-sriov.h @@ -1,14 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - * - * Copyright 2018 Red Hat, Inc. + * Copyright (C) 2018 Red Hat, Inc. */ #ifndef NM_SETTING_SRIOV_H diff --git a/libnm-core/nm-setting-tc-config.c b/libnm-core/nm-setting-tc-config.c index fe8e695c..af503741 100644 --- a/libnm-core/nm-setting-tc-config.c +++ b/libnm-core/nm-setting-tc-config.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #include "nm-default.h" @@ -1814,13 +1800,13 @@ nm_setting_tc_config_class_init (NMSettingTCConfigClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_QDISCS], - G_VARIANT_TYPE ("aa{sv}"), - tc_qdiscs_get, - tc_qdiscs_set, - NULL); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_QDISCS], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = tc_qdiscs_get, + .from_dbus_fcn = tc_qdiscs_set, + )); /** * NMSettingTCConfig:tfilters: (type GPtrArray(NMTCTfilter)) @@ -1840,13 +1826,13 @@ nm_setting_tc_config_class_init (NMSettingTCConfigClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_TFILTERS], - G_VARIANT_TYPE ("aa{sv}"), - tc_tfilters_get, - tc_tfilters_set, - NULL); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_TFILTERS], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = tc_tfilters_get, + .from_dbus_fcn = tc_tfilters_set, + )); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-tc-config.h b/libnm-core/nm-setting-tc-config.h index ab99e3cc..648e6403 100644 --- a/libnm-core/nm-setting-tc-config.h +++ b/libnm-core/nm-setting-tc-config.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #ifndef NM_SETTING_TC_CONFIG_H diff --git a/libnm-core/nm-setting-team-port.c b/libnm-core/nm-setting-team-port.c index 6c087aa9..e256a503 100644 --- a/libnm-core/nm-setting-team-port.c +++ b/libnm-core/nm-setting-team-port.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. - * Copyright 2013 Jiri Pirko <jiri@resnulli.us> + * Copyright (C) 2017 Red Hat, Inc. + * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us> */ #include "nm-default.h" @@ -550,13 +536,6 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *klass) setting_class->duplicate_copy_properties = duplicate_copy_properties; setting_class->init_from_dbus = init_from_dbus; -#define _property_override(_properties_override, _param_spec, _variant_type, _is_link_watcher) \ - _properties_override_add ((_properties_override), \ - .param_spec = (_param_spec), \ - .dbus_type = G_VARIANT_TYPE (""_variant_type""), \ - .to_dbus_fcn = _nm_team_settings_property_to_dbus, \ - .gprop_from_dbus_fcn = ((_is_link_watcher) ? _nm_team_settings_property_from_dbus_link_watchers : NULL)) - /** * NMSettingTeamPort:config: * @@ -577,7 +556,7 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_CONFIG], "s", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_CONFIG], &nm_sett_info_propert_type_team_s); /** * NMSettingTeamPort:queue-id: @@ -592,7 +571,7 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_QUEUE_ID], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_QUEUE_ID], &nm_sett_info_propert_type_team_i); /** * NMSettingTeamPort:prio: @@ -606,7 +585,7 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *klass) G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_PRIO], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_PRIO], &nm_sett_info_propert_type_team_i); /** * NMSettingTeamPort:sticky: @@ -620,7 +599,7 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *klass) FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_STICKY], "b", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_STICKY], &nm_sett_info_propert_type_team_b); /** * NMSettingTeamPort:lacp-prio: @@ -634,7 +613,7 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_LACP_PRIO], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_LACP_PRIO], &nm_sett_info_propert_type_team_i); /** * NMSettingTeamPort:lacp-key: @@ -648,7 +627,7 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_LACP_KEY], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_LACP_KEY], &nm_sett_info_propert_type_team_i); /** * NMSettingTeamPort:link-watchers: (type GPtrArray(NMTeamLinkWatcher)) @@ -669,7 +648,7 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *klass) G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS], "aa{sv}", TRUE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS], &nm_sett_info_propert_type_team_link_watchers); g_object_class_install_properties (object_class, G_N_ELEMENTS (obj_properties), obj_properties); diff --git a/libnm-core/nm-setting-team-port.h b/libnm-core/nm-setting-team-port.h index 527c9077..f0fbbb32 100644 --- a/libnm-core/nm-setting-team-port.h +++ b/libnm-core/nm-setting-team-port.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2013 Jiri Pirko <jiri@resnulli.us> + * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us> */ #ifndef __NM_SETTING_TEAM_PORT_H__ diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c index d4940924..1e8c7149 100644 --- a/libnm-core/nm-setting-team.c +++ b/libnm-core/nm-setting-team.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. - * Copyright 2013 Jiri Pirko <jiri@resnulli.us> + * Copyright (C) 2017 Red Hat, Inc. + * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us> */ #include "nm-default.h" @@ -1497,13 +1483,6 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) setting_class->duplicate_copy_properties = duplicate_copy_properties; setting_class->init_from_dbus = init_from_dbus; -#define _property_override(_properties_override, _param_spec, _variant_type, _is_link_watcher) \ - _properties_override_add ((_properties_override), \ - .param_spec = (_param_spec), \ - .dbus_type = G_VARIANT_TYPE (""_variant_type""), \ - .to_dbus_fcn = _nm_team_settings_property_to_dbus, \ - .gprop_from_dbus_fcn = ((_is_link_watcher) ? _nm_team_settings_property_from_dbus_link_watchers : NULL)) - /** * NMSettingTeam:config: * @@ -1524,7 +1503,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_CONFIG], "s", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_CONFIG], &nm_sett_info_propert_type_team_s); /** * NMSettingTeam:notify-peers-count: @@ -1538,7 +1517,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_NOTIFY_PEERS_COUNT], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_NOTIFY_PEERS_COUNT], &nm_sett_info_propert_type_team_i); /** * NMSettingTeam:notify-peers-interval: @@ -1552,7 +1531,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_NOTIFY_PEERS_INTERVAL], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_NOTIFY_PEERS_INTERVAL], &nm_sett_info_propert_type_team_i); /** * NMSettingTeam:mcast-rejoin-count: @@ -1566,7 +1545,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_MCAST_REJOIN_COUNT], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_MCAST_REJOIN_COUNT], &nm_sett_info_propert_type_team_i); /** * NMSettingTeam:mcast-rejoin-interval: @@ -1580,7 +1559,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_MCAST_REJOIN_INTERVAL], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_MCAST_REJOIN_INTERVAL], &nm_sett_info_propert_type_team_i); /** * NMSettingTeam:runner: @@ -1596,7 +1575,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER], "s", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER], &nm_sett_info_propert_type_team_s); /** * NMSettingTeam:runner-hwaddr-policy: @@ -1610,7 +1589,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_HWADDR_POLICY], "s", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_HWADDR_POLICY], &nm_sett_info_propert_type_team_s); /** * NMSettingTeam:runner-tx-hash: @@ -1625,7 +1604,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_TX_HASH], "as", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_TX_HASH], &nm_sett_info_propert_type_team_as); /** * NMSettingTeam:runner-tx-balancer: @@ -1639,7 +1618,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_TX_BALANCER], "s", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_TX_BALANCER], &nm_sett_info_propert_type_team_s); /** * NMSettingTeam:runner-tx-balancer-interval: @@ -1653,7 +1632,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_TX_BALANCER_INTERVAL], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_TX_BALANCER_INTERVAL], &nm_sett_info_propert_type_team_i); /** * NMSettingTeam:runner-active: @@ -1667,7 +1646,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_ACTIVE], "b", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_ACTIVE], &nm_sett_info_propert_type_team_b); /** * NMSettingTeam:runner-fast-rate: @@ -1681,7 +1660,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_FAST_RATE], "b", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_FAST_RATE], &nm_sett_info_propert_type_team_b); /** * NMSettingTeam:runner-sys-prio: @@ -1695,7 +1674,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_SYS_PRIO], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_SYS_PRIO], &nm_sett_info_propert_type_team_i); /** * NMSettingTeam:runner-min-ports: @@ -1709,7 +1688,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_MININT32, G_MAXINT32, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_MIN_PORTS], "i", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_MIN_PORTS], &nm_sett_info_propert_type_team_i); /** * NMSettingTeam:runner-agg-select-policy: @@ -1723,7 +1702,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_AGG_SELECT_POLICY], "s", FALSE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_MASTER_RUNNER_AGG_SELECT_POLICY], &nm_sett_info_propert_type_team_s); /** * NMSettingTeam:link-watchers: (type GPtrArray(NMTeamLinkWatcher)) @@ -1744,7 +1723,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS], "aa{sv}", TRUE); + _nm_properties_override_gobj (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS], &nm_sett_info_propert_type_team_link_watchers); /* ---dbus--- * property: interface-name @@ -1754,11 +1733,7 @@ nm_setting_team_class_init (NMSettingTeamClass *klass) * team's interface name. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "interface-name", - G_VARIANT_TYPE_STRING, - _nm_setting_get_deprecated_virtual_interface_name, - NULL); + _nm_properties_override_dbus (properties_override, "interface-name", &nm_sett_info_propert_type_deprecated_interface_name); g_object_class_install_properties (object_class, G_N_ELEMENTS (obj_properties), obj_properties); diff --git a/libnm-core/nm-setting-team.h b/libnm-core/nm-setting-team.h index 75943b20..809fd4f0 100644 --- a/libnm-core/nm-setting-team.h +++ b/libnm-core/nm-setting-team.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2013 Jiri Pirko <jiri@resnulli.us> + * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us> */ #ifndef __NM_SETTING_TEAM_H__ diff --git a/libnm-core/nm-setting-tun.c b/libnm-core/nm-setting-tun.c index 649c32a9..312c5c53 100644 --- a/libnm-core/nm-setting-tun.c +++ b/libnm-core/nm-setting-tun.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-tun.h b/libnm-core/nm-setting-tun.h index 0be19754..14ba562a 100644 --- a/libnm-core/nm-setting-tun.h +++ b/libnm-core/nm-setting-tun.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #ifndef __NM_SETTING_TUN_H__ diff --git a/libnm-core/nm-setting-user.c b/libnm-core/nm-setting-user.c index 6cdf8ca2..87a0dfed 100644 --- a/libnm-core/nm-setting-user.c +++ b/libnm-core/nm-setting-user.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #include "nm-default.h" @@ -585,12 +571,7 @@ nm_setting_user_class_init (NMSettingUserClass *klass) G_TYPE_HASH_TABLE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_DATA], - G_VARIANT_TYPE ("a{ss}"), - _nm_utils_strdict_to_dbus, - _nm_utils_strdict_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_DATA], &nm_sett_info_propert_type_strdict); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-user.h b/libnm-core/nm-setting-user.h index 588b841d..e50a3243 100644 --- a/libnm-core/nm-setting-user.h +++ b/libnm-core/nm-setting-user.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2017 Red Hat, Inc. + * Copyright (C) 2017 Red Hat, Inc. */ #ifndef __NM_SETTING_USER_H__ diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c index d69a8946..84b974dc 100644 --- a/libnm-core/nm-setting-vlan.c +++ b/libnm-core/nm-setting-vlan.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 - 2014 Red Hat, Inc. + * Copyright (C) 2011 - 2014 Red Hat, Inc. */ #include "nm-default.h" @@ -922,13 +908,13 @@ nm_setting_vlan_class_init (NMSettingVlanClass *klass) G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_FLAGS], - G_VARIANT_TYPE_UINT32, - _override_flags_get, - NULL, - _override_flags_not_set); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_FLAGS], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_UINT32, + .to_dbus_fcn = _override_flags_get, + .missing_from_dbus_fcn = _override_flags_not_set, + )); /** * NMSettingVlan:ingress-priority-map: @@ -988,11 +974,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *klass) * vlan's interface name. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "interface-name", - G_VARIANT_TYPE_STRING, - _nm_setting_get_deprecated_virtual_interface_name, - NULL); + _nm_properties_override_dbus (properties_override, "interface-name", &nm_sett_info_propert_type_deprecated_interface_name); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-vlan.h b/libnm-core/nm-setting-vlan.h index 8d5ece60..bd0da80f 100644 --- a/libnm-core/nm-setting-vlan.h +++ b/libnm-core/nm-setting-vlan.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 - 2014 Red Hat, Inc. + * Copyright (C) 2011 - 2014 Red Hat, Inc. */ #ifndef __NM_SETTING_VLAN_H__ diff --git a/libnm-core/nm-setting-vpn.c b/libnm-core/nm-setting-vpn.c index a011be77..05fca918 100644 --- a/libnm-core/nm-setting-vpn.c +++ b/libnm-core/nm-setting-vpn.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -935,6 +921,9 @@ vpn_secrets_to_dbus (const NMSettInfoSetting *sett_info, const char *key, *value; NMSettingSecretFlags secret_flags; + if (NM_FLAGS_HAS (flags, NM_CONNECTION_SERIALIZE_NO_SECRETS)) + return NULL; + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}")); g_object_get (setting, property_name, &secrets, NULL); @@ -1143,12 +1132,7 @@ nm_setting_vpn_class_init (NMSettingVpnClass *klass) G_TYPE_HASH_TABLE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_DATA], - G_VARIANT_TYPE ("a{ss}"), - _nm_utils_strdict_to_dbus, - _nm_utils_strdict_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_DATA], &nm_sett_info_propert_type_strdict); /** * NMSettingVpn:secrets: (type GHashTable(utf8,utf8)): @@ -1169,14 +1153,15 @@ nm_setting_vpn_class_init (NMSettingVpnClass *klass) G_TYPE_HASH_TABLE, G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | + NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_SECRETS], - G_VARIANT_TYPE ("a{ss}"), - vpn_secrets_to_dbus, - vpn_secrets_from_dbus, - NULL); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_SECRETS], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("a{ss}"), + .to_dbus_fcn = vpn_secrets_to_dbus, + .from_dbus_fcn = vpn_secrets_from_dbus, + )); /** * NMSettingVpn:timeout: diff --git a/libnm-core/nm-setting-vpn.h b/libnm-core/nm-setting-vpn.h index fa46af93..d27af357 100644 --- a/libnm-core/nm-setting-vpn.h +++ b/libnm-core/nm-setting-vpn.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2013 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_VPN_H__ diff --git a/libnm-core/nm-setting-vxlan.c b/libnm-core/nm-setting-vxlan.c index 4f788eb5..d363ff20 100644 --- a/libnm-core/nm-setting-vxlan.c +++ b/libnm-core/nm-setting-vxlan.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-vxlan.h b/libnm-core/nm-setting-vxlan.h index 081e6166..c3240cc9 100644 --- a/libnm-core/nm-setting-vxlan.h +++ b/libnm-core/nm-setting-vxlan.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #ifndef __NM_SETTING_VXLAN_H__ diff --git a/libnm-core/nm-setting-wifi-p2p.c b/libnm-core/nm-setting-wifi-p2p.c index 490c2ef9..df33f1d0 100644 --- a/libnm-core/nm-setting-wifi-p2p.c +++ b/libnm-core/nm-setting-wifi-p2p.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2019 Red Hat, Inc. + * Copyright (C) 2019 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-wifi-p2p.h b/libnm-core/nm-setting-wifi-p2p.h index ddb611c1..075aa121 100644 --- a/libnm-core/nm-setting-wifi-p2p.h +++ b/libnm-core/nm-setting-wifi-p2p.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2019 Red Hat, Inc. + * Copyright (C) 2019 Red Hat, Inc. */ #ifndef __NM_SETTING_WIFI_P2P_H__ diff --git a/libnm-core/nm-setting-wimax.c b/libnm-core/nm-setting-wimax.c index ecb5a77a..cfc1250e 100644 --- a/libnm-core/nm-setting-wimax.c +++ b/libnm-core/nm-setting-wimax.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011 - 2013 Red Hat, Inc. - * Copyright 2009 Novell, Inc. + * Copyright (C) 2011 - 2013 Red Hat, Inc. + * Copyright (C) 2009 Novell, Inc. */ #include "nm-default.h" @@ -250,12 +236,7 @@ nm_setting_wimax_class_init (NMSettingWimaxClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_MAC_ADDRESS], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_to_dbus, - _nm_utils_hwaddr_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_MAC_ADDRESS], &nm_sett_info_propert_type_mac_addrees); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-wimax.h b/libnm-core/nm-setting-wimax.h index 22450b8d..0f00e4ba 100644 --- a/libnm-core/nm-setting-wimax.h +++ b/libnm-core/nm-setting-wimax.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2009 Novell, Inc. + * Copyright (C) 2009 Novell, Inc. */ #ifndef __NM_SETTING_WIMAX_H__ diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index 450ad1de..f328e7a6 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -1320,13 +1306,12 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_AUTO_NEGOTIATE], - G_VARIANT_TYPE_BOOLEAN, - _override_autoneg_get, - NULL, - NULL); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_AUTO_NEGOTIATE], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_BOOLEAN, + .to_dbus_fcn = _override_autoneg_get, + )); /** * NMSettingWired:mac-address: @@ -1358,12 +1343,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_MAC_ADDRESS], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_to_dbus, - _nm_utils_hwaddr_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_MAC_ADDRESS], &nm_sett_info_propert_type_mac_addrees); /** * NMSettingWired:cloned-mac-address: @@ -1414,13 +1394,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_CLONED_MAC_ADDRESS], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_cloned_get, - _nm_utils_hwaddr_cloned_set, - _nm_utils_hwaddr_cloned_not_set); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_CLONED_MAC_ADDRESS], &nm_sett_info_propert_type_cloned_mac_address); /* ---dbus--- * property: assigned-mac-address @@ -1434,11 +1408,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * "cloned-mac-address". * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "assigned-mac-address", - G_VARIANT_TYPE_STRING, - _nm_utils_hwaddr_cloned_data_synth, - _nm_utils_hwaddr_cloned_data_set); + _nm_properties_override_dbus (properties_override, "assigned-mac-address", &nm_sett_info_propert_type_assigned_mac_address); /** * NMSettingWired:generate-mac-address-mask: @@ -1602,12 +1572,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_S390_OPTIONS], - G_VARIANT_TYPE ("a{ss}"), - _nm_utils_strdict_to_dbus, - _nm_utils_strdict_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_S390_OPTIONS], &nm_sett_info_propert_type_strdict); /** * NMSettingWired:wake-on-lan: diff --git a/libnm-core/nm-setting-wired.h b/libnm-core/nm-setting-wired.h index a2d8555a..73a09aed 100644 --- a/libnm-core/nm-setting-wired.h +++ b/libnm-core/nm-setting-wired.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_WIRED_H__ diff --git a/libnm-core/nm-setting-wireguard.c b/libnm-core/nm-setting-wireguard.c index 17c35efc..ecfc5bb3 100644 --- a/libnm-core/nm-setting-wireguard.c +++ b/libnm-core/nm-setting-wireguard.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. + * Copyright (C) 2018 - 2019 Red Hat, Inc. */ #include "nm-default.h" @@ -2585,11 +2571,13 @@ nm_setting_wireguard_class_init (NMSettingWireGuardClass *klass) * description: Array of dictionaries for the WireGuard peers. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - NM_SETTING_WIREGUARD_PEERS, - G_VARIANT_TYPE ("aa{sv}"), - _peers_dbus_only_synth, - _peers_dbus_only_set); + _nm_properties_override_dbus (properties_override, + NM_SETTING_WIREGUARD_PEERS, + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = _peers_dbus_only_synth, + .from_dbus_fcn = _peers_dbus_only_set, + )); g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/libnm-core/nm-setting-wireguard.h b/libnm-core/nm-setting-wireguard.h index 1f81422f..6da24e3c 100644 --- a/libnm-core/nm-setting-wireguard.h +++ b/libnm-core/nm-setting-wireguard.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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. + * Copyright (C) 2018 - 2019 Red Hat, Inc. */ #ifndef __NM_SETTING_WIREGUARD_H__ diff --git a/libnm-core/nm-setting-wireless-security.c b/libnm-core/nm-setting-wireless-security.c index efb4860b..a634546d 100644 --- a/libnm-core/nm-setting-wireless-security.c +++ b/libnm-core/nm-setting-wireless-security.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2017 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2017 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -849,9 +835,8 @@ need_secrets (NMSetting *setting) goto no_secrets; } - /* WPA-PSK infrastructure and adhoc */ - if ( (strcmp (priv->key_mgmt, "wpa-none") == 0) - || (strcmp (priv->key_mgmt, "wpa-psk") == 0)) { + /* WPA-PSK infrastructure */ + if (strcmp (priv->key_mgmt, "wpa-psk") == 0) { if (!nm_utils_wpa_psk_valid (priv->psk)) { g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_PSK); return secrets; @@ -899,7 +884,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self); - const char *valid_key_mgmt[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", "sae", NULL }; + const char *valid_key_mgmt[] = { "none", "ieee8021x", "wpa-psk", "wpa-eap", "sae", NULL }; const char *valid_auth_algs[] = { "open", "shared", "leap", NULL }; const char *valid_protos[] = { "wpa", "rsn", NULL }; const char *valid_pairwise[] = { "tkip", "ccmp", NULL }; @@ -1024,33 +1009,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } if (priv->pairwise) { - const char *wpa_none[] = { "wpa-none", NULL }; - - /* For ad-hoc connections, pairwise must be "none" */ - if (g_strv_contains (wpa_none, priv->key_mgmt)) { - GSList *iter; - gboolean found = FALSE; - - for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) { - if (!strcmp ((char *) iter->data, "none")) { - found = TRUE; - break; - } - } - - /* pairwise cipher list didn't contain "none", which is invalid - * for WPA adhoc connections. - */ - if (!found) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%s' connections require '%s' in this property"), - NM_SETTING_WIRELESS_MODE_ADHOC, "none"); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PAIRWISE); - return FALSE; - } - } else if (!_nm_utils_string_slist_validate (priv->pairwise, valid_pairwise)) { + if (!_nm_utils_string_slist_validate (priv->pairwise, valid_pairwise)) { g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1468,10 +1427,10 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *klass) /** * NMSettingWirelessSecurity:key-mgmt: * - * 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. + * Key management used for the connection. One of "none" (WEP), + * "ieee8021x" (Dynamic WEP), "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. **/ /* ---ifcfg-rh--- * property: key-mgmt @@ -1852,12 +1811,13 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_WEP_KEY_TYPE], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_UINT32, + .gprop_to_dbus_fcn = wep_key_type_to_dbus, + )); - _properties_override_add_transform (properties_override, - obj_properties[PROP_WEP_KEY_TYPE], - G_VARIANT_TYPE_UINT32, - wep_key_type_to_dbus, - NULL); /** * NMSettingWirelessSecurity:wps-method: * diff --git a/libnm-core/nm-setting-wireless-security.h b/libnm-core/nm-setting-wireless-security.h index d5c069cf..c9e921af 100644 --- a/libnm-core/nm-setting-wireless-security.h +++ b/libnm-core/nm-setting-wireless-security.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2017 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2017 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_WIRELESS_SECURITY_H__ diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c index f735bd47..1731673f 100644 --- a/libnm-core/nm-setting-wireless.c +++ b/libnm-core/nm-setting-wireless.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -157,14 +143,6 @@ nm_setting_wireless_ap_security_compatible (NMSettingWireless *s_wireless, return TRUE; } - /* Adhoc WPA */ - if (!strcmp (key_mgmt, "wpa-none")) { - if (ap_mode != NM_802_11_MODE_ADHOC) - return FALSE; - /* FIXME: validate ciphers if they're in the beacon */ - return TRUE; - } - /* Adhoc WPA2 (ie, RSN IBSS) */ if (ap_mode == NM_802_11_MODE_ADHOC) { if (strcmp (key_mgmt, "wpa-psk")) @@ -1095,7 +1073,8 @@ get_property (GObject *object, guint prop_id, g_value_take_boxed (value, priv->seen_bssids ? nm_utils_strv_dup (priv->seen_bssids->pdata, - priv->seen_bssids->len) + priv->seen_bssids->len, + TRUE) : NULL); break; case PROP_HIDDEN: @@ -1398,12 +1377,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_BSSID], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_to_dbus, - _nm_utils_hwaddr_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_BSSID], &nm_sett_info_propert_type_mac_addrees); /** * NMSettingWireless:rate: @@ -1477,12 +1451,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_transform (properties_override, - obj_properties[PROP_MAC_ADDRESS], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_to_dbus, - _nm_utils_hwaddr_from_dbus); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_MAC_ADDRESS], &nm_sett_info_propert_type_mac_addrees); /** * NMSettingWireless:cloned-mac-address: @@ -1532,13 +1501,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_CLONED_MAC_ADDRESS], - G_VARIANT_TYPE_BYTESTRING, - _nm_utils_hwaddr_cloned_get, - _nm_utils_hwaddr_cloned_set, - _nm_utils_hwaddr_cloned_not_set); + _nm_properties_override_gobj (properties_override, obj_properties[PROP_CLONED_MAC_ADDRESS], &nm_sett_info_propert_type_cloned_mac_address); /* ---dbus--- * property: assigned-mac-address @@ -1552,11 +1515,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *klass) * "cloned-mac-address". * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "assigned-mac-address", - G_VARIANT_TYPE_STRING, - _nm_utils_hwaddr_cloned_data_synth, - _nm_utils_hwaddr_cloned_data_set); + _nm_properties_override_dbus (properties_override, "assigned-mac-address", &nm_sett_info_propert_type_assigned_mac_address); /** * NMSettingWireless:generate-mac-address-mask: @@ -1653,13 +1612,12 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *klass) G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); - - _properties_override_add_override (properties_override, - obj_properties[PROP_SEEN_BSSIDS], - G_VARIANT_TYPE_STRING_ARRAY, - _to_dbus_fcn_seen_bssids, - NULL, - NULL); + _nm_properties_override_gobj (properties_override, + obj_properties[PROP_SEEN_BSSIDS], + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_STRING_ARRAY, + .to_dbus_fcn = _to_dbus_fcn_seen_bssids, + )); /** * NMSettingWireless:mtu: @@ -1777,11 +1735,12 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *klass) * NetworkManager daemons. * ---end--- */ - _properties_override_add_dbus_only (properties_override, - "security", - G_VARIANT_TYPE_STRING, - nm_setting_wireless_get_security, - NULL); + _nm_properties_override_dbus (properties_override, + "security", + NM_SETT_INFO_PROPERT_TYPE ( + .dbus_type = G_VARIANT_TYPE_STRING, + .to_dbus_fcn = nm_setting_wireless_get_security, + )); /** * NMSettingWireless:wake-on-wlan: diff --git a/libnm-core/nm-setting-wireless.h b/libnm-core/nm-setting-wireless.h index d04bad3a..093e2ef0 100644 --- a/libnm-core/nm-setting-wireless.h +++ b/libnm-core/nm-setting-wireless.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_WIRELESS_H__ diff --git a/libnm-core/nm-setting-wpan.c b/libnm-core/nm-setting-wpan.c index f4270032..bfc5af76 100644 --- a/libnm-core/nm-setting-wpan.c +++ b/libnm-core/nm-setting-wpan.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 Lubomir Rintel <lkundrak@v3.sk> + * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk> */ #include "nm-default.h" diff --git a/libnm-core/nm-setting-wpan.h b/libnm-core/nm-setting-wpan.h index aaea1086..3f82aab0 100644 --- a/libnm-core/nm-setting-wpan.h +++ b/libnm-core/nm-setting-wpan.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 Lubomir Rintel <lkundrak@v3.sk> + * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk> */ #ifndef __NM_SETTING_WPAN_H__ diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index 1010e4cc..b7be9c65 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2011 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" @@ -216,158 +202,43 @@ _gprop_to_dbus_fcn_flags (const GValue *val) return g_variant_new_uint32 (g_value_get_flags (val)); } -void -_properties_override_add_struct (GArray *properties_override, - const NMSettInfoProperty *prop_info) +gboolean +_nm_properties_override_assert (const NMSettInfoProperty *prop_info) { - NMSettInfoProperty *p; - - nm_assert (properties_override); nm_assert (prop_info); - nm_assert (prop_info->name || prop_info->param_spec); + nm_assert ((!!prop_info->name) != (!!prop_info->param_spec)); nm_assert (!prop_info->param_spec || !prop_info->name || nm_streq0 (prop_info->name, prop_info->param_spec->name)); - nm_assert (!_nm_sett_info_property_find_in_array ((NMSettInfoProperty *) properties_override->data, - properties_override->len, - prop_info->name ?: prop_info->param_spec->name)); - nm_assert (!prop_info->gprop_from_dbus_fcn || prop_info->dbus_type); - nm_assert (!prop_info->from_dbus_fcn || prop_info->dbus_type); - nm_assert (!prop_info->to_dbus_fcn || prop_info->dbus_type); +#define _PROPERT_EXTRA(prop_info, member) \ + ({ \ + const NMSettInfoProperty *_prop_info = (prop_info); \ + \ + (_prop_info->property_type ? _prop_info->property_type->member : 0); \ + }) - nm_assert (!prop_info->to_dbus_fcn || !prop_info->gprop_to_dbus_fcn); - nm_assert (!prop_info->from_dbus_fcn || !prop_info->gprop_from_dbus_fcn); + nm_assert (!_PROPERT_EXTRA (prop_info, gprop_from_dbus_fcn) || _PROPERT_EXTRA (prop_info, dbus_type)); + nm_assert (!_PROPERT_EXTRA (prop_info, from_dbus_fcn) || _PROPERT_EXTRA (prop_info, dbus_type)); + nm_assert (!_PROPERT_EXTRA (prop_info, to_dbus_fcn) || _PROPERT_EXTRA (prop_info, dbus_type)); - nm_assert (!prop_info->gprop_to_dbus_fcn || prop_info->param_spec); - nm_assert (!prop_info->gprop_from_dbus_fcn || prop_info->param_spec); + nm_assert (!_PROPERT_EXTRA (prop_info, to_dbus_fcn) || !_PROPERT_EXTRA (prop_info, gprop_to_dbus_fcn)); + nm_assert (!_PROPERT_EXTRA (prop_info, from_dbus_fcn) || !_PROPERT_EXTRA (prop_info, gprop_from_dbus_fcn)); - g_array_append_vals (properties_override, prop_info, 1); + nm_assert (!_PROPERT_EXTRA (prop_info, gprop_to_dbus_fcn) || prop_info->param_spec); + nm_assert (!_PROPERT_EXTRA (prop_info, gprop_from_dbus_fcn) || prop_info->param_spec); - if (!prop_info->name) { - /* for convenience, allow omitting "name" if "param_spec" is given. */ - p = &g_array_index (properties_override, - NMSettInfoProperty, - properties_override->len - 1); - nm_assert (p->param_spec); - p->name = p->param_spec->name; - } -} +#undef _PROPERT_EXTRA -/** - * _properties_override_add_dbus_only: - * @properties_override: an array collecting the overrides - * @property_name: the name of the property to override - * @dbus_type: the type of the property (in its D-Bus representation) - * @to_dbus_fcn: (allow-none): function to call to synthesize a value for the property - * @from_dbus_fcn: (allow-none): function to call to set the value of the property - * - * Registers a property named @property_name, which will be used in the D-Bus - * serialization of objects of this setting type, but which does not correspond to - * a #GObject property. - * - * When serializing a setting to D-Bus, @to_dbus_fcn will be called to synthesize - * a value for the property. (If it returns %NULL, no value will be added to the - * serialization. If @to_dbus_fcn is %NULL, the property will always be omitted - * in the serialization.) - * - * When deserializing a D-Bus representation into a setting, if @property_name - * is present, then @from_dbus_fcn will be called to set it. (If @from_dbus_fcn is %NULL - * then the property will be ignored when deserializing.) - */ -void -_properties_override_add_dbus_only (GArray *properties_override, - const char *property_name, - const GVariantType *dbus_type, - NMSettInfoPropToDBusFcn to_dbus_fcn, - NMSettInfoPropFromDBusFcn from_dbus_fcn) -{ - _properties_override_add (properties_override, - .name = property_name, - .dbus_type = dbus_type, - .to_dbus_fcn = to_dbus_fcn, - .from_dbus_fcn = from_dbus_fcn); + return TRUE; } -/** - * _properties_override_add_override: - * @properties_override: an array collecting the overrides - * @param_spec: the name of the property to override - * @dbus_type: the type of the property (in its D-Bus representation) - * @to_dbus_fcn: (allow-none): function to call to get the value of the property - * @from_dbus_fcn: (allow-none): function to call to set the value of the property - * @missing_from_dbus_fcn: (allow-none): function to call to indicate the property was not set - * - * Overrides the D-Bus representation of the #GObject property that shares the - * same name as @param_spec. - * - * When serializing a setting to D-Bus, if @to_dbus_fcn is non-%NULL, then it will - * be called to get the property's value. If it returns a #GVariant, the - * property will be added to the hash, and if it returns %NULL, the property - * will be omitted. (If @to_dbus_fcn is %NULL, the property will be read normally - * with g_object_get_property(), and added to the hash if it is not the default - * value.) - * - * When deserializing a D-Bus representation into a setting, if a value with - * the name of @param_spec is present, then @from_dbus_fcn will be called to set it. - * (If @from_dbus_fcn is %NULL then the property will be set normally with - * g_object_set_property().) - * - * If @missing_from_dbus_fcn is non-%NULL, then it will be called when deserializing a - * representation that does NOT contain a value for the property. This can be used, - * eg, if a new property needs to be initialized from some older deprecated property - * when it is not present. - */ -void -_properties_override_add_override (GArray *properties_override, - GParamSpec *param_spec, - const GVariantType *dbus_type, - NMSettInfoPropToDBusFcn to_dbus_fcn, - NMSettInfoPropFromDBusFcn from_dbus_fcn, - NMSettInfoPropMissingFromDBusFcn missing_from_dbus_fcn) -{ - nm_assert (param_spec); - - _properties_override_add (properties_override, - .param_spec = param_spec, - .dbus_type = dbus_type, - .to_dbus_fcn = to_dbus_fcn, - .from_dbus_fcn = from_dbus_fcn, - .missing_from_dbus_fcn = missing_from_dbus_fcn); -} +static NMSettInfoSetting _sett_info_settings[_NM_META_SETTING_TYPE_NUM]; -/** - * _properties_override_add_transform: - * @properties_override: an array collecting the overrides - * @param_spec: the param spec of the property to transform. - * @dbus_type: the type of the property (in its D-Bus representation) - * @gprop_to_dbus_fcn: function to convert from object to D-Bus format - * @gprop_from_dbus_fcn: function to convert from D-Bus to object format - * - * Indicates that @property on @setting_class does not have the same format as - * its corresponding D-Bus representation, and so must be transformed when - * serializing/deserializing. - * - * The transformation will also be used by nm_setting_compare(), meaning that - * the underlying object property does not need to be of a type that - * nm_property_compare() recognizes, as long as it recognizes @dbus_type. - */ -void -_properties_override_add_transform (GArray *properties_override, - GParamSpec *param_spec, - const GVariantType *dbus_type, - NMSettInfoPropGPropToDBusFcn gprop_to_dbus_fcn, - NMSettInfoPropGPropFromDBusFcn gprop_from_dbus_fcn) +const NMSettInfoSetting * +nmtst_sett_info_settings (void) { - nm_assert (param_spec); - - _properties_override_add (properties_override, - .param_spec = param_spec, - .dbus_type = dbus_type, - .gprop_to_dbus_fcn = gprop_to_dbus_fcn, - .gprop_from_dbus_fcn = gprop_from_dbus_fcn); + return _sett_info_settings; } -static NMSettInfoSetting _sett_info_settings[_NM_META_SETTING_TYPE_NUM]; - static int _property_infos_sort_cmp_setting_connection (gconstpointer p_a, gconstpointer p_b, @@ -469,6 +340,18 @@ _nm_setting_class_commit_full (NMSettingClass *setting_class, property_specs = g_object_class_list_properties (G_OBJECT_CLASS (setting_class), &n_property_specs); + for (i = 0; i < properties_override->len; i++) { + NMSettInfoProperty *p = &g_array_index (properties_override, NMSettInfoProperty, i); + + nm_assert ((!!p->name) != (!!p->param_spec)); + + if (!p->name) { + nm_assert (p->param_spec); + p->name = p->param_spec->name; + } else + nm_assert (!p->param_spec); + } + #if NM_MORE_ASSERTS > 10 /* assert that properties_override is constructed consistently. */ for (i = 0; i < override_len; i++) { @@ -510,43 +393,46 @@ _nm_setting_class_commit_full (NMSettingClass *setting_class, NMSettInfoProperty *p = &g_array_index (properties_override, NMSettInfoProperty, i); GType vtype; - if (p->dbus_type) - continue; + if (p->property_type) + goto has_property_type; nm_assert (p->param_spec); - nm_assert (!p->gprop_to_dbus_fcn); vtype = p->param_spec->value_type; if (vtype == G_TYPE_BOOLEAN) - p->dbus_type = G_VARIANT_TYPE_BOOLEAN; + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_BOOLEAN); else if (vtype == G_TYPE_UCHAR) - p->dbus_type = G_VARIANT_TYPE_BYTE; + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_BYTE); else if (vtype == G_TYPE_INT) - p->dbus_type = G_VARIANT_TYPE_INT32; + p->property_type = &nm_sett_info_propert_type_plain_i; else if (vtype == G_TYPE_UINT) - p->dbus_type = G_VARIANT_TYPE_UINT32; + p->property_type = &nm_sett_info_propert_type_plain_u; else if (vtype == G_TYPE_INT64) - p->dbus_type = G_VARIANT_TYPE_INT64; + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_INT64); else if (vtype == G_TYPE_UINT64) - p->dbus_type = G_VARIANT_TYPE_UINT64; + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_UINT64); else if (vtype == G_TYPE_STRING) - p->dbus_type = G_VARIANT_TYPE_STRING; + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_STRING); else if (vtype == G_TYPE_DOUBLE) - p->dbus_type = G_VARIANT_TYPE_DOUBLE; + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_DOUBLE); else if (vtype == G_TYPE_STRV) - p->dbus_type = G_VARIANT_TYPE_STRING_ARRAY; + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_STRING_ARRAY); else if (vtype == G_TYPE_BYTES) { - p->dbus_type = G_VARIANT_TYPE_BYTESTRING; - p->gprop_to_dbus_fcn = _gprop_to_dbus_fcn_bytes; + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_BYTESTRING, + .gprop_to_dbus_fcn = _gprop_to_dbus_fcn_bytes); } else if (g_type_is_a (vtype, G_TYPE_ENUM)) { - p->dbus_type = G_VARIANT_TYPE_INT32; - p->gprop_to_dbus_fcn = _gprop_to_dbus_fcn_enum; + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_INT32, + .gprop_to_dbus_fcn = _gprop_to_dbus_fcn_enum); } else if (g_type_is_a (vtype, G_TYPE_FLAGS)) { - p->dbus_type = G_VARIANT_TYPE_UINT32; - p->gprop_to_dbus_fcn = _gprop_to_dbus_fcn_flags; - } + p->property_type = NM_SETT_INFO_PROPERT_TYPE (.dbus_type = G_VARIANT_TYPE_UINT32, + .gprop_to_dbus_fcn = _gprop_to_dbus_fcn_flags); + } else + nm_assert_not_reached (); - nm_assert (p->dbus_type); +has_property_type: + nm_assert (p->property_type); + nm_assert (p->property_type->dbus_type); + nm_assert (g_variant_type_string_is_valid ((const char *) p->property_type->dbus_type)); } G_STATIC_ASSERT_EXPR (G_STRUCT_OFFSET (NMSettInfoProperty, name) == 0); @@ -556,13 +442,15 @@ _nm_setting_class_commit_full (NMSettingClass *setting_class, sett_info->setting_class = setting_class; if (detail) sett_info->detail = *detail; + nm_assert (properties_override->len > 0); sett_info->property_infos_len = properties_override->len; - sett_info->property_infos = (const NMSettInfoProperty *) g_array_free (properties_override, - properties_override->len == 0); + sett_info->property_infos = nm_memdup (properties_override->data, sizeof (NMSettInfoProperty) * properties_override->len); sett_info->property_infos_sorted = _property_infos_sort (sett_info->property_infos, sett_info->property_infos_len, setting_class); + + g_array_free (properties_override, TRUE); } const NMSettInfoProperty * @@ -693,18 +581,16 @@ property_to_dbus (const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property = &sett_info->property_infos[property_idx]; GVariant *variant; - nm_assert (property->dbus_type); + nm_assert (property->property_type->dbus_type); if (!property->param_spec) { - if (!property->to_dbus_fcn) + if (!property->property_type->to_dbus_fcn) return NULL; - } else if (!ignore_flags) { + } else if ( !ignore_flags + && !NM_FLAGS_HAS (property->param_spec->flags, NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS)) { if (!NM_FLAGS_HAS (property->param_spec->flags, G_PARAM_WRITABLE)) return NULL; - if (NM_FLAGS_ANY (property->param_spec->flags, NM_SETTING_PARAM_GENDATA_BACKED)) - return NULL; - if ( NM_FLAGS_HAS (property->param_spec->flags, NM_SETTING_PARAM_LEGACY) && !_nm_utils_is_manager_process) return NULL; @@ -713,13 +599,7 @@ property_to_dbus (const NMSettInfoSetting *sett_info, if (NM_FLAGS_HAS (flags, NM_CONNECTION_SERIALIZE_NO_SECRETS)) return NULL; - /* Check agent secrets. Secrets in the vpn.secrets property are special as - * the flag for each of them is specified as a separate key in the - * vpn.data property. They are handled separately in the to_dbus_fcn() - * of VPN setting. */ - if ( NM_FLAGS_HAS (flags, NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED) - && !nm_streq (nm_setting_get_name (setting), NM_SETTING_VPN_SETTING_NAME) - && !nm_streq (property->name, NM_SETTING_VPN_SECRETS)) { + if (NM_FLAGS_HAS (flags, NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED)) { NMSettingSecretFlags f; /* see also _nm_connection_serialize_secrets() */ @@ -734,8 +614,8 @@ property_to_dbus (const NMSettInfoSetting *sett_info, } } - if (property->to_dbus_fcn) { - variant = property->to_dbus_fcn (sett_info, property_idx, connection, setting, flags, options); + if (property->property_type->to_dbus_fcn) { + variant = property->property_type->to_dbus_fcn (sett_info, property_idx, connection, setting, flags, options); nm_g_variant_take_ref (variant); } else { nm_auto_unset_gvalue GValue prop_value = { 0, }; @@ -750,15 +630,15 @@ property_to_dbus (const NMSettInfoSetting *sett_info, && g_param_value_defaults (property->param_spec, &prop_value)) return NULL; - if (property->gprop_to_dbus_fcn) { - variant = property->gprop_to_dbus_fcn (&prop_value); + if (property->property_type->gprop_to_dbus_fcn) { + variant = property->property_type->gprop_to_dbus_fcn (&prop_value); nm_g_variant_take_ref (variant); } else - variant = g_dbus_gvalue_to_gvariant (&prop_value, property->dbus_type); + variant = g_dbus_gvalue_to_gvariant (&prop_value, property->property_type->dbus_type); } nm_assert (!variant || !g_variant_is_floating (variant)); - nm_assert (!variant || g_variant_is_of_type (variant, property->dbus_type)); + nm_assert (!variant || g_variant_is_of_type (variant, property->property_type->dbus_type)); return variant; } @@ -769,12 +649,12 @@ set_property_from_dbus (const NMSettInfoProperty *property, GValue *dst_value) { nm_assert (property->param_spec); - nm_assert (property->dbus_type); + nm_assert (property->property_type->dbus_type); - if (property->gprop_from_dbus_fcn) { - if (!g_variant_type_equal (g_variant_get_type (src_value), property->dbus_type)) + if (property->property_type->gprop_from_dbus_fcn) { + if (!g_variant_type_equal (g_variant_get_type (src_value), property->property_type->dbus_type)) return FALSE; - property->gprop_from_dbus_fcn (src_value, dst_value); + property->property_type->gprop_from_dbus_fcn (src_value, dst_value); } else if (dst_value->g_type == G_TYPE_BYTES) { if (!g_variant_is_of_type (src_value, G_VARIANT_TYPE_BYTESTRING)) return FALSE; @@ -1010,16 +890,16 @@ init_from_dbus (NMSetting *setting, g_hash_table_remove (keys, property_info->name); if ( value - && property_info->from_dbus_fcn) { + && property_info->property_type->from_dbus_fcn) { - if (!g_variant_type_equal (g_variant_get_type (value), property_info->dbus_type)) { + if (!g_variant_type_equal (g_variant_get_type (value), property_info->property_type->dbus_type)) { /* for backward behavior, fail unless best-effort is chosen. */ if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)) continue; g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, _("can't set property of type '%s' from value of type '%s'"), - property_info->dbus_type ? - g_variant_type_peek_string (property_info->dbus_type) : + property_info->property_type->dbus_type ? + g_variant_type_peek_string (property_info->property_type->dbus_type) : property_info->param_spec ? g_type_name (property_info->param_spec->value_type) : "(unknown)", g_variant_get_type_string (value)); @@ -1027,12 +907,12 @@ init_from_dbus (NMSetting *setting, return FALSE; } - if (!property_info->from_dbus_fcn (setting, - connection_dict, - property_info->name, - value, - parse_flags, - &local)) { + if (!property_info->property_type->from_dbus_fcn (setting, + connection_dict, + property_info->name, + value, + parse_flags, + &local)) { if (!NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) continue; g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1042,12 +922,12 @@ init_from_dbus (NMSetting *setting, return FALSE; } } else if ( !value - && property_info->missing_from_dbus_fcn) { - if (!property_info->missing_from_dbus_fcn (setting, - connection_dict, - property_info->name, - parse_flags, - &local)) { + && property_info->property_type->missing_from_dbus_fcn) { + if (!property_info->property_type->missing_from_dbus_fcn (setting, + connection_dict, + property_info->name, + parse_flags, + &local)) { if (!NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) continue; g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1067,8 +947,8 @@ init_from_dbus (NMSetting *setting, continue; g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, _("can't set property of type '%s' from value of type '%s'"), - property_info->dbus_type - ? g_variant_type_peek_string (property_info->dbus_type) + property_info->property_type->dbus_type + ? g_variant_type_peek_string (property_info->property_type->dbus_type) : ( property_info->param_spec ? g_type_name (property_info->param_spec->value_type) : "(unknown)"), @@ -1115,9 +995,10 @@ nm_setting_get_dbus_property_type (NMSetting *setting, g_return_val_if_fail (property != NULL, NULL); - nm_assert (property->dbus_type); + nm_assert (property->property_type); + nm_assert (g_variant_type_string_is_valid ((const char *) property->property_type->dbus_type)); - return property->dbus_type; + return property->property_type->dbus_type; } gboolean @@ -1400,7 +1281,7 @@ _nm_setting_should_compare_secret_property (NMSetting *setting, } /* when @setting has the secret-flags that should be ignored, - * we skip the comparisong if: + * we skip the comparison if: * * - @other is not present, * - @other does not have a secret named @secret_name @@ -1512,6 +1393,18 @@ _compare_property (const NMSettInfoSetting *sett_info, || NM_FLAGS_HAS (sett_info->property_infos[property_idx].param_spec->flags, NM_SETTING_PARAM_INFERRABLE) || compare_result == NM_TERNARY_DEFAULT); +#if NM_MORE_ASSERTS > 10 + /* assert that compare_property() is symeric. */ + nm_assert ( !set_b + || compare_result == NM_SETTING_GET_CLASS (set_a)->compare_property (sett_info, + property_idx, + con_b, + set_b, + con_a, + set_a, + flags)); +#endif + return compare_result; } @@ -2412,7 +2305,7 @@ nm_setting_to_string (NMSetting *setting) return g_string_free (string, FALSE); } -GVariant * +static GVariant * _nm_setting_get_deprecated_virtual_interface_name (const NMSettInfoSetting *sett_info, guint property_idx, NMConnection *connection, @@ -2435,6 +2328,29 @@ _nm_setting_get_deprecated_virtual_interface_name (const NMSettInfoSetting *sett return NULL; } +const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name = { + .dbus_type = G_VARIANT_TYPE_STRING, + .to_dbus_fcn = _nm_setting_get_deprecated_virtual_interface_name, +}; + +const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i = { + .dbus_type = G_VARIANT_TYPE_INT32, + /* No functions set. This property type is to silently ignore the value on D-Bus. */ +}; + +const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u = { + .dbus_type = G_VARIANT_TYPE_UINT32, + /* No functions set. This property type is to silently ignore the value on D-Bus. */ +}; + +const NMSettInfoPropertType nm_sett_info_propert_type_plain_i = { + .dbus_type = G_VARIANT_TYPE_INT32, +}; + +const NMSettInfoPropertType nm_sett_info_propert_type_plain_u = { + .dbus_type = G_VARIANT_TYPE_UINT32, +}; + /*****************************************************************************/ static GenData * diff --git a/libnm-core/nm-setting.h b/libnm-core/nm-setting.h index 34586cce..26c1b1ee 100644 --- a/libnm-core/nm-setting.h +++ b/libnm-core/nm-setting.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2011 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #ifndef __NM_SETTING_H__ diff --git a/libnm-core/nm-simple-connection.c b/libnm-core/nm-simple-connection.c index f58f145f..fd7eb870 100644 --- a/libnm-core/nm-simple-connection.c +++ b/libnm-core/nm-simple-connection.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2008 Novell, Inc. - * Copyright 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-simple-connection.h b/libnm-core/nm-simple-connection.h index 65c12fad..02e28ac1 100644 --- a/libnm-core/nm-simple-connection.h +++ b/libnm-core/nm-simple-connection.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2014 Red Hat, Inc. + * Copyright (C) 2014 Red Hat, Inc. */ #ifndef __NM_SIMPLE_CONNECTION_H__ diff --git a/libnm-core/nm-team-utils.c b/libnm-core/nm-team-utils.c index 63018b09..084547c8 100644 --- a/libnm-core/nm-team-utils.c +++ b/libnm-core/nm-team-utils.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2019 Red Hat, Inc. + * Copyright (C) 2019 Red Hat, Inc. */ #define NM_VALUE_TYPE_DEFINE_FUNCTIONS @@ -2434,7 +2420,7 @@ _nm_setting_get_team_setting (struct _NMSetting *setting) return _nm_setting_team_port_get_team_setting (NM_SETTING_TEAM_PORT (setting)); } -GVariant * +static GVariant * _nm_team_settings_property_to_dbus (const NMSettInfoSetting *sett_info, guint property_idx, NMConnection *connection, @@ -2481,7 +2467,7 @@ _nm_team_settings_property_to_dbus (const NMSettInfoSetting *sett_info, return NULL; } -void +static void _nm_team_settings_property_from_dbus_link_watchers (GVariant *dbus_value, GValue *prop_value) { @@ -2489,6 +2475,32 @@ _nm_team_settings_property_from_dbus_link_watchers (GVariant *dbus_value, _nm_utils_team_link_watchers_from_variant (dbus_value, FALSE, NULL)); } +const NMSettInfoPropertType nm_sett_info_propert_type_team_b = { + .dbus_type = G_VARIANT_TYPE_BOOLEAN, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, +}; + +const NMSettInfoPropertType nm_sett_info_propert_type_team_i = { + .dbus_type = G_VARIANT_TYPE_INT32, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, +}; + +const NMSettInfoPropertType nm_sett_info_propert_type_team_s = { + .dbus_type = G_VARIANT_TYPE_STRING, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, +}; + +const NMSettInfoPropertType nm_sett_info_propert_type_team_as = { + .dbus_type = NM_G_VARIANT_TYPE ("as"), + .to_dbus_fcn = _nm_team_settings_property_to_dbus, +}; + +const NMSettInfoPropertType nm_sett_info_propert_type_team_link_watchers = { + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = _nm_team_settings_property_to_dbus, + .gprop_from_dbus_fcn = _nm_team_settings_property_from_dbus_link_watchers, +}; + /*****************************************************************************/ NMTeamSetting * diff --git a/libnm-core/nm-team-utils.h b/libnm-core/nm-team-utils.h index c4631bec..2d22d63e 100644 --- a/libnm-core/nm-team-utils.h +++ b/libnm-core/nm-team-utils.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2019 Red Hat, Inc. + * Copyright (C) 2019 Red Hat, Inc. */ #ifndef __NM_TEAM_UITLS_H__ @@ -25,6 +11,7 @@ #endif #include "nm-glib-aux/nm-value-type.h" +#include "nm-core-internal.h" struct _NMSetting; @@ -291,17 +278,10 @@ NMTeamSetting *_nm_setting_get_team_setting (struct _NMSetting *setting); /*****************************************************************************/ -#include "nm-connection.h" -#include "nm-core-internal.h" - -GVariant *_nm_team_settings_property_to_dbus (const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection *connection, - NMSetting *setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options); - -void _nm_team_settings_property_from_dbus_link_watchers (GVariant *dbus_value, - GValue *prop_value); +extern const NMSettInfoPropertType nm_sett_info_propert_type_team_b; +extern const NMSettInfoPropertType nm_sett_info_propert_type_team_i; +extern const NMSettInfoPropertType nm_sett_info_propert_type_team_s; +extern const NMSettInfoPropertType nm_sett_info_propert_type_team_as; +extern const NMSettInfoPropertType nm_sett_info_propert_type_team_link_watchers; #endif /* __NM_TEAM_UITLS_H__ */ diff --git a/libnm-core/nm-utils-private.h b/libnm-core/nm-utils-private.h index 22943edd..4ca9dfc2 100644 --- a/libnm-core/nm-utils-private.h +++ b/libnm-core/nm-utils-private.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2005 - 2017 Red Hat, Inc. + * Copyright (C) 2005 - 2017 Red Hat, Inc. */ #ifndef __NM_UTILS_PRIVATE_H__ @@ -61,41 +47,16 @@ gboolean _nm_utils_wps_method_validate (NMSettingWirelessSecurityWpsMethod wps_m /* D-Bus transform funcs */ -GVariant *_nm_utils_hwaddr_cloned_get (const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection *connection, - NMSetting *setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options); -gboolean _nm_utils_hwaddr_cloned_set (NMSetting *setting, - GVariant *connection_dict, - const char *property, - GVariant *value, - NMSettingParseFlags parse_flags, - GError **error); -gboolean _nm_utils_hwaddr_cloned_not_set (NMSetting *setting, - GVariant *connection_dict, - const char *property, - NMSettingParseFlags parse_flags, - GError **error); -GVariant * _nm_utils_hwaddr_cloned_data_synth (const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection *connection, - NMSetting *setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options); -gboolean _nm_utils_hwaddr_cloned_data_set (NMSetting *setting, - GVariant *connection_dict, - const char *property, - GVariant *value, - NMSettingParseFlags parse_flags, - GError **error); - -GVariant * _nm_utils_hwaddr_to_dbus (const GValue *prop_value); -void _nm_utils_hwaddr_from_dbus (GVariant *dbus_value, - GValue *prop_value); - -GVariant * _nm_utils_strdict_to_dbus (const GValue *prop_value); +extern const NMSettInfoPropertType nm_sett_info_propert_type_strdict; + +extern const NMSettInfoPropertType nm_sett_info_propert_type_mac_addrees; + +extern const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address; + +extern const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address; + +extern const NMSettInfoPropertType nm_sett_info_propert_type_bridge_vlans; + void _nm_utils_strdict_from_dbus (GVariant *dbus_value, GValue *prop_value); @@ -111,19 +72,6 @@ void _nm_utils_format_variant_attributes_full (GString *str, char key_value_separator); gboolean _nm_sriov_vf_parse_vlans (NMSriovVF *vf, const char *str, GError **error); -GVariant * _nm_utils_bridge_vlans_to_dbus (const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection *connection, - NMSetting *setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options); - -gboolean _nm_utils_bridge_vlans_from_dbus (NMSetting *setting, - GVariant *connection_dict, - const char *property, - GVariant *value, - NMSettingParseFlags parse_flags, - GError **error); gboolean _nm_utils_bridge_vlan_verify_list (GPtrArray *vlans, gboolean check_normalizable, GError **error, diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 8f2b4018..4659734b 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2005 - 2017 Red Hat, Inc. + * Copyright (C) 2005 - 2017 Red Hat, Inc. */ #include "nm-default.h" @@ -814,7 +800,7 @@ _nm_utils_hash_values_to_slist (GHashTable *hash) return list; } -GVariant * +static GVariant * _nm_utils_strdict_to_dbus (const GValue *prop_value) { GHashTable *hash; @@ -839,9 +825,15 @@ _nm_utils_strdict_to_dbus (const GValue *prop_value) if (len == 1) g_variant_builder_add (&builder, "{ss}", key, value); else { - gs_free NMUtilsNamedValue *idx = NULL; + gs_free NMUtilsNamedValue *idx_free = NULL; + NMUtilsNamedValue *idx; + + if (len > 300 / sizeof (NMUtilsNamedValue)) { + idx_free = g_new (NMUtilsNamedValue, len); + idx = idx_free; + } else + idx = g_alloca (sizeof (NMUtilsNamedValue) * len); - idx = g_new (NMUtilsNamedValue, len); i = 0; do { idx[i].name = key; @@ -876,6 +868,12 @@ _nm_utils_strdict_from_dbus (GVariant *dbus_value, g_value_take_boxed (prop_value, hash); } +const NMSettInfoPropertType nm_sett_info_propert_type_strdict = { + .dbus_type = NM_G_VARIANT_TYPE ("a{ss}"), + .gprop_to_dbus_fcn = _nm_utils_strdict_to_dbus, + .gprop_from_dbus_fcn = _nm_utils_strdict_from_dbus, +}; + GHashTable * _nm_utils_copy_strdict (GHashTable *strdict) { @@ -1215,46 +1213,30 @@ nm_utils_security_valid (NMUtilsSecurityType type, break; case NMU_SEC_WPA_PSK: if (adhoc) - return FALSE; /* FIXME: Kernel WPA Ad-Hoc support is buggy */ + return FALSE; if (!(wifi_caps & NM_WIFI_DEVICE_CAP_WPA)) return FALSE; if (have_ap) { - /* Ad-Hoc WPA APs won't necessarily have the PSK flag set, and - * they don't have any pairwise ciphers. */ - if (adhoc) { - /* coverity[dead_error_line] */ - if ( (ap_wpa & NM_802_11_AP_SEC_GROUP_TKIP) + if (ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_PSK) { + if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_TKIP) && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP)) return TRUE; - if ( (ap_wpa & NM_802_11_AP_SEC_GROUP_CCMP) + if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_CCMP) && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP)) return TRUE; - } else { - if (ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_PSK) { - if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_TKIP) - && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP)) - return TRUE; - if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_CCMP) - && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP)) - return TRUE; - } } return FALSE; } break; case NMU_SEC_WPA2_PSK: - if (adhoc) - return FALSE; /* FIXME: Kernel WPA Ad-Hoc support is buggy */ if (!(wifi_caps & NM_WIFI_DEVICE_CAP_RSN)) return FALSE; if (have_ap) { - /* Ad-Hoc WPA APs won't necessarily have the PSK flag set, and - * they don't have any pairwise ciphers, nor any RSA flags yet. */ if (adhoc) { - /* coverity[dead_error_line] */ - if (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP) - return TRUE; - if (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP) + if (!(wifi_caps & NM_WIFI_DEVICE_CAP_IBSS_RSN)) + return FALSE; + if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_CCMP) + && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP)) return TRUE; } else { if (ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK) { @@ -1296,18 +1278,24 @@ nm_utils_security_valid (NMUtilsSecurityType type, } break; case NMU_SEC_SAE: - if (adhoc) - return FALSE; if (!(wifi_caps & NM_WIFI_DEVICE_CAP_RSN)) return FALSE; if (have_ap) { - if (ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_SAE) { - if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_TKIP) - && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP)) - return TRUE; + if (adhoc) { + if (!(wifi_caps & NM_WIFI_DEVICE_CAP_IBSS_RSN)) + return FALSE; if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_CCMP) && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP)) return TRUE; + } else { + if (ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_SAE) { + if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_TKIP) + && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP)) + return TRUE; + if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_CCMP) + && (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP)) + return TRUE; + } } return FALSE; } @@ -1740,7 +1728,9 @@ nm_utils_ip6_dns_to_variant (char **dns) * @value: a #GVariant of type 'aay' * * Utility function to convert a #GVariant of type 'aay' representing a list of - * IPv6 addresses into an array of IP address strings. + * IPv6 addresses into an array of IP address strings. Each "ay" entry must be + * a IPv6 address in binary form (16 bytes long). Invalid entries are silently + * ignored. * * Returns: (transfer full) (type utf8): a %NULL-terminated array of IP address strings. **/ @@ -1762,14 +1752,9 @@ nm_utils_ip6_dns_from_variant (GVariant *value) gsize length; const struct in6_addr *ip = g_variant_get_fixed_array (ip_var, &length, 1); - if (length != sizeof (struct in6_addr)) { - g_warning ("%s: ignoring invalid IP6 address of length %d", - __func__, (int) length); - g_variant_unref (ip_var); - continue; - } + if (length == sizeof (struct in6_addr)) + dns[i++] = nm_utils_inet6_ntop_dup (ip); - dns[i++] = nm_utils_inet6_ntop_dup (ip); g_variant_unref (ip_var); } dns[i] = NULL; @@ -4354,7 +4339,7 @@ _nm_utils_hwaddr_to_dbus_impl (const char *str) return g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, buf, len, 1); } -GVariant * +static GVariant * _nm_utils_hwaddr_cloned_get (const NMSettInfoSetting *sett_info, guint property_idx, NMConnection *connection, @@ -4370,7 +4355,7 @@ _nm_utils_hwaddr_cloned_get (const NMSettInfoSetting *sett_info, return _nm_utils_hwaddr_to_dbus_impl (addr); } -gboolean +static gboolean _nm_utils_hwaddr_cloned_set (NMSetting *setting, GVariant *connection_dict, const char *property, @@ -4402,7 +4387,7 @@ _nm_utils_hwaddr_cloned_set (NMSetting *setting, return TRUE; } -gboolean +static gboolean _nm_utils_hwaddr_cloned_not_set (NMSetting *setting, GVariant *connection_dict, const char *property, @@ -4413,7 +4398,14 @@ _nm_utils_hwaddr_cloned_not_set (NMSetting *setting, return TRUE; } -GVariant * +const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address = { + .dbus_type = G_VARIANT_TYPE_BYTESTRING, + .to_dbus_fcn = _nm_utils_hwaddr_cloned_get, + .from_dbus_fcn = _nm_utils_hwaddr_cloned_set, + .missing_from_dbus_fcn = _nm_utils_hwaddr_cloned_not_set, +}; + +static GVariant * _nm_utils_hwaddr_cloned_data_synth (const NMSettInfoSetting *sett_info, guint property_idx, NMConnection *connection, @@ -4452,7 +4444,7 @@ _nm_utils_hwaddr_cloned_data_synth (const NMSettInfoSetting *sett_info, : NULL; } -gboolean +static gboolean _nm_utils_hwaddr_cloned_data_set (NMSetting *setting, GVariant *connection_dict, const char *property, @@ -4472,13 +4464,19 @@ _nm_utils_hwaddr_cloned_data_set (NMSetting *setting, return TRUE; } -GVariant * +const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address = { + .dbus_type = G_VARIANT_TYPE_STRING, + .to_dbus_fcn = _nm_utils_hwaddr_cloned_data_synth, + .from_dbus_fcn = _nm_utils_hwaddr_cloned_data_set, +}; + +static GVariant * _nm_utils_hwaddr_to_dbus (const GValue *prop_value) { return _nm_utils_hwaddr_to_dbus_impl (g_value_get_string (prop_value)); } -void +static void _nm_utils_hwaddr_from_dbus (GVariant *dbus_value, GValue *prop_value) { @@ -4490,6 +4488,12 @@ _nm_utils_hwaddr_from_dbus (GVariant *dbus_value, g_value_take_string (prop_value, str); } +const NMSettInfoPropertType nm_sett_info_propert_type_mac_addrees = { + .dbus_type = G_VARIANT_TYPE_BYTESTRING, + .gprop_to_dbus_fcn = _nm_utils_hwaddr_to_dbus, + .gprop_from_dbus_fcn = _nm_utils_hwaddr_from_dbus, +}; + /*****************************************************************************/ /* Validate secret-flags. Most settings don't validate them, which is a bug. @@ -5551,6 +5555,48 @@ attribute_unescape (const char *start, const char *end) return ret; } +gboolean +_nmtst_variant_attribute_spec_assert_sorted (const NMVariantAttributeSpec *const*array, + gsize len) +{ + gsize i; + + g_assert (array); + g_assert (len > 0); + g_assert_cmpint(len, ==, NM_PTRARRAY_LEN (array)); + + for (i = 0; i < len; i++) { + nm_assert (array[i]->name); + nm_assert (array[i]->name[0]); + if (i > 0) + nm_assert (strcmp (array[i - 1]->name, array[i]->name) < 0); + } + nm_assert (!array[i]); + + return TRUE; +} + +const NMVariantAttributeSpec * +_nm_variant_attribute_spec_find_binary_search (const NMVariantAttributeSpec *const*array, + gsize len, + const char *name) +{ + gssize idx; + + G_STATIC_ASSERT_EXPR (G_STRUCT_OFFSET (NMVariantAttributeSpec, name) == 0); + + idx = nm_utils_ptrarray_find_binary_search ((gconstpointer *) array, + len, + &name, + nm_strcmp_p_with_data, + NULL, + NULL, + NULL); + if (idx < 0) + return NULL; + return array[idx]; +} + /** * nm_utils_parse_variant_attributes: * @string: the input string @@ -5861,6 +5907,14 @@ nm_utils_version (void) /*****************************************************************************/ +NM_UTILS_FLAGS2STR_DEFINE (nm_bluetooth_capability_to_string, NMBluetoothCapabilities, + NM_UTILS_FLAGS2STR (NM_BT_CAPABILITY_NONE, "NONE"), + NM_UTILS_FLAGS2STR (NM_BT_CAPABILITY_DUN, "DUN"), + NM_UTILS_FLAGS2STR (NM_BT_CAPABILITY_NAP, "NAP"), +) + +/*****************************************************************************/ + /** * nm_utils_base64secret_decode: * @base64_key: the (possibly invalid) base64 encode key. @@ -5930,7 +5984,7 @@ nm_utils_base64secret_normalize (const char *base64_key, return TRUE; } -GVariant * +static GVariant * _nm_utils_bridge_vlans_to_dbus (const NMSettInfoSetting *sett_info, guint property_idx, NMConnection *connection, @@ -5972,7 +6026,7 @@ _nm_utils_bridge_vlans_to_dbus (const NMSettInfoSetting *sett_info, return g_variant_builder_end (&builder); } -gboolean +static gboolean _nm_utils_bridge_vlans_from_dbus (NMSetting *setting, GVariant *connection_dict, const char *property, @@ -6026,6 +6080,12 @@ _nm_utils_bridge_vlans_from_dbus (NMSetting *setting, return TRUE; } +const NMSettInfoPropertType nm_sett_info_propert_type_bridge_vlans = { + .dbus_type = NM_G_VARIANT_TYPE ("aa{sv}"), + .to_dbus_fcn = _nm_utils_bridge_vlans_to_dbus, + .from_dbus_fcn = _nm_utils_bridge_vlans_from_dbus, +}; + gboolean _nm_utils_bridge_vlan_verify_list (GPtrArray *vlans, gboolean check_normalizable, @@ -6104,28 +6164,77 @@ _nm_utils_bridge_vlan_verify_list (GPtrArray *vlans, } gboolean -nm_utils_connection_is_adhoc_wpa (NMConnection *connection) +_nm_utils_iaid_verify (const char *str, gint64 *out_value) { - NMSettingWireless *s_wifi; - NMSettingWirelessSecurity *s_wsec; - const char *key_mgmt; - const char *mode; + gint64 iaid; + + NM_SET_OUT (out_value, -1); - s_wifi = nm_connection_get_setting_wireless (connection); - if (!s_wifi) + if (!str || !str[0]) return FALSE; - mode = nm_setting_wireless_get_mode (s_wifi); - if (!nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC)) + if (NM_IAID_IS_SPECIAL (str)) + return TRUE; + + if ( NM_STRCHAR_ALL (str, ch, ch >= '0' && ch <= '9') + && (str[0] != '0' || str[1] == '\0') + && (iaid = _nm_utils_ascii_str_to_int64 (str, 10, 0, G_MAXUINT32, -1)) != -1) { + NM_SET_OUT (out_value, iaid); + return TRUE; + } + + return FALSE; +} + +gboolean +_nm_utils_validate_dhcp_hostname_flags (NMDhcpHostnameFlags flags, + int addr_family, + GError **error) +{ + NMDhcpHostnameFlags unknown; + + unknown = flags; + unknown &= ~( NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED + | NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE + | NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE + | NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS); + if (unknown) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("unknown flags 0x%x"), (guint) unknown); return FALSE; + } - s_wsec = nm_connection_get_setting_wireless_security (connection); - if (!s_wsec) + if (NM_FLAGS_ALL (flags, + NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE + | NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'fqdn-no-update' and 'fqdn-serv-update' flags cannot be set at the same time")); return FALSE; + } - key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec); - if (!nm_streq0 (key_mgmt, "wpa-none")) + if ( NM_FLAGS_HAS (flags, NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS) + && NM_FLAGS_ANY (flags, NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE + | NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED + | NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'fqdn-clear-flags' flag is incompatible with other FQDN flags")); return FALSE; + } + + if ( addr_family == AF_INET6 + && (flags & NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("DHCPv6 does not support the E (encoded) FQDN flag")); + return FALSE; + } return TRUE; } diff --git a/libnm-core/nm-utils.h b/libnm-core/nm-utils.h index a0fa8d7f..5418a1e6 100644 --- a/libnm-core/nm-utils.h +++ b/libnm-core/nm-utils.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2005 - 2017 Red Hat, Inc. + * Copyright (C) 2005 - 2017 Red Hat, Inc. */ #ifndef __NM_UTILS_H__ diff --git a/libnm-core/nm-version.h b/libnm-core/nm-version.h index 61b4e667..3180c7e2 100644 --- a/libnm-core/nm-version.h +++ b/libnm-core/nm-version.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2011, 2015 Red Hat, Inc. + * Copyright (C) 2011, 2015 Red Hat, Inc. */ #ifndef NM_VERSION_H @@ -215,11 +201,44 @@ # define NM_AVAILABLE_IN_1_20 #endif -#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_20_6 -# define NM_AVAILABLE_IN_1_20_6 G_UNAVAILABLE(1,20.6) +#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_22 +# define NM_DEPRECATED_IN_1_22 G_DEPRECATED +# define NM_DEPRECATED_IN_1_22_FOR(f) G_DEPRECATED_FOR(f) #else -# define NM_AVAILABLE_IN_1_20_6 +# define NM_DEPRECATED_IN_1_22 +# define NM_DEPRECATED_IN_1_22_FOR(f) #endif +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_22 +# define NM_AVAILABLE_IN_1_22 G_UNAVAILABLE(1,22) +#else +# define NM_AVAILABLE_IN_1_22 +#endif + +/* + * Synchronous API for calling D-Bus in libnm is deprecated. See + * https://developer.gnome.org/libnm/stable/usage.html#sync-api + * + * Note that "deprecated" here does not really mean that the API is going + * to be removed. We don't break API. Just comment that it is awkward and + * discouraged. The user may: + * + * - continue to use this API. It's deprecated, awkward and discouraged, + * but if it works for you, that's fine. + * + * - use asynchronous API. That's the only sensible way to use D-Bus. + * If libnm lacks a certain asynchronous counterpart, it should be + * added. + * + * - use GDBusConnection directly. There really isn't anything wrong + * with D-Bus or GDBusConnection. This deprecated API is just a wrapper + * around g_dbus_connection_call_sync(). You may call it directly + * without feeling dirty. + * + * We don't want to force users away from this API, for that reason the + * macro does not yet expand to G_DEPRECATED. + */ +#define _NM_DEPRECATED_SYNC_METHOD /*NM_DEPRECATED_IN_1_22*/ +#define _NM_DEPRECATED_SYNC_WRITABLE_PROPERTY /*NM_DEPRECATED_IN_1_22*/ #endif /* NM_VERSION_H */ diff --git a/libnm-core/nm-vpn-dbus-interface.h b/libnm-core/nm-vpn-dbus-interface.h index 3c8b19f1..8d2aaabc 100644 --- a/libnm-core/nm-vpn-dbus-interface.h +++ b/libnm-core/nm-vpn-dbus-interface.h @@ -1,19 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2004 Red Hat, Inc. + * Copyright (C) 2004 Red Hat, Inc. */ /* D-Bus-related definitions for NetworkManager VPN plugins. diff --git a/libnm-core/nm-vpn-editor-plugin.c b/libnm-core/nm-vpn-editor-plugin.c index d465695e..27dd2e23 100644 --- a/libnm-core/nm-vpn-editor-plugin.c +++ b/libnm-core/nm-vpn-editor-plugin.c @@ -1,22 +1,8 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2008 Novell, Inc. - * Copyright 2008 - 2010 Red Hat, Inc. - * Copyright 2015 Red Hat, Inc. + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2010 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-vpn-editor-plugin.h b/libnm-core/nm-vpn-editor-plugin.h index 2be6c379..b4ab6a91 100644 --- a/libnm-core/nm-vpn-editor-plugin.h +++ b/libnm-core/nm-vpn-editor-plugin.h @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2008 Novell, Inc. - * Copyright 2008 - 2015 Red Hat, Inc. + * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2008 - 2015 Red Hat, Inc. */ #ifndef __NM_VPN_EDITOR_PLUGIN_H__ diff --git a/libnm-core/nm-vpn-plugin-info.c b/libnm-core/nm-vpn-plugin-info.c index 462e41a6..df3ef08d 100644 --- a/libnm-core/nm-vpn-plugin-info.c +++ b/libnm-core/nm-vpn-plugin-info.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/nm-vpn-plugin-info.h b/libnm-core/nm-vpn-plugin-info.h index 08414113..c6242ac6 100644 --- a/libnm-core/nm-vpn-plugin-info.h +++ b/libnm-core/nm-vpn-plugin-info.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #ifndef __NM_VPN_PLUGIN_INFO_H__ diff --git a/libnm-core/tests/meson.build b/libnm-core/tests/meson.build index 1afb9c4b..292eeaa0 100644 --- a/libnm-core/tests/meson.build +++ b/libnm-core/tests/meson.build @@ -9,14 +9,24 @@ enum_types = 'nm-core-tests-enum-types' -enum = gnome.mkenums( +enum_sources = gnome.mkenums_simple( enum_types, sources: 'test-general-enums.h', identifier_prefix: nm_id_prefix, - c_template: enum_types + '.c.template', - h_template: enum_types + '.h.template', ) +deps = [ + libnm_core_dep, + libnm_core_nm_default_dep, +] + +c_flags = [ + '-DNETWORKMANAGER_COMPILATION_TEST', + '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', +] + +test_cert_dir = join_paths(meson.current_source_dir(), 'certs') + test_units = [ 'test-compare', 'test-crypto', @@ -27,22 +37,15 @@ test_units = [ 'test-settings-defaults', ] -test_cert_dir = join_paths(meson.current_source_dir(), 'certs') - foreach test_unit: test_units exe = executable( 'libnm-core-' + test_unit, - [test_unit + '.c'] + enum, - dependencies: [ - libnm_core_dep, - libnm_systemd_shared_no_logging_dep, - ], - c_args: [ - '-DNETWORKMANAGER_COMPILATION_TEST', - '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', - ], - link_with: libnm_core, + [test_unit + '.c'] + enum_sources, + dependencies: deps, + c_args: c_flags, + link_with: libnm_systemd_logging_stub, ) + test( 'libnm-core/' + test_unit, test_script, diff --git a/libnm-core/tests/test-compare.c b/libnm-core/tests/test-compare.c index ec4ca437..77f0ba4f 100644 --- a/libnm-core/tests/test-compare.c +++ b/libnm-core/tests/test-compare.c @@ -1,21 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2007 - 2014 Red Hat, Inc. - * Copyright 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2014 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. */ #include "nm-default.h" diff --git a/libnm-core/tests/test-crypto.c b/libnm-core/tests/test-crypto.c index 9eab29d4..538bf858 100644 --- a/libnm-core/tests/test-crypto.c +++ b/libnm-core/tests/test-crypto.c @@ -1,22 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* * Dan Williams <dcbw@redhat.com> - * - * 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 2007 - 2011 Red Hat, Inc. + * Copyright (C) 2007 - 2011 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/tests/test-general-enums.h b/libnm-core/tests/test-general-enums.h index 72981171..451f1b50 100644 --- a/libnm-core/tests/test-general-enums.h +++ b/libnm-core/tests/test-general-enums.h @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: LGPL-2.1+ /* - * 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 2015 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. */ #ifndef _NM_TEST_GENERAL_ENUMS_H_ diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 13fed902..c1b7b84a 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -1,27 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT SC WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2008 - 2018 Red Hat, Inc. - * + * Copyright (C) 2008 - 2018 Red Hat, Inc. */ #define NM_GLIB_COMPAT_H_TEST #include "nm-default.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <glib-unix.h> + #include "nm-std-aux/c-list-util.h" #include "nm-glib-aux/nm-enum-utils.h" @@ -1755,7 +1745,7 @@ test_setting_gsm_apn_bad_chars (void) /* 0 characters long */ g_object_set (s_gsm, NM_SETTING_GSM_APN, "", NULL); - g_assert (!nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL)); + g_assert (nm_setting_verify (NM_SETTING (s_gsm), NULL, NULL)); /* 65-character long */ g_object_set (s_gsm, NM_SETTING_GSM_APN, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl1", NULL); @@ -3061,11 +3051,13 @@ test_connection_diff_a_only (void) { NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS,NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP4_CONFIG_DHCP_FQDN, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_NEVER_DEFAULT, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_MAY_FAIL, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_DAD_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_DNS_PRIORITY, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_IP_CONFIG_DHCP_IAID, NM_SETTING_DIFF_RESULT_IN_A }, { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN }, } }, }; @@ -6572,6 +6564,11 @@ test_nm_utils_ascii_str_to_int64 (void) test_nm_utils_ascii_str_to_int64_do ("080", 0, G_MININT64, G_MAXINT64, -1, EINVAL, -1); test_nm_utils_ascii_str_to_int64_do ("070", 0, G_MININT64, G_MAXINT64, -1, 0, 7*8); test_nm_utils_ascii_str_to_int64_do ("0x70", 0, G_MININT64, G_MAXINT64, -1, 0, 0x70); + + g_assert_cmpint (21, ==, _nm_utils_ascii_str_to_int64 ("025", 0, 0, 1000, -1)); + g_assert_cmpint (21, ==, _nm_utils_ascii_str_to_int64 ("0025", 0, 0, 1000, -1)); + g_assert_cmpint (25, ==, _nm_utils_ascii_str_to_int64 ("025", 10, 0, 1000, -1)); + g_assert_cmpint (25, ==, _nm_utils_ascii_str_to_int64 ("0025", 10, 0, 1000, -1)); } /*****************************************************************************/ @@ -7990,6 +7987,33 @@ test_route_attributes_format (void) /*****************************************************************************/ +static void +test_variant_attribute_spec (void) +{ + const NMVariantAttributeSpec *const *const specs_list[] = { + nm_ip_route_get_variant_attribute_spec (), + }; + int i_specs; + + for (i_specs = 0; i_specs < G_N_ELEMENTS (specs_list); i_specs++) { + const NMVariantAttributeSpec *const *const specs = specs_list[i_specs]; + gsize len; + gsize i; + + g_assert (specs); + + len = NM_PTRARRAY_LEN (specs); + g_assert_cmpint (len, >, 0u); + + _nmtst_variant_attribute_spec_assert_sorted (specs, len); + for (i = 0; i < len; i++) + g_assert (specs[i] == _nm_variant_attribute_spec_find_binary_search (specs, len, specs[i]->name)); + g_assert (!_nm_variant_attribute_spec_find_binary_search (specs, len, "bogus")); + } +} + +/*****************************************************************************/ + static gboolean do_test_nm_set_out_called (int *call_count) { @@ -8112,6 +8136,191 @@ test_ethtool_offload (void) /*****************************************************************************/ +typedef struct { + GMainLoop *loop1; + GMainContext *c2; + GSource *extra_sources[2]; + bool got_signal[5]; + int fd_2; +} IntegData; + +static gboolean +_test_integrate_cb_handle (IntegData *d, int signal) +{ + int i; + + g_assert (d); + g_assert (signal >= 0); + g_assert (signal < G_N_ELEMENTS (d->got_signal)); + + g_assert (!d->got_signal[signal]); + d->got_signal[signal] = TRUE; + + for (i = 0; i < G_N_ELEMENTS (d->got_signal); i++) { + if (!d->got_signal[i]) + break; + } + if (i == G_N_ELEMENTS (d->got_signal)) + g_main_loop_quit (d->loop1); + return G_SOURCE_REMOVE; +} + +static gboolean +_test_integrate_cb_timeout_1 (gpointer user_data) +{ + return _test_integrate_cb_handle (user_data, 0); +} + +static gboolean +_test_integrate_cb_fd_2 (int fd, + GIOCondition condition, + gpointer user_data) + +{ + IntegData *d = user_data; + + g_assert (d->got_signal[1]); + g_assert (d->got_signal[2]); + g_assert (d->got_signal[3]); + g_assert (d->extra_sources[0]); + g_assert (d->extra_sources[1]); + + return _test_integrate_cb_handle (d, 4); +} + +static gboolean +_test_integrate_cb_idle_2 (gpointer user_data) +{ + IntegData *d = user_data; + GSource *extra_source; + + g_assert (d->got_signal[1]); + g_assert (d->got_signal[2]); + g_assert (d->extra_sources[0]); + g_assert (!d->extra_sources[1]); + + extra_source = g_unix_fd_source_new (d->fd_2, G_IO_IN); + g_source_set_callback (extra_source, G_SOURCE_FUNC (_test_integrate_cb_fd_2), d, NULL); + g_source_attach (extra_source, d->c2); + + d->extra_sources[1] = extra_source; + + return _test_integrate_cb_handle (d, 3); +} + +static gboolean +_test_integrate_cb_idle_1 (gpointer user_data) +{ + IntegData *d = user_data; + GSource *extra_source; + + g_assert (d->got_signal[2]); + g_assert (!d->extra_sources[0]); + + extra_source = g_idle_source_new (); + g_source_set_callback (extra_source, _test_integrate_cb_idle_2, d, NULL); + g_source_attach (extra_source, d->c2); + + d->extra_sources[0] = extra_source; + + return _test_integrate_cb_handle (d, 1); +} + +static gboolean +_test_integrate_cb_fd_1 (int fd, + GIOCondition condition, + gpointer user_data) + +{ + IntegData *d = user_data; + + g_assert (!d->got_signal[1]); + return _test_integrate_cb_handle (d, 2); +} + +static gboolean +_test_integrate_maincontext_cb_idle1 (gpointer user_data) +{ + guint32 *p_count = user_data; + + g_assert (*p_count < 5); + (*p_count)++; + return G_SOURCE_CONTINUE; +} + +static void +test_integrate_maincontext (gconstpointer test_data) +{ + const guint TEST_IDX = GPOINTER_TO_UINT (test_data); + GMainContext *c1 = g_main_context_default (); + nm_auto_unref_gmaincontext GMainContext *c2 = g_main_context_new (); + nm_auto_destroy_and_unref_gsource GSource *integ_source = NULL; + + integ_source = nm_utils_g_main_context_create_integrate_source (c2); + g_source_attach (integ_source, c1); + + if (TEST_IDX == 1) { + nm_auto_destroy_and_unref_gsource GSource *idle_source_1 = NULL; + guint32 count = 0; + + idle_source_1 = g_idle_source_new (); + g_source_set_callback (idle_source_1, _test_integrate_maincontext_cb_idle1, &count, NULL); + g_source_attach (idle_source_1, c2); + + nmtst_main_context_iterate_until (c1, 2000, count == 5); + } + + if (TEST_IDX == 2) { + nm_auto_destroy_and_unref_gsource GSource *main_timeout_source = NULL; + nm_auto_destroy_and_unref_gsource GSource *timeout_source_1 = NULL; + nm_auto_destroy_and_unref_gsource GSource *idle_source_1 = NULL; + nm_auto_destroy_and_unref_gsource GSource *fd_source_1 = NULL; + nm_auto_unref_gmainloop GMainLoop *loop1 = NULL; + nm_auto_close int fd_1 = -1; + nm_auto_close int fd_2 = -1; + IntegData d; + int i; + + main_timeout_source = g_timeout_source_new (3000); + g_source_set_callback (main_timeout_source, nmtst_g_source_assert_not_called, NULL, NULL); + g_source_attach (main_timeout_source, c1); + + loop1 = g_main_loop_new (c1, FALSE); + + d = (IntegData) { + .loop1 = loop1, + .c2 = c2, + }; + + fd_1 = open ("/dev/null", O_RDONLY | O_CLOEXEC); + g_assert (fd_1 >= 0); + fd_source_1 = g_unix_fd_source_new (fd_1, G_IO_IN); + g_source_set_callback (fd_source_1, G_SOURCE_FUNC (_test_integrate_cb_fd_1), &d, NULL); + g_source_attach (fd_source_1, c2); + + fd_2 = open ("/dev/null", O_RDONLY | O_CLOEXEC); + g_assert (fd_2 >= 0); + d.fd_2 = fd_2; + + idle_source_1 = g_idle_source_new (); + g_source_set_callback (idle_source_1, _test_integrate_cb_idle_1, &d, NULL); + g_source_attach (idle_source_1, c2); + + timeout_source_1 = g_timeout_source_new (5); + g_source_set_callback (timeout_source_1, _test_integrate_cb_timeout_1, &d, NULL); + g_source_attach (timeout_source_1, c2); + + g_main_loop_run (loop1); + + for (i = 0; i < G_N_ELEMENTS (d.extra_sources); i++) { + g_assert (d.extra_sources[i]); + nm_clear_pointer (&d.extra_sources[i], nm_g_source_destroy_and_unref); + } + } +} + +/*****************************************************************************/ + NMTST_DEFINE (); int main (int argc, char **argv) @@ -8267,10 +8476,14 @@ int main (int argc, char **argv) g_test_add_func ("/core/general/nm-set-out", test_nm_set_out); g_test_add_func ("/core/general/route_attributes/parse", test_route_attributes_parse); g_test_add_func ("/core/general/route_attributes/format", test_route_attributes_format); + g_test_add_func ("/core/general/test_variant_attribute_spec", test_variant_attribute_spec); g_test_add_func ("/core/general/get_start_time_for_pid", test_get_start_time_for_pid); g_test_add_func ("/core/general/test_nm_va_args_macros", test_nm_va_args_macros); g_test_add_func ("/core/general/test_ethtool_offload", test_ethtool_offload); + g_test_add_data_func ("/core/general/test_integrate_maincontext/1", GUINT_TO_POINTER (1), test_integrate_maincontext); + g_test_add_data_func ("/core/general/test_integrate_maincontext/2", GUINT_TO_POINTER (2), test_integrate_maincontext); + return g_test_run (); } diff --git a/libnm-core/tests/test-keyfile.c b/libnm-core/tests/test-keyfile.c index 195f3797..574d671f 100644 --- a/libnm-core/tests/test-keyfile.c +++ b/libnm-core/tests/test-keyfile.c @@ -1,21 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2015 Red Hat, Inc. - * + * Copyright (C) 2015 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/tests/test-secrets.c b/libnm-core/tests/test-secrets.c index d657a43c..63335669 100644 --- a/libnm-core/tests/test-secrets.c +++ b/libnm-core/tests/test-secrets.c @@ -1,21 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2008 - 2011 Red Hat, Inc. - * + * Copyright (C) 2008 - 2011 Red Hat, Inc. */ #include "nm-default.h" diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c index 0ddf3e8e..40852277 100644 --- a/libnm-core/tests/test-setting.c +++ b/libnm-core/tests/test-setting.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2008 - 2017 Red Hat, Inc. - * + * Copyright (C) 2008 - 2017 Red Hat, Inc. */ #include "nm-default.h" @@ -22,6 +8,7 @@ #include <linux/pkt_sched.h> #include <net/if.h> +#include "nm-core-internal.h" #include "nm-utils.h" #include "nm-utils-private.h" #include "nm-core-internal.h" @@ -3172,7 +3159,9 @@ test_routing_rule (gconstpointer test_data) _rr_from_str ("priority 5 from :: iif a\\\\303b table 25"); _rr_from_str ("priority 5 to 0.0.0.0 sport 10 table 6", "priority 5 to 0.0.0.0 sport 10-10 table 6"); - _rr_from_str ("not priority 5 to 0.0.0.0 dport 10-133 table 6", + _rr_from_str ("priority 5 not to 0.0.0.0 dport 10-133 table 6", + "not priority 5 to 0.0.0.0 dport 10-133 table 6", + "not priority 5 not to 0.0.0.0 dport 10-133 table 6", "priority 5 to 0.0.0.0 not dport 10-133 not table 6", "priority 5 to 0.0.0.0 not dport 10-\\ 133 not table 6"); _rr_from_str ("priority 5 to 0.0.0.0 ipproto 10 sport 10 table 6"); @@ -3328,6 +3317,275 @@ test_empty_setting (void) /*****************************************************************************/ +static guint +_PROP_IDX_PACK (NMMetaSettingType meta_type, + guint idx) +{ + return (((guint) meta_type) & 0xFFu) + | (idx << 8); +} + +static const char * +_PROP_IDX_OWNER (GHashTable *h_property_types, + const NMSettInfoPropertType *property_type) +{ + const NMSettInfoSetting *sett_info_settings = nmtst_sett_info_settings (); + const NMSettInfoSetting *sis; + const NMMetaSettingInfo *msi; + GArray *arr; + guint idx; + NMMetaSettingType meta_type; + guint prop_idx; + char sbuf[300]; + + g_assert (h_property_types); + g_assert (property_type); + + arr = g_hash_table_lookup (h_property_types, property_type); + + g_assert (arr); + g_assert (arr->len > 0); + + idx = g_array_index (arr, guint, 0); + + meta_type = (idx & 0xFFu); + prop_idx = idx >> 8; + + g_assert (meta_type < _NM_META_SETTING_TYPE_NUM); + + sis = &sett_info_settings[meta_type]; + msi = &nm_meta_setting_infos[meta_type]; + + g_assert (prop_idx < sis->property_infos_len); + + nm_sprintf_buf (sbuf, "%s.%s", msi->setting_name, sis->property_infos[prop_idx].name); + + return g_intern_string (sbuf); +} + +static void +test_setting_metadata (void) +{ + const NMSettInfoSetting *sett_info_settings = nmtst_sett_info_settings (); + NMMetaSettingType meta_type; + gs_unref_hashtable GHashTable *h_property_types = NULL; + + G_STATIC_ASSERT (_NM_META_SETTING_TYPE_NUM == NM_META_SETTING_TYPE_UNKNOWN); + + h_property_types = g_hash_table_new_full (nm_direct_hash, NULL, NULL, (GDestroyNotify) g_array_unref); + + for (meta_type = 0; meta_type < _NM_META_SETTING_TYPE_NUM; meta_type++) { + const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; + nm_auto_unref_gtypeclass NMSettingClass *klass = NULL; + GType gtype; + + g_assert (msi->setting_name); + g_assert (msi->get_setting_gtype); + g_assert (msi->meta_type == meta_type); + g_assert (msi->setting_priority >= NM_SETTING_PRIORITY_CONNECTION); + g_assert (msi->setting_priority <= NM_SETTING_PRIORITY_USER); + + if (meta_type > 0) + g_assert_cmpint (strcmp (nm_meta_setting_infos[meta_type - 1].setting_name, msi->setting_name), <, 0); + + gtype = msi->get_setting_gtype (); + + g_assert (g_type_is_a (gtype, NM_TYPE_SETTING)); + g_assert (gtype != NM_TYPE_SETTING); + + klass = g_type_class_ref (gtype); + g_assert (klass); + g_assert (NM_IS_SETTING_CLASS (klass)); + + g_assert (msi == klass->setting_info); + } + + g_assert (sett_info_settings); + + for (meta_type = 0; meta_type < _NM_META_SETTING_TYPE_NUM; meta_type++) { + const NMSettInfoSetting *sis = &sett_info_settings[meta_type]; + const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; + gs_unref_hashtable GHashTable *h_properties = NULL; + GType gtype; + gs_unref_object NMSetting *setting = NULL; + guint prop_idx; + gs_free GParamSpec **property_specs = NULL; + guint n_property_specs; + + g_assert (sis); + + g_assert (NM_IS_SETTING_CLASS (sis->setting_class)); + + gtype = msi->get_setting_gtype (); + + g_assert (G_TYPE_FROM_CLASS (sis->setting_class) == gtype); + + setting = g_object_new (gtype, NULL); + + g_assert (NM_IS_SETTING (setting)); + + g_assert_cmpint (sis->property_infos_len, >, 0); + g_assert (sis->property_infos); + + h_properties = g_hash_table_new (nm_str_hash, g_str_equal); + + for (prop_idx = 0; prop_idx < sis->property_infos_len; prop_idx++) { + const NMSettInfoProperty *sip = &sis->property_infos[prop_idx]; + GArray *property_types_data; + guint prop_idx_val; + + g_assert (sip->name); + + if (prop_idx > 0) + g_assert_cmpint (strcmp (sis->property_infos[prop_idx - 1].name, sip->name), <, 0); + + g_assert (sip->property_type); + g_assert (sip->property_type->dbus_type); + g_assert (g_variant_type_string_is_valid ((const char *) sip->property_type->dbus_type)); + + g_assert (!sip->property_type->to_dbus_fcn || !sip->property_type->gprop_to_dbus_fcn); + g_assert (!sip->property_type->from_dbus_fcn || !sip->property_type->gprop_from_dbus_fcn); + + if (!g_hash_table_insert (h_properties, (char *) sip->name, sip->param_spec)) + g_assert_not_reached (); + + property_types_data = g_hash_table_lookup (h_property_types, sip->property_type); + if (!property_types_data) { + property_types_data = g_array_new (FALSE, FALSE, sizeof (guint)); + if (!g_hash_table_insert (h_property_types, (gpointer) sip->property_type, property_types_data)) + g_assert_not_reached (); + } + prop_idx_val = _PROP_IDX_PACK (meta_type, prop_idx); + g_array_append_val (property_types_data, prop_idx_val); + + if (sip->param_spec) { + nm_auto_unset_gvalue GValue val = G_VALUE_INIT; + + g_assert_cmpstr (sip->name, ==, sip->param_spec->name); + + g_value_init (&val, sip->param_spec->value_type); + g_object_get_property (G_OBJECT (setting), sip->name, &val); + + if (sip->param_spec->value_type == G_TYPE_STRING) { + const char *default_value; + + default_value = ((const GParamSpecString *) sip->param_spec)->default_value; + if (default_value) { + /* having a string property with a default != NULL is really ugly. They + * should be best avoided... */ + if ( meta_type == NM_META_SETTING_TYPE_DCB + && nm_streq (sip->name, NM_SETTING_DCB_APP_FCOE_MODE)) { + /* Whitelist the properties that have a non-NULL default value. */ + g_assert_cmpstr (default_value, ==, NM_SETTING_DCB_FCOE_MODE_FABRIC); + } else + g_assert_not_reached (); + } + + if (nm_streq (sip->name, NM_SETTING_NAME)) + g_assert_cmpstr (g_value_get_string (&val), ==, msi->setting_name); + else + g_assert_cmpstr (g_value_get_string (&val), ==, default_value); + } + + if (NM_FLAGS_HAS (sip->param_spec->flags, NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS)) + g_assert (sip->property_type->to_dbus_fcn); + } + } + + /* check that all GObject based properties are tracked by the settings. */ + property_specs = g_object_class_list_properties (G_OBJECT_CLASS (sis->setting_class), + &n_property_specs); + g_assert (property_specs); + g_assert_cmpint (n_property_specs, >, 0); + for (prop_idx = 0; prop_idx < n_property_specs; prop_idx++) { + const GParamSpec *pip = property_specs[prop_idx]; + + g_assert (g_hash_table_lookup (h_properties, pip->name) == pip); + } + + /* check that property_infos_sorted is as expected. */ + if (sis->property_infos_sorted) { + gs_unref_hashtable GHashTable *h = g_hash_table_new (nm_direct_hash, NULL); + + /* property_infos_sorted is only implemented for [connection] type */ + g_assert_cmpint (meta_type, ==, NM_META_SETTING_TYPE_CONNECTION); + + /* ensure that there are no duplicates, and that all properties are also + * tracked by sis->property_infos. */ + for (prop_idx = 0; prop_idx < sis->property_infos_len; prop_idx++) { + const NMSettInfoProperty *sip = sis->property_infos_sorted[prop_idx]; + + if (!g_hash_table_add (h, (gpointer) sip)) + g_assert_not_reached (); + } + for (prop_idx = 0; prop_idx < sis->property_infos_len; prop_idx++) { + const NMSettInfoProperty *sip = &sis->property_infos[prop_idx]; + + g_assert (g_hash_table_contains (h, sip)); + } + } else + g_assert_cmpint (meta_type, !=, NM_META_SETTING_TYPE_CONNECTION); + + /* consistency check for gendata-info. */ + if (sis->detail.gendata_info) { + g_assert_cmpint (meta_type, ==, NM_META_SETTING_TYPE_ETHTOOL); + g_assert (sis->detail.gendata_info->get_variant_type); + + /* the gendata info based setting has only one regular property: the "name". */ + g_assert_cmpint (sis->property_infos_len, ==, 1); + g_assert_cmpstr (sis->property_infos[0].name, ==, NM_SETTING_NAME); + } else + g_assert_cmpint (meta_type, !=, NM_META_SETTING_TYPE_ETHTOOL); + } + + { + gs_free NMSettInfoPropertType **a_property_types = NULL; + guint a_property_types_len; + guint prop_idx; + guint prop_idx_2; + + a_property_types = (NMSettInfoPropertType **) g_hash_table_get_keys_as_array (h_property_types, &a_property_types_len); + + for (prop_idx = 0; prop_idx < a_property_types_len; prop_idx++) { + const NMSettInfoPropertType *pt = a_property_types[prop_idx]; + + for (prop_idx_2 = prop_idx + 1; prop_idx_2 < a_property_types_len; prop_idx_2++) { + const NMSettInfoPropertType *pt_2 = a_property_types[prop_idx_2]; + + if ( !g_variant_type_equal (pt->dbus_type, pt_2->dbus_type) + || pt->to_dbus_fcn != pt_2->to_dbus_fcn + || pt->from_dbus_fcn != pt_2->from_dbus_fcn + || pt->missing_from_dbus_fcn != pt_2->missing_from_dbus_fcn + || pt->gprop_to_dbus_fcn != pt_2->gprop_to_dbus_fcn + || pt->gprop_from_dbus_fcn != pt_2->gprop_from_dbus_fcn) + continue; + + if ( (pt == &nm_sett_info_propert_type_plain_i && pt_2 == &nm_sett_info_propert_type_deprecated_ignore_i) + || (pt_2 == &nm_sett_info_propert_type_plain_i && pt == &nm_sett_info_propert_type_deprecated_ignore_i) + || (pt == &nm_sett_info_propert_type_plain_u && pt_2 == &nm_sett_info_propert_type_deprecated_ignore_u) + || (pt_2 == &nm_sett_info_propert_type_plain_u && pt == &nm_sett_info_propert_type_deprecated_ignore_u)) { + /* These are known to be duplicated. This is the case for + * "gsm.network-type" and plain properies like "802-11-wireless-security.fils" ("i" D-Bus type) + * "gsm.allowed-bands" and plain properies like "802-11-olpc-mesh.channel" ("u" D-Bus type) + * While the content/behaviour of the property types are identical, their purpose + * is different. So allowe them. + */ + continue; + } + + /* the property-types with same content should all be shared. Here we have two that + * are the same content, but different instances. Bug. */ + g_error ("The identical property type for D-Bus type \"%s\" is used by: %s and %s", + (const char *) pt->dbus_type, + _PROP_IDX_OWNER (h_property_types, pt), + _PROP_IDX_OWNER (h_property_types, pt_2)); + } + } + } +} + +/*****************************************************************************/ + NMTST_DEFINE (); int @@ -3417,5 +3675,7 @@ main (int argc, char **argv) g_test_add_func ("/libnm/test_empty_setting", test_empty_setting); + g_test_add_func ("/libnm/test_setting_metadata", test_setting_metadata); + return g_test_run (); } diff --git a/libnm-core/tests/test-settings-defaults.c b/libnm-core/tests/test-settings-defaults.c index c5156fc9..7cba245c 100644 --- a/libnm-core/tests/test-settings-defaults.c +++ b/libnm-core/tests/test-settings-defaults.c @@ -1,21 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright 2008 - 2011 Red Hat, Inc. - * + * Copyright (C) 2008 - 2011 Red Hat, Inc. */ #include "nm-default.h" |