mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 21:38:06 +02:00
l3cfg: add flags for NML3ConfigData
Add a flags parameter. That is useful to bundle multiple simple boolean properties, without need to implement individual accessors.
This commit is contained in:
parent
d9547e8452
commit
99f096577c
2 changed files with 57 additions and 0 deletions
|
|
@ -95,6 +95,8 @@ struct _NML3ConfigData {
|
|||
|
||||
int ref_count;
|
||||
|
||||
NML3ConfigDatFlags flags;
|
||||
|
||||
bool is_sealed:1;
|
||||
};
|
||||
|
||||
|
|
@ -272,6 +274,7 @@ nm_l3_config_data_new (NMDedupMultiIndex *multi_idx,
|
|||
.multi_idx = nm_dedup_multi_index_ref (multi_idx),
|
||||
.mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT,
|
||||
.llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT,
|
||||
.flags = NM_L3_CONFIG_DAT_FLAGS_NONE,
|
||||
};
|
||||
|
||||
_idx_type_init (&self->idx_addresses_4, NMP_OBJECT_TYPE_IP4_ADDRESS);
|
||||
|
|
@ -392,6 +395,8 @@ nm_l3_config_data_lookup_objs (const NML3ConfigData *self, NMPObjectType obj_typ
|
|||
return nm_dedup_multi_index_lookup_head (self->multi_idx, &idx->parent, NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int
|
||||
nm_l3_config_data_get_ifindex (const NML3ConfigData *self)
|
||||
{
|
||||
|
|
@ -402,6 +407,28 @@ nm_l3_config_data_get_ifindex (const NML3ConfigData *self)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NML3ConfigDatFlags
|
||||
nm_l3_config_data_get_flags (const NML3ConfigData *self)
|
||||
{
|
||||
nm_assert (NM_IS_L3_CONFIG_DATA (self, TRUE));
|
||||
|
||||
return self->flags;
|
||||
}
|
||||
|
||||
void
|
||||
nm_l3_config_data_set_flags_full (NML3ConfigData *self,
|
||||
NML3ConfigDatFlags flags,
|
||||
NML3ConfigDatFlags mask)
|
||||
{
|
||||
nm_assert (NM_IS_L3_CONFIG_DATA (self, FALSE));
|
||||
nm_assert (!NM_FLAGS_ANY (flags, ~mask));
|
||||
|
||||
self->flags = (self->flags & ~mask)
|
||||
| (flags & mask);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
_l3_config_data_add_obj (NMDedupMultiIndex *multi_idx,
|
||||
DedupMultiIdxType *idx_type,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,14 @@
|
|||
#include "nm-setting-ip6-config.h"
|
||||
#include "platform/nm-platform.h"
|
||||
|
||||
typedef enum {
|
||||
NM_L3_CONFIG_DAT_FLAGS_NONE = 0,
|
||||
|
||||
/* if set, then the merge flag NM_L3_CONFIG_MERGE_FLAGS_NO_DEFAULT_ROUTES gets
|
||||
* ignored during merge. */
|
||||
NM_L3_CONFIG_DAT_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES = (1ull << 0),
|
||||
} NML3ConfigDatFlags;
|
||||
|
||||
typedef struct _NML3ConfigData NML3ConfigData;
|
||||
|
||||
NML3ConfigData *nm_l3_config_data_new (NMDedupMultiIndex *multi_idx,
|
||||
|
|
@ -98,6 +106,28 @@ int nm_l3_config_data_get_ifindex (const NML3ConfigData *self);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NML3ConfigDatFlags nm_l3_config_data_get_flags (const NML3ConfigData *self);
|
||||
|
||||
void nm_l3_config_data_set_flags_full (NML3ConfigData *self,
|
||||
NML3ConfigDatFlags flags,
|
||||
NML3ConfigDatFlags mask);
|
||||
|
||||
static inline void
|
||||
nm_l3_config_data_set_flags (NML3ConfigData *self,
|
||||
NML3ConfigDatFlags flags)
|
||||
{
|
||||
nm_l3_config_data_set_flags_full (self, flags, flags);
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_l3_config_data_unset_flags (NML3ConfigData *self,
|
||||
NML3ConfigDatFlags flags)
|
||||
{
|
||||
nm_l3_config_data_set_flags_full (self, NM_L3_CONFIG_DAT_FLAGS_NONE, flags);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_l3_config_data_add_address (NML3ConfigData *self,
|
||||
int addr_family,
|
||||
const NMPObject *obj_new,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue