mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-01 09:08:05 +02:00
libnm-base: add internal _NMSettingWirelessWakeOnWLan type
NMSettingWirelessWakeOnWLan is public API of libnm/libnm-core in "src/libnm-core-public/" We want that libnm-platform is independet of libnm-core to keep the dependencies smaller and code better separated. Hence we cannot use that enum there. Duplicate NMSettingWirelessWakeOnWLan as _NMSettingWirelessWakeOnWLan in libnm-base.
This commit is contained in:
parent
c61d869646
commit
096ee5ed6e
3 changed files with 86 additions and 2 deletions
|
|
@ -153,6 +153,7 @@ nm_ethtool_id_is_ring(NMEthtoolID id)
|
|||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
/* Mirrors libnm's NMSettingWiredWakeOnLan */
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_NONE = 0,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_PHY = 0x2,
|
||||
_NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST = 0x4,
|
||||
|
|
@ -168,6 +169,27 @@ typedef enum {
|
|||
_NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS = 0x8001,
|
||||
} _NMSettingWiredWakeOnLan;
|
||||
|
||||
typedef enum {
|
||||
/* Mirrors libnm's NMSettingWirelessWakeOnWLan */
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE = 0,
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY = 0x2,
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT = 0x4,
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC = 0x8,
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE = 0x10,
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST = 0x20,
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE = 0x40,
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE = 0x80,
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP = 0x100,
|
||||
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL = 0x1FE,
|
||||
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT = 0x1,
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE = 0x8000,
|
||||
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS =
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT | _NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE,
|
||||
} _NMSettingWirelessWakeOnWLan;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
|
|
|
|||
|
|
@ -156,6 +156,60 @@ test_wired_wake_on_lan_enum(void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_wireless_wake_on_wlan_enum(void)
|
||||
{
|
||||
nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL;
|
||||
gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL);
|
||||
guint i;
|
||||
|
||||
G_STATIC_ASSERT_EXPR(sizeof(NMSettingWirelessWakeOnWLan)
|
||||
== sizeof(_NMSettingWirelessWakeOnWLan));
|
||||
G_STATIC_ASSERT_EXPR(sizeof(NMSettingWirelessWakeOnWLan) < sizeof(gint64));
|
||||
|
||||
G_STATIC_ASSERT_EXPR(sizeof(NMSettingWirelessWakeOnWLan) < sizeof(gint64));
|
||||
g_assert((((gint64)((NMSettingWirelessWakeOnWLan) -1)) < 0)
|
||||
== (((gint64)((_NMSettingWirelessWakeOnWLan) -1)) < 0));
|
||||
|
||||
#define _E(n) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
G_STATIC_ASSERT_EXPR(n == (gint64) _##n); \
|
||||
G_STATIC_ASSERT_EXPR(_##n == (gint64) n); \
|
||||
g_assert(_##n == _NM_SETTING_WIRELESS_WAKE_ON_WLAN_CAST(n)); \
|
||||
if (!g_hash_table_add(vals, GUINT_TO_POINTER(n))) \
|
||||
g_assert_not_reached(); \
|
||||
} \
|
||||
G_STMT_END
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE);
|
||||
_E(NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS);
|
||||
#undef _E
|
||||
|
||||
flags_class = G_FLAGS_CLASS(g_type_class_ref(NM_TYPE_SETTING_WIRELESS_WAKE_ON_WLAN));
|
||||
for (i = 0; i < flags_class->n_values; i++) {
|
||||
const GFlagsValue *value = &flags_class->values[i];
|
||||
|
||||
if (!g_hash_table_contains(vals, GUINT_TO_POINTER(value->value))) {
|
||||
g_error("The enum value %s from NMSettingWirelessWakeOnWLan is not checked for "
|
||||
"_NMSettingWirelessWakeOnWLan",
|
||||
value->value_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _nm_packed {
|
||||
int v0;
|
||||
char v1;
|
||||
|
|
@ -10326,6 +10380,8 @@ main(int argc, char **argv)
|
|||
|
||||
g_test_add_func("/core/general/test_nm_ascii_spaces", test_nm_ascii_spaces);
|
||||
g_test_add_func("/core/general/test_wired_wake_on_lan_enum", test_wired_wake_on_lan_enum);
|
||||
g_test_add_func("/core/general/test_wireless_wake_on_wlan_enum",
|
||||
test_wireless_wake_on_wlan_enum);
|
||||
g_test_add_func("/core/general/test_nm_hash", test_nm_hash);
|
||||
g_test_add_func("/core/general/test_nm_g_slice_free_fcn", test_nm_g_slice_free_fcn);
|
||||
g_test_add_func("/core/general/test_c_list_sort", test_c_list_sort);
|
||||
|
|
|
|||
|
|
@ -222,12 +222,18 @@ _NM_SETTING_WIRED_WAKE_ON_LAN_CAST(NMSettingWiredWakeOnLan v)
|
|||
/* _NMSettingWiredWakeOnLan and NMSettingWiredWakeOnLan enums are really
|
||||
* the same.
|
||||
*
|
||||
* The former is used by nm-platform (which should have no libnm-core dependency),
|
||||
* the latter is used by libnm-core. A unit test ensures they are exactly the same,
|
||||
* The former is used by libnm-platform (which should have no libnm-core* dependency),
|
||||
* the latter is public API in libnm-core-public. A unit test ensures they are exactly the same,
|
||||
* so we can just cast them. */
|
||||
return (_NMSettingWiredWakeOnLan) v;
|
||||
}
|
||||
|
||||
static inline _NMSettingWirelessWakeOnWLan
|
||||
_NM_SETTING_WIRELESS_WAKE_ON_WLAN_CAST(NMSettingWirelessWakeOnWLan v)
|
||||
{
|
||||
return (_NMSettingWirelessWakeOnWLan) v;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline NMTernary
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue