2019-09-10 11:19:01 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1+
|
2014-07-24 08:53:33 -04:00
|
|
|
/*
|
libnm-core/utils: add some special properties for the attributes
"no_value" indicates that the the attribute is a single word, not a
key=value pair. If the type is BOOLEAN then the attribute is considered
true, if it's a STRING then the key is used instead of a value.
"consumes_rest" indicates that the particular key takes the unparseable
tail of the string for a value.
This allows parsing tc-style strings. Consider this filter:
,------ regular key/value pair
,-----'----.
root handle 1234: matchall action simple foo bar baz
| | `-----------.-----------'
| | `- "", STRING, consumes_rest
| `------------------- "kind", STRING, no_value
`-------------------------------------- "root', BOOLEAN, no_value
2017-12-04 11:40:32 +01:00
|
|
|
* Copyright 2005 - 2017 Red Hat, Inc.
|
2014-07-24 08:53:33 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __NM_UTILS_PRIVATE_H__
|
|
|
|
|
#define __NM_UTILS_PRIVATE_H__
|
|
|
|
|
|
2018-01-02 13:37:06 +01:00
|
|
|
#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE)
|
|
|
|
|
#error Cannot use this header.
|
2015-05-20 12:23:03 +02:00
|
|
|
#endif
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-setting-private.h"
|
2015-03-26 08:57:02 +01:00
|
|
|
#include "nm-setting-ip-config.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-03-02 11:08:34 +01:00
|
|
|
struct _NMVariantAttributeSpec {
|
|
|
|
|
char *name;
|
|
|
|
|
const GVariantType *type;
|
2017-02-15 15:06:24 +01:00
|
|
|
bool v4:1;
|
|
|
|
|
bool v6:1;
|
libnm-core/utils: add some special properties for the attributes
"no_value" indicates that the the attribute is a single word, not a
key=value pair. If the type is BOOLEAN then the attribute is considered
true, if it's a STRING then the key is used instead of a value.
"consumes_rest" indicates that the particular key takes the unparseable
tail of the string for a value.
This allows parsing tc-style strings. Consider this filter:
,------ regular key/value pair
,-----'----.
root handle 1234: matchall action simple foo bar baz
| | `-----------.-----------'
| | `- "", STRING, consumes_rest
| `------------------- "kind", STRING, no_value
`-------------------------------------- "root', BOOLEAN, no_value
2017-12-04 11:40:32 +01:00
|
|
|
bool no_value:1;
|
|
|
|
|
bool consumes_rest:1;
|
2017-02-15 15:06:24 +01:00
|
|
|
char str_type;
|
2017-03-02 11:08:34 +01:00
|
|
|
};
|
|
|
|
|
|
2019-05-01 11:56:29 +02:00
|
|
|
#define NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(_name, _type, ...) \
|
|
|
|
|
(&((const NMVariantAttributeSpec) { \
|
|
|
|
|
.name = _name, \
|
|
|
|
|
.type = _type, \
|
|
|
|
|
__VA_ARGS__ \
|
|
|
|
|
}))
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
gboolean _nm_utils_string_slist_validate (GSList *list,
|
|
|
|
|
const char **valid_values);
|
|
|
|
|
|
2019-02-09 11:14:51 +01:00
|
|
|
gboolean _nm_utils_secret_flags_validate (NMSettingSecretFlags secret_flags,
|
|
|
|
|
const char *setting_name,
|
|
|
|
|
const char *property_name,
|
|
|
|
|
NMSettingSecretFlags disallowed_flags,
|
|
|
|
|
GError **error);
|
|
|
|
|
|
2019-01-28 00:36:08 +01:00
|
|
|
gboolean _nm_utils_wps_method_validate (NMSettingWirelessSecurityWpsMethod wps_method,
|
|
|
|
|
const char *setting_name,
|
|
|
|
|
const char *property_name,
|
|
|
|
|
gboolean wps_required,
|
|
|
|
|
GError **error);
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
/* D-Bus transform funcs */
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2019-04-24 17:41:32 +02:00
|
|
|
GVariant *_nm_utils_hwaddr_cloned_get (const NMSettInfoSetting *sett_info,
|
|
|
|
|
guint property_idx,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
NMSetting *setting,
|
2019-06-27 09:07:16 +02:00
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options);
|
device: extend MAC address handling including randomization for ethernet and wifi
Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address"
settings. Instead of specifying an explicit MAC address, the additional
special values "permanent", "preserve", "random", "random-bia", "stable" and
"stable-bia" are supported.
"permanent" means to use the permanent hardware address. Previously that
was the default if no explict cloned-mac-address was set. The default is
thus still "permanent", but it can be overwritten by global
configuration.
"preserve" means not to configure the MAC address when activating the
device. That was actually the default behavior before introducing MAC
address handling with commit 1b49f941a69af910b0e68530be7339e8053068e5.
"random" and "random-bia" use a randomized MAC address for each
connection. "stable" and "stable-bia" use a generated, stable
address based on some token. The "bia" suffix says to generate a
burned-in address. The stable method by default uses as token the
connection UUID, but the token can be explicitly choosen via
"stable:<TOKEN>" and "stable-bia:<TOKEN>".
On a D-Bus level, the "cloned-mac-address" is a bytestring and thus
cannot express the new forms. It is replaced by the new
"assigned-mac-address" field. For the GObject property, libnm's API,
nmcli, keyfile, etc. the old name "cloned-mac-address" is still used.
Deprecating the old field seems more complicated then just extending
the use of the existing "cloned-mac-address" field, although the name
doesn't match well with the extended meaning.
There is some overlap with the "wifi.mac-address-randomization" setting.
https://bugzilla.gnome.org/show_bug.cgi?id=705545
https://bugzilla.gnome.org/show_bug.cgi?id=708820
https://bugzilla.gnome.org/show_bug.cgi?id=758301
2016-05-24 15:57:16 +02:00
|
|
|
gboolean _nm_utils_hwaddr_cloned_set (NMSetting *setting,
|
|
|
|
|
GVariant *connection_dict,
|
|
|
|
|
const char *property,
|
|
|
|
|
GVariant *value,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError **error);
|
|
|
|
|
gboolean _nm_utils_hwaddr_cloned_not_set (NMSetting *setting,
|
|
|
|
|
GVariant *connection_dict,
|
|
|
|
|
const char *property,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError **error);
|
2019-01-02 15:54:18 +01:00
|
|
|
GVariant * _nm_utils_hwaddr_cloned_data_synth (const NMSettInfoSetting *sett_info,
|
|
|
|
|
guint property_idx,
|
device: extend MAC address handling including randomization for ethernet and wifi
Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address"
settings. Instead of specifying an explicit MAC address, the additional
special values "permanent", "preserve", "random", "random-bia", "stable" and
"stable-bia" are supported.
"permanent" means to use the permanent hardware address. Previously that
was the default if no explict cloned-mac-address was set. The default is
thus still "permanent", but it can be overwritten by global
configuration.
"preserve" means not to configure the MAC address when activating the
device. That was actually the default behavior before introducing MAC
address handling with commit 1b49f941a69af910b0e68530be7339e8053068e5.
"random" and "random-bia" use a randomized MAC address for each
connection. "stable" and "stable-bia" use a generated, stable
address based on some token. The "bia" suffix says to generate a
burned-in address. The stable method by default uses as token the
connection UUID, but the token can be explicitly choosen via
"stable:<TOKEN>" and "stable-bia:<TOKEN>".
On a D-Bus level, the "cloned-mac-address" is a bytestring and thus
cannot express the new forms. It is replaced by the new
"assigned-mac-address" field. For the GObject property, libnm's API,
nmcli, keyfile, etc. the old name "cloned-mac-address" is still used.
Deprecating the old field seems more complicated then just extending
the use of the existing "cloned-mac-address" field, although the name
doesn't match well with the extended meaning.
There is some overlap with the "wifi.mac-address-randomization" setting.
https://bugzilla.gnome.org/show_bug.cgi?id=705545
https://bugzilla.gnome.org/show_bug.cgi?id=708820
https://bugzilla.gnome.org/show_bug.cgi?id=758301
2016-05-24 15:57:16 +02:00
|
|
|
NMConnection *connection,
|
2019-01-02 15:54:18 +01:00
|
|
|
NMSetting *setting,
|
2019-06-27 09:07:16 +02:00
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options);
|
device: extend MAC address handling including randomization for ethernet and wifi
Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address"
settings. Instead of specifying an explicit MAC address, the additional
special values "permanent", "preserve", "random", "random-bia", "stable" and
"stable-bia" are supported.
"permanent" means to use the permanent hardware address. Previously that
was the default if no explict cloned-mac-address was set. The default is
thus still "permanent", but it can be overwritten by global
configuration.
"preserve" means not to configure the MAC address when activating the
device. That was actually the default behavior before introducing MAC
address handling with commit 1b49f941a69af910b0e68530be7339e8053068e5.
"random" and "random-bia" use a randomized MAC address for each
connection. "stable" and "stable-bia" use a generated, stable
address based on some token. The "bia" suffix says to generate a
burned-in address. The stable method by default uses as token the
connection UUID, but the token can be explicitly choosen via
"stable:<TOKEN>" and "stable-bia:<TOKEN>".
On a D-Bus level, the "cloned-mac-address" is a bytestring and thus
cannot express the new forms. It is replaced by the new
"assigned-mac-address" field. For the GObject property, libnm's API,
nmcli, keyfile, etc. the old name "cloned-mac-address" is still used.
Deprecating the old field seems more complicated then just extending
the use of the existing "cloned-mac-address" field, although the name
doesn't match well with the extended meaning.
There is some overlap with the "wifi.mac-address-randomization" setting.
https://bugzilla.gnome.org/show_bug.cgi?id=705545
https://bugzilla.gnome.org/show_bug.cgi?id=708820
https://bugzilla.gnome.org/show_bug.cgi?id=758301
2016-05-24 15:57:16 +02:00
|
|
|
gboolean _nm_utils_hwaddr_cloned_data_set (NMSetting *setting,
|
|
|
|
|
GVariant *connection_dict,
|
|
|
|
|
const char *property,
|
|
|
|
|
GVariant *value,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError **error);
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariant * _nm_utils_hwaddr_to_dbus (const GValue *prop_value);
|
|
|
|
|
void _nm_utils_hwaddr_from_dbus (GVariant *dbus_value,
|
2014-07-30 10:57:45 -04:00
|
|
|
GValue *prop_value);
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariant * _nm_utils_strdict_to_dbus (const GValue *prop_value);
|
|
|
|
|
void _nm_utils_strdict_from_dbus (GVariant *dbus_value,
|
2014-06-24 17:40:08 -04:00
|
|
|
GValue *prop_value);
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
void _nm_utils_bytes_from_dbus (GVariant *dbus_value,
|
2014-06-26 10:42:11 -04:00
|
|
|
GValue *prop_value);
|
|
|
|
|
|
2014-10-28 08:56:07 -04:00
|
|
|
char * _nm_utils_hwaddr_canonical_or_invalid (const char *mac, gssize length);
|
|
|
|
|
|
2018-06-18 18:46:52 +02:00
|
|
|
void _nm_utils_format_variant_attributes_full (GString *str,
|
|
|
|
|
const NMUtilsNamedValue *values,
|
|
|
|
|
guint num_values,
|
|
|
|
|
char attr_separator,
|
|
|
|
|
char key_value_separator);
|
2018-05-25 12:05:24 +02:00
|
|
|
gboolean _nm_sriov_vf_parse_vlans (NMSriovVF *vf, const char *str, GError **error);
|
2018-06-18 18:46:52 +02:00
|
|
|
|
2019-04-24 17:41:32 +02:00
|
|
|
GVariant * _nm_utils_bridge_vlans_to_dbus (const NMSettInfoSetting *sett_info,
|
|
|
|
|
guint property_idx,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
NMSetting *setting,
|
2019-06-27 09:07:16 +02:00
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options);
|
2019-04-24 17:41:32 +02:00
|
|
|
|
2019-03-16 17:21:35 +01:00
|
|
|
gboolean _nm_utils_bridge_vlans_from_dbus (NMSetting *setting,
|
|
|
|
|
GVariant *connection_dict,
|
|
|
|
|
const char *property,
|
|
|
|
|
GVariant *value,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError **error);
|
|
|
|
|
gboolean _nm_utils_bridge_vlan_verify_list (GPtrArray *vlans,
|
|
|
|
|
gboolean check_normalizable,
|
|
|
|
|
GError **error,
|
|
|
|
|
const char *setting,
|
|
|
|
|
const char *property);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#endif
|