From c333f062ddcba9b35330647bf6cbd0a07f2d786e Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 11 May 2017 14:55:55 +0200 Subject: New upstream version 1.8.0 --- libnm/NetworkManager.h | 149 ++++++++++++++++++----------------- libnm/generate-setting-docs.py | 16 +++- libnm/libnm.ver | 34 ++++++++ libnm/nm-access-point.c | 27 ++++--- libnm/nm-access-point.h | 2 +- libnm/nm-active-connection.c | 74 +++++++++++++++++ libnm/nm-active-connection.h | 34 ++++---- libnm/nm-client.c | 42 ++++++---- libnm/nm-client.h | 2 +- libnm/nm-device-adsl.h | 2 +- libnm/nm-device-bond.h | 2 +- libnm/nm-device-bridge.h | 2 +- libnm/nm-device-bt.h | 2 +- libnm/nm-device-dummy.c | 80 +++++++++++++++++++ libnm/nm-device-dummy.h | 57 ++++++++++++++ libnm/nm-device-ethernet.h | 2 +- libnm/nm-device-generic.h | 2 +- libnm/nm-device-infiniband.h | 2 +- libnm/nm-device-ip-tunnel.h | 2 +- libnm/nm-device-macsec.h | 2 +- libnm/nm-device-macvlan.h | 2 +- libnm/nm-device-modem.h | 2 +- libnm/nm-device-olpc-mesh.h | 2 +- libnm/nm-device-team.h | 2 +- libnm/nm-device-tun.h | 2 +- libnm/nm-device-vlan.h | 2 +- libnm/nm-device-vxlan.h | 2 +- libnm/nm-device-wifi.h | 2 +- libnm/nm-device-wimax.h | 2 +- libnm/nm-device.c | 126 ++++++++++------------------- libnm/nm-device.h | 2 +- libnm/nm-dhcp-config.h | 2 +- libnm/nm-dhcp4-config.h | 2 +- libnm/nm-dhcp6-config.h | 2 +- libnm/nm-dns-manager.h | 2 +- libnm/nm-ip-config.h | 2 +- libnm/nm-ip4-config.h | 2 +- libnm/nm-ip6-config.h | 2 +- libnm/nm-manager.c | 14 ++-- libnm/nm-manager.h | 4 +- libnm/nm-object-private.h | 3 + libnm/nm-object.c | 33 ++++++-- libnm/nm-object.h | 2 +- libnm/nm-property-docs.xml | 129 +++++++++++++++++------------- libnm/nm-remote-connection.c | 2 + libnm/nm-remote-connection.h | 2 +- libnm/nm-remote-settings.h | 2 +- libnm/nm-secret-agent-old.h | 2 +- libnm/nm-settings-docs-overrides.xml | 4 + libnm/nm-settings-docs.xml | 129 +++++++++++++++++------------- libnm/nm-settings-ifcfg-rh-docs.xml | 8 +- libnm/nm-settings-keyfile-docs.xml | 4 + libnm/nm-types.h | 5 +- libnm/nm-vpn-connection.c | 4 + libnm/nm-vpn-connection.h | 14 +++- libnm/nm-vpn-editor.h | 4 +- libnm/nm-vpn-plugin-old.c | 2 +- libnm/nm-vpn-plugin-old.h | 4 +- libnm/nm-vpn-service-plugin.c | 4 +- libnm/nm-vpn-service-plugin.h | 4 +- libnm/nm-wimax-nsp.h | 2 +- 61 files changed, 699 insertions(+), 377 deletions(-) create mode 100644 libnm/nm-device-dummy.c create mode 100644 libnm/nm-device-dummy.h (limited to 'libnm') diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h index d0dec1a0..97327f92 100644 --- a/libnm/NetworkManager.h +++ b/libnm/NetworkManager.h @@ -23,79 +23,82 @@ #define __NETWORKMANAGER_H_INSIDE__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "nm-access-point.h" +#include "nm-active-connection.h" +#include "nm-client.h" +#include "nm-connection.h" +#include "nm-core-enum-types.h" +#include "nm-dbus-interface.h" +#include "nm-device-adsl.h" +#include "nm-device-bond.h" +#include "nm-device-bridge.h" +#include "nm-device-bt.h" +#include "nm-device-dummy.h" +#include "nm-device-ethernet.h" +#include "nm-device-generic.h" +#include "nm-device-infiniband.h" +#include "nm-device-ip-tunnel.h" +#include "nm-device-macvlan.h" +#include "nm-device-modem.h" +#include "nm-device-olpc-mesh.h" +#include "nm-device-team.h" +#include "nm-device-tun.h" +#include "nm-device-vlan.h" +#include "nm-device-vxlan.h" +#include "nm-device-wifi.h" +#include "nm-device-wimax.h" +#include "nm-device.h" +#include "nm-dhcp-config.h" +#include "nm-enum-types.h" +#include "nm-ip-config.h" +#include "nm-object.h" +#include "nm-remote-connection.h" +#include "nm-setting-8021x.h" +#include "nm-setting-adsl.h" +#include "nm-setting-bluetooth.h" +#include "nm-setting-bond.h" +#include "nm-setting-bridge.h" +#include "nm-setting-bridge-port.h" +#include "nm-setting-cdma.h" +#include "nm-setting-connection.h" +#include "nm-setting-dcb.h" +#include "nm-setting-dummy.h" +#include "nm-setting-generic.h" +#include "nm-setting-gsm.h" +#include "nm-setting-infiniband.h" +#include "nm-setting-ip4-config.h" +#include "nm-setting-ip6-config.h" +#include "nm-setting-ip-config.h" +#include "nm-setting-ip-tunnel.h" +#include "nm-setting-macsec.h" +#include "nm-setting-macvlan.h" +#include "nm-setting-olpc-mesh.h" +#include "nm-setting-ppp.h" +#include "nm-setting-pppoe.h" +#include "nm-setting-proxy.h" +#include "nm-setting-serial.h" +#include "nm-setting-team.h" +#include "nm-setting-team-port.h" +#include "nm-setting-tun.h" +#include "nm-setting-user.h" +#include "nm-setting-vlan.h" +#include "nm-setting-vpn.h" +#include "nm-setting-vxlan.h" +#include "nm-setting-wimax.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless.h" +#include "nm-setting-wireless-security.h" +#include "nm-setting.h" +#include "nm-simple-connection.h" +#include "nm-utils.h" +#include "nm-version.h" +#include "nm-vpn-connection.h" +#include "nm-vpn-dbus-interface.h" +#include "nm-vpn-editor.h" +#include "nm-vpn-editor-plugin.h" +#include "nm-vpn-plugin-info.h" +#include "nm-vpn-service-plugin.h" +#include "nm-wimax-nsp.h" #undef __NETWORKMANAGER_H_INSIDE__ diff --git a/libnm/generate-setting-docs.py b/libnm/generate-setting-docs.py index e1ea9723..d0625b01 100755 --- a/libnm/generate-setting-docs.py +++ b/libnm/generate-setting-docs.py @@ -112,7 +112,7 @@ def get_prop_type(setting, pspec, propxml): return prop_type -def get_docs(setting, pspec, propxml): +def get_docs(propxml): doc_xml = propxml.find('gi:doc', ns_map) if doc_xml is None: return None @@ -162,6 +162,11 @@ def get_default_value(setting, pspec, propxml): return default_value +def settings_sort_key(x): + x_prefix = x.attrib['{%s}symbol-prefix' % ns_map['c']] + # always sort NMSettingConnection first + return (x_prefix != "setting_connection", x_prefix); + def escape(val): return str(val).replace('"', '"') @@ -186,7 +191,7 @@ settings = girxml.findall('./gi:namespace/gi:class[@parent="Setting"]', ns_map) # Hack. Need a better way to do this ipxml = girxml.find('./gi:namespace/gi:class[@name="SettingIPConfig"]', ns_map) settings.extend(girxml.findall('./gi:namespace/gi:class[@parent="SettingIPConfig"]', ns_map)) -settings = sorted(settings, key=lambda setting: setting.attrib['{%s}symbol-prefix' % ns_map['c']]) +settings = sorted(settings, key=settings_sort_key) init_constants(girxml, settings) @@ -207,7 +212,10 @@ for settingxml in settings: new_func = NM.__getattr__(settingxml.attrib['name']) setting = new_func() - outfile.write(" \n" % setting.props.name) + 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)) setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) } if args.overrides is None: @@ -231,7 +239,7 @@ for settingxml in settings: propxml = ipxml.find('./gi:property[@name="%s"]' % pspec.name, ns_map) value_type = get_prop_type(setting, pspec, propxml) - value_desc = get_docs(setting, pspec, propxml) + value_desc = get_docs(propxml) default_value = get_default_value(setting, pspec, propxml) if prop in setting_overrides: diff --git a/libnm/libnm.ver b/libnm/libnm.ver index d0562e2c..b767bf83 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1143,3 +1143,37 @@ global: nm_utils_version; nm_utils_is_valid_iface_name; } libnm_1_4_0; + +libnm_1_8_0 { +global: + nm_active_connection_state_reason_get_type; + nm_active_connection_get_state_reason; + nm_connection_get_setting_dummy; + nm_device_dummy_get_type; + nm_ip_route_get_variant_attribute_spec; + nm_ip_route_attribute_validate; + nm_setting_802_1x_auth_flags_get_type; + nm_setting_802_1x_get_auth_timeout; + nm_setting_802_1x_get_ca_cert_password; + nm_setting_802_1x_get_ca_cert_password_flags; + nm_setting_802_1x_get_client_cert_password; + nm_setting_802_1x_get_client_cert_password_flags; + nm_setting_802_1x_get_phase1_auth_flags; + nm_setting_802_1x_get_phase2_ca_cert_password; + nm_setting_802_1x_get_phase2_ca_cert_password_flags; + nm_setting_802_1x_get_phase2_client_cert_password; + nm_setting_802_1x_get_phase2_client_cert_password_flags; + nm_setting_cdma_get_mtu; + nm_setting_dummy_get_type; + nm_setting_dummy_new; + nm_setting_gsm_get_mtu; + nm_setting_user_check_key; + nm_setting_user_check_val; + nm_setting_user_get_data; + nm_setting_user_get_keys; + nm_setting_user_get_type; + nm_setting_user_new; + nm_setting_user_set_data; + nm_utils_format_variant_attributes; + nm_utils_parse_variant_attributes; +} libnm_1_6_0; diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index 60b8e33d..ed0135ba 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -271,9 +271,11 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection) guint32 ap_freq, setting_chan, ap_chan; s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); + if (!s_con) + return FALSE; + ctype = nm_setting_connection_get_connection_type (s_con); - if (strcmp (ctype, NM_SETTING_WIRELESS_SETTING_NAME) != 0) + if (!ctype || !nm_streq (ctype, NM_SETTING_WIRELESS_SETTING_NAME)) return FALSE; s_wifi = nm_connection_get_setting_wireless (connection); @@ -282,25 +284,30 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection) /* SSID checks */ ap_ssid = nm_access_point_get_ssid (ap); - g_warn_if_fail (ap_ssid != NULL); - setting_ssid = nm_setting_wireless_get_ssid (s_wifi); - if (!setting_ssid || !ap_ssid) + if (!ap_ssid) return FALSE; - if (!g_bytes_equal (ap_ssid, setting_ssid)) + setting_ssid = nm_setting_wireless_get_ssid (s_wifi); + if ( !setting_ssid + || !g_bytes_equal (ap_ssid, setting_ssid)) return FALSE; /* BSSID checks */ ap_bssid = nm_access_point_get_bssid (ap); - g_warn_if_fail (ap_bssid); + if (!ap_bssid) + return FALSE; setting_bssid = nm_setting_wireless_get_bssid (s_wifi); - if (setting_bssid && ap_bssid) { - if (!nm_utils_hwaddr_matches (ap_bssid, -1, setting_bssid, -1)) + if (setting_bssid) { + guint8 c[ETH_ALEN]; + + if ( !nm_utils_hwaddr_aton (ap_bssid, c, ETH_ALEN) + || !nm_utils_hwaddr_matches (c, ETH_ALEN, setting_bssid, -1)) return FALSE; } /* Mode */ ap_mode = nm_access_point_get_mode (ap); - g_warn_if_fail (ap_mode != NM_802_11_MODE_UNKNOWN); + if (ap_mode == NM_802_11_MODE_UNKNOWN) + return FALSE; setting_mode = nm_setting_wireless_get_mode (s_wifi); if (setting_mode && ap_mode) { if (!strcmp (setting_mode, "infrastructure") && (ap_mode != NM_802_11_MODE_INFRA)) diff --git a/libnm/nm-access-point.h b/libnm/nm-access-point.h index 142ab295..177b6a9a 100644 --- a/libnm/nm-access-point.h +++ b/libnm/nm-access-point.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-object.h" G_BEGIN_DECLS diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 6a823403..412cb3ba 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -37,6 +37,8 @@ #include "nm-ip6-config.h" #include "nm-remote-connection.h" +#include "introspection/org.freedesktop.NetworkManager.Connection.Active.h" + G_DEFINE_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_OBJECT); #define NM_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionPrivate)) @@ -57,6 +59,7 @@ typedef struct { NMDhcpConfig *dhcp6_config; gboolean is_vpn; NMDevice *master; + NMActiveConnectionStateReason reason; } NMActiveConnectionPrivate; enum { @@ -80,6 +83,14 @@ enum { LAST_PROP }; +enum { + STATE_CHANGED, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + /** * nm_active_connection_get_connection: * @connection: a #NMActiveConnection @@ -204,6 +215,24 @@ nm_active_connection_get_state (NMActiveConnection *connection) return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->state; } +/** + * nm_active_connection_get_state_reason: + * @connection: a #NMActiveConnection + * + * Gets the reason for active connection's state. + * + * Returns: the reason + * + * Since: 1.8 + **/ +NMActiveConnectionStateReason +nm_active_connection_get_state_reason (NMActiveConnection *connection) +{ + g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_ACTIVE_CONNECTION_STATE_REASON_UNKNOWN); + + return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->reason; +} + /** * nm_active_connection_get_default: * @connection: a #NMActiveConnection @@ -350,10 +379,39 @@ nm_active_connection_init (NMActiveConnection *connection) priv->devices = g_ptr_array_new (); } +static void +state_changed_proxy (NMDBusActiveConnectionProxy *proxy, + NMActiveConnectionState state, + NMActiveConnectionStateReason reason, + gpointer user_data) +{ + NMActiveConnection *connection = NM_ACTIVE_CONNECTION (user_data); + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection); + + priv->state = state; + priv->reason = reason; + g_signal_emit (connection, signals[STATE_CHANGED], 0, state, reason); + g_object_notify (G_OBJECT (connection), NM_ACTIVE_CONNECTION_STATE); +} + +static void +constructed (GObject *object) +{ + GDBusProxy *proxy; + + proxy = _nm_object_get_proxy (NM_OBJECT (object), NM_DBUS_INTERFACE_ACTIVE_CONNECTION); + g_signal_connect (proxy, "state-changed", + G_CALLBACK (state_changed_proxy), object); + g_object_unref (proxy); + + G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object); +} + static void dispose (GObject *object) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); + GDBusProxy *proxy; g_clear_pointer (&priv->devices, g_ptr_array_unref); @@ -364,6 +422,12 @@ dispose (GObject *object) g_clear_object (&priv->ip6_config); g_clear_object (&priv->dhcp6_config); + proxy = _nm_object_get_proxy (NM_OBJECT (object), NM_DBUS_INTERFACE_ACTIVE_CONNECTION); + if (proxy) { + g_signal_handlers_disconnect_by_data (proxy, object); + g_object_unref (proxy); + } + G_OBJECT_CLASS (nm_active_connection_parent_class)->dispose (object); } @@ -503,6 +567,7 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) /* virtual methods */ object_class->get_property = get_property; + object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; @@ -693,4 +758,13 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) NM_TYPE_DEVICE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /* signals */ + signals[STATE_CHANGED] = + g_signal_new ("state-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_UINT); } diff --git a/libnm/nm-active-connection.h b/libnm/nm-active-connection.h index 13e50a06..23cd7372 100644 --- a/libnm/nm-active-connection.h +++ b/libnm/nm-active-connection.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-object.h" G_BEGIN_DECLS @@ -69,21 +69,23 @@ typedef struct { GType nm_active_connection_get_type (void); -NMRemoteConnection *nm_active_connection_get_connection (NMActiveConnection *connection); -const char *nm_active_connection_get_id (NMActiveConnection *connection); -const char *nm_active_connection_get_uuid (NMActiveConnection *connection); -const char *nm_active_connection_get_connection_type (NMActiveConnection *connection); -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); -NMDevice *nm_active_connection_get_master (NMActiveConnection *connection); -gboolean nm_active_connection_get_default (NMActiveConnection *connection); -NMIPConfig *nm_active_connection_get_ip4_config (NMActiveConnection *connection); -NMDhcpConfig *nm_active_connection_get_dhcp4_config (NMActiveConnection *connection); -gboolean nm_active_connection_get_default6 (NMActiveConnection *connection); -NMIPConfig *nm_active_connection_get_ip6_config (NMActiveConnection *connection); -NMDhcpConfig *nm_active_connection_get_dhcp6_config (NMActiveConnection *connection); -gboolean nm_active_connection_get_vpn (NMActiveConnection *connection); +NMRemoteConnection *nm_active_connection_get_connection (NMActiveConnection *connection); +const char *nm_active_connection_get_id (NMActiveConnection *connection); +const char *nm_active_connection_get_uuid (NMActiveConnection *connection); +const char *nm_active_connection_get_connection_type (NMActiveConnection *connection); +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_8 +NMActiveConnectionStateReason nm_active_connection_get_state_reason (NMActiveConnection *connection); +NMDevice *nm_active_connection_get_master (NMActiveConnection *connection); +gboolean nm_active_connection_get_default (NMActiveConnection *connection); +NMIPConfig *nm_active_connection_get_ip4_config (NMActiveConnection *connection); +NMDhcpConfig *nm_active_connection_get_dhcp4_config (NMActiveConnection *connection); +gboolean nm_active_connection_get_default6 (NMActiveConnection *connection); +NMIPConfig *nm_active_connection_get_ip6_config (NMActiveConnection *connection); +NMDhcpConfig *nm_active_connection_get_dhcp6_config (NMActiveConnection *connection); +gboolean nm_active_connection_get_vpn (NMActiveConnection *connection); G_END_DECLS diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 63eaa84c..47f1548e 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -22,6 +22,7 @@ #include "nm-default.h" #include +#include #include "nm-utils.h" #include "nm-client.h" @@ -45,6 +46,7 @@ #include "introspection/org.freedesktop.NetworkManager.Settings.h" #include "introspection/org.freedesktop.NetworkManager.Settings.Connection.h" #include "introspection/org.freedesktop.NetworkManager.VPN.Connection.h" +#include "introspection/org.freedesktop.NetworkManager.Connection.Active.h" #include "nm-access-point.h" #include "nm-active-connection.h" @@ -52,6 +54,7 @@ #include "nm-device-bond.h" #include "nm-device-bridge.h" #include "nm-device-bt.h" +#include "nm-device-dummy.h" #include "nm-device-ethernet.h" #include "nm-device-generic.h" #include "nm-device-infiniband.h" @@ -94,6 +97,7 @@ typedef struct { NMDnsManager *dns_manager; GDBusObjectManager *object_manager; GCancellable *new_object_manager_cancellable; + struct udev *udev; } NMClientPrivate; enum { @@ -153,15 +157,7 @@ static const GPtrArray empty = { 0, }; * * Returns: the error quark used for #NMClient errors. **/ -GQuark -nm_client_error_quark (void) -{ - static GQuark quark; - - if (G_UNLIKELY (!quark)) - quark = g_quark_from_static_string ("nm-client-error-quark"); - return quark; -} +NM_CACHED_QUARK_FCN ("nm-client-error-quark", nm_client_error_quark) /*****************************************************************************/ @@ -2015,6 +2011,8 @@ proxy_type (GDBusObjectManagerClient *manager, return NMDBUS_TYPE_DNS_MANAGER_PROXY; else if (strcmp (interface_name, NM_DBUS_INTERFACE_VPN_CONNECTION) == 0) return NMDBUS_TYPE_VPN_CONNECTION_PROXY; + else if (strcmp (interface_name, NM_DBUS_INTERFACE_ACTIVE_CONNECTION) == 0) + return NMDBUS_TYPE_ACTIVE_CONNECTION_PROXY; /* Use a generic D-Bus Proxy whenever we can. The typed GDBusProxy * subclasses actually use quite some memory, so they're better avoided. */ @@ -2022,8 +2020,9 @@ proxy_type (GDBusObjectManagerClient *manager, } static NMObject * -obj_nm_for_gdbus_object (GDBusObject *object, GDBusObjectManager *object_manager) +obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager *object_manager) { + NMClientPrivate *priv; GList *interfaces; GList *l; GType type = G_TYPE_INVALID; @@ -2054,6 +2053,8 @@ obj_nm_for_gdbus_object (GDBusObject *object, GDBusObjectManager *object_manager type = NM_TYPE_DEVICE_BRIDGE; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_BLUETOOTH) == 0) type = NM_TYPE_DEVICE_BT; + else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_DUMMY) == 0) + type = NM_TYPE_DEVICE_DUMMY; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WIRED) == 0) type = NM_TYPE_DEVICE_ETHERNET; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_GENERIC) == 0) @@ -2113,6 +2114,12 @@ obj_nm_for_gdbus_object (GDBusObject *object, GDBusObjectManager *object_manager NM_OBJECT_DBUS_OBJECT, object, NM_OBJECT_DBUS_OBJECT_MANAGER, object_manager, NULL); + if (NM_IS_DEVICE (obj_nm)) { + priv = NM_CLIENT_GET_PRIVATE (self); + if (!priv->udev) + priv->udev = udev_new (); + _nm_device_set_udev (NM_DEVICE (obj_nm), priv->udev); + } g_object_set_qdata_full (G_OBJECT (object), _nm_object_obj_nm_quark (), obj_nm, g_object_unref); return obj_nm; @@ -2132,9 +2139,10 @@ obj_nm_inited (GObject *object, GAsyncResult *result, gpointer user_data) static void object_added (GDBusObjectManager *object_manager, GDBusObject *object, gpointer user_data) { + NMClient *client = user_data; NMObject *obj_nm; - obj_nm = obj_nm_for_gdbus_object (object, object_manager); + obj_nm = obj_nm_for_gdbus_object (client, object, object_manager); if (obj_nm) { g_async_initable_init_async (G_ASYNC_INITABLE (obj_nm), G_PRIORITY_DEFAULT, NULL, @@ -2161,7 +2169,7 @@ objects_created (NMClient *client, GDBusObjectManager *object_manager, GError ** /* First just ensure all the NMObjects for known GDBusObjects exist. */ objects = g_dbus_object_manager_get_objects (object_manager); for (iter = objects; iter; iter = iter->next) - obj_nm_for_gdbus_object (iter->data, object_manager); + obj_nm_for_gdbus_object (client, iter->data, object_manager); g_list_free_full (objects, g_object_unref); manager = g_dbus_object_manager_get_object (object_manager, NM_DBUS_PATH); @@ -2530,10 +2538,7 @@ dispose (GObject *object) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object); - if (priv->new_object_manager_cancellable) { - g_cancellable_cancel (priv->new_object_manager_cancellable); - g_clear_object (&priv->new_object_manager_cancellable); - } + nm_clear_g_cancellable (&priv->new_object_manager_cancellable); if (priv->manager) { g_signal_handlers_disconnect_by_data (priv->manager, object); @@ -2564,6 +2569,11 @@ dispose (GObject *object) } G_OBJECT_CLASS (nm_client_parent_class)->dispose (object); + + if (priv->udev) { + udev_unref (priv->udev); + priv->udev = NULL; + } } static void diff --git a/libnm/nm-client.h b/libnm/nm-client.h index 65e0bac8..5da16490 100644 --- a/libnm/nm-client.h +++ b/libnm/nm-client.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-types.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-adsl.h b/libnm/nm-device-adsl.h index 113d25b1..0c922299 100644 --- a/libnm/nm-device-adsl.h +++ b/libnm/nm-device-adsl.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-bond.h b/libnm/nm-device-bond.h index 67f64280..da666b6e 100644 --- a/libnm/nm-device-bond.h +++ b/libnm/nm-device-bond.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-bridge.h b/libnm/nm-device-bridge.h index df0cb303..b860da7c 100644 --- a/libnm/nm-device-bridge.h +++ b/libnm/nm-device-bridge.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-bt.h b/libnm/nm-device-bt.h index 773cb148..8d6da684 100644 --- a/libnm/nm-device-bt.h +++ b/libnm/nm-device-bt.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-dummy.c b/libnm/nm-device-dummy.c new file mode 100644 index 00000000..f5910dc8 --- /dev/null +++ b/libnm/nm-device-dummy.c @@ -0,0 +1,80 @@ +/* -*- 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. + * + * 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-dummy.h" +#include "nm-object-private.h" +#include "nm-setting-dummy.h" +#include "nm-setting-connection.h" + +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)) + +/*****************************************************************************/ + +static gboolean +connection_compatible (NMDevice *device, NMConnection *connection, GError **error) +{ + const char *iface_name; + + if (!NM_DEVICE_CLASS (nm_device_dummy_parent_class)->connection_compatible (device, connection, error)) + return FALSE; + + if (!nm_connection_is_type (connection, NM_SETTING_DUMMY_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a dummy 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_DUMMY; +} + +/*****************************************************************************/ + +static void +nm_device_dummy_init (NMDeviceDummy *device) +{ +} + +static void +nm_device_dummy_class_init (NMDeviceDummyClass *klass) +{ + NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); + + device_class->connection_compatible = connection_compatible; + device_class->get_setting_type = get_setting_type; +} diff --git a/libnm/nm-device-dummy.h b/libnm/nm-device-dummy.h new file mode 100644 index 00000000..85ee2bab --- /dev/null +++ b/libnm/nm-device-dummy.h @@ -0,0 +1,57 @@ +/* -*- 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. + * + * 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_DUMMY_H__ +#define __NM_DEVICE_DUMMY_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_DUMMY (nm_device_dummy_get_type ()) +#define NM_DEVICE_DUMMY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_DUMMY, NMDeviceDummy)) +#define NM_DEVICE_DUMMY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_DUMMY, NMDeviceDummyClass)) +#define NM_IS_DEVICE_DUMMY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_DUMMY)) +#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)) + +/** + * NMDeviceDummy: + */ +struct _NMDeviceDummy { + NMDevice parent; +}; + +typedef struct { + NMDeviceClass parent; + + /*< private >*/ + gpointer padding[4]; +} NMDeviceDummyClass; + +GType nm_device_dummy_get_type (void); + +G_END_DECLS + +#endif /* __NM_DEVICE_DUMMY_H__ */ diff --git a/libnm/nm-device-ethernet.h b/libnm/nm-device-ethernet.h index 76f4fde1..86231781 100644 --- a/libnm/nm-device-ethernet.h +++ b/libnm/nm-device-ethernet.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-generic.h b/libnm/nm-device-generic.h index 2a4a1160..c37c9495 100644 --- a/libnm/nm-device-generic.h +++ b/libnm/nm-device-generic.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-infiniband.h b/libnm/nm-device-infiniband.h index 1f4ea217..38c81d9e 100644 --- a/libnm/nm-device-infiniband.h +++ b/libnm/nm-device-infiniband.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-ip-tunnel.h b/libnm/nm-device-ip-tunnel.h index 14251849..6d748d96 100644 --- a/libnm/nm-device-ip-tunnel.h +++ b/libnm/nm-device-ip-tunnel.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-macsec.h b/libnm/nm-device-macsec.h index d6d7c0ef..60f7d7f0 100644 --- a/libnm/nm-device-macsec.h +++ b/libnm/nm-device-macsec.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-macvlan.h b/libnm/nm-device-macvlan.h index aec280bd..5ccdbd2c 100644 --- a/libnm/nm-device-macvlan.h +++ b/libnm/nm-device-macvlan.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-modem.h b/libnm/nm-device-modem.h index fdf5c41f..a5af0346 100644 --- a/libnm/nm-device-modem.h +++ b/libnm/nm-device-modem.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-olpc-mesh.h b/libnm/nm-device-olpc-mesh.h index fc88beb9..5089bfd1 100644 --- a/libnm/nm-device-olpc-mesh.h +++ b/libnm/nm-device-olpc-mesh.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-team.h b/libnm/nm-device-team.h index 522e3d29..deecf072 100644 --- a/libnm/nm-device-team.h +++ b/libnm/nm-device-team.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-tun.h b/libnm/nm-device-tun.h index 71649f8f..2fea4544 100644 --- a/libnm/nm-device-tun.h +++ b/libnm/nm-device-tun.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-vlan.h b/libnm/nm-device-vlan.h index 1ee03bd5..158a89aa 100644 --- a/libnm/nm-device-vlan.h +++ b/libnm/nm-device-vlan.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-vxlan.h b/libnm/nm-device-vxlan.h index 70c7ed51..bd84f6f0 100644 --- a/libnm/nm-device-vxlan.h +++ b/libnm/nm-device-vxlan.h @@ -25,7 +25,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-wifi.h b/libnm/nm-device-wifi.h index ee0238df..8cfea1f3 100644 --- a/libnm/nm-device-wifi.h +++ b/libnm/nm-device-wifi.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device-wimax.h b/libnm/nm-device-wimax.h index 424779bd..cc3fc6e1 100644 --- a/libnm/nm-device-wimax.h +++ b/libnm/nm-device-wimax.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-device.h" G_BEGIN_DECLS diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 02b5cad5..9cbdbd00 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -24,7 +24,7 @@ #include "nm-device.h" #include -#include +#include #include "nm-dbus-interface.h" #include "nm-active-connection.h" @@ -40,6 +40,7 @@ #include "nm-dbus-helpers.h" #include "nm-device-tun.h" #include "nm-setting-connection.h" +#include "shared/nm-utils/nm-udev-utils.h" #include "introspection/org.freedesktop.NetworkManager.Device.h" @@ -79,7 +80,7 @@ typedef struct { NMActiveConnection *active_connection; GPtrArray *available_connections; - GUdevClient *client; + struct udev *udev; char *product, *short_product; char *vendor, *short_vendor; char *description, *bus_name; @@ -277,6 +278,7 @@ coerce_type (NMDeviceType type) case NM_DEVICE_TYPE_UNUSED1: case NM_DEVICE_TYPE_UNUSED2: case NM_DEVICE_TYPE_UNKNOWN: + case NM_DEVICE_TYPE_DUMMY: return type; } return NM_DEVICE_TYPE_UNKNOWN; @@ -291,12 +293,16 @@ dispose (GObject *object) g_clear_object (&priv->dhcp4_config); g_clear_object (&priv->ip6_config); g_clear_object (&priv->dhcp6_config); - g_clear_object (&priv->client); g_clear_object (&priv->active_connection); + udev_unref (priv->udev); + priv->udev = NULL; + g_clear_pointer (&priv->available_connections, g_ptr_array_unref); g_clear_pointer (&priv->lldp_neighbors, g_ptr_array_unref); + if (priv->proxy) + g_signal_handlers_disconnect_by_func (priv->proxy, device_state_reason_changed, object); g_clear_object (&priv->proxy); G_OBJECT_CLASS (nm_device_parent_class)->dispose (object); @@ -1287,56 +1293,19 @@ nm_device_get_available_connections (NMDevice *device) return NM_DEVICE_GET_PRIVATE (device)->available_connections; } -static inline guint8 -hex2byte (const char *hex) -{ - int a, b; - a = g_ascii_xdigit_value (*hex++); - if (a < 0) - return -1; - b = g_ascii_xdigit_value (*hex++); - if (b < 0) - return -1; - return (a << 4) | b; -} - -static char * -get_decoded_property (GUdevDevice *device, const char *property) +void +_nm_device_set_udev (NMDevice *device, struct udev *udev) { - const char *orig, *p; - char *unescaped, *n; - guint len; - - p = orig = g_udev_device_get_property (device, property); - if (!orig) - return NULL; - - len = strlen (orig); - n = unescaped = g_malloc0 (len + 1); - while (*p) { - if ((len >= 4) && (*p == '\\') && (*(p+1) == 'x')) { - *n++ = (char) hex2byte (p + 2); - p += 4; - len -= 4; - } else { - *n++ = *p++; - len--; - } - } + NMDevicePrivate *priv; - return unescaped; -} + nm_assert (NM_IS_DEVICE (device)); + nm_assert (udev); -static gboolean -ensure_udev_client (NMDevice *device) -{ - static const char *const subsys[3] = { "net", "tty", NULL }; - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); + priv = NM_DEVICE_GET_PRIVATE (device); - if (!priv->client) - priv->client = g_udev_client_new (subsys); + nm_assert (!priv->udev); - return priv->client != NULL; + priv->udev = udev_ref (udev); } static char * @@ -1345,51 +1314,37 @@ _get_udev_property (NMDevice *device, const char *db_prop) /* ID_XXX_FROM_DATABASE */ { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); - GUdevDevice *udev_device = NULL, *tmpdev, *olddev; + struct udev_device *udev_device, *tmpdev; const char *ifname; guint32 count = 0; char *enc_value = NULL, *db_value = NULL; - if (!ensure_udev_client (device)) + if (!priv->udev) return NULL; ifname = nm_device_get_iface (device); if (!ifname) return NULL; - udev_device = g_udev_client_query_by_subsystem_and_name (priv->client, "net", ifname); - if (!udev_device) - udev_device = g_udev_client_query_by_subsystem_and_name (priv->client, "tty", ifname); - if (!udev_device) - return NULL; - + udev_device = udev_device_new_from_subsystem_sysname (priv->udev, "net", ifname); + if (!udev_device) { + udev_device = udev_device_new_from_subsystem_sysname (priv->udev, "tty", ifname); + if (!udev_device) + return NULL; + } /* Walk up the chain of the device and its parents a few steps to grab * vendor and device ID information off it. */ - - /* Ref the device again because we have to unref it each iteration, - * as g_udev_device_get_parent() returns a ref-ed object. - */ - tmpdev = g_object_ref (udev_device); + tmpdev = udev_device; while ((count++ < 3) && tmpdev && !enc_value) { if (!enc_value) - enc_value = get_decoded_property (tmpdev, enc_prop); + enc_value = nm_udev_utils_property_decode_cp (udev_device_get_property_value (tmpdev, enc_prop)); if (!db_value) - db_value = g_strdup (g_udev_device_get_property (tmpdev, db_prop)); + db_value = g_strdup (udev_device_get_property_value (tmpdev, db_prop)); - olddev = tmpdev; - tmpdev = g_udev_device_get_parent (tmpdev); - g_object_unref (olddev); + tmpdev = udev_device_get_parent (tmpdev); } - - /* Unref the last device if we found what we needed before running out - * of parents. - */ - if (tmpdev) - g_object_unref (tmpdev); - - /* Balance the initial g_udev_client_query_by_subsystem_and_name() */ - g_object_unref (udev_device); + udev_device_unref (udev_device); /* Prefer the encoded value which comes directly from the device * over the hwdata database value. @@ -1694,6 +1649,8 @@ get_type_name (NMDevice *device) return _("Veth"); case NM_DEVICE_TYPE_MACSEC: return _("MACsec"); + case NM_DEVICE_TYPE_DUMMY: + return _("Dummy"); case NM_DEVICE_TYPE_GENERIC: case NM_DEVICE_TYPE_UNUSED1: case NM_DEVICE_TYPE_UNUSED2: @@ -1735,26 +1692,26 @@ static const char * get_bus_name (NMDevice *device) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); - GUdevDevice *udevice; + struct udev_device *udevice; const char *ifname, *bus; if (priv->bus_name) goto out; - if (!ensure_udev_client (device)) + if (!priv->udev) return NULL; ifname = nm_device_get_iface (device); if (!ifname) return NULL; - udevice = g_udev_client_query_by_subsystem_and_name (priv->client, "net", ifname); - if (!udevice) - udevice = g_udev_client_query_by_subsystem_and_name (priv->client, "tty", ifname); - if (!udevice) - return NULL; - - bus = g_udev_device_get_property (udevice, "ID_BUS"); + udevice = udev_device_new_from_subsystem_sysname (priv->udev, "net", ifname); + if (!udevice) { + udevice = udev_device_new_from_subsystem_sysname (priv->udev, "tty", ifname); + if (!udevice) + return NULL; + } + bus = udev_device_get_property_value (udevice, "ID_BUS"); if (!g_strcmp0 (bus, "pci")) priv->bus_name = g_strdup (_("PCI")); else if (!g_strcmp0 (bus, "usb")) @@ -1765,6 +1722,7 @@ get_bus_name (NMDevice *device) */ priv->bus_name = g_strdup (""); } + udev_device_unref (udevice); out: if (*priv->bus_name) diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 5ffeb42e..91f31b87 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-object.h" G_BEGIN_DECLS diff --git a/libnm/nm-dhcp-config.h b/libnm/nm-dhcp-config.h index be32992f..ef64048a 100644 --- a/libnm/nm-dhcp-config.h +++ b/libnm/nm-dhcp-config.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-object.h" G_BEGIN_DECLS diff --git a/libnm/nm-dhcp4-config.h b/libnm/nm-dhcp4-config.h index 4978f848..2cbbdc9e 100644 --- a/libnm/nm-dhcp4-config.h +++ b/libnm/nm-dhcp4-config.h @@ -21,7 +21,7 @@ #ifndef __NM_DHCP4_CONFIG_H__ #define __NM_DHCP4_CONFIG_H__ -#include +#include "nm-dhcp-config.h" G_BEGIN_DECLS diff --git a/libnm/nm-dhcp6-config.h b/libnm/nm-dhcp6-config.h index b7c7c822..2d6568e1 100644 --- a/libnm/nm-dhcp6-config.h +++ b/libnm/nm-dhcp6-config.h @@ -21,7 +21,7 @@ #ifndef __NM_DHCP6_CONFIG_H__ #define __NM_DHCP6_CONFIG_H__ -#include +#include "nm-dhcp-config.h" G_BEGIN_DECLS diff --git a/libnm/nm-dns-manager.h b/libnm/nm-dns-manager.h index 9ed3dfbe..63989451 100644 --- a/libnm/nm-dns-manager.h +++ b/libnm/nm-dns-manager.h @@ -21,7 +21,7 @@ #ifndef __NM_DNS_MANAGER_H__ #define __NM_DNS_MANAGER_H__ -#include +#include "nm-object.h" #include "nm-client.h" G_BEGIN_DECLS diff --git a/libnm/nm-ip-config.h b/libnm/nm-ip-config.h index 38d5b454..c407c7fe 100644 --- a/libnm/nm-ip-config.h +++ b/libnm/nm-ip-config.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-object.h" G_BEGIN_DECLS diff --git a/libnm/nm-ip4-config.h b/libnm/nm-ip4-config.h index 196fe09a..d99b2113 100644 --- a/libnm/nm-ip4-config.h +++ b/libnm/nm-ip4-config.h @@ -22,7 +22,7 @@ #ifndef __NM_IP4_CONFIG_H__ #define __NM_IP4_CONFIG_H__ -#include +#include "nm-ip-config.h" G_BEGIN_DECLS diff --git a/libnm/nm-ip6-config.h b/libnm/nm-ip6-config.h index fa67517c..12e723b2 100644 --- a/libnm/nm-ip6-config.h +++ b/libnm/nm-ip6-config.h @@ -22,7 +22,7 @@ #ifndef __NM_IP6_CONFIG_H__ #define __NM_IP6_CONFIG_H__ -#include +#include "nm-ip-config.h" G_BEGIN_DECLS diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 1b453bd9..d3df7337 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -1026,8 +1026,8 @@ device_ac_changed (GObject *object, GParamSpec *pspec, gpointer user_data) static void device_added (NMManager *self, NMDevice *device) { - g_signal_connect (device, "notify::" NM_DEVICE_ACTIVE_CONNECTION, - G_CALLBACK (device_ac_changed), self); + g_signal_connect_object (device, "notify::" NM_DEVICE_ACTIVE_CONNECTION, + G_CALLBACK (device_ac_changed), self, 0); } static void @@ -1047,8 +1047,8 @@ ac_devices_changed (GObject *object, GParamSpec *pspec, gpointer user_data) static void active_connection_added (NMManager *self, NMActiveConnection *ac) { - g_signal_connect (ac, "notify::" NM_ACTIVE_CONNECTION_DEVICES, - G_CALLBACK (ac_devices_changed), self); + g_signal_connect_object (ac, "notify::" NM_ACTIVE_CONNECTION_DEVICES, + G_CALLBACK (ac_devices_changed), self, 0); recheck_pending_activations (self); } @@ -1274,11 +1274,7 @@ dispose (GObject *object) NMManager *manager = NM_MANAGER (object); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (object); - if (priv->perm_call_cancellable) { - g_cancellable_cancel (priv->perm_call_cancellable); - g_clear_object (&priv->perm_call_cancellable); - } - + nm_clear_g_cancellable (&priv->perm_call_cancellable); if (priv->devices) { g_ptr_array_unref (priv->devices); diff --git a/libnm/nm-manager.h b/libnm/nm-manager.h index 362b5f2f..7c63a333 100644 --- a/libnm/nm-manager.h +++ b/libnm/nm-manager.h @@ -22,8 +22,8 @@ #ifndef __NM_MANAGER_H__ #define __NM_MANAGER_H__ -#include -#include +#include "nm-object.h" +#include "nm-client.h" G_BEGIN_DECLS diff --git a/libnm/nm-object-private.h b/libnm/nm-object-private.h index 63c4142d..8c2f3a9c 100644 --- a/libnm/nm-object-private.h +++ b/libnm/nm-object-private.h @@ -56,4 +56,7 @@ void _nm_object_set_property (NMObject *object, GDBusProxy *_nm_object_get_proxy (NMObject *object, const char *interface); +struct udev; +void _nm_device_set_udev (NMDevice *device, struct udev *udev); + #endif /* __NM_OBJECT_PRIVATE_H__ */ diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 6a47c659..95346e06 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -37,7 +37,7 @@ static gboolean debug = FALSE; #define dbgmsg(f,...) if (G_UNLIKELY (debug)) { g_message (f, ## __VA_ARGS__ ); } -G_DEFINE_QUARK (nm-obj-nm, _nm_object_obj_nm); +NM_CACHED_QUARK_FCN ("nm-obj-nm", _nm_object_obj_nm_quark) static void nm_object_initable_iface_init (GInitableIface *iface); static void nm_object_async_initable_iface_init (GAsyncInitableIface *iface); @@ -85,6 +85,7 @@ typedef struct { GError *reload_error; GSList *pending; /* ordered list of pending property updates. */ + GPtrArray *proxies; } NMObjectPrivate; enum { @@ -128,11 +129,16 @@ GDBusProxy * _nm_object_get_proxy (NMObject *object, const char *interface) { + NMObjectPrivate *priv; GDBusInterface *proxy; g_return_val_if_fail (NM_IS_OBJECT (object), NULL); - proxy = g_dbus_object_get_interface (NM_OBJECT_GET_PRIVATE (object)->object, interface); + priv = NM_OBJECT_GET_PRIVATE (object); + if (priv->object == NULL) + return NULL; + + proxy = g_dbus_object_get_interface (priv->object, interface); g_return_val_if_fail (proxy != NULL, NULL); return G_DBUS_PROXY (proxy); @@ -939,7 +945,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_object_unref (proxy); + g_ptr_array_add (priv->proxies, proxy); instance = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); priv->property_tables = g_slist_prepend (priv->property_tables, instance); @@ -1053,7 +1059,7 @@ init_if (GDBusInterface *interface, gpointer user_data) props = g_dbus_proxy_get_cached_property_names (proxy); - for (prop = props; *prop; prop++) { + for (prop = props; prop && *prop; prop++) { val = g_dbus_proxy_get_cached_property (proxy, *prop); str = g_variant_print (val, TRUE); handle_property_changed (self, *prop, val); @@ -1188,6 +1194,7 @@ 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 (); } static void @@ -1198,11 +1205,13 @@ set_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_DBUS_OBJECT: - /* Construct only */ + /* construct-only */ priv->object = g_value_dup_object (value); + if (!priv->object) + g_return_if_reached (); break; case PROP_DBUS_OBJECT_MANAGER: - /* Construct only */ + /* construct-only */ priv->object_manager = g_value_dup_object (value); break; default: @@ -1240,6 +1249,7 @@ static void dispose (GObject *object) { NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); + guint i; nm_clear_g_source (&priv->notify_id); @@ -1251,6 +1261,17 @@ dispose (GObject *object) g_clear_object (&priv->object); g_clear_object (&priv->object_manager); + if (priv->proxies) { + for (i = 0; i < priv->proxies->len; i++) { + g_signal_handlers_disconnect_by_func (priv->proxies->pdata[i], + properties_changed, + object); + g_object_unref (priv->proxies->pdata[i]); + } + g_ptr_array_free (priv->proxies, TRUE); + priv->proxies = NULL; + } + G_OBJECT_CLASS (nm_object_parent_class)->dispose (object); } diff --git a/libnm/nm-object.h b/libnm/nm-object.h index bcf47ba6..5b4580eb 100644 --- a/libnm/nm-object.h +++ b/libnm/nm-object.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-types.h" G_BEGIN_DECLS diff --git a/libnm/nm-property-docs.xml b/libnm/nm-property-docs.xml index 9d58df94..7754187d 100644 --- a/libnm/nm-property-docs.xml +++ b/libnm/nm-property-docs.xml @@ -3,12 +3,39 @@ ]> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -18,6 +45,7 @@ + @@ -25,22 +53,26 @@ + + + + - + - + - + @@ -50,16 +82,16 @@ - + - + - + @@ -70,42 +102,21 @@ - + - + + - - - - - - - - - - - - - - - - - - - - - - - + @@ -123,13 +134,17 @@ - + + + + - + + @@ -141,7 +156,7 @@ - + @@ -149,7 +164,7 @@ - + @@ -171,7 +186,7 @@ - + @@ -194,7 +209,7 @@ - + @@ -209,7 +224,7 @@ - + @@ -220,20 +235,20 @@ - + - + - + @@ -254,21 +269,21 @@ - + - + - + @@ -276,15 +291,15 @@ - + - + - + @@ -293,7 +308,11 @@ - + + + + + @@ -301,7 +320,7 @@ - + @@ -310,7 +329,7 @@ - + @@ -329,12 +348,12 @@ - + - + @@ -351,7 +370,7 @@ - + @@ -370,7 +389,7 @@ - + diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index fe78f7b8..0f7ea58e 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -763,6 +763,8 @@ get_property (GObject *object, guint prop_id, static void constructed (GObject *object) { + G_OBJECT_CLASS (nm_remote_connection_parent_class)->constructed (object); + nm_connection_set_path (NM_CONNECTION (object), nm_object_get_path (NM_OBJECT (object))); } diff --git a/libnm/nm-remote-connection.h b/libnm/nm-remote-connection.h index a7235755..c04ae367 100644 --- a/libnm/nm-remote-connection.h +++ b/libnm/nm-remote-connection.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-object.h" G_BEGIN_DECLS diff --git a/libnm/nm-remote-settings.h b/libnm/nm-remote-settings.h index f8eddc5b..06d3ac0a 100644 --- a/libnm/nm-remote-settings.h +++ b/libnm/nm-remote-settings.h @@ -22,7 +22,7 @@ #ifndef __NM_REMOTE_SETTINGS_H__ #define __NM_REMOTE_SETTINGS_H__ -#include +#include "nm-object.h" G_BEGIN_DECLS diff --git a/libnm/nm-secret-agent-old.h b/libnm/nm-secret-agent-old.h index 476cc2a2..4f6665d1 100644 --- a/libnm/nm-secret-agent-old.h +++ b/libnm/nm-secret-agent-old.h @@ -21,7 +21,7 @@ #ifndef __NM_SECRET_AGENT_OLD_H__ #define __NM_SECRET_AGENT_OLD_H__ -#include +#include "nm-types.h" G_BEGIN_DECLS diff --git a/libnm/nm-settings-docs-overrides.xml b/libnm/nm-settings-docs-overrides.xml index 474b7319..2b27b640 100644 --- a/libnm/nm-settings-docs-overrides.xml +++ b/libnm/nm-settings-docs-overrides.xml @@ -27,6 +27,8 @@ bridge's interface name."/> + + @@ -133,6 +135,8 @@ team's interface name."/> + + ]> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -18,6 +45,7 @@ + @@ -25,22 +53,26 @@ + + + + - + - + - + @@ -50,17 +82,17 @@ - + - + - + @@ -72,42 +104,21 @@ - + - + + - - - - - - - - - - - - - - - - - - - - - - - + @@ -125,13 +136,17 @@ - + + + + - + + @@ -143,7 +158,7 @@ - + @@ -151,7 +166,7 @@ - + @@ -175,7 +190,7 @@ - + @@ -200,7 +215,7 @@ - + @@ -215,7 +230,7 @@ - + @@ -226,20 +241,20 @@ - + - + - + @@ -260,21 +275,21 @@ - + - + - + @@ -282,16 +297,16 @@ - + - + - + @@ -300,7 +315,11 @@ - + + + + + @@ -309,7 +328,7 @@ - + @@ -318,7 +337,7 @@ - + @@ -337,12 +356,12 @@ - + - + @@ -360,7 +379,7 @@ - + @@ -381,7 +400,7 @@ - + diff --git a/libnm/nm-settings-ifcfg-rh-docs.xml b/libnm/nm-settings-ifcfg-rh-docs.xml index aaf3880e..7664fc57 100644 --- a/libnm/nm-settings-ifcfg-rh-docs.xml +++ b/libnm/nm-settings-ifcfg-rh-docs.xml @@ -17,6 +17,7 @@ + + @@ -126,6 +128,8 @@ The sum of the numbers must be 100."/> "may not utilize all bandwidth", "1" means "may utilize all bandwidth"."/> + + @@ -155,7 +159,7 @@ servers, initscripts and resolver only care about the first three, usually."/> - @@ -233,6 +237,8 @@ proxy configuration, or set the PAC file via PAC_URL or PAC_SCRIPT."/> + + diff --git a/libnm/nm-settings-keyfile-docs.xml b/libnm/nm-settings-keyfile-docs.xml index 2b59e9a9..33f53c4c 100644 --- a/libnm/nm-settings-keyfile-docs.xml +++ b/libnm/nm-settings-keyfile-docs.xml @@ -24,6 +24,8 @@ or semicolon separated list of 6 decimal bytes (obsolete)"/> + + @@ -72,6 +74,8 @@ versions of NetworkManager stored this as an integer: 69 ('E') for eve + + diff --git a/libnm/nm-types.h b/libnm/nm-types.h index 7d224c86..84cf48f4 100644 --- a/libnm/nm-types.h +++ b/libnm/nm-types.h @@ -23,8 +23,8 @@ #include -#include -#include +#include "nm-dbus-interface.h" +#include "nm-connection.h" typedef struct _NMAccessPoint NMAccessPoint; typedef struct _NMActiveConnection NMActiveConnection; @@ -34,6 +34,7 @@ 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; diff --git a/libnm/nm-vpn-connection.c b/libnm/nm-vpn-connection.c index a91a6f69..814f45f0 100644 --- a/libnm/nm-vpn-connection.c +++ b/libnm/nm-vpn-connection.c @@ -36,6 +36,8 @@ G_DEFINE_TYPE (NMVpnConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION) #define NM_VPN_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_VPN_CONNECTION, NMVpnConnectionPrivate)) +G_STATIC_ASSERT (sizeof (NMVpnConnectionStateReason) == sizeof (NMActiveConnectionStateReason)); + typedef struct { char *banner; NMVpnConnectionState vpn_state; @@ -220,6 +222,7 @@ nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class) G_PARAM_STATIC_STRINGS)); /* signals */ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS signals[VPN_STATE_CHANGED] = g_signal_new ("vpn-state-changed", G_OBJECT_CLASS_TYPE (object_class), @@ -228,4 +231,5 @@ nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class) NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); + G_GNUC_END_IGNORE_DEPRECATIONS } diff --git a/libnm/nm-vpn-connection.h b/libnm/nm-vpn-connection.h index 79ec90a0..d53f8e92 100644 --- a/libnm/nm-vpn-connection.h +++ b/libnm/nm-vpn-connection.h @@ -26,8 +26,8 @@ #error "Only can be included directly." #endif -#include -#include +#include "nm-active-connection.h" +#include "nm-vpn-dbus-interface.h" G_BEGIN_DECLS @@ -52,9 +52,19 @@ typedef struct { NMActiveConnectionClass parent; /* Signals */ + + /* NMVpnConnectionStateReason got deprecated in 1.8.0. Thus, vpn_state_changed() + * uses a deprecated type and is itself deprecated. + * + * If you use this signal slot, you are advised to cast the reason + * to the NMActiveConnectionStateReason type, which is fully compatible. + */ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + NM_DEPRECATED_IN_1_8 void (*vpn_state_changed) (NMVpnConnection *connection, NMVpnConnectionState state, NMVpnConnectionStateReason reason); + G_GNUC_END_IGNORE_DEPRECATIONS /*< private >*/ gpointer padding[4]; diff --git a/libnm/nm-vpn-editor.h b/libnm/nm-vpn-editor.h index d450bbd6..26e48662 100644 --- a/libnm/nm-vpn-editor.h +++ b/libnm/nm-vpn-editor.h @@ -28,9 +28,9 @@ #include #include -#include +#include "nm-types.h" -#include +#include "nm-vpn-editor-plugin.h" G_BEGIN_DECLS diff --git a/libnm/nm-vpn-plugin-old.c b/libnm/nm-vpn-plugin-old.c index aff23b20..2b5922b9 100644 --- a/libnm/nm-vpn-plugin-old.c +++ b/libnm/nm-vpn-plugin-old.c @@ -1025,7 +1025,7 @@ set_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_DBUS_SERVICE_NAME: - /* Construct-only */ + /* construct-only */ priv->dbus_service_name = g_value_dup_string (value); break; case PROP_STATE: diff --git a/libnm/nm-vpn-plugin-old.h b/libnm/nm-vpn-plugin-old.h index 50e34450..48f3fba1 100644 --- a/libnm/nm-vpn-plugin-old.h +++ b/libnm/nm-vpn-plugin-old.h @@ -23,8 +23,8 @@ #define __NM_VPN_PLUGIN_OLD_H__ #include -#include -#include +#include "nm-vpn-dbus-interface.h" +#include "nm-connection.h" G_BEGIN_DECLS diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index 0b47bf53..31e12954 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -1047,11 +1047,11 @@ set_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_DBUS_SERVICE_NAME: - /* Construct-only */ + /* construct-only */ priv->dbus_service_name = g_value_dup_string (value); break; case PROP_DBUS_WATCH_PEER: - /* Construct-only */ + /* construct-only */ priv->dbus_watch_peer = g_value_get_boolean (value); break; case PROP_STATE: diff --git a/libnm/nm-vpn-service-plugin.h b/libnm/nm-vpn-service-plugin.h index 0b655296..329345ea 100644 --- a/libnm/nm-vpn-service-plugin.h +++ b/libnm/nm-vpn-service-plugin.h @@ -27,8 +27,8 @@ #endif #include -#include -#include +#include "nm-vpn-dbus-interface.h" +#include "nm-connection.h" G_BEGIN_DECLS diff --git a/libnm/nm-wimax-nsp.h b/libnm/nm-wimax-nsp.h index e1f63400..ed399346 100644 --- a/libnm/nm-wimax-nsp.h +++ b/libnm/nm-wimax-nsp.h @@ -26,7 +26,7 @@ #error "Only can be included directly." #endif -#include +#include "nm-object.h" G_BEGIN_DECLS -- cgit 1.3.0-6-gf8a5