2020-12-23 22:21:36 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2014-07-24 08:53:33 -04:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 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)
|
2021-07-09 08:48:48 +02:00
|
|
|
#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
|
|
|
|
2019-05-01 11:56:29 +02:00
|
|
|
#define NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(_name, _type, ...) \
|
|
|
|
|
(&((const NMVariantAttributeSpec){.name = _name, .type = _type, __VA_ARGS__}))
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
gboolean _nm_utils_string_slist_validate(GSList *list, const char **valid_values);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2019-02-09 11:14:51 +01:00
|
|
|
gboolean _nm_utils_secret_flags_validate(NMSettingSecretFlags secret_flags,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *setting_name,
|
|
|
|
|
const char *property_name,
|
2019-02-09 11:14:51 +01:00
|
|
|
NMSettingSecretFlags disallowed_flags,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2019-01-28 00:36:08 +01:00
|
|
|
gboolean _nm_utils_wps_method_validate(NMSettingWirelessSecurityWpsMethod wps_method,
|
2021-11-09 13:28:54 +01:00
|
|
|
const char *setting_name,
|
|
|
|
|
const char *property_name,
|
2019-01-28 00:36:08 +01:00
|
|
|
gboolean wps_required,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error);
|
2019-01-28 00:36:08 +01:00
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
/* D-Bus transform funcs */
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2021-07-14 13:22:40 +02:00
|
|
|
gboolean _nm_property_variant_to_gvalue(GVariant *src_value, GValue *dst_value);
|
|
|
|
|
|
2019-09-22 10:57:57 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_strdict;
|
|
|
|
|
|
|
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address;
|
|
|
|
|
|
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.
Instead of repeatedly spelling out the function arguments, use a macro.
Advantages:
- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this
is an implementation of a property. You can now grep for these macros
to find all implementation. That was previously rather imprecise, you
could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
implementations.
As the goal is to keep properties "similar", there is a desire to
reduce the number of similar implementations and to find them.
- changing the arguments now no longer will require you to go through
all implementations. At least not, if you merely add an argument that
has a reasonable default behavior and does not require explicit
handling by most implementation.
- it's convenient to be able to patch the argument list to let the
compiler help to reason about something. For example, the
"connection_dict" argument to from_dbus_fcn() is usually unused.
If you'd like to find who uses it, rename the parameter, and
review the (few) compiler errors.
- it does save 573 LOC of boilerplate with no actual logic or useful
information. I argue, that this simplifies the code and review, by
increasing the relative amount of actually meaningful code.
Disadvantages:
- the user no longer directly sees the argument list. They would need
cscope/ctags or an IDE to jump to the macro definition and conveniently
see all arguments.
Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-07-26 23:45:31 +02:00
|
|
|
void _nm_utils_strdict_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil);
|
2014-06-24 17:40:08 -04:00
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
void _nm_utils_bytes_from_dbus(GVariant *dbus_value, GValue *prop_value);
|
2014-06-26 10:42:11 -04:00
|
|
|
|
2014-10-28 08:56:07 -04:00
|
|
|
char *_nm_utils_hwaddr_canonical_or_invalid(const char *mac, gssize length);
|
|
|
|
|
|
2022-01-05 13:37:12 +01:00
|
|
|
char *
|
|
|
|
|
_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip, gboolean map_zero_to_null);
|
2021-07-14 07:40:35 +02:00
|
|
|
|
2020-03-23 19:29:24 +01:00
|
|
|
gboolean _nm_utils_hwaddr_link_local_valid(const char *mac);
|
|
|
|
|
|
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
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean _nm_utils_bridge_vlan_verify_list(GPtrArray *vlans,
|
2019-03-16 17:21:35 +01:00
|
|
|
gboolean check_normalizable,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error,
|
2019-03-16 17:21:35 +01:00
|
|
|
const char *setting,
|
|
|
|
|
const char *property);
|
|
|
|
|
|
2021-06-29 14:37:16 +02:00
|
|
|
NMTernary _nm_utils_bridge_compare_vlans(GPtrArray *vlans_a, GPtrArray *vlans_b);
|
|
|
|
|
|
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.
Instead of repeatedly spelling out the function arguments, use a macro.
Advantages:
- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this
is an implementation of a property. You can now grep for these macros
to find all implementation. That was previously rather imprecise, you
could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
implementations.
As the goal is to keep properties "similar", there is a desire to
reduce the number of similar implementations and to find them.
- changing the arguments now no longer will require you to go through
all implementations. At least not, if you merely add an argument that
has a reasonable default behavior and does not require explicit
handling by most implementation.
- it's convenient to be able to patch the argument list to let the
compiler help to reason about something. For example, the
"connection_dict" argument to from_dbus_fcn() is usually unused.
If you'd like to find who uses it, rename the parameter, and
review the (few) compiler errors.
- it does save 573 LOC of boilerplate with no actual logic or useful
information. I argue, that this simplifies the code and review, by
increasing the relative amount of actually meaningful code.
Disadvantages:
- the user no longer directly sees the argument list. They would need
cscope/ctags or an IDE to jump to the macro definition and conveniently
see all arguments.
Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-07-26 23:45:31 +02:00
|
|
|
GVariant *_nm_team_settings_property_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
2021-06-29 14:37:16 +02:00
|
|
|
|
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.
Instead of repeatedly spelling out the function arguments, use a macro.
Advantages:
- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this
is an implementation of a property. You can now grep for these macros
to find all implementation. That was previously rather imprecise, you
could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
implementations.
As the goal is to keep properties "similar", there is a desire to
reduce the number of similar implementations and to find them.
- changing the arguments now no longer will require you to go through
all implementations. At least not, if you merely add an argument that
has a reasonable default behavior and does not require explicit
handling by most implementation.
- it's convenient to be able to patch the argument list to let the
compiler help to reason about something. For example, the
"connection_dict" argument to from_dbus_fcn() is usually unused.
If you'd like to find who uses it, rename the parameter, and
review the (few) compiler errors.
- it does save 573 LOC of boilerplate with no actual logic or useful
information. I argue, that this simplifies the code and review, by
increasing the relative amount of actually meaningful code.
Disadvantages:
- the user no longer directly sees the argument list. They would need
cscope/ctags or an IDE to jump to the macro definition and conveniently
see all arguments.
Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-07-26 23:45:31 +02:00
|
|
|
void _nm_team_settings_property_from_dbus_link_watchers(
|
|
|
|
|
_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil);
|
2021-06-29 14:37:16 +02:00
|
|
|
|
2022-10-24 18:36:29 +02:00
|
|
|
GVariant *nm_utils_dns_to_variant(int addr_family, const char *const *dns, gssize len);
|
2021-06-29 21:53:55 +02:00
|
|
|
|
2022-01-02 20:43:09 +01:00
|
|
|
const char *const *nmtst_system_encodings_for_lang(const char *lang);
|
|
|
|
|
const char *const *nmtst_system_encodings_get_default(void);
|
|
|
|
|
const char *const *nmtst_system_encodings_get(void);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#endif
|