static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMSettingWired *setting = NM_SETTING_WIRED (object); NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting); switch (prop_id) { case PROP_PORT: g_value_set_string (value, nm_setting_wired_get_port (setting)); break; case PROP_SPEED: g_value_set_uint (value, nm_setting_wired_get_speed (setting)); break; case PROP_DUPLEX: g_value_set_string (value, nm_setting_wired_get_duplex (setting)); break; case PROP_AUTO_NEGOTIATE: g_value_set_boolean (value, nm_setting_wired_get_auto_negotiate (setting)); break; case PROP_MAC_ADDRESS: g_value_set_boxed (value, nm_setting_wired_get_mac_address (setting)); break; case PROP_CLONED_MAC_ADDRESS: g_value_set_boxed (value, nm_setting_wired_get_cloned_mac_address (setting)); break; case PROP_MAC_ADDRESS_BLACKLIST: g_value_set_boxed (value, nm_setting_wired_get_mac_address_blacklist (setting)); break; case PROP_MTU: g_value_set_uint (value, nm_setting_wired_get_mtu (setting)); break; case PROP_S390_SUBCHANNELS: g_value_set_boxed (value, nm_setting_wired_get_s390_subchannels (setting)); break; case PROP_S390_NETTYPE: g_value_set_string (value, nm_setting_wired_get_s390_nettype (setting)); break; case PROP_S390_OPTIONS: g_value_set_boxed (value, priv->s390_options); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static gboolean check_connection_s390_props (NMConnection *orig, NMConnection *candidate, GHashTable *settings) { GHashTable *props1, *props2, *props3; NMSettingWired *s_wired_orig, *s_wired_cand; props1 = check_property_in_hash (settings, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS); props2 = check_property_in_hash (settings, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_NETTYPE); props3 = check_property_in_hash (settings, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_OPTIONS); if (!props1 && !props2 && !props3) return TRUE; /* If the generated connection did not contain wired setting, * allow it to match to a connection with a wired setting, * but default (empty) s390-* properties */ s_wired_orig = nm_connection_get_setting_wired (orig); s_wired_cand = nm_connection_get_setting_wired (candidate); if (!s_wired_orig && s_wired_cand) { const char * const *subchans = nm_setting_wired_get_s390_subchannels (s_wired_cand); const char *nettype = nm_setting_wired_get_s390_nettype (s_wired_cand); guint32 num_options = nm_setting_wired_get_num_s390_options (s_wired_cand); if ((!subchans || !*subchans) && !nettype && num_options == 0) { remove_from_hash (settings, props1, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS); remove_from_hash (settings, props2, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_NETTYPE); remove_from_hash (settings, props3, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_OPTIONS); return TRUE; } } return FALSE; }
static gboolean match_subchans (NMDeviceEthernet *self, NMSettingWired *s_wired, gboolean *try_mac) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); const char * const *subchans; guint32 num1, num2; int i, j; *try_mac = TRUE; subchans = nm_setting_wired_get_s390_subchannels (s_wired); num1 = _subchannels_count_num (subchans); num2 = _subchannels_count_num ((const char * const *) priv->s390_subchannels); /* connection has no subchannels */ if (num1 == 0) return TRUE; /* connection requires subchannels but the device has none */ if (num2 == 0) return FALSE; /* number of subchannels differ */ if (num1 != num2) return FALSE; /* Make sure each subchannel in the connection is a subchannel of this device */ for (i = 0; subchans[i]; i++) { const char *candidate = subchans[i]; gboolean found = FALSE; for (j = 0; priv->s390_subchannels[j]; j++) { if (!g_strcmp0 (priv->s390_subchannels[j], candidate)) found = TRUE; } if (!found) return FALSE; /* a subchannel was not found */ } *try_mac = FALSE; return TRUE; }