cli: implement dcb priority as plain int property
There are basically three options: 1) use a separate _get_fcn_gobject_dcb_priority() getter and implement them as a new type _pt_gobject_dcb_priority. 2a) implement them as _pt_gobject_int and set nicks as value_infos, repeating the nicks 3 times. 2b) like 2a, but use a macro to define how the DCB priority shall behave at one place. I think 1) is ugly. In the previous form, it also does not support setting the property to "unset". We should implement properties as types, and modify their behavior (by setting value_infos), instead of implementing multiple, different types. I slightly prefer 2b) over 2a) because it defines the behavior once, but it's a bit harder to follow.
This commit is contained in:
@@ -647,20 +647,6 @@ _get_fcn_gobject_int (ARGS_GET_FCN)
|
||||
out_to_free);
|
||||
}
|
||||
|
||||
static gconstpointer
|
||||
_get_fcn_gobject_dcb_priority (ARGS_GET_FCN)
|
||||
{
|
||||
static const NMMetaUtilsIntValueInfo value_infos[] = {
|
||||
{
|
||||
.value = -1,
|
||||
.nick = "unset",
|
||||
},
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
return _get_fcn_gobject_int_impl (property_info, setting, get_type, value_infos, out_to_free);
|
||||
}
|
||||
|
||||
static gconstpointer
|
||||
_get_fcn_gobject_mtu (ARGS_GET_FCN)
|
||||
{
|
||||
@@ -4408,11 +4394,6 @@ static const NMMetaPropertyType _pt_gobject_mtu = {
|
||||
.set_fcn = _set_fcn_gobject_mtu,
|
||||
};
|
||||
|
||||
static const NMMetaPropertyType _pt_gobject_dcb_priority = {
|
||||
.get_fcn = _get_fcn_gobject_dcb_priority,
|
||||
.set_fcn = _set_fcn_gobject_int,
|
||||
};
|
||||
|
||||
static const NMMetaPropertyType _pt_gobject_mac = {
|
||||
.get_fcn = _get_fcn_gobject,
|
||||
.set_fcn = _set_fcn_gobject_mac,
|
||||
@@ -4479,6 +4460,17 @@ static const NMMetaPropertyType _pt_gobject_devices = {
|
||||
"{ \"device\": \"team0\", \"runner\": {\"name\": \"roundrobin\"}, \"ports\": {\"eth1\": {}, \"eth2\": {}} }\n" \
|
||||
" set team.config /etc/my-team.conf\n")
|
||||
|
||||
#define DEFINE_DCB_PROPRITY_PROPERTY_TYPE \
|
||||
.property_type = &_pt_gobject_int, \
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_int, \
|
||||
.value_infos = INT_VALUE_INFOS ( \
|
||||
{ \
|
||||
.value = -1, \
|
||||
.nick = "unset", \
|
||||
} \
|
||||
), \
|
||||
),
|
||||
|
||||
#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_802_1X
|
||||
static const NMMetaPropertyInfo *const property_infos_802_1X[] = {
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_802_1X_EAP,
|
||||
@@ -5104,7 +5096,7 @@ static const NMMetaPropertyInfo *const property_infos_DCB[] = {
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_FCOE_PRIORITY,
|
||||
.property_type = &_pt_gobject_dcb_priority,
|
||||
DEFINE_DCB_PROPRITY_PROPERTY_TYPE
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_FCOE_MODE,
|
||||
.property_type = &_pt_gobject_string,
|
||||
@@ -5120,7 +5112,7 @@ static const NMMetaPropertyInfo *const property_infos_DCB[] = {
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_ISCSI_PRIORITY,
|
||||
.property_type = &_pt_gobject_dcb_priority,
|
||||
DEFINE_DCB_PROPRITY_PROPERTY_TYPE
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_FIP_FLAGS,
|
||||
.property_type = DEFINE_PROPERTY_TYPE (
|
||||
@@ -5129,7 +5121,7 @@ static const NMMetaPropertyInfo *const property_infos_DCB[] = {
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_FIP_PRIORITY,
|
||||
.property_type = &_pt_gobject_dcb_priority,
|
||||
DEFINE_DCB_PROPRITY_PROPERTY_TYPE
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS,
|
||||
.property_type = DEFINE_PROPERTY_TYPE (
|
||||
|
Reference in New Issue
Block a user