mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 20:40:34 +01:00
libnm: add nm_setting_ethtool_get_optnames() function
It's rather limiting if we have no API to ask NMSettingEthtool which options are set. Note that currently NMSettingEthtool only supports offload features. In the future, it should also support other options like coalesce or ring options. Hence, this returns all option names, not only features. If a caller needs to know whether the name is an option name, he/she should call nm_ethtool_optname_is_feature().
This commit is contained in:
parent
1850dc4952
commit
356a159731
3 changed files with 39 additions and 0 deletions
|
|
@ -91,6 +91,9 @@ _notify_attributes (NMSettingEthtool *self)
|
|||
* Gets and offload feature setting. Returns %NM_TERNARY_DEFAULT if the
|
||||
* feature is not set.
|
||||
*
|
||||
* Note that @optname must be a valid name for a feature, according to
|
||||
* nm_ethtool_optname_is_feature().
|
||||
*
|
||||
* Returns: a #NMTernary value indicating whether the offload feature
|
||||
* is enabled, disabled, or left untouched.
|
||||
*
|
||||
|
|
@ -124,6 +127,9 @@ nm_setting_ethtool_get_feature (NMSettingEthtool *setting,
|
|||
*
|
||||
* Sets and offload feature setting.
|
||||
*
|
||||
* Note that @optname must be a valid name for a feature, according to
|
||||
* nm_ethtool_optname_is_feature().
|
||||
*
|
||||
* Since: 1.14
|
||||
*/
|
||||
void
|
||||
|
|
@ -245,6 +251,34 @@ nm_setting_ethtool_init_features (NMSettingEthtool *setting,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_setting_ethtool_get_optnames:
|
||||
* @setting: the #NMSettingEthtool instance.
|
||||
* @out_length: (out) (optional): return location for the number of keys returned, or %NULL
|
||||
*
|
||||
* This returns all options names that are set. This includes the feature names
|
||||
* like %NM_ETHTOOL_OPTNAME_FEATURE_GRO. See nm_ethtool_optname_is_feature() to
|
||||
* check whether the option name is valid for offload features.
|
||||
*
|
||||
* Returns: (array zero-terminated=1) (transfer container): list of set option
|
||||
* names or %NULL if no options are set. The option names are still owned by
|
||||
* @setting and may get invalidated when @setting gets modified.
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
const char **
|
||||
nm_setting_ethtool_get_optnames (NMSettingEthtool *setting,
|
||||
guint *out_length)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ETHTOOL (setting), NULL);
|
||||
|
||||
return nm_utils_strdict_get_keys (_nm_setting_gendata_hash (NM_SETTING (setting), FALSE),
|
||||
TRUE,
|
||||
out_length);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,6 +119,10 @@ void nm_setting_ethtool_set_feature (NMSettingEthtool *setting,
|
|||
NM_AVAILABLE_IN_1_14
|
||||
void nm_setting_ethtool_clear_features (NMSettingEthtool *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_20
|
||||
const char ** nm_setting_ethtool_get_optnames (NMSettingEthtool *setting,
|
||||
guint *out_length);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_ETHTOOL_H__ */
|
||||
|
|
|
|||
|
|
@ -1610,4 +1610,5 @@ global:
|
|||
nm_device_modem_get_apn;
|
||||
nm_device_modem_get_device_id;
|
||||
nm_device_modem_get_operator_code;
|
||||
nm_setting_ethtool_get_optnames;
|
||||
} libnm_1_18_0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue