mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 03:20:11 +01:00
core: add NMIPConfigFlags for NMIPConfig flags
This will be useful to set future options on the NMIPConfig.
Yes, the code duplication of NMIP[46]Config is horrible. Needs
to be unified in the future.
(cherry picked from commit e8b86f8445)
This commit is contained in:
parent
aa759765c5
commit
7e598a8aa7
4 changed files with 70 additions and 0 deletions
|
|
@ -303,6 +303,7 @@ typedef struct {
|
|||
NMIPConfigDedupMultiIdxType idx_ip4_routes_;
|
||||
NMDedupMultiIdxType idx_ip4_routes;
|
||||
};
|
||||
NMIPConfigFlags config_flags;
|
||||
} NMIP4ConfigPrivate;
|
||||
|
||||
struct _NMIP4Config {
|
||||
|
|
@ -2659,6 +2660,28 @@ nm_ip4_config_llmnr_set (NMIP4Config *self,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMIPConfigFlags
|
||||
nm_ip4_config_get_config_flags (const NMIP4Config *self)
|
||||
{
|
||||
return NM_IP4_CONFIG_GET_PRIVATE (self)->config_flags;
|
||||
}
|
||||
|
||||
void
|
||||
nm_ip4_config_set_config_flags (NMIP4Config *self, NMIPConfigFlags flags, NMIPConfigFlags mask)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
|
||||
|
||||
if (mask == 0) {
|
||||
/* for convenience, accept 0 mask to set any flags. */
|
||||
mask = flags;
|
||||
}
|
||||
|
||||
nm_assert (!NM_FLAGS_ANY (flags, ~mask));
|
||||
priv->config_flags = (flags & mask) | (priv->config_flags & ~mask);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_ip4_config_set_dns_priority (NMIP4Config *self, int priority)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum _NMIPConfigFlags {
|
||||
NM_IP_CONFIG_FLAG_NONE = 0,
|
||||
} NMIPConfigFlags;
|
||||
|
||||
typedef struct {
|
||||
NMDedupMultiIdxType parent;
|
||||
NMPObjectType obj_type;
|
||||
|
|
@ -196,6 +200,9 @@ NMSettingConnectionLlmnr nm_ip4_config_llmnr_get (const NMIP4Config *self);
|
|||
void nm_ip4_config_llmnr_set (NMIP4Config *self,
|
||||
NMSettingConnectionLlmnr llmnr);
|
||||
|
||||
void nm_ip4_config_set_config_flags (NMIP4Config *self, NMIPConfigFlags flags, NMIPConfigFlags mask);
|
||||
NMIPConfigFlags nm_ip4_config_get_config_flags (const NMIP4Config *self);
|
||||
|
||||
const NMDedupMultiHeadEntry *nm_ip4_config_lookup_addresses (const NMIP4Config *self);
|
||||
void nm_ip4_config_reset_addresses (NMIP4Config *self);
|
||||
void nm_ip4_config_add_address (NMIP4Config *self, const NMPlatformIP4Address *address);
|
||||
|
|
@ -513,6 +520,18 @@ nm_ip_config_best_default_route_get (const NMIPConfig *self)
|
|||
_NM_IP_CONFIG_DISPATCH (self, nm_ip4_config_best_default_route_get, nm_ip6_config_best_default_route_get);
|
||||
}
|
||||
|
||||
static inline NMIPConfigFlags
|
||||
nm_ip_config_get_config_flags (const NMIPConfig *self)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH (self, nm_ip4_config_get_config_flags, nm_ip6_config_get_config_flags);
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_ip_config_set_config_flags (NMIPConfig *self, NMIPConfigFlags flags, NMIPConfigFlags mask)
|
||||
{
|
||||
_NM_IP_CONFIG_DISPATCH_VOID (self, nm_ip4_config_set_config_flags, nm_ip6_config_set_config_flags, flags, mask);
|
||||
}
|
||||
|
||||
#define _NM_IP_CONFIG_DISPATCH_SET_OP(_return, dst, src, v4_func, v6_func, ...) \
|
||||
G_STMT_START { \
|
||||
gpointer _dst = (dst); \
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ typedef struct {
|
|||
NMIPConfigDedupMultiIdxType idx_ip6_routes_;
|
||||
NMDedupMultiIdxType idx_ip6_routes;
|
||||
};
|
||||
NMIPConfigFlags config_flags;
|
||||
bool ipv6_disabled;
|
||||
} NMIP6ConfigPrivate;
|
||||
|
||||
|
|
@ -2296,6 +2297,28 @@ nm_ip6_config_get_dns_option (const NMIP6Config *self, guint i)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMIPConfigFlags
|
||||
nm_ip6_config_get_config_flags (const NMIP6Config *self)
|
||||
{
|
||||
return NM_IP6_CONFIG_GET_PRIVATE (self)->config_flags;
|
||||
}
|
||||
|
||||
void
|
||||
nm_ip6_config_set_config_flags (NMIP6Config *self, NMIPConfigFlags flags, NMIPConfigFlags mask)
|
||||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
|
||||
|
||||
if (mask == 0) {
|
||||
/* for convenience, accept 0 mask to set any flags. */
|
||||
mask = flags;
|
||||
}
|
||||
|
||||
nm_assert (!NM_FLAGS_ANY (flags, ~mask));
|
||||
priv->config_flags = (flags & mask) | (priv->config_flags & ~mask);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_ip6_config_set_dns_priority (NMIP6Config *self, int priority)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -128,6 +128,11 @@ gboolean nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboole
|
|||
const NMPObject *nm_ip6_config_best_default_route_get (const NMIP6Config *self);
|
||||
const NMPObject *_nm_ip6_config_best_default_route_find (const NMIP6Config *self);
|
||||
|
||||
enum _NMIPConfigFlags;
|
||||
|
||||
void nm_ip6_config_set_config_flags (NMIP6Config *self, enum _NMIPConfigFlags flags, enum _NMIPConfigFlags mask);
|
||||
enum _NMIPConfigFlags nm_ip6_config_get_config_flags (const NMIP6Config *self);
|
||||
|
||||
const NMDedupMultiHeadEntry *nm_ip6_config_lookup_addresses (const NMIP6Config *self);
|
||||
void nm_ip6_config_reset_addresses (NMIP6Config *self);
|
||||
void nm_ip6_config_add_address (NMIP6Config *self, const NMPlatformIP6Address *address);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue