2017-03-28 11:38:00 +02:00
|
|
|
/* nmcli - command-line tool to control NetworkManager
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2010 - 2017 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __NM_META_SETTING_DESC_H__
|
|
|
|
|
#define __NM_META_SETTING_DESC_H__
|
|
|
|
|
|
|
|
|
|
#include "nm-meta-setting.h"
|
|
|
|
|
|
|
|
|
|
#define NM_META_TEXT_HIDDEN "<hidden>"
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
NM_META_ACCESSOR_GET_TYPE_PRETTY,
|
|
|
|
|
NM_META_ACCESSOR_GET_TYPE_PARSABLE,
|
|
|
|
|
} NMMetaAccessorGetType;
|
|
|
|
|
|
2017-04-04 13:14:23 +02:00
|
|
|
typedef enum {
|
|
|
|
|
NM_META_ACCESSOR_GET_FLAGS_NONE = 0,
|
|
|
|
|
NM_META_ACCESSOR_GET_FLAGS_SHOW_SECRETS = (1LL << 0),
|
|
|
|
|
} NMMetaAccessorGetFlags;
|
|
|
|
|
|
2017-03-28 18:06:14 +02:00
|
|
|
typedef enum {
|
|
|
|
|
NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PRETTY_NUMERIC = (1LL << 0),
|
|
|
|
|
NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PRETTY_NUMERIC_HEX = (1LL << 1),
|
|
|
|
|
NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PRETTY_TEXT = (1LL << 2),
|
|
|
|
|
NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PRETTY_TEXT_L10N = (1LL << 3),
|
|
|
|
|
NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PARSABLE_NUMERIC = (1LL << 4),
|
|
|
|
|
NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PARSABLE_NUMERIC_HEX = (1LL << 5),
|
|
|
|
|
NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PARSABLE_TEXT = (1LL << 6),
|
|
|
|
|
} NMMetaPropertyTypFlags;
|
|
|
|
|
|
2017-03-28 11:38:00 +02:00
|
|
|
typedef enum {
|
|
|
|
|
NM_META_PROPERTY_TYPE_MAC_MODE_DEFAULT,
|
|
|
|
|
NM_META_PROPERTY_TYPE_MAC_MODE_CLONED,
|
|
|
|
|
NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND,
|
|
|
|
|
} NMMetaPropertyTypeMacMode;
|
|
|
|
|
|
2017-03-31 16:16:06 +02:00
|
|
|
typedef struct _NMMetaEnvironment NMMetaEnvironment;
|
|
|
|
|
typedef struct _NMMetaType NMMetaType;
|
|
|
|
|
typedef struct _NMMetaAbstractInfo NMMetaAbstractInfo;
|
2017-03-28 11:38:00 +02:00
|
|
|
typedef struct _NMMetaSettingInfoEditor NMMetaSettingInfoEditor;
|
2017-03-31 16:16:06 +02:00
|
|
|
typedef struct _NMMetaPropertyInfo NMMetaPropertyInfo;
|
|
|
|
|
typedef struct _NMMetaPropertyType NMMetaPropertyType;
|
|
|
|
|
typedef struct _NMMetaPropertyTypData NMMetaPropertyTypData;
|
2017-03-28 11:38:00 +02:00
|
|
|
|
|
|
|
|
struct _NMMetaPropertyType {
|
|
|
|
|
|
2017-03-31 16:16:06 +02:00
|
|
|
const char *(*describe_fcn) (const NMMetaPropertyInfo *property_info,
|
2017-03-28 11:38:00 +02:00
|
|
|
char **out_to_free);
|
|
|
|
|
|
2017-04-04 13:14:23 +02:00
|
|
|
char *(*get_fcn) (const NMMetaEnvironment *environment,
|
|
|
|
|
gpointer environment_user_data,
|
|
|
|
|
const NMMetaPropertyInfo *property_info,
|
2017-03-28 11:38:00 +02:00
|
|
|
NMSetting *setting,
|
|
|
|
|
NMMetaAccessorGetType get_type,
|
2017-04-04 13:14:23 +02:00
|
|
|
NMMetaAccessorGetFlags get_flags);
|
2017-03-30 18:07:26 +02:00
|
|
|
gboolean (*set_fcn) (const NMMetaEnvironment *environment,
|
|
|
|
|
gpointer environment_user_data,
|
2017-03-28 11:38:00 +02:00
|
|
|
const NMMetaPropertyInfo *property_info,
|
|
|
|
|
NMSetting *setting,
|
|
|
|
|
const char *value,
|
|
|
|
|
GError **error);
|
2017-03-30 18:07:26 +02:00
|
|
|
gboolean (*remove_fcn) (const NMMetaEnvironment *environment,
|
|
|
|
|
gpointer environment_user_data,
|
2017-03-28 11:38:00 +02:00
|
|
|
const NMMetaPropertyInfo *property_info,
|
|
|
|
|
NMSetting *setting,
|
|
|
|
|
const char *option,
|
|
|
|
|
guint32 idx,
|
|
|
|
|
GError **error);
|
|
|
|
|
|
2017-03-31 16:16:06 +02:00
|
|
|
const char *const*(*values_fcn) (const NMMetaPropertyInfo *property_info,
|
2017-03-28 11:38:00 +02:00
|
|
|
char ***out_to_free);
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-28 18:06:14 +02:00
|
|
|
struct _NMUtilsEnumValueInfo;
|
|
|
|
|
|
2017-03-28 11:38:00 +02:00
|
|
|
struct _NMMetaPropertyTypData {
|
|
|
|
|
union {
|
|
|
|
|
struct {
|
|
|
|
|
gboolean (*fcn) (NMSetting *setting);
|
|
|
|
|
} get_with_default;
|
|
|
|
|
struct {
|
|
|
|
|
GType (*get_gtype) (void);
|
|
|
|
|
int min;
|
|
|
|
|
int max;
|
2017-03-28 18:06:14 +02:00
|
|
|
const struct _NMUtilsEnumValueInfo *value_infos;
|
2017-03-28 11:38:00 +02:00
|
|
|
} gobject_enum;
|
|
|
|
|
struct {
|
|
|
|
|
guint32 (*get_fcn) (NMSetting *setting);
|
|
|
|
|
} mtu;
|
|
|
|
|
struct {
|
|
|
|
|
NMMetaPropertyTypeMacMode mode;
|
|
|
|
|
} mac;
|
|
|
|
|
} subtype;
|
|
|
|
|
const char *const*values_static;
|
2017-03-28 18:06:14 +02:00
|
|
|
NMMetaPropertyTypFlags typ_flags;
|
2017-03-28 11:38:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _NMMetaPropertyInfo {
|
2017-03-31 16:16:06 +02:00
|
|
|
const NMMetaType *meta_type;
|
|
|
|
|
|
|
|
|
|
const NMMetaSettingInfoEditor *setting_info;
|
|
|
|
|
|
2017-03-28 11:38:00 +02:00
|
|
|
const char *property_name;
|
|
|
|
|
|
|
|
|
|
/* the property list for now must contain as first field the
|
|
|
|
|
* "name", which isn't a regular property. This is required by
|
|
|
|
|
* NmcOutputField and this first field is ignored for the
|
|
|
|
|
* group_list/setting_info. */
|
|
|
|
|
bool is_name:1;
|
|
|
|
|
|
|
|
|
|
bool is_secret:1;
|
|
|
|
|
|
2017-03-30 16:34:55 +02:00
|
|
|
const char *describe_doc;
|
|
|
|
|
|
2017-03-28 11:38:00 +02:00
|
|
|
const char *describe_message;
|
|
|
|
|
|
|
|
|
|
const NMMetaPropertyType *property_type;
|
|
|
|
|
const NMMetaPropertyTypData *property_typ_data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _NMMetaSettingInfoEditor {
|
2017-03-31 16:16:06 +02:00
|
|
|
const NMMetaType *meta_type;
|
2017-03-28 11:38:00 +02:00
|
|
|
const NMMetaSettingInfo *general;
|
|
|
|
|
/* the order of the properties matter. The first *must* be the
|
|
|
|
|
* "name", and then the order is as they are listed by default. */
|
|
|
|
|
const NMMetaPropertyInfo *properties;
|
|
|
|
|
guint properties_num;
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-31 16:16:06 +02:00
|
|
|
struct _NMMetaType {
|
|
|
|
|
const char *type_name;
|
cli: split tracking of meta data out of NmcOutputField
When generating output data, nmcli iterates over a list of
property-descriptors (nmc_fields_ip4_config), creates an intermediate
array (output_data) and finally prints it.
However, previously both the meta data (nmc_fields_ip4_config) and
the intermediate format use the same type NmcOutputField. This means,
certain fields are relevant to describe a property, and other fields
are output/formatting fields.
Split this up. Now, the meta data is tracked in form of an NMMetaAbstractInfo
lists. This separates the information about properties from intermediate steps
during creation of the output.
Note that currently functions like print_ip4_config() still have all the
knowledge about how to generate the output. That is wrong, instead, the
meta data (NMMetaAbstractInfo) should describe how to create the output
and then all those functions could be replaced. This means, later we want
to add more knowledge to the NMMetaAbstractInfo, so it is important to
keep them separate from NmcOutputField.
2017-03-31 19:18:16 +02:00
|
|
|
const char *(*get_name) (const NMMetaAbstractInfo *abstract_info);
|
2017-04-03 14:04:28 +02:00
|
|
|
const NMMetaAbstractInfo *const*(*get_nested) (const NMMetaAbstractInfo *abstract_info,
|
|
|
|
|
guint *out_len,
|
|
|
|
|
gpointer *out_to_free);
|
2017-04-04 15:07:06 +02:00
|
|
|
gconstpointer (*get_fcn) (const NMMetaEnvironment *environment,
|
|
|
|
|
gpointer environment_user_data,
|
|
|
|
|
const NMMetaAbstractInfo *info,
|
|
|
|
|
gpointer target,
|
|
|
|
|
NMMetaAccessorGetType get_type,
|
|
|
|
|
NMMetaAccessorGetFlags get_flags,
|
|
|
|
|
gpointer *out_to_free);
|
2017-03-31 16:16:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _NMMetaAbstractInfo {
|
|
|
|
|
union {
|
|
|
|
|
const NMMetaType *meta_type;
|
|
|
|
|
union {
|
|
|
|
|
NMMetaSettingInfoEditor setting_info;
|
|
|
|
|
NMMetaPropertyInfo property_info;
|
|
|
|
|
} as;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern const NMMetaType nm_meta_type_setting_info_editor;
|
|
|
|
|
extern const NMMetaType nm_meta_type_property_info;
|
|
|
|
|
|
2017-03-28 11:38:00 +02:00
|
|
|
extern const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[_NM_META_SETTING_TYPE_NUM];
|
|
|
|
|
|
2017-03-30 18:07:26 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
NM_META_ENV_WARN_LEVEL_INFO,
|
|
|
|
|
NM_META_ENV_WARN_LEVEL_WARN,
|
|
|
|
|
} NMMetaEnvWarnLevel;
|
|
|
|
|
|
|
|
|
|
/* the settings-meta data is supposed to be independent of an actual client
|
|
|
|
|
* implementation. Hence, there is a need for hooks to the meta-data.
|
|
|
|
|
* The meta-data handlers may call back to the enviroment with certain
|
|
|
|
|
* actions. */
|
|
|
|
|
struct _NMMetaEnvironment {
|
|
|
|
|
|
|
|
|
|
void (*warn_fcn) (const NMMetaEnvironment *environment,
|
|
|
|
|
gpointer environment_user_data,
|
|
|
|
|
NMMetaEnvWarnLevel warn_level,
|
|
|
|
|
const char *fmt_l10n, /* the untranslated format string, but it is marked for translation using N_(). */
|
|
|
|
|
va_list ap);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-28 11:38:00 +02:00
|
|
|
#endif /* __NM_META_SETTING_DESC_H__ */
|