/** * nm_setting_wired_get_s390_option: * @setting: the #NMSettingWired * @idx: index of the desired option, from 0 to * nm_setting_wired_get_num_s390_options() - 1 * @out_key: (out): on return, the key name of the s390 specific option; this * value is owned by the setting and should not be modified * @out_value: (out): on return, the value of the key of the s390 specific * option; this value is owned by the setting and should not be modified * * Given an index, return the value of the s390 option at that index. indexes * are *not* guaranteed to be static across modifications to options done by * nm_setting_wired_add_s390_option() and nm_setting_wired_remove_s390_option(), * and should not be used to refer to options except for short periods of time * such as during option iteration. * * Returns: %TRUE on success if the index was valid and an option was found, * %FALSE if the index was invalid (ie, greater than the number of options * currently held by the setting) **/ gboolean nm_setting_wired_get_s390_option (NMSettingWired *setting, guint32 idx, const char **out_key, const char **out_value) { NMSettingWiredPrivate *priv; guint32 num_keys; GList *keys; const char *_key = NULL, *_value = NULL; g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); priv = NM_SETTING_WIRED_GET_PRIVATE (setting); num_keys = nm_setting_wired_get_num_s390_options (setting); g_return_val_if_fail (idx < num_keys, FALSE); keys = g_hash_table_get_keys (priv->s390_options); _key = g_list_nth_data (keys, idx); _value = g_hash_table_lookup (priv->s390_options, _key); if (out_key) *out_key = _key; if (out_value) *out_value = _value; return TRUE; }
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; }