From 90e8691111889a7b5f3c812f5a41f15a8a058913 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 7 Nov 2017 00:14:39 +0100 Subject: New upstream version 1.9.90 --- libnm/NetworkManager.h | 7 + libnm/generate-plugin-docs.pl | 8 +- libnm/generate-setting-docs.py | 23 +- libnm/libnm.ver | 44 ++ libnm/nm-active-connection.c | 39 ++ libnm/nm-active-connection.h | 3 + libnm/nm-client.c | 125 ++++- libnm/nm-client.h | 17 +- libnm/nm-device-bridge.c | 11 +- libnm/nm-device-bt.c | 10 +- libnm/nm-device-dummy.c | 108 ++++- libnm/nm-device-dummy.h | 4 + libnm/nm-device-ovs-bridge.c | 96 ++++ libnm/nm-device-ovs-bridge.h | 45 ++ libnm/nm-device-ovs-interface.c | 96 ++++ libnm/nm-device-ovs-interface.h | 45 ++ libnm/nm-device-ovs-port.c | 95 ++++ libnm/nm-device-ovs-port.h | 45 ++ libnm/nm-device-ppp.c | 39 ++ libnm/nm-device-ppp.h | 36 ++ libnm/nm-device.c | 14 +- libnm/nm-dns-manager.c | 2 +- libnm/nm-manager.c | 113 ++++- libnm/nm-manager.h | 12 + libnm/nm-object.c | 106 ++--- libnm/nm-property-docs.xml | 841 ++++++++++++++++++---------------- libnm/nm-remote-connection.c | 6 +- libnm/nm-settings-docs-overrides.xml | 10 +- libnm/nm-settings-docs.xml | 863 ++++++++++++++++++----------------- libnm/nm-settings-ifcfg-rh-docs.xml | 26 +- libnm/nm-settings-keyfile-docs.xml | 10 +- libnm/nm-types.h | 62 +-- libnm/nm-vpn-connection.c | 4 +- 33 files changed, 2003 insertions(+), 962 deletions(-) create mode 100644 libnm/nm-device-ovs-bridge.c create mode 100644 libnm/nm-device-ovs-bridge.h create mode 100644 libnm/nm-device-ovs-interface.c create mode 100644 libnm/nm-device-ovs-interface.h create mode 100644 libnm/nm-device-ovs-port.c create mode 100644 libnm/nm-device-ovs-port.h create mode 100644 libnm/nm-device-ppp.c create mode 100644 libnm/nm-device-ppp.h (limited to 'libnm') diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h index 97327f92..27737e0e 100644 --- a/libnm/NetworkManager.h +++ b/libnm/NetworkManager.h @@ -41,6 +41,9 @@ #include "nm-device-macvlan.h" #include "nm-device-modem.h" #include "nm-device-olpc-mesh.h" +#include "nm-device-ovs-interface.h" +#include "nm-device-ovs-port.h" +#include "nm-device-ovs-bridge.h" #include "nm-device-team.h" #include "nm-device-tun.h" #include "nm-device-vlan.h" @@ -73,6 +76,10 @@ #include "nm-setting-macsec.h" #include "nm-setting-macvlan.h" #include "nm-setting-olpc-mesh.h" +#include "nm-setting-ovs-bridge.h" +#include "nm-setting-ovs-interface.h" +#include "nm-setting-ovs-patch.h" +#include "nm-setting-ovs-port.h" #include "nm-setting-ppp.h" #include "nm-setting-pppoe.h" #include "nm-setting-proxy.h" diff --git a/libnm/generate-plugin-docs.pl b/libnm/generate-plugin-docs.pl index 405c6e11..24912a03 100755 --- a/libnm/generate-plugin-docs.pl +++ b/libnm/generate-plugin-docs.pl @@ -75,9 +75,11 @@ write_header(); foreach my $c_file (@source_files) { my $path = "$srcdir/$c_file"; my $setting_name = get_setting_name($path); - write_item(""); - scan_doc_comments($path, $start_tag, $end_tag); - write_item(""); + if ($setting_name) { + write_item(""); + scan_doc_comments($path, $start_tag, $end_tag); + write_item(""); + } } # write XML footer diff --git a/libnm/generate-setting-docs.py b/libnm/generate-setting-docs.py index d0625b01..aa0c96eb 100755 --- a/libnm/generate-setting-docs.py +++ b/libnm/generate-setting-docs.py @@ -76,6 +76,12 @@ constants = { 'NULL': 'NULL' } setting_names = {} +def get_setting_name_define(setting): + n = setting.attrib[symbol_prefix_key] + if n and n.startswith("setting_"): + return n[8:].upper() + raise Exception("Unexpected symbol_prefix_key \"%s\"" % (n)) + def init_constants(girxml, settings): for const in girxml.findall('./gi:namespace/gi:constant', ns_map): cname = const.attrib['{%s}type' % ns_map['c']] @@ -98,7 +104,7 @@ def init_constants(girxml, settings): for setting in settings: setting_type_name = 'NM' + setting.attrib['name']; - setting_name_symbol = 'NM_' + setting.attrib[symbol_prefix_key].upper() + '_SETTING_NAME' + setting_name_symbol = 'NM_SETTING_' + get_setting_name_define(setting) + '_SETTING_NAME' if setting_name_symbol in constants: setting_name = constants[setting_name_symbol] setting_names[setting_type_name] = setting_name @@ -215,7 +221,7 @@ for settingxml in settings: class_desc = get_docs(settingxml) if class_desc is None: raise Exception("%s needs a gtk-doc block with one-line description" % setting.props.name) - outfile.write(" \n" % (setting.props.name, class_desc)) + outfile.write(" \n" % (setting.props.name, class_desc, get_setting_name_define (settingxml))) setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) } if args.overrides is None: @@ -249,12 +255,17 @@ for settingxml in settings: if override.attrib['description'] != '': value_desc = override.attrib['description'] + prop_upper = prop.upper().replace('-', '_') + + if value_desc is None: + raise Exception("%s.%s needs a documentation description" % (setting.props.name, prop)) + if default_value is not None: - outfile.write(" \n" % - (prop, value_type, escape(default_value), escape(value_desc))) + outfile.write(" \n" % + (prop, prop_upper, value_type, escape(default_value), escape(value_desc))) else: - outfile.write(" \n" % - (prop, value_type, escape(value_desc))) + outfile.write(" \n" % + (prop, prop_upper, value_type, escape(value_desc))) outfile.write(" \n") diff --git a/libnm/libnm.ver b/libnm/libnm.ver index b767bf83..18ff993d 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1177,3 +1177,47 @@ global: nm_utils_format_variant_attributes; nm_utils_parse_variant_attributes; } libnm_1_6_0; + +libnm_1_10_0 { +global: + nm_activation_state_flags_get_type; + nm_active_connection_get_state_flags; + nm_client_connectivity_check_get_available; + nm_client_connectivity_check_get_enabled; + nm_client_connectivity_check_set_enabled; + nm_connection_get_settings; + nm_device_dummy_get_hw_address; + nm_device_ovs_bridge_get_type; + nm_device_ovs_interface_get_type; + nm_device_ovs_port_get_type; + nm_device_ppp_get_type; + nm_ip_route_equal_full; + nm_setting_bridge_get_group_forward_mask; + nm_setting_connection_get_auth_retries; + nm_setting_ip_config_get_route_table; + nm_setting_ovs_bridge_get_fail_mode; + nm_setting_ovs_bridge_get_mcast_snooping_enable; + nm_setting_ovs_bridge_get_rstp_enable; + nm_setting_ovs_bridge_get_stp_enable; + nm_setting_ovs_bridge_get_type; + nm_setting_ovs_bridge_new; + nm_setting_ovs_interface_get_interface_type; + nm_setting_ovs_interface_get_type; + nm_setting_ovs_interface_new; + nm_setting_ovs_patch_get_peer; + nm_setting_ovs_patch_get_type; + nm_setting_ovs_patch_new; + nm_setting_ovs_port_get_bond_downdelay; + nm_setting_ovs_port_get_bond_mode; + nm_setting_ovs_port_get_bond_updelay; + nm_setting_ovs_port_get_lacp; + nm_setting_ovs_port_get_tag; + nm_setting_ovs_port_get_type; + nm_setting_ovs_port_get_vlan_mode; + nm_setting_ovs_port_new; + nm_setting_pppoe_get_parent; + nm_setting_wireless_security_get_pmf; + nm_setting_wireless_security_get_wps_method; + nm_setting_wireless_security_pmf_get_type; + nm_setting_wireless_security_wps_method_get_type; +} libnm_1_8_0; diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 412cb3ba..a0ea8a25 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -51,6 +51,7 @@ typedef struct { char *specific_object_path; GPtrArray *devices; NMActiveConnectionState state; + guint state_flags; gboolean is_default; NMIPConfig *ip4_config; NMDhcpConfig *dhcp4_config; @@ -71,6 +72,7 @@ enum { PROP_SPECIFIC_OBJECT_PATH, PROP_DEVICES, PROP_STATE, + PROP_STATE_FLAGS, PROP_DEFAULT, PROP_IP4_CONFIG, PROP_DHCP4_CONFIG, @@ -215,6 +217,24 @@ nm_active_connection_get_state (NMActiveConnection *connection) return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->state; } +/** + * nm_active_connection_get_state_flags: + * @connection: a #NMActiveConnection + * + * Gets the active connection's state flags. + * + * Returns: the state flags + * + * Since: 1.10 + **/ +NMActivationStateFlags +nm_active_connection_get_state_flags (NMActiveConnection *connection) +{ + g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_ACTIVATION_STATE_FLAG_NONE); + + return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->state_flags; +} + /** * nm_active_connection_get_state_reason: * @connection: a #NMActiveConnection @@ -474,6 +494,9 @@ get_property (GObject *object, case PROP_STATE: g_value_set_enum (value, nm_active_connection_get_state (self)); break; + case PROP_STATE_FLAGS: + g_value_set_uint (value, nm_active_connection_get_state_flags (self)); + break; case PROP_DEFAULT: g_value_set_boolean (value, nm_active_connection_get_default (self)); break; @@ -537,6 +560,7 @@ init_dbus (NMObject *object) { "specific-object", &priv->specific_object_path, demarshal_specific_object_path }, { NM_ACTIVE_CONNECTION_DEVICES, &priv->devices, NULL, NM_TYPE_DEVICE }, { NM_ACTIVE_CONNECTION_STATE, &priv->state }, + { NM_ACTIVE_CONNECTION_STATE_FLAGS, &priv->state_flags }, { NM_ACTIVE_CONNECTION_DEFAULT, &priv->is_default }, { NM_ACTIVE_CONNECTION_IP4_CONFIG, &priv->ip4_config, NULL, NM_TYPE_IP4_CONFIG }, { NM_ACTIVE_CONNECTION_DHCP4_CONFIG, &priv->dhcp4_config, NULL, NM_TYPE_DHCP4_CONFIG }, @@ -663,6 +687,21 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMActiveConnection:state-flags: + * + * The state flags of the active connection. + * + * Since: 1.10 + **/ + g_object_class_install_property + (object_class, PROP_STATE_FLAGS, + g_param_spec_uint (NM_ACTIVE_CONNECTION_STATE_FLAGS, "", "", + 0, G_MAXUINT32, + NM_ACTIVATION_STATE_FLAG_NONE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + /** * NMActiveConnection:default: * diff --git a/libnm/nm-active-connection.h b/libnm/nm-active-connection.h index 23cd7372..093ca64e 100644 --- a/libnm/nm-active-connection.h +++ b/libnm/nm-active-connection.h @@ -44,6 +44,7 @@ G_BEGIN_DECLS #define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT_PATH "specific-object-path" #define NM_ACTIVE_CONNECTION_DEVICES "devices" #define NM_ACTIVE_CONNECTION_STATE "state" +#define NM_ACTIVE_CONNECTION_STATE_FLAGS "state-flags" #define NM_ACTIVE_CONNECTION_DEFAULT "default" #define NM_ACTIVE_CONNECTION_IP4_CONFIG "ip4-config" #define NM_ACTIVE_CONNECTION_DHCP4_CONFIG "dhcp4-config" @@ -76,6 +77,8 @@ const char *nm_active_connection_get_connection_type (NM const char *nm_active_connection_get_specific_object_path (NMActiveConnection *connection); const GPtrArray *nm_active_connection_get_devices (NMActiveConnection *connection); NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *connection); +NM_AVAILABLE_IN_1_10 +NMActivationStateFlags nm_active_connection_get_state_flags (NMActiveConnection *connection); NM_AVAILABLE_IN_1_8 NMActiveConnectionStateReason nm_active_connection_get_state_reason (NMActiveConnection *connection); NMDevice *nm_active_connection_get_master (NMActiveConnection *connection); diff --git a/libnm/nm-client.c b/libnm/nm-client.c index c8707f50..8f9c50e9 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -63,6 +63,10 @@ #include "nm-device-macvlan.h" #include "nm-device-modem.h" #include "nm-device-olpc-mesh.h" +#include "nm-device-ovs-interface.h" +#include "nm-device-ovs-port.h" +#include "nm-device-ovs-bridge.h" +#include "nm-device-ppp.h" #include "nm-device-team.h" #include "nm-device-tun.h" #include "nm-device-vlan.h" @@ -122,6 +126,8 @@ enum { PROP_WIMAX_HARDWARE_ENABLED, PROP_ACTIVE_CONNECTIONS, PROP_CONNECTIVITY, + PROP_CONNECTIVITY_CHECK_AVAILABLE, + PROP_CONNECTIVITY_CHECK_ENABLED, PROP_PRIMARY_CONNECTION, PROP_ACTIVATING_CONNECTION, PROP_DEVICES, @@ -472,6 +478,72 @@ nm_client_wimax_hardware_get_enabled (NMClient *client) return nm_manager_wimax_hardware_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager); } +/** + * nm_client_connectivity_check_get_available: + * @client: a #NMClient + * + * Determine whether connectivity checking is available. This + * requires that the URI of a connectivity service has been set in the + * configuration file. + * + * Returns: %TRUE if connectivity checking is available. + * + * Since: 1.10 + */ +gboolean +nm_client_connectivity_check_get_available (NMClient *client) +{ + g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); + + if (!nm_client_get_nm_running (client)) + return FALSE; + + return nm_manager_connectivity_check_get_available (NM_CLIENT_GET_PRIVATE (client)->manager); +} + +/** + * nm_client_connectivity_check_get_enabled: + * @client: a #NMClient + * + * Determine whether connectivity checking is enabled. + * + * Returns: %TRUE if connectivity checking is enabled. + * + * Since: 1.10 + */ +gboolean +nm_client_connectivity_check_get_enabled (NMClient *client) +{ + g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); + + if (!nm_client_get_nm_running (client)) + return FALSE; + + return nm_manager_connectivity_check_get_enabled (NM_CLIENT_GET_PRIVATE (client)->manager); +} + +/** + * nm_client_connectivity_check_set_enabled: + * @client: a #NMClient + * @enabled: %TRUE to enable connectivity checking + * + * Enable or disable connectivity checking. Note that if a + * connectivity checking URI has not been configured, this will not + * have any effect. + * + * Since: 1.10 + */ +void +nm_client_connectivity_check_set_enabled (NMClient *client, gboolean enabled) +{ + g_return_if_fail (NM_IS_CLIENT (client)); + + if (!nm_client_get_nm_running (client)) + return; + + nm_manager_connectivity_check_set_enabled (NM_CLIENT_GET_PRIVATE (client)->manager, enabled); +} + /** * nm_client_get_logging: * @client: a #NMClient @@ -1013,7 +1085,7 @@ activate_cb (GObject *object, * picks the best available connection for the device and activates it. * * Note that the callback is invoked when NetworkManager has started activating - * the new connection, not when it finishes. You can used the returned + * the new connection, not when it finishes. You can use the returned * #NMActiveConnection object (in particular, #NMActiveConnection:state) to * track the activation to its completion. **/ @@ -2078,6 +2150,14 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager type = NM_TYPE_DEVICE_MODEM; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OLPC_MESH) == 0) type = NM_TYPE_DEVICE_OLPC_MESH; + else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OVS_INTERFACE) == 0) + type = NM_TYPE_DEVICE_OVS_INTERFACE; + else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OVS_PORT) == 0) + type = NM_TYPE_DEVICE_OVS_PORT; + else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE) == 0) + type = NM_TYPE_DEVICE_OVS_BRIDGE; + else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_PPP) == 0) + type = NM_TYPE_DEVICE_PPP; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_TEAM) == 0) type = NM_TYPE_DEVICE_TEAM; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_TUN) == 0) @@ -2591,6 +2671,7 @@ set_property (GObject *object, guint prop_id, case PROP_WIRELESS_ENABLED: case PROP_WWAN_ENABLED: case PROP_WIMAX_ENABLED: + case PROP_CONNECTIVITY_CHECK_ENABLED: if (priv->manager) g_object_set_property (G_OBJECT (priv->manager), pspec->name, value); break; @@ -2630,7 +2711,7 @@ get_property (GObject *object, guint prop_id, break; case PROP_WIRELESS_HARDWARE_ENABLED: if (priv->manager) - g_object_get_property (G_OBJECT (priv->settings), pspec->name, value); + g_object_get_property (G_OBJECT (priv->manager), pspec->name, value); else g_value_set_boolean (value, FALSE); break; @@ -2639,7 +2720,7 @@ get_property (GObject *object, guint prop_id, break; case PROP_WWAN_HARDWARE_ENABLED: if (priv->manager) - g_object_get_property (G_OBJECT (priv->settings), pspec->name, value); + g_object_get_property (G_OBJECT (priv->manager), pspec->name, value); else g_value_set_boolean (value, FALSE); break; @@ -2648,7 +2729,7 @@ get_property (GObject *object, guint prop_id, break; case PROP_WIMAX_HARDWARE_ENABLED: if (priv->manager) - g_object_get_property (G_OBJECT (priv->settings), pspec->name, value); + g_object_get_property (G_OBJECT (priv->manager), pspec->name, value); else g_value_set_boolean (value, FALSE); break; @@ -2658,6 +2739,12 @@ get_property (GObject *object, guint prop_id, case PROP_CONNECTIVITY: g_value_set_enum (value, nm_client_get_connectivity (self)); break; + case PROP_CONNECTIVITY_CHECK_AVAILABLE: + g_value_set_boolean (value, nm_client_connectivity_check_get_available (self)); + break; + case PROP_CONNECTIVITY_CHECK_ENABLED: + g_value_set_boolean (value, nm_client_connectivity_check_get_enabled (self)); + break; case PROP_PRIMARY_CONNECTION: g_value_set_object (value, nm_client_get_primary_connection (self)); break; @@ -2669,7 +2756,7 @@ get_property (GObject *object, guint prop_id, break; case PROP_METERED: if (priv->manager) - g_object_get_property (G_OBJECT (priv->settings), pspec->name, value); + g_object_get_property (G_OBJECT (priv->manager), pspec->name, value); else g_value_set_uint (value, NM_METERED_UNKNOWN); break; @@ -2895,6 +2982,34 @@ nm_client_class_init (NMClientClass *client_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMClient::connectivity-check-available + * + * Whether a connectivity checking service has been configured. + * + * Since: 1.10 + */ + g_object_class_install_property + (object_class, PROP_CONNECTIVITY_CHECK_AVAILABLE, + g_param_spec_boolean (NM_CLIENT_CONNECTIVITY_CHECK_AVAILABLE, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + /** + * NMClient::connectivity-check-enabled + * + * Whether a connectivity checking service has been enabled. + * + * Since: 1.10 + */ + g_object_class_install_property + (object_class, PROP_CONNECTIVITY_CHECK_ENABLED, + g_param_spec_boolean (NM_CLIENT_CONNECTIVITY_CHECK_ENABLED, "", "", + FALSE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + /** * NMClient:primary-connection: * diff --git a/libnm/nm-client.h b/libnm/nm-client.h index 5da16490..3b37b55a 100644 --- a/libnm/nm-client.h +++ b/libnm/nm-client.h @@ -50,6 +50,8 @@ G_BEGIN_DECLS #define NM_CLIENT_WIMAX_HARDWARE_ENABLED "wimax-hardware-enabled" #define NM_CLIENT_ACTIVE_CONNECTIONS "active-connections" #define NM_CLIENT_CONNECTIVITY "connectivity" +#define NM_CLIENT_CONNECTIVITY_CHECK_AVAILABLE "connectivity-check-available" +#define NM_CLIENT_CONNECTIVITY_CHECK_ENABLED "connectivity-check-enabled" #define NM_CLIENT_PRIMARY_CONNECTION "primary-connection" #define NM_CLIENT_ACTIVATING_CONNECTION "activating-connection" #define NM_CLIENT_DEVICES "devices" @@ -103,6 +105,8 @@ G_BEGIN_DECLS * @NM_CLIENT_PERMISSION_CHECKPOINT_ROLLBACK: permission to create checkpoints. * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS: controls whether device * statistics can be globally enabled or disabled + * @NM_CLIENT_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK: controls whether + * connectivity check can be enabled or disabled * @NM_CLIENT_PERMISSION_LAST: a reserved boundary value * * #NMClientPermission values indicate various permissions that NetworkManager @@ -125,8 +129,9 @@ typedef enum { NM_CLIENT_PERMISSION_RELOAD = 13, NM_CLIENT_PERMISSION_CHECKPOINT_ROLLBACK = 14, NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS = 15, + NM_CLIENT_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK = 16, - NM_CLIENT_PERMISSION_LAST = 15, + NM_CLIENT_PERMISSION_LAST = 16, } NMClientPermission; /** @@ -249,6 +254,16 @@ gboolean nm_client_wimax_get_enabled (NMClient *client); void nm_client_wimax_set_enabled (NMClient *client, gboolean enabled); gboolean nm_client_wimax_hardware_get_enabled (NMClient *client); +NM_AVAILABLE_IN_1_10 +gboolean nm_client_connectivity_check_get_available (NMClient *client); + +NM_AVAILABLE_IN_1_10 +gboolean nm_client_connectivity_check_get_enabled (NMClient *client); + +NM_AVAILABLE_IN_1_10 +void nm_client_connectivity_check_set_enabled (NMClient *client, + gboolean enabled); + gboolean nm_client_get_logging (NMClient *client, char **level, char **domains, diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index 55f09a20..27f362b2 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -107,9 +107,14 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro return FALSE; if (!nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) { - g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, - _("The connection was not a bridge connection.")); - return FALSE; + if ( _nm_connection_get_setting_bluetooth_for_nap (connection) + && nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)) { + /* a bluetooth NAP setting is a compatible connection for a bridge. */ + } else { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a bridge connection.")); + return FALSE; + } } /* FIXME: check ports? */ diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index 0fcd28b9..a47e3958 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -131,12 +131,19 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->connection_compatible (device, connection, error)) return FALSE; - if (!nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)) { + if ( !nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME) + || !(s_bt = nm_connection_get_setting_bluetooth (connection))) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, _("The connection was not a Bluetooth connection.")); return FALSE; } + if (nm_streq0 (nm_setting_bluetooth_get_connection_type (s_bt), NM_SETTING_BLUETOOTH_TYPE_NAP)) { + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection is of Bluetooth NAP type.")); + return FALSE; + } + /* Check BT address */ hw_addr = nm_device_bt_get_hw_address (NM_DEVICE_BT (device)); if (hw_addr) { @@ -145,7 +152,6 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro _("Invalid device Bluetooth address.")); return FALSE; } - s_bt = nm_connection_get_setting_bluetooth (connection); setting_addr = nm_setting_bluetooth_get_bdaddr (s_bt); if (setting_addr && !nm_utils_hwaddr_matches (setting_addr, -1, hw_addr, -1)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, diff --git a/libnm/nm-device-dummy.c b/libnm/nm-device-dummy.c index f5910dc8..4c202025 100644 --- a/libnm/nm-device-dummy.c +++ b/libnm/nm-device-dummy.c @@ -31,8 +31,38 @@ G_DEFINE_TYPE (NMDeviceDummy, nm_device_dummy, NM_TYPE_DEVICE) #define NM_DEVICE_DUMMY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_DUMMY, NMDeviceDummyPrivate)) +typedef struct { + char *hw_address; +} NMDeviceDummyPrivate; + +enum { + PROP_0, + PROP_HW_ADDRESS, + + LAST_PROP +}; + /*****************************************************************************/ +/** + * nm_device_dummy_get_hw_address: + * @device: a #NMDeviceDummy + * + * Gets the hardware (MAC) address of the #NMDeviceDummy + * + * Returns: the hardware address. This is the internal string used by the + * device, and must not be modified. + * + * Since: 1.10 + **/ +const char * +nm_device_dummy_get_hw_address (NMDeviceDummy *device) +{ + g_return_val_if_fail (NM_IS_DEVICE_DUMMY (device), NULL); + + return nm_str_not_empty (NM_DEVICE_DUMMY_GET_PRIVATE (device)->hw_address); +} + static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { @@ -63,6 +93,12 @@ get_setting_type (NMDevice *device) return NM_TYPE_SETTING_DUMMY; } +static const char * +get_hw_address (NMDevice *device) +{ + return nm_device_dummy_get_hw_address (NM_DEVICE_DUMMY (device)); +} + /*****************************************************************************/ static void @@ -71,10 +107,78 @@ nm_device_dummy_init (NMDeviceDummy *device) } static void -nm_device_dummy_class_init (NMDeviceDummyClass *klass) +init_dbus (NMObject *object) +{ + NMDeviceDummyPrivate *priv = NM_DEVICE_DUMMY_GET_PRIVATE (object); + const NMPropertiesInfo property_info[] = { + { NM_DEVICE_DUMMY_HW_ADDRESS, &priv->hw_address }, + { NULL }, + }; + + NM_OBJECT_CLASS (nm_device_dummy_parent_class)->init_dbus (object); + + _nm_object_register_properties (object, + NM_DBUS_INTERFACE_DEVICE_DUMMY, + property_info); +} + +static void +dispose (GObject *object) { - NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); + NMDeviceDummyPrivate *priv = NM_DEVICE_DUMMY_GET_PRIVATE (object); + + g_clear_pointer (&priv->hw_address, g_free); + + G_OBJECT_CLASS (nm_device_dummy_parent_class)->dispose (object); +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NMDeviceDummy *device = NM_DEVICE_DUMMY (object); + + switch (prop_id) { + case PROP_HW_ADDRESS: + g_value_set_string (value, nm_device_dummy_get_hw_address (device)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_device_dummy_class_init (NMDeviceDummyClass *dummy_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (dummy_class); + NMObjectClass *nm_object_class = NM_OBJECT_CLASS (dummy_class); + NMDeviceClass *device_class = NM_DEVICE_CLASS (dummy_class); + + g_type_class_add_private (dummy_class, sizeof (NMDeviceDummyPrivate)); + + object_class->dispose = dispose; + object_class->get_property = get_property; + + nm_object_class->init_dbus = init_dbus; device_class->connection_compatible = connection_compatible; + device_class->get_hw_address = get_hw_address; device_class->get_setting_type = get_setting_type; + + /** + * NMDeviceDummy:hw-address: + * + * The active hardware (MAC) address of the device. + * + * Since: 1.10 + **/ + g_object_class_install_property + (object_class, PROP_HW_ADDRESS, + g_param_spec_string (NM_DEVICE_DUMMY_HW_ADDRESS, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); } diff --git a/libnm/nm-device-dummy.h b/libnm/nm-device-dummy.h index 85ee2bab..084d2d50 100644 --- a/libnm/nm-device-dummy.h +++ b/libnm/nm-device-dummy.h @@ -36,6 +36,8 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_DUMMY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_DUMMY)) #define NM_DEVICE_DUMMY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_DUMMY, NMDeviceDummyClass)) +#define NM_DEVICE_DUMMY_HW_ADDRESS "hw-address" + /** * NMDeviceDummy: */ @@ -51,6 +53,8 @@ typedef struct { } NMDeviceDummyClass; GType nm_device_dummy_get_type (void); +NM_AVAILABLE_IN_1_10 +const char *nm_device_dummy_get_hw_address (NMDeviceDummy *device); G_END_DECLS diff --git a/libnm/nm-device-ovs-bridge.c b/libnm/nm-device-ovs-bridge.c new file mode 100644 index 00000000..798f6d20 --- /dev/null +++ b/libnm/nm-device-ovs-bridge.c @@ -0,0 +1,96 @@ +/* + * 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. + */ + +#include "nm-default.h" + +#include + +#include "nm-device-ovs-bridge.h" +#include "nm-object-private.h" +#include "nm-setting-ovs-bridge.h" +#include "nm-setting-ovs-port.h" +#include "nm-setting-connection.h" + +/** + * NMDeviceOvsBridge: + */ +struct _NMDeviceOvsBridge { + NMDevice parent; +}; + +struct _NMDeviceOvsBridgeClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceOvsBridge, nm_device_ovs_bridge, NM_TYPE_DEVICE) + +/*****************************************************************************/ + +static const char * +get_type_description (NMDevice *device) +{ + return "ovs-bridge"; +} + +static gboolean +connection_compatible (NMDevice *device, NMConnection *connection, GError **error) +{ + const char *iface_name; + + if (!NM_DEVICE_CLASS (nm_device_ovs_bridge_parent_class)->connection_compatible (device, connection, error)) + return FALSE; + + if (!nm_connection_is_type (connection, NM_SETTING_OVS_BRIDGE_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a ovs_bridge connection.")); + return FALSE; + } + + iface_name = nm_connection_get_interface_name (connection); + if (!iface_name) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + _("The connection did not specify an interface name.")); + return FALSE; + } + + return TRUE; +} + +static GType +get_setting_type (NMDevice *device) +{ + return NM_TYPE_SETTING_OVS_BRIDGE; +} + +/*****************************************************************************/ + +static void +nm_device_ovs_bridge_init (NMDeviceOvsBridge *device) +{ +} + +static void +nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *ovs_bridge_class) +{ + NMDeviceClass *device_class = NM_DEVICE_CLASS (ovs_bridge_class); + + device_class->get_type_description = get_type_description; + device_class->connection_compatible = connection_compatible; + device_class->get_setting_type = get_setting_type; +} diff --git a/libnm/nm-device-ovs-bridge.h b/libnm/nm-device-ovs-bridge.h new file mode 100644 index 00000000..b4b0b98b --- /dev/null +++ b/libnm/nm-device-ovs-bridge.h @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#ifndef __NM_DEVICE_OVS_BRIDGE_H__ +#define __NM_DEVICE_OVS_BRIDGE_H__ + +#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION) +#error "Only can be included directly." +#endif + +#include "nm-device.h" + +G_BEGIN_DECLS + +#define NM_TYPE_DEVICE_OVS_BRIDGE (nm_device_ovs_bridge_get_type ()) +#define NM_DEVICE_OVS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_OVS_BRIDGE, NMDeviceOvsBridge)) +#define NM_DEVICE_OVS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_OVS_BRIDGE, NMDeviceOvsBridgeClass)) +#define NM_IS_DEVICE_OVS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_OVS_BRIDGE)) +#define NM_IS_DEVICE_OVS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_OVS_BRIDGE)) +#define NM_DEVICE_OVS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_OVS_BRIDGE, NMDeviceOvsBridgeClass)) + +typedef struct _NMDeviceOvsBridgeClass NMDeviceOvsBridgeClass; + +NM_AVAILABLE_IN_1_10 +GType nm_device_ovs_bridge_get_type (void); + +G_END_DECLS + +#endif /* __NM_DEVICE_OVS_BRIDGE_H__ */ diff --git a/libnm/nm-device-ovs-interface.c b/libnm/nm-device-ovs-interface.c new file mode 100644 index 00000000..ed3dbd4c --- /dev/null +++ b/libnm/nm-device-ovs-interface.c @@ -0,0 +1,96 @@ +/* + * 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. + */ + +#include "nm-default.h" + +#include + +#include "nm-device-ovs-interface.h" +#include "nm-object-private.h" +#include "nm-setting-ovs-interface.h" +#include "nm-setting-ovs-port.h" +#include "nm-setting-connection.h" + +/** + * NMDeviceOvsInterface: + */ +struct _NMDeviceOvsInterface { + NMDevice parent; +}; + +struct _NMDeviceOvsInterfaceClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceOvsInterface, nm_device_ovs_interface, NM_TYPE_DEVICE) + +/*****************************************************************************/ + +static const char * +get_type_description (NMDevice *device) +{ + return "ovs-interface"; +} + +static gboolean +connection_compatible (NMDevice *device, NMConnection *connection, GError **error) +{ + const char *iface_name; + + if (!NM_DEVICE_CLASS (nm_device_ovs_interface_parent_class)->connection_compatible (device, connection, error)) + return FALSE; + + if (!nm_connection_is_type (connection, NM_SETTING_OVS_INTERFACE_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a ovs_interface connection.")); + return FALSE; + } + + iface_name = nm_connection_get_interface_name (connection); + if (!iface_name) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + _("The connection did not specify an interface name.")); + return FALSE; + } + + return TRUE; +} + +static GType +get_setting_type (NMDevice *device) +{ + return NM_TYPE_SETTING_OVS_INTERFACE; +} + +/*****************************************************************************/ + +static void +nm_device_ovs_interface_init (NMDeviceOvsInterface *device) +{ +} + +static void +nm_device_ovs_interface_class_init (NMDeviceOvsInterfaceClass *ovs_interface_class) +{ + NMDeviceClass *device_class = NM_DEVICE_CLASS (ovs_interface_class); + + device_class->get_type_description = get_type_description; + device_class->connection_compatible = connection_compatible; + device_class->get_setting_type = get_setting_type; +} diff --git a/libnm/nm-device-ovs-interface.h b/libnm/nm-device-ovs-interface.h new file mode 100644 index 00000000..a49db559 --- /dev/null +++ b/libnm/nm-device-ovs-interface.h @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#ifndef __NM_DEVICE_OVS_INTERFACE_H__ +#define __NM_DEVICE_OVS_INTERFACE_H__ + +#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION) +#error "Only can be included directly." +#endif + +#include "nm-device.h" + +G_BEGIN_DECLS + +#define NM_TYPE_DEVICE_OVS_INTERFACE (nm_device_ovs_interface_get_type ()) +#define NM_DEVICE_OVS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_OVS_INTERFACE, NMDeviceOvsInterface)) +#define NM_DEVICE_OVS_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_OVS_INTERFACE, NMDeviceOvsInterfaceClass)) +#define NM_IS_DEVICE_OVS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_OVS_INTERFACE)) +#define NM_IS_DEVICE_OVS_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_OVS_INTERFACE)) +#define NM_DEVICE_OVS_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_OVS_INTERFACE, NMDeviceOvsInterfaceClass)) + +typedef struct _NMDeviceOvsInterfaceClass NMDeviceOvsInterfaceClass; + +NM_AVAILABLE_IN_1_10 +GType nm_device_ovs_interface_get_type (void); + +G_END_DECLS + +#endif /* __NM_DEVICE_OVS_INTERFACE_H__ */ diff --git a/libnm/nm-device-ovs-port.c b/libnm/nm-device-ovs-port.c new file mode 100644 index 00000000..17176dba --- /dev/null +++ b/libnm/nm-device-ovs-port.c @@ -0,0 +1,95 @@ +/* + * 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. + */ + +#include "nm-default.h" + +#include + +#include "nm-device-ovs-port.h" +#include "nm-object-private.h" +#include "nm-setting-ovs-port.h" +#include "nm-setting-ovs-port.h" +#include "nm-setting-connection.h" + +/** + * NMDeviceOvsPort: + */ +struct _NMDeviceOvsPort { + NMDevice parent; +}; + +struct _NMDeviceOvsPortClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceOvsPort, nm_device_ovs_port, NM_TYPE_DEVICE) + +/*****************************************************************************/ + +static const char * +get_type_description (NMDevice *device) +{ + return "ovs-port"; +} +static gboolean +connection_compatible (NMDevice *device, NMConnection *connection, GError **error) +{ + const char *iface_name; + + if (!NM_DEVICE_CLASS (nm_device_ovs_port_parent_class)->connection_compatible (device, connection, error)) + return FALSE; + + if (!nm_connection_is_type (connection, NM_SETTING_OVS_PORT_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a ovs_port connection.")); + return FALSE; + } + + iface_name = nm_connection_get_interface_name (connection); + if (!iface_name) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + _("The connection did not specify an interface name.")); + return FALSE; + } + + return TRUE; +} + +static GType +get_setting_type (NMDevice *device) +{ + return NM_TYPE_SETTING_OVS_PORT; +} + +/*****************************************************************************/ + +static void +nm_device_ovs_port_init (NMDeviceOvsPort *device) +{ +} + +static void +nm_device_ovs_port_class_init (NMDeviceOvsPortClass *ovs_port_class) +{ + NMDeviceClass *device_class = NM_DEVICE_CLASS (ovs_port_class); + + device_class->get_type_description = get_type_description; + device_class->connection_compatible = connection_compatible; + device_class->get_setting_type = get_setting_type; +} diff --git a/libnm/nm-device-ovs-port.h b/libnm/nm-device-ovs-port.h new file mode 100644 index 00000000..af661e7b --- /dev/null +++ b/libnm/nm-device-ovs-port.h @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#ifndef __NM_DEVICE_OVS_PORT_H__ +#define __NM_DEVICE_OVS_PORT_H__ + +#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION) +#error "Only can be included directly." +#endif + +#include "nm-device.h" + +G_BEGIN_DECLS + +#define NM_TYPE_DEVICE_OVS_PORT (nm_device_ovs_port_get_type ()) +#define NM_DEVICE_OVS_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_OVS_PORT, NMDeviceOvsPort)) +#define NM_DEVICE_OVS_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_OVS_PORT, NMDeviceOvsPortClass)) +#define NM_IS_DEVICE_OVS_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_OVS_PORT)) +#define NM_IS_DEVICE_OVS_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_OVS_PORT)) +#define NM_DEVICE_OVS_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_OVS_PORT, NMDeviceOvsPortClass)) + +typedef struct _NMDeviceOvsPortClass NMDeviceOvsPortClass; + +NM_AVAILABLE_IN_1_10 +GType nm_device_ovs_port_get_type (void); + +G_END_DECLS + +#endif /* __NM_DEVICE_OVS_PORT_H__ */ diff --git a/libnm/nm-device-ppp.c b/libnm/nm-device-ppp.c new file mode 100644 index 00000000..805d1428 --- /dev/null +++ b/libnm/nm-device-ppp.c @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * 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 . + * + * Copyright 2017 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-device-ppp.h" +#include "nm-device.h" + +struct _NMDevicePpp { + NMDevice parent; +}; + +struct _NMDevicePppClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDevicePpp, nm_device_ppp, NM_TYPE_DEVICE) + +#define NM_DEVICE_PPP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_PPP, NMDevicePppPrivate)) + +static void +nm_device_ppp_init (NMDevicePpp *device) +{ +} + +static void +nm_device_ppp_class_init (NMDevicePppClass *klass) +{ +} diff --git a/libnm/nm-device-ppp.h b/libnm/nm-device-ppp.h new file mode 100644 index 00000000..58ff5e18 --- /dev/null +++ b/libnm/nm-device-ppp.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * 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 . + * + * Copyright 2017 Red Hat, Inc. + */ + +#ifndef __NM_DEVICE_PPP_H__ +#define __NM_DEVICE_PPP_H__ + +#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION) +#error "Only can be included directly." +#endif + +G_BEGIN_DECLS + +#define NM_TYPE_DEVICE_PPP (nm_device_ppp_get_type ()) +#define NM_DEVICE_PPP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_PPP, NMDevicePpp)) +#define NM_DEVICE_PPP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_PPP, NMDevicePppClass)) +#define NM_IS_DEVICE_PPP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_PPP)) +#define NM_IS_DEVICE_PPP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_PPP)) +#define NM_DEVICE_PPP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_PPP, NMDevicePppClass)) + +typedef struct _NMDevicePppClass NMDevicePppClass; + +GType nm_device_ppp_get_type (void); + +G_END_DECLS + +#endif /* __NM_DEVICE_PPP_H__ */ diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 969d08a6..65afd078 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -261,6 +261,9 @@ coerce_type (NMDeviceType type) case NM_DEVICE_TYPE_WIFI: case NM_DEVICE_TYPE_BT: case NM_DEVICE_TYPE_OLPC_MESH: + case NM_DEVICE_TYPE_OVS_INTERFACE: + case NM_DEVICE_TYPE_OVS_PORT: + case NM_DEVICE_TYPE_OVS_BRIDGE: case NM_DEVICE_TYPE_WIMAX: case NM_DEVICE_TYPE_MODEM: case NM_DEVICE_TYPE_INFINIBAND: @@ -280,6 +283,7 @@ coerce_type (NMDeviceType type) case NM_DEVICE_TYPE_UNUSED2: case NM_DEVICE_TYPE_UNKNOWN: case NM_DEVICE_TYPE_DUMMY: + case NM_DEVICE_TYPE_PPP: return type; } return NM_DEVICE_TYPE_UNKNOWN; @@ -1521,6 +1525,12 @@ get_type_name (NMDevice *device) return _("Bluetooth"); case NM_DEVICE_TYPE_OLPC_MESH: return _("OLPC Mesh"); + case NM_DEVICE_TYPE_OVS_INTERFACE: + return _("OpenVSwitch Interface"); + case NM_DEVICE_TYPE_OVS_PORT: + return _("OpenVSwitch Port"); + case NM_DEVICE_TYPE_OVS_BRIDGE: + return _("OpenVSwitch Bridge"); case NM_DEVICE_TYPE_WIMAX: return _("WiMAX"); case NM_DEVICE_TYPE_MODEM: @@ -1551,6 +1561,8 @@ get_type_name (NMDevice *device) return _("MACsec"); case NM_DEVICE_TYPE_DUMMY: return _("Dummy"); + case NM_DEVICE_TYPE_PPP: + return _("PPP"); case NM_DEVICE_TYPE_GENERIC: case NM_DEVICE_TYPE_UNUSED1: case NM_DEVICE_TYPE_UNUSED2: @@ -2138,7 +2150,7 @@ out: * @callback: callback to be called when the reapply operation completes * @user_data: caller-specific data passed to @callback * - * Asynchronously begins an get the a currently applied connection. + * Asynchronously begins and gets the currently applied connection. * * Since: 1.2 **/ diff --git a/libnm/nm-dns-manager.c b/libnm/nm-dns-manager.c index f9ee332b..b833d0c6 100644 --- a/libnm/nm-dns-manager.c +++ b/libnm/nm-dns-manager.c @@ -313,9 +313,9 @@ demarshal_dns_configuration (NMObject *object, GParamSpec *pspec, GVariant *valu vpn); g_free (domains); g_free (nameservers); + g_variant_unref (entry_var); if (!entry) { g_warning ("Ignoring invalid DNS entry"); - g_variant_unref (entry_var); continue; } diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index d3df7337..e664b710 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -34,6 +34,7 @@ #include "nm-active-connection.h" #include "nm-vpn-connection.h" #include "nm-dbus-helpers.h" +#include "nm-utils/c-list.h" #include "introspection/org.freedesktop.NetworkManager.h" @@ -71,7 +72,7 @@ typedef struct { /* Activations waiting for their NMActiveConnection * to appear and then their callback to be called. */ - GSList *pending_activations; + CList pending_activations; gboolean networking_enabled; gboolean wireless_enabled; @@ -82,6 +83,9 @@ typedef struct { gboolean wimax_enabled; gboolean wimax_hw_enabled; + + gboolean connectivity_check_available; + gboolean connectivity_check_enabled; } NMManagerPrivate; enum { @@ -98,6 +102,8 @@ enum { PROP_WIMAX_HARDWARE_ENABLED, PROP_ACTIVE_CONNECTIONS, PROP_CONNECTIVITY, + PROP_CONNECTIVITY_CHECK_AVAILABLE, + PROP_CONNECTIVITY_CHECK_ENABLED, PROP_PRIMARY_CONNECTION, PROP_ACTIVATING_CONNECTION, PROP_DEVICES, @@ -128,6 +134,8 @@ nm_manager_init (NMManager *manager) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); + c_list_init (&priv->pending_activations); + priv->state = NM_STATE_UNKNOWN; priv->connectivity = NM_CONNECTIVITY_UNKNOWN; @@ -176,6 +184,8 @@ init_dbus (NMObject *object) { NM_MANAGER_WIMAX_HARDWARE_ENABLED, &priv->wimax_hw_enabled }, { NM_MANAGER_ACTIVE_CONNECTIONS, &priv->active_connections, NULL, NM_TYPE_ACTIVE_CONNECTION, "active-connection" }, { NM_MANAGER_CONNECTIVITY, &priv->connectivity }, + { NM_MANAGER_CONNECTIVITY_CHECK_AVAILABLE, &priv->connectivity_check_available }, + { NM_MANAGER_CONNECTIVITY_CHECK_ENABLED, &priv->connectivity_check_enabled }, { NM_MANAGER_PRIMARY_CONNECTION, &priv->primary_connection, NULL, NM_TYPE_ACTIVE_CONNECTION }, { NM_MANAGER_ACTIVATING_CONNECTION, &priv->activating_connection, NULL, NM_TYPE_ACTIVE_CONNECTION }, { NM_MANAGER_DEVICES, &priv->devices, NULL, NM_TYPE_DEVICE, "device" }, @@ -192,8 +202,8 @@ init_dbus (NMObject *object) property_info); /* Permissions */ - g_signal_connect (priv->proxy, "check-permissions", - G_CALLBACK (manager_recheck_permissions), object); + g_signal_connect_object (priv->proxy, "check-permissions", + G_CALLBACK (manager_recheck_permissions), object, 0); } static NMClientPermission @@ -229,6 +239,8 @@ nm_permission_to_client (const char *nm) return NM_CLIENT_PERMISSION_CHECKPOINT_ROLLBACK; else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_STATISTICS)) return NM_CLIENT_PERMISSION_ENABLE_DISABLE_STATISTICS; + else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK)) + return NM_CLIENT_PERMISSION_ENABLE_DISABLE_CONNECTIVITY_CHECK; return NM_CLIENT_PERMISSION_NONE; } @@ -498,6 +510,31 @@ nm_manager_wimax_hardware_get_enabled (NMManager *manager) return NM_MANAGER_GET_PRIVATE (manager)->wimax_hw_enabled; } +gboolean +nm_manager_connectivity_check_get_available (NMManager *manager) +{ + g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE); + + return NM_MANAGER_GET_PRIVATE (manager)->connectivity_check_available; +} + +gboolean +nm_manager_connectivity_check_get_enabled (NMManager *manager) +{ + return NM_MANAGER_GET_PRIVATE (manager)->connectivity_check_enabled; +} + +void +nm_manager_connectivity_check_set_enabled (NMManager *manager, gboolean enabled) +{ + g_return_if_fail (NM_IS_MANAGER (manager)); + + _nm_object_set_property (NM_OBJECT (manager), + NM_DBUS_INTERFACE, + "ConnectivityCheckEnabled", + "b", enabled); +} + gboolean nm_manager_get_logging (NMManager *manager, char **level, char **domains, GError **error) { @@ -576,8 +613,13 @@ nm_manager_check_connectivity (NMManager *manager, if (nmdbus_manager_call_check_connectivity_sync (priv->proxy, &connectivity, - cancellable, error)) + cancellable, error)) { + if (connectivity != priv->connectivity) { + priv->connectivity = connectivity; + g_object_notify (G_OBJECT (manager), NM_MANAGER_CONNECTIVITY); + } return connectivity; + } else { if (error && *error) g_dbus_error_strip_remote_error (*error); @@ -593,12 +635,21 @@ check_connectivity_cb (GObject *object, GSimpleAsyncResult *simple = user_data; guint32 connectivity; GError *error = NULL; + NMManager *manager; + NMManagerPrivate *priv; if (nmdbus_manager_call_check_connectivity_finish (NMDBUS_MANAGER (object), &connectivity, - result, &error)) + result, &error)) { g_simple_async_result_set_op_res_gssize (simple, connectivity); - else { + + manager = NM_MANAGER (g_async_result_get_source_object (G_ASYNC_RESULT (simple))); + priv = NM_MANAGER_GET_PRIVATE (manager); + if (connectivity != priv->connectivity) { + priv->connectivity = connectivity; + g_object_notify (G_OBJECT (manager), NM_MANAGER_CONNECTIVITY); + } + } else { g_dbus_error_strip_remote_error (error); g_simple_async_result_take_error (simple, error); } @@ -735,6 +786,7 @@ nm_manager_get_activating_connection (NMManager *manager) } typedef struct { + CList lst; NMManager *manager; GSimpleAsyncResult *simple; GCancellable *cancellable; @@ -748,15 +800,13 @@ activate_info_complete (ActivateInfo *info, NMActiveConnection *active, GError *error) { - NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (info->manager); - if (active) g_simple_async_result_set_op_res_gpointer (info->simple, g_object_ref (active), g_object_unref); else g_simple_async_result_set_from_error (info->simple, error); g_simple_async_result_complete (info->simple); - priv->pending_activations = g_slist_remove (priv->pending_activations, info); + c_list_unlink (&info->lst); g_free (info->active_path); g_free (info->new_connection_path); @@ -790,7 +840,7 @@ static void recheck_pending_activations (NMManager *self) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); - GSList *iter, *next; + CList *iter, *safe; NMActiveConnection *candidate; const GPtrArray *devices; NMDevice *device; @@ -804,12 +854,10 @@ recheck_pending_activations (NMManager *self) * device have both updated their properties to point to each other, and * call the pending connection's callback. */ - for (iter = priv->pending_activations; iter; iter = next) { - ActivateInfo *info = iter->data; + c_list_for_each_safe (iter, safe, &priv->pending_activations) { + ActivateInfo *info = c_list_entry (iter, ActivateInfo, lst); gs_unref_object GDBusObject *dbus_obj = NULL; - next = g_slist_next (iter); - if (!info->active_path) continue; @@ -901,14 +949,15 @@ nm_manager_activate_connection_async (NMManager *manager, if (connection) g_return_if_fail (NM_IS_CONNECTION (connection)); + priv = NM_MANAGER_GET_PRIVATE (manager); + info = g_slice_new0 (ActivateInfo); info->manager = manager; info->simple = g_simple_async_result_new (G_OBJECT (manager), callback, user_data, nm_manager_activate_connection_async); info->cancellable = cancellable ? g_object_ref (cancellable) : NULL; - priv = NM_MANAGER_GET_PRIVATE (manager); - priv->pending_activations = g_slist_prepend (priv->pending_activations, info); + c_list_link_tail (&priv->pending_activations, &info->lst); nmdbus_manager_call_activate_connection (priv->proxy, connection ? nm_connection_get_path (connection) : "/", @@ -977,14 +1026,15 @@ nm_manager_add_and_activate_connection_async (NMManager *manager, if (partial) g_return_if_fail (NM_IS_CONNECTION (partial)); + priv = NM_MANAGER_GET_PRIVATE (manager); + info = g_slice_new0 (ActivateInfo); info->manager = manager; info->simple = g_simple_async_result_new (G_OBJECT (manager), callback, user_data, nm_manager_add_and_activate_connection_async); info->cancellable = cancellable ? g_object_ref (cancellable) : NULL; - priv = NM_MANAGER_GET_PRIVATE (manager); - priv->pending_activations = g_slist_prepend (priv->pending_activations, info); + c_list_link_tail (&priv->pending_activations, &info->lst); if (partial) dict = nm_connection_to_dbus (partial, NM_CONNECTION_SERIALIZE_ALL); @@ -1294,7 +1344,7 @@ dispose (GObject *object) /* Each activation should hold a ref on @manager, so if we're being disposed, * there shouldn't be any pending. */ - g_warn_if_fail (priv->pending_activations == NULL); + g_warn_if_fail (c_list_is_empty (&priv->pending_activations)); g_hash_table_destroy (priv->permissions); priv->permissions = NULL; @@ -1348,6 +1398,13 @@ set_property (GObject *object, guint prop_id, /* Let the property value flip when we get the change signal from NM */ } break; + case PROP_CONNECTIVITY_CHECK_ENABLED: + b = g_value_get_boolean (value); + if (priv->connectivity_check_enabled != b) { + nm_manager_connectivity_check_set_enabled (NM_MANAGER (object), b); + /* Let the property value flip when we get the change signal from NM */ + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1400,6 +1457,12 @@ get_property (GObject *object, case PROP_CONNECTIVITY: g_value_set_enum (value, priv->connectivity); break; + case PROP_CONNECTIVITY_CHECK_AVAILABLE: + g_value_set_boolean (value, priv->connectivity_check_available); + break; + case PROP_CONNECTIVITY_CHECK_ENABLED: + g_value_set_boolean (value, priv->connectivity_check_enabled); + break; case PROP_PRIMARY_CONNECTION: g_value_set_object (value, priv->primary_connection); break; @@ -1519,6 +1582,18 @@ nm_manager_class_init (NMManagerClass *manager_class) NM_CONNECTIVITY_UNKNOWN, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property + (object_class, PROP_CONNECTIVITY_CHECK_AVAILABLE, + g_param_spec_boolean (NM_MANAGER_CONNECTIVITY_CHECK_AVAILABLE, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + g_object_class_install_property + (object_class, PROP_CONNECTIVITY_CHECK_ENABLED, + g_param_spec_boolean (NM_MANAGER_CONNECTIVITY_CHECK_ENABLED, "", "", + FALSE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_PRIMARY_CONNECTION, g_param_spec_object (NM_MANAGER_PRIMARY_CONNECTION, "", "", diff --git a/libnm/nm-manager.h b/libnm/nm-manager.h index 7c63a333..209a99a0 100644 --- a/libnm/nm-manager.h +++ b/libnm/nm-manager.h @@ -46,6 +46,8 @@ G_BEGIN_DECLS #define NM_MANAGER_WIMAX_HARDWARE_ENABLED "wimax-hardware-enabled" #define NM_MANAGER_ACTIVE_CONNECTIONS "active-connections" #define NM_MANAGER_CONNECTIVITY "connectivity" +#define NM_MANAGER_CONNECTIVITY_CHECK_AVAILABLE "connectivity-check-available" +#define NM_MANAGER_CONNECTIVITY_CHECK_ENABLED "connectivity-check-enabled" #define NM_MANAGER_PRIMARY_CONNECTION "primary-connection" #define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection" #define NM_MANAGER_DEVICES "devices" @@ -97,6 +99,16 @@ gboolean nm_manager_wimax_get_enabled (NMManager *manager); void nm_manager_wimax_set_enabled (NMManager *manager, gboolean enabled); gboolean nm_manager_wimax_hardware_get_enabled (NMManager *manager); +NM_AVAILABLE_IN_1_10 +gboolean nm_manager_connectivity_check_get_available (NMManager *manager); + +NM_AVAILABLE_IN_1_10 +gboolean nm_manager_connectivity_check_get_enabled (NMManager *manager); + +NM_AVAILABLE_IN_1_10 +void nm_manager_connectivity_check_set_enabled (NMManager *manager, + gboolean enabled); + gboolean nm_manager_get_logging (NMManager *manager, char **level, char **domains, diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 6bf1d063..ef335862 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -33,6 +33,7 @@ #include "nm-dbus-helpers.h" #include "nm-client.h" #include "nm-core-internal.h" +#include "nm-utils/c-list.h" static gboolean debug = FALSE; #define dbgmsg(f,...) if (G_UNLIKELY (debug)) { g_message (f, ## __VA_ARGS__ ); } @@ -77,14 +78,12 @@ typedef struct { GSList *waiters; /* if async init did not finish, users of this object need * to defer their notifications by adding themselves here. */ - GSList *notify_items; - guint32 notify_id; + CList notify_items; + guint notify_id; - GSList *reload_results; guint reload_remaining; - GError *reload_error; - GSList *pending; /* ordered list of pending property updates. */ + CList pending; /* ordered list of pending property updates. */ GPtrArray *proxies; } NMObjectPrivate; @@ -152,6 +151,7 @@ typedef enum { } NotifySignalPending; typedef struct { + CList lst; const char *property; const char *signal_prefix; NotifySignalPending pending; @@ -161,6 +161,7 @@ typedef struct { static void notify_item_free (NotifyItem *item) { + c_list_unlink (&item->lst); g_clear_object (&item->changed); g_slice_free (NotifyItem, item); } @@ -171,7 +172,8 @@ deferred_notify_cb (gpointer data) NMObject *object = NM_OBJECT (data); NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); NMObjectClass *object_class = NM_OBJECT_GET_CLASS (object); - GSList *props, *iter; + CList props; + CList *iter, *safe; priv->notify_id = 0; @@ -184,16 +186,16 @@ deferred_notify_cb (gpointer data) * during the g_object_notify() call separately from the property * list we're iterating. */ - props = g_slist_reverse (priv->notify_items); - priv->notify_items = NULL; + c_list_link_after (&priv->notify_items, &props); + c_list_unlink_init (&priv->notify_items); g_object_ref (object); /* Emit added/removed signals first since some of our internal objects * use the added/removed signals for new object processing. */ - for (iter = props; iter; iter = g_slist_next (iter)) { - NotifyItem *item = iter->data; + c_list_for_each (iter, &props) { + NotifyItem *item = c_list_entry (iter, NotifyItem, lst); char buf[50]; gint ret = 0; @@ -219,8 +221,8 @@ deferred_notify_cb (gpointer data) } /* Emit property change notifications second */ - for (iter = props; iter; iter = g_slist_next (iter)) { - NotifyItem *item = iter->data; + c_list_for_each (iter, &props) { + NotifyItem *item = c_list_entry (iter, NotifyItem, lst); if (item->property) g_object_notify (G_OBJECT (object), item->property); @@ -228,7 +230,9 @@ deferred_notify_cb (gpointer data) g_object_unref (object); - g_slist_free_full (props, (GDestroyNotify) notify_item_free); + c_list_for_each_safe (iter, safe, &props) + notify_item_free (c_list_entry (iter, NotifyItem, lst)); + return G_SOURCE_REMOVE; } @@ -250,7 +254,7 @@ _nm_object_queue_notify_full (NMObject *object, { NMObjectPrivate *priv; NotifyItem *item; - GSList *iter; + CList *iter; g_return_if_fail (NM_IS_OBJECT (object)); g_return_if_fail (!signal_prefix != !property); @@ -261,8 +265,8 @@ _nm_object_queue_notify_full (NMObject *object, property = g_intern_string (property); signal_prefix = g_intern_string (signal_prefix); - for (iter = priv->notify_items; iter; iter = g_slist_next (iter)) { - item = iter->data; + c_list_for_each (iter, &priv->notify_items) { + item = c_list_entry (iter, NotifyItem, lst); if (property && (property == item->property)) return; @@ -314,7 +318,7 @@ _nm_object_queue_notify_full (NMObject *object, item->pending = added ? NOTIFY_SIGNAL_PENDING_ADDED : NOTIFY_SIGNAL_PENDING_REMOVED; item->changed = changed ? g_object_ref (changed) : NULL; } - priv->notify_items = g_slist_prepend (priv->notify_items, item); + c_list_link_tail (&priv->notify_items, &item->lst); } void @@ -324,6 +328,7 @@ _nm_object_queue_notify (NMObject *object, const char *property) } typedef struct { + CList lst_pending; NMObject *self; PropertyInfo *pi; @@ -339,6 +344,7 @@ odata_free (gpointer data) { ObjectCreatedData *odata = data; + c_list_unlink (&odata->lst_pending); g_object_unref (odata->self); g_free (odata->objects); g_slice_free (ObjectCreatedData, odata); @@ -445,9 +451,10 @@ object_property_maybe_complete (NMObject *self) /* The odata may hold the last reference. */ _nm_unused gs_unref_object NMObject *self_keep_alive = g_object_ref (self); int i; + CList *iter, *safe; - while (priv->pending) { - ObjectCreatedData *odata = priv->pending->data; + c_list_for_each_safe (iter, safe, &priv->pending) { + ObjectCreatedData *odata = c_list_entry (iter, ObjectCreatedData, lst_pending); PropertyInfo *pi = odata->pi; gboolean different = TRUE; @@ -505,16 +512,16 @@ object_property_maybe_complete (NMObject *self) /* Emit added & removed */ for (i = 0; i < removed->len; i++) { queue_added_removed_signal (self, - pi->signal_prefix, - g_ptr_array_index (removed, i), - FALSE); + pi->signal_prefix, + g_ptr_array_index (removed, i), + FALSE); } for (i = 0; i < added->len; i++) { queue_added_removed_signal (self, - pi->signal_prefix, - g_ptr_array_index (added, i), - TRUE); + pi->signal_prefix, + g_ptr_array_index (added, i), + TRUE); } different = removed->len || added->len; @@ -547,7 +554,6 @@ object_property_maybe_complete (NMObject *self) if (--priv->reload_remaining == 0) reload_complete (self, TRUE); - priv->pending = g_slist_remove (priv->pending, odata); odata_free (odata); } } @@ -588,7 +594,8 @@ handle_object_property (NMObject *self, const char *property_name, GVariant *val odata->array = FALSE; odata->property_name = property_name; - priv->pending = g_slist_append (priv->pending, odata); + c_list_link_tail (&priv->pending, &odata->lst_pending); + priv->reload_remaining++; path = g_variant_get_string (value, NULL); @@ -644,7 +651,8 @@ handle_object_array_property (NMObject *self, const char *property_name, GVarian odata->array = TRUE; odata->property_name = property_name; - priv->pending = g_slist_append (priv->pending, odata); + c_list_link_tail (&priv->pending, &odata->lst_pending); + priv->reload_remaining++; if (npaths == 0) { @@ -944,7 +952,7 @@ _nm_object_register_properties (NMObject *object, proxy = _nm_object_get_proxy (object, interface); g_signal_connect (proxy, "g-properties-changed", - G_CALLBACK (properties_changed), object); + G_CALLBACK (properties_changed), object); g_ptr_array_add (priv->proxies, proxy); instance = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); @@ -1004,34 +1012,12 @@ static void reload_complete (NMObject *object, gboolean emit_now) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); - GSimpleAsyncResult *simple; - GSList *results, *iter; - GError *error; if (emit_now) { nm_clear_g_source (&priv->notify_id); deferred_notify_cb (object); } else _nm_object_defer_notify (object); - - results = priv->reload_results; - priv->reload_results = NULL; - error = priv->reload_error; - priv->reload_error = NULL; - - for (iter = results; iter; iter = iter->next) { - simple = iter->data; - - if (error) - g_simple_async_result_set_from_error (simple, error); - else - g_simple_async_result_set_op_res_gboolean (simple, TRUE); - - g_simple_async_result_complete (simple); - g_object_unref (simple); - } - g_slist_free (results); - g_clear_error (&error); } GDBusObjectManager * @@ -1048,15 +1034,16 @@ init_dbus (NMObject *object) } static void -init_if (GDBusInterface *interface, gpointer user_data) +init_if (GDBusProxy *proxy, NMObject *self) { - NMObject *self = NM_OBJECT (user_data); - GDBusProxy *proxy = G_DBUS_PROXY (interface); gchar **props; char **prop; GVariant *val; gchar *str; + nm_assert (G_IS_DBUS_PROXY (proxy)); + nm_assert (NM_IS_OBJECT (self)); + props = g_dbus_proxy_get_cached_property_names (proxy); for (prop = props; prop && *prop; prop++) { @@ -1194,7 +1181,11 @@ nm_object_async_initable_iface_init (GAsyncInitableIface *iface) static void nm_object_init (NMObject *object) { - NM_OBJECT_GET_PRIVATE (object)->proxies = g_ptr_array_new (); + NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); + + c_list_init (&priv->notify_items); + c_list_init (&priv->pending); + priv->proxies = g_ptr_array_new (); } static void @@ -1243,12 +1234,13 @@ static void dispose (GObject *object) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); + CList *iter, *safe; guint i; nm_clear_g_source (&priv->notify_id); - g_slist_free_full (priv->notify_items, (GDestroyNotify) notify_item_free); - priv->notify_items = NULL; + c_list_for_each_safe (iter, safe, &priv->notify_items) + notify_item_free (c_list_entry (iter, NotifyItem, lst)); g_slist_free_full (priv->waiters, odata_free); diff --git a/libnm/nm-property-docs.xml b/libnm/nm-property-docs.xml index 28578123..f2249942 100644 --- a/libnm/nm-property-docs.xml +++ b/libnm/nm-property-docs.xml @@ -3,410 +3,441 @@ ]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index 0f7ea58e..5cd42555 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -641,7 +641,7 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error) GVariant *settings; priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (NM_OBJECT (initable), NM_DBUS_INTERFACE_SETTINGS_CONNECTION)); - g_signal_connect (priv->proxy, "updated", G_CALLBACK (updated_cb), initable); + g_signal_connect_object (priv->proxy, "updated", G_CALLBACK (updated_cb), initable, 0); if (nmdbus_settings_connection_call_get_settings_sync (priv->proxy, &settings, @@ -730,8 +730,8 @@ init_async (GAsyncInitable *initable, int io_priority, priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (NM_OBJECT (initable), NM_DBUS_INTERFACE_SETTINGS_CONNECTION)); - g_signal_connect (priv->proxy, "updated", - G_CALLBACK (updated_cb), initable); + g_signal_connect_object (priv->proxy, "updated", + G_CALLBACK (updated_cb), initable, 0); nmdbus_settings_connection_call_get_settings (NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->initable)->proxy, init_data->cancellable, diff --git a/libnm/nm-settings-docs-overrides.xml b/libnm/nm-settings-docs-overrides.xml index 2b27b640..3e4a57d0 100644 --- a/libnm/nm-settings-docs-overrides.xml +++ b/libnm/nm-settings-docs-overrides.xml @@ -35,8 +35,6 @@ bridge's interface name."/> - - @@ -116,6 +114,14 @@ also exist on some routes."/> + + + + + + + + diff --git a/libnm/nm-settings-docs.xml b/libnm/nm-settings-docs.xml index ecc32400..0a5aa3f7 100644 --- a/libnm/nm-settings-docs.xml +++ b/libnm/nm-settings-docs.xml @@ -3,421 +3,452 @@ ]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libnm/nm-settings-ifcfg-rh-docs.xml b/libnm/nm-settings-ifcfg-rh-docs.xml index 0d386d2a..7f3cf25d 100644 --- a/libnm/nm-settings-ifcfg-rh-docs.xml +++ b/libnm/nm-settings-ifcfg-rh-docs.xml @@ -29,7 +29,8 @@ IEEE_8021X_INNER_AUTH_METHODS is also used for 'phase2-auth' values."/ - + pinging the gateway and waiting for the specified timeout (in seconds)."/> + @@ -149,8 +151,6 @@ or a decimal number. When PKEY_ID is specified, PHYSDEV and DEVICE also must be specified."/> - - @@ -173,6 +173,7 @@ meaning as 'never-default' property."/> + @@ -204,6 +205,7 @@ meaning as 'never-default' property."/> + @@ -218,6 +220,14 @@ IPV6_PRIVACY_PREFER_PUBLIC_IP: yes, no" default="no" example="IPV6_PRIVACY=rfc30 + + + + + + + + @@ -240,6 +250,12 @@ proxy configuration, or set the PAC file via PAC_URL or PAC_SCRIPT."/> + @@ -292,6 +308,7 @@ is listed."/> separated list."/> + @@ -306,6 +323,9 @@ lookaside file, or it can be owned by a secret agent."/> + diff --git a/libnm/nm-settings-keyfile-docs.xml b/libnm/nm-settings-keyfile-docs.xml index 33f53c4c..c7f68ab4 100644 --- a/libnm/nm-settings-keyfile-docs.xml +++ b/libnm/nm-settings-keyfile-docs.xml @@ -34,8 +34,6 @@ or semicolon separated list of 6 decimal bytes (obsolete)"/> - - @@ -57,6 +55,14 @@ route2=7.7.0.0/16" description="List of IP routes."/> + + + + + + + + diff --git a/libnm/nm-types.h b/libnm/nm-types.h index 84cf48f4..4310120f 100644 --- a/libnm/nm-types.h +++ b/libnm/nm-types.h @@ -26,34 +26,38 @@ #include "nm-dbus-interface.h" #include "nm-connection.h" -typedef struct _NMAccessPoint NMAccessPoint; -typedef struct _NMActiveConnection NMActiveConnection; -typedef struct _NMClient NMClient; -typedef struct _NMDevice NMDevice; -typedef struct _NMDeviceAdsl NMDeviceAdsl; -typedef struct _NMDeviceBond NMDeviceBond; -typedef struct _NMDeviceBridge NMDeviceBridge; -typedef struct _NMDeviceBt NMDeviceBt; -typedef struct _NMDeviceDummy NMDeviceDummy; -typedef struct _NMDeviceEthernet NMDeviceEthernet; -typedef struct _NMDeviceGeneric NMDeviceGeneric; -typedef struct _NMDeviceInfiniband NMDeviceInfiniband; -typedef struct _NMDeviceIPTunnel NMDeviceIPTunnel; -typedef struct _NMDeviceMacsec NMDeviceMacsec; -typedef struct _NMDeviceMacvlan NMDeviceMacvlan; -typedef struct _NMDeviceModem NMDeviceModem; -typedef struct _NMDeviceOlpcMesh NMDeviceOlpcMesh; -typedef struct _NMDeviceTeam NMDeviceTeam; -typedef struct _NMDeviceTun NMDeviceTun; -typedef struct _NMDeviceVlan NMDeviceVlan; -typedef struct _NMDeviceVxlan NMDeviceVxlan; -typedef struct _NMDeviceWifi NMDeviceWifi; -typedef struct _NMDeviceWimax NMDeviceWimax; -typedef struct _NMDhcpConfig NMDhcpConfig; -typedef struct _NMIPConfig NMIPConfig; -typedef struct _NMObject NMObject; -typedef struct _NMRemoteConnection NMRemoteConnection; -typedef struct _NMVpnConnection NMVpnConnection; -typedef struct _NMWimaxNsp NMWimaxNsp; +typedef struct _NMAccessPoint NMAccessPoint; +typedef struct _NMActiveConnection NMActiveConnection; +typedef struct _NMClient NMClient; +typedef struct _NMDevice NMDevice; +typedef struct _NMDeviceAdsl NMDeviceAdsl; +typedef struct _NMDeviceBond NMDeviceBond; +typedef struct _NMDeviceBridge NMDeviceBridge; +typedef struct _NMDeviceBt NMDeviceBt; +typedef struct _NMDeviceDummy NMDeviceDummy; +typedef struct _NMDeviceEthernet NMDeviceEthernet; +typedef struct _NMDeviceGeneric NMDeviceGeneric; +typedef struct _NMDeviceInfiniband NMDeviceInfiniband; +typedef struct _NMDeviceIPTunnel NMDeviceIPTunnel; +typedef struct _NMDeviceMacsec NMDeviceMacsec; +typedef struct _NMDeviceMacvlan NMDeviceMacvlan; +typedef struct _NMDeviceModem NMDeviceModem; +typedef struct _NMDeviceOlpcMesh NMDeviceOlpcMesh; +typedef struct _NMDeviceOvsBridge NMDeviceOvsBridge; +typedef struct _NMDeviceOvsInterface NMDeviceOvsInterface; +typedef struct _NMDeviceOvsPort NMDeviceOvsPort; +typedef struct _NMDevicePpp NMDevicePpp; +typedef struct _NMDeviceTeam NMDeviceTeam; +typedef struct _NMDeviceTun NMDeviceTun; +typedef struct _NMDeviceVlan NMDeviceVlan; +typedef struct _NMDeviceVxlan NMDeviceVxlan; +typedef struct _NMDeviceWifi NMDeviceWifi; +typedef struct _NMDeviceWimax NMDeviceWimax; +typedef struct _NMDhcpConfig NMDhcpConfig; +typedef struct _NMIPConfig NMIPConfig; +typedef struct _NMObject NMObject; +typedef struct _NMRemoteConnection NMRemoteConnection; +typedef struct _NMVpnConnection NMVpnConnection; +typedef struct _NMWimaxNsp NMWimaxNsp; #endif /* NM_TYPES_H */ diff --git a/libnm/nm-vpn-connection.c b/libnm/nm-vpn-connection.c index 814f45f0..636c3950 100644 --- a/libnm/nm-vpn-connection.c +++ b/libnm/nm-vpn-connection.c @@ -144,8 +144,8 @@ init_dbus (NMObject *object) property_info); proxy = _nm_object_get_proxy (object, NM_DBUS_INTERFACE_VPN_CONNECTION); - g_signal_connect (proxy, "vpn-state-changed", - G_CALLBACK (vpn_state_changed_proxy), object); + g_signal_connect_object (proxy, "vpn-state-changed", + G_CALLBACK (vpn_state_changed_proxy), object, 0); g_object_unref (proxy); } -- cgit 1.3.0-6-gf8a5