mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-10 04:20:36 +01:00
merge: branch 'ih/nmcli_field_ports'
nmcli: add BRIDGE.PORTS, TEAM.PORTS and GENERAL.CONTROLLER-PATH fields. Replace SLAVE for PORT in `c show` https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2369
This commit is contained in:
commit
121034d655
9 changed files with 1464 additions and 1246 deletions
|
|
@ -191,6 +191,17 @@ nm_meta_abstract_info_get_name(const NMMetaAbstractInfo *abstract_info, gboolean
|
|||
return n;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_meta_abstract_info_get_alias(const NMMetaAbstractInfo *abstract_info)
|
||||
{
|
||||
nm_assert(abstract_info);
|
||||
nm_assert(abstract_info->meta_type);
|
||||
|
||||
if (abstract_info->meta_type->get_alias)
|
||||
return abstract_info->meta_type->get_alias(abstract_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const NMMetaAbstractInfo *const *
|
||||
nm_meta_abstract_info_get_nested(const NMMetaAbstractInfo *abstract_info,
|
||||
guint *out_len,
|
||||
|
|
@ -466,10 +477,15 @@ _output_selection_select_one(const NMMetaAbstractInfo *const *fields_array,
|
|||
|
||||
for (i = 0; fields_array[i]; i++) {
|
||||
const NMMetaAbstractInfo *fi = fields_array[i];
|
||||
const char *name, *alias;
|
||||
const NMMetaAbstractInfo *const *nested;
|
||||
gs_free gpointer nested_to_free = NULL;
|
||||
|
||||
if (g_ascii_strcasecmp(i_name, nm_meta_abstract_info_get_name(fi, FALSE)) != 0)
|
||||
name = nm_meta_abstract_info_get_name(fi, FALSE);
|
||||
alias = nm_meta_abstract_info_get_alias(fi);
|
||||
|
||||
if (g_ascii_strcasecmp(i_name, name) != 0
|
||||
&& (alias == NULL || g_ascii_strcasecmp(i_name, alias) != 0))
|
||||
continue;
|
||||
|
||||
if (!right || !validate_nested) {
|
||||
|
|
@ -480,8 +496,11 @@ _output_selection_select_one(const NMMetaAbstractInfo *const *fields_array,
|
|||
nested = nm_meta_abstract_info_get_nested(fi, NULL, &nested_to_free);
|
||||
if (nested) {
|
||||
for (j = 0; nested[j]; nested++) {
|
||||
if (g_ascii_strcasecmp(right, nm_meta_abstract_info_get_name(nested[j], FALSE))
|
||||
== 0) {
|
||||
name = nm_meta_abstract_info_get_name(nested[j], FALSE);
|
||||
alias = nm_meta_abstract_info_get_alias(nested[j]);
|
||||
|
||||
if (g_ascii_strcasecmp(right, name) == 0
|
||||
|| (alias && g_ascii_strcasecmp(right, alias) == 0)) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ const NMMetaSettingInfoEditor *const *nm_meta_setting_infos_editor_p(void);
|
|||
|
||||
const char *nm_meta_abstract_info_get_name(const NMMetaAbstractInfo *abstract_info,
|
||||
gboolean for_header);
|
||||
const char *nm_meta_abstract_info_get_alias(const NMMetaAbstractInfo *abstract_info);
|
||||
|
||||
const NMMetaAbstractInfo *const *
|
||||
nm_meta_abstract_info_get_nested(const NMMetaAbstractInfo *abstract_info,
|
||||
|
|
|
|||
|
|
@ -482,6 +482,7 @@ struct _NMMetaType {
|
|||
NMObjBaseClass parent;
|
||||
const char *type_name;
|
||||
const char *(*get_name)(const NMMetaAbstractInfo *abstract_info, gboolean for_header);
|
||||
const char *(*get_alias)(const NMMetaAbstractInfo *abstract_info);
|
||||
const NMMetaAbstractInfo *const *(*get_nested)(const NMMetaAbstractInfo *abstract_info,
|
||||
guint *out_len,
|
||||
gpointer *out_to_free);
|
||||
|
|
|
|||
|
|
@ -818,8 +818,11 @@ _metagen_con_show_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
}
|
||||
|
||||
const NmcMetaGenericInfo *const metagen_con_show[_NMC_GENERIC_INFO_TYPE_CON_SHOW_NUM + 1] = {
|
||||
#define _METAGEN_CON_SHOW(type, name) \
|
||||
[type] = NMC_META_GENERIC(name, .info_type = type, .get_fcn = _metagen_con_show_get_fcn)
|
||||
#define _METAGEN_CON_SHOW(type, name, ...) \
|
||||
[type] = NMC_META_GENERIC(name, \
|
||||
.info_type = type, \
|
||||
.get_fcn = _metagen_con_show_get_fcn, \
|
||||
__VA_ARGS__)
|
||||
_METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_NAME, "NAME"),
|
||||
_METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_UUID, "UUID"),
|
||||
_METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_TYPE, "TYPE"),
|
||||
|
|
@ -833,7 +836,7 @@ const NmcMetaGenericInfo *const metagen_con_show[_NMC_GENERIC_INFO_TYPE_CON_SHOW
|
|||
_METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_DEVICE, "DEVICE"),
|
||||
_METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_STATE, "STATE"),
|
||||
_METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_ACTIVE_PATH, "ACTIVE-PATH"),
|
||||
_METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_PORT, "SLAVE"),
|
||||
_METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_PORT, "PORT", .alias = "SLAVE"),
|
||||
_METAGEN_CON_SHOW(NMC_GENERIC_INFO_TYPE_CON_SHOW_FILENAME, "FILENAME"),
|
||||
};
|
||||
#define NMC_FIELDS_CON_SHOW_COMMON "NAME,UUID,TYPE,DEVICE"
|
||||
|
|
@ -920,6 +923,7 @@ _metagen_con_active_general_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ARGS)
|
|||
* but the settings-connection profile. There is no guarantee, that they agree. */
|
||||
return s_con ? nm_setting_connection_get_zone(s_con) : NULL;
|
||||
case NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CONTROLLER_PATH:
|
||||
case NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_MASTER_PATH:
|
||||
dev = nm_active_connection_get_controller(ac);
|
||||
return dev ? nm_object_get_path(NM_OBJECT(dev)) : NULL;
|
||||
default:
|
||||
|
|
@ -949,6 +953,8 @@ const NmcMetaGenericInfo
|
|||
_METAGEN_CON_ACTIVE_GENERAL(NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CON_PATH, "CON-PATH"),
|
||||
_METAGEN_CON_ACTIVE_GENERAL(NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_ZONE, "ZONE"),
|
||||
_METAGEN_CON_ACTIVE_GENERAL(NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CONTROLLER_PATH,
|
||||
"CONTROLLER-PATH"),
|
||||
_METAGEN_CON_ACTIVE_GENERAL(NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_MASTER_PATH,
|
||||
"MASTER-PATH"),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -766,17 +766,19 @@ const NmcMetaGenericInfo *const nmc_fields_dev_wimax_list[] = {
|
|||
const NmcMetaGenericInfo *const nmc_fields_dev_show_controller_prop[] = {
|
||||
NMC_META_GENERIC("NAME"), /* 0 */
|
||||
NMC_META_GENERIC("SLAVES"), /* 1 */
|
||||
NMC_META_GENERIC("PORTS"), /* 2 */
|
||||
NULL,
|
||||
};
|
||||
#define NMC_FIELDS_DEV_SHOW_CONTROLLER_PROP_COMMON "NAME,SLAVES"
|
||||
#define NMC_FIELDS_DEV_SHOW_CONTROLLER_PROP_COMMON "NAME,SLAVES,PORTS"
|
||||
|
||||
const NmcMetaGenericInfo *const nmc_fields_dev_show_team_prop[] = {
|
||||
NMC_META_GENERIC("NAME"), /* 0 */
|
||||
NMC_META_GENERIC("SLAVES"), /* 1 */
|
||||
NMC_META_GENERIC("CONFIG"), /* 2 */
|
||||
NMC_META_GENERIC("PORTS"), /* 2 */
|
||||
NMC_META_GENERIC("CONFIG"), /* 3 */
|
||||
NULL,
|
||||
};
|
||||
#define NMC_FIELDS_DEV_SHOW_TEAM_PROP_COMMON "NAME,SLAVES,CONFIG"
|
||||
#define NMC_FIELDS_DEV_SHOW_TEAM_PROP_COMMON "NAME,SLAVES,PORTS,CONFIG"
|
||||
|
||||
const NmcMetaGenericInfo *const nmc_fields_dev_show_vlan_prop[] = {
|
||||
NMC_META_GENERIC("NAME"), /* 0 */
|
||||
|
|
@ -1537,7 +1539,8 @@ print_bond_bridge_info(NMDevice *device,
|
|||
|
||||
arr = nmc_dup_fields_array(tmpl, NMC_OF_FLAG_SECTION_PREFIX);
|
||||
set_val_strc(arr, 0, group_prefix); /* i.e. BOND, TEAM, BRIDGE */
|
||||
set_val_str(arr, 1, g_string_free(ports_str, FALSE));
|
||||
set_val_str(arr, 1, g_strdup(ports_str->str));
|
||||
set_val_str(arr, 2, g_string_free(ports_str, FALSE));
|
||||
g_ptr_array_add(out.output_data, arr);
|
||||
|
||||
print_data_prepare_width(out.output_data);
|
||||
|
|
@ -1600,8 +1603,9 @@ print_team_info(NMDevice *device, NmCli *nmc, const char *group_prefix, const ch
|
|||
|
||||
arr = nmc_dup_fields_array(tmpl, NMC_OF_FLAG_SECTION_PREFIX);
|
||||
set_val_strc(arr, 0, group_prefix); /* TEAM */
|
||||
set_val_str(arr, 1, g_string_free(ports_str, FALSE));
|
||||
set_val_str(arr, 2, sanitize_team_config(nm_device_team_get_config(NM_DEVICE_TEAM(device))));
|
||||
set_val_str(arr, 1, g_strdup(ports_str->str));
|
||||
set_val_str(arr, 2, g_string_free(ports_str, FALSE));
|
||||
set_val_str(arr, 3, sanitize_team_config(nm_device_team_get_config(NM_DEVICE_TEAM(device))));
|
||||
g_ptr_array_add(out.output_data, arr);
|
||||
|
||||
print_data_prepare_width(out.output_data);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,14 @@ _meta_type_nmc_generic_info_get_name(const NMMetaAbstractInfo *abstract_info, gb
|
|||
return info->name;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_meta_type_nmc_generic_info_get_alias(const NMMetaAbstractInfo *abstract_info)
|
||||
{
|
||||
const NmcMetaGenericInfo *info = (const NmcMetaGenericInfo *) abstract_info;
|
||||
|
||||
return info->alias;
|
||||
}
|
||||
|
||||
static const NMMetaAbstractInfo *const *
|
||||
_meta_type_nmc_generic_info_get_nested(const NMMetaAbstractInfo *abstract_info,
|
||||
guint *out_len,
|
||||
|
|
@ -101,6 +109,7 @@ _meta_type_nmc_generic_info_get_fcn(const NMMetaAbstractInfo *abstract_info,
|
|||
const NMMetaType nmc_meta_type_generic_info = {
|
||||
.type_name = "nmc-generic-info",
|
||||
.get_name = _meta_type_nmc_generic_info_get_name,
|
||||
.get_alias = _meta_type_nmc_generic_info_get_alias,
|
||||
.get_nested = _meta_type_nmc_generic_info_get_nested,
|
||||
.get_fcn = _meta_type_nmc_generic_info_get_fcn,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ typedef enum {
|
|||
NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CON_PATH,
|
||||
NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_ZONE,
|
||||
NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_CONTROLLER_PATH,
|
||||
NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_MASTER_PATH,
|
||||
_NMC_GENERIC_INFO_TYPE_CON_ACTIVE_GENERAL_NUM,
|
||||
|
||||
NMC_GENERIC_INFO_TYPE_CON_VPN_TYPE = 0,
|
||||
|
|
@ -260,6 +261,7 @@ struct _NmcMetaGenericInfo {
|
|||
NmcGenericInfoType info_type;
|
||||
const char *name;
|
||||
const char *name_header;
|
||||
const char *alias;
|
||||
const NmcMetaGenericInfo *const *nested;
|
||||
|
||||
#define NMC_META_GENERIC_INFO_GET_FCN_ARGS \
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue