From 2ab87642f6ba2a4d24dd079242a1e1330b70b7bd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 4 Mar 2021 10:35:06 +0100 Subject: [PATCH] glib-aux: move NMLinkType to "libnm-glib-aux/nm-shared-utils.h" It is a bit odd to do this, because usually libnm-glib-aux is not about network related stuff. But that is not true entirely, because it also contains NMIPAddr and other related helper funcitons. NMLinkType is only a plain enum, there is no logic beyond it. As such, I think it's acceptable to move it here. There reason to do this, is that I want to move NMUtilsIPv6IfaceId and nm_utils_get_ipv6_interface_identifier() out of src/core/, and since that API is also trival helpers without complex state, it fits to libnm-glib-aux. As such, we will need also NMLinkType there. --- src/core/nm-types.h | 77 --------------------------- src/libnm-glib-aux/nm-shared-utils.h | 79 ++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 77 deletions(-) diff --git a/src/core/nm-types.h b/src/core/nm-types.h index ab2314594d..882de865e5 100644 --- a/src/core/nm-types.h +++ b/src/core/nm-types.h @@ -88,83 +88,6 @@ typedef struct _NMPlatformIP6Route NMPlatformIP6Route; typedef struct _NMPlatformLink NMPlatformLink; typedef struct _NMPObject NMPObject; -typedef enum { - - /* No type, used as error value */ - NM_LINK_TYPE_NONE, - - NM_LINK_TYPE_UNKNOWN, - - NM_LINK_TYPE_ANY, - -#define _NM_LINK_TYPE_REAL_FIRST NM_LINK_TYPE_ETHERNET - -/* Hardware types */ -#define _NM_LINK_TYPE_HW_FIRST NM_LINK_TYPE_ETHERNET - NM_LINK_TYPE_ETHERNET, - NM_LINK_TYPE_INFINIBAND, - NM_LINK_TYPE_OLPC_MESH, - NM_LINK_TYPE_WIFI, - NM_LINK_TYPE_WWAN_NET, /* WWAN kernel netdevice */ - NM_LINK_TYPE_WIMAX, - NM_LINK_TYPE_WPAN, - NM_LINK_TYPE_6LOWPAN, - NM_LINK_TYPE_WIFI_P2P, -#define _NM_LINK_TYPE_HW_LAST NM_LINK_TYPE_WIFI_P2P - -/* Software types */ -#define _NM_LINK_TYPE_SW_FIRST NM_LINK_TYPE_BNEP - NM_LINK_TYPE_BNEP, /* Bluetooth Ethernet emulation */ - NM_LINK_TYPE_DUMMY, - NM_LINK_TYPE_GRE, - NM_LINK_TYPE_GRETAP, - NM_LINK_TYPE_IFB, - NM_LINK_TYPE_IP6TNL, - NM_LINK_TYPE_IP6GRE, - NM_LINK_TYPE_IP6GRETAP, - NM_LINK_TYPE_IPIP, - NM_LINK_TYPE_LOOPBACK, - NM_LINK_TYPE_MACSEC, - NM_LINK_TYPE_MACVLAN, - NM_LINK_TYPE_MACVTAP, - NM_LINK_TYPE_OPENVSWITCH, - NM_LINK_TYPE_PPP, - NM_LINK_TYPE_SIT, - NM_LINK_TYPE_TUN, - NM_LINK_TYPE_VETH, - NM_LINK_TYPE_VLAN, - NM_LINK_TYPE_VRF, - NM_LINK_TYPE_VXLAN, - NM_LINK_TYPE_WIREGUARD, -#define _NM_LINK_TYPE_SW_LAST NM_LINK_TYPE_WIREGUARD - -/* Software types with slaves */ -#define _NM_LINK_TYPE_SW_MASTER_FIRST NM_LINK_TYPE_BRIDGE - NM_LINK_TYPE_BRIDGE, - NM_LINK_TYPE_BOND, - NM_LINK_TYPE_TEAM, -#define _NM_LINK_TYPE_SW_MASTER_LAST NM_LINK_TYPE_TEAM - -#define _NM_LINK_TYPE_REAL_LAST NM_LINK_TYPE_TEAM - -#define _NM_LINK_TYPE_REAL_NUM ((int) (_NM_LINK_TYPE_REAL_LAST - _NM_LINK_TYPE_REAL_FIRST + 1)) - -} NMLinkType; - -static inline gboolean -nm_link_type_is_software(NMLinkType link_type) -{ - G_STATIC_ASSERT(_NM_LINK_TYPE_SW_LAST + 1 == _NM_LINK_TYPE_SW_MASTER_FIRST); - - return link_type >= _NM_LINK_TYPE_SW_FIRST && link_type <= _NM_LINK_TYPE_SW_MASTER_LAST; -} - -static inline gboolean -nm_link_type_supports_slaves(NMLinkType link_type) -{ - return link_type >= _NM_LINK_TYPE_SW_MASTER_FIRST && link_type <= _NM_LINK_TYPE_SW_MASTER_LAST; -} - typedef enum { NMP_OBJECT_TYPE_UNKNOWN, NMP_OBJECT_TYPE_LINK, diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index bededbdfc6..48a2b50e2d 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -95,6 +95,85 @@ G_STATIC_ASSERT(sizeof(int) == sizeof(gint32)); /*****************************************************************************/ +typedef enum { + + /* No type, used as error value */ + NM_LINK_TYPE_NONE, + + NM_LINK_TYPE_UNKNOWN, + + NM_LINK_TYPE_ANY, + +#define _NM_LINK_TYPE_REAL_FIRST NM_LINK_TYPE_ETHERNET + +/* Hardware types */ +#define _NM_LINK_TYPE_HW_FIRST NM_LINK_TYPE_ETHERNET + NM_LINK_TYPE_ETHERNET, + NM_LINK_TYPE_INFINIBAND, + NM_LINK_TYPE_OLPC_MESH, + NM_LINK_TYPE_WIFI, + NM_LINK_TYPE_WWAN_NET, /* WWAN kernel netdevice */ + NM_LINK_TYPE_WIMAX, + NM_LINK_TYPE_WPAN, + NM_LINK_TYPE_6LOWPAN, + NM_LINK_TYPE_WIFI_P2P, +#define _NM_LINK_TYPE_HW_LAST NM_LINK_TYPE_WIFI_P2P + +/* Software types */ +#define _NM_LINK_TYPE_SW_FIRST NM_LINK_TYPE_BNEP + NM_LINK_TYPE_BNEP, /* Bluetooth Ethernet emulation */ + NM_LINK_TYPE_DUMMY, + NM_LINK_TYPE_GRE, + NM_LINK_TYPE_GRETAP, + NM_LINK_TYPE_IFB, + NM_LINK_TYPE_IP6TNL, + NM_LINK_TYPE_IP6GRE, + NM_LINK_TYPE_IP6GRETAP, + NM_LINK_TYPE_IPIP, + NM_LINK_TYPE_LOOPBACK, + NM_LINK_TYPE_MACSEC, + NM_LINK_TYPE_MACVLAN, + NM_LINK_TYPE_MACVTAP, + NM_LINK_TYPE_OPENVSWITCH, + NM_LINK_TYPE_PPP, + NM_LINK_TYPE_SIT, + NM_LINK_TYPE_TUN, + NM_LINK_TYPE_VETH, + NM_LINK_TYPE_VLAN, + NM_LINK_TYPE_VRF, + NM_LINK_TYPE_VXLAN, + NM_LINK_TYPE_WIREGUARD, +#define _NM_LINK_TYPE_SW_LAST NM_LINK_TYPE_WIREGUARD + +/* Software types with slaves */ +#define _NM_LINK_TYPE_SW_MASTER_FIRST NM_LINK_TYPE_BRIDGE + NM_LINK_TYPE_BRIDGE, + NM_LINK_TYPE_BOND, + NM_LINK_TYPE_TEAM, +#define _NM_LINK_TYPE_SW_MASTER_LAST NM_LINK_TYPE_TEAM + +#define _NM_LINK_TYPE_REAL_LAST NM_LINK_TYPE_TEAM + +#define _NM_LINK_TYPE_REAL_NUM ((int) (_NM_LINK_TYPE_REAL_LAST - _NM_LINK_TYPE_REAL_FIRST + 1)) + +} NMLinkType; + +static inline gboolean +nm_link_type_is_software(NMLinkType link_type) +{ + G_STATIC_ASSERT(_NM_LINK_TYPE_SW_LAST + 1 == _NM_LINK_TYPE_SW_MASTER_FIRST); + + return link_type >= _NM_LINK_TYPE_SW_FIRST && link_type <= _NM_LINK_TYPE_SW_MASTER_LAST; +} + +static inline gboolean +nm_link_type_supports_slaves(NMLinkType link_type) +{ + return link_type >= _NM_LINK_TYPE_SW_MASTER_FIRST && link_type <= _NM_LINK_TYPE_SW_MASTER_LAST; +} + +/*****************************************************************************/ + typedef struct { guint8 ether_addr_octet[6 /*ETH_ALEN*/]; } NMEtherAddr;