platform: merge branch 'th/platform-move'

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/769
This commit is contained in:
Thomas Haller 2021-03-05 11:29:09 +01:00
commit 7ad2b8f20a
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
145 changed files with 2169 additions and 1852 deletions

View file

@ -571,15 +571,42 @@ src_libnm_platform_libnm_platform_la_CPPFLAGS = \
$(NULL)
src_libnm_platform_libnm_platform_la_SOURCES = \
\
src/linux-headers/nl802154.h \
\
src/libnm-platform/nm-linux-platform.c \
src/libnm-platform/nm-linux-platform.h \
src/libnm-platform/nm-netlink.c \
src/libnm-platform/nm-netlink.h \
src/libnm-platform/nm-platform-private.h \
src/libnm-platform/nm-platform-utils.c \
src/libnm-platform/nm-platform-utils.h \
src/libnm-platform/nm-platform.c \
src/libnm-platform/nm-platform.h \
src/libnm-platform/nmp-base.h \
src/libnm-platform/nmp-netns.c \
src/libnm-platform/nmp-netns.h \
src/libnm-platform/nmp-object.c \
src/libnm-platform/nmp-object.h \
src/libnm-platform/nmp-rules-manager.c \
src/libnm-platform/nmp-rules-manager.h \
src/libnm-platform/wifi/nm-wifi-utils-nl80211.c \
src/libnm-platform/wifi/nm-wifi-utils-nl80211.h \
src/libnm-platform/wifi/nm-wifi-utils-private.h \
src/libnm-platform/wifi/nm-wifi-utils.c \
src/libnm-platform/wifi/nm-wifi-utils.h \
src/libnm-platform/wpan/nm-wpan-utils.c \
src/libnm-platform/wpan/nm-wpan-utils.h \
\
$(NULL)
if WITH_WEXT
src_libnm_platform_libnm_platform_la_SOURCES += \
src/libnm-platform/wifi/nm-wifi-utils-wext.c \
src/libnm-platform/wifi/nm-wifi-utils-wext.h \
$(NULL)
endif
src_libnm_platform_libnm_platform_la_LDFLAGS = \
$(CODE_COVERAGE_LDFLAGS) \
$(SANITIZER_LIB_LDFLAGS) \
@ -1201,7 +1228,6 @@ src_libnm_core_impl_lib_h_priv = \
src/libnm-core-impl/nm-team-utils.h \
src/libnm-core-impl/nm-utils-private.h \
src/libnm-core-intern/nm-core-internal.h \
src/libnm-core-intern/nm-core-types-internal.h \
src/libnm-core-intern/nm-keyfile-internal.h \
src/libnm-core-intern/nm-keyfile-utils.h \
src/libnm-core-intern/nm-meta-setting-base-impl.h \
@ -2310,23 +2336,6 @@ src_core_libNetworkManagerBase_la_SOURCES = \
src/core/NetworkManagerUtils.c \
src/core/NetworkManagerUtils.h \
\
src/core/platform/nmp-object.c \
src/core/platform/nmp-object.h \
src/core/platform/nm-platform.c \
src/core/platform/nm-platform.h \
src/core/platform/nm-platform-private.h \
src/core/platform/nm-linux-platform.c \
src/core/platform/nm-linux-platform.h \
src/core/platform/nmp-rules-manager.c \
src/core/platform/nmp-rules-manager.h \
src/core/platform/wifi/nm-wifi-utils-nl80211.c \
src/core/platform/wifi/nm-wifi-utils-nl80211.h \
src/core/platform/wifi/nm-wifi-utils-private.h \
src/core/platform/wifi/nm-wifi-utils.c \
src/core/platform/wifi/nm-wifi-utils.h \
src/core/platform/wpan/nm-wpan-utils.c \
src/core/platform/wpan/nm-wpan-utils.h \
\
src/core/ndisc/nm-lndp-ndisc.c \
src/core/ndisc/nm-lndp-ndisc.h \
src/core/ndisc/nm-ndisc.c \
@ -2369,12 +2378,6 @@ src_core_libNetworkManagerBase_la_SOURCES = \
\
$(NULL)
if WITH_WEXT
src_core_libNetworkManagerBase_la_SOURCES += \
src/core/platform/wifi/nm-wifi-utils-wext.c \
src/core/platform/wifi/nm-wifi-utils-wext.h
endif
src_core_libNetworkManagerBase_la_LIBADD = \
$(GLIB_LIBS) \
$(LIBUDEV_LIBS) \
@ -2382,9 +2385,6 @@ src_core_libNetworkManagerBase_la_LIBADD = \
$(src_core_libNetworkManagerBase_la_OBJECTS): $(src_libnm_core_public_mkenums_h)
EXTRA_DIST += \
src/core/platform/linux/nl802154.h
###############################################################################
src_core_libNetworkManager_la_CPPFLAGS = $(src_core_cppflags)

View file

@ -41,7 +41,6 @@ IGNORE_HFILES= \
common.h \
nm-core-internal.h \
nm-core-tests-enum-types.h \
nm-core-types-internal.h \
nm-crypto-impl.h \
nm-crypto.h \
nm-dbus-helpers.h \

View file

@ -4,7 +4,6 @@ private_headers = [
'common.h',
'nm-core-internal.h',
'nm-core-tests-enum-types.h',
'nm-core-types-internal.h',
'nm-crypto-impl.h',
'nm-crypto.h',
'nm-dbus-helpers.h',

View file

@ -20,9 +20,10 @@
#include "nm-setting-ip4-config.h"
#include "nm-setting-ip6-config.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nmp-object.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nm-linux-platform.h"
#include "nm-auth-utils.h"
#include "libnm-systemd-shared/nm-sd-utils-shared.h"
@ -1829,3 +1830,63 @@ nm_utils_share_rules_add_all_rules(NMUtilsShareRules *self,
"INPUT --in-interface %s --protocol tcp --destination-port 53 --jump ACCEPT",
ip_iface);
}
/*****************************************************************************/
/* Singleton NMPlatform subclass instance and cached class object */
NM_DEFINE_SINGLETON_INSTANCE(NMPlatform);
NM_DEFINE_SINGLETON_REGISTER(NMPlatform);
/**
* nm_platform_setup:
* @instance: the #NMPlatform instance
*
* Failing to set up #NMPlatform singleton results in a fatal error,
* as well as trying to initialize it multiple times without freeing
* it.
*
* NetworkManager will typically use only one platform object during
* its run. Test programs might want to switch platform implementations,
* though.
*/
void
nm_platform_setup(NMPlatform *instance)
{
g_return_if_fail(NM_IS_PLATFORM(instance));
g_return_if_fail(!singleton_instance);
singleton_instance = instance;
nm_singleton_instance_register();
nm_log_dbg(LOGD_CORE,
"setup %s singleton (" NM_HASH_OBFUSCATE_PTR_FMT ")",
"NMPlatform",
NM_HASH_OBFUSCATE_PTR(instance));
}
/**
* nm_platform_get:
* @self: platform instance
*
* Retrieve #NMPlatform singleton. Use this whenever you want to connect to
* #NMPlatform signals. It is an error to call it before nm_platform_setup().
*
* Returns: (transfer none): The #NMPlatform singleton reference.
*/
NMPlatform *
nm_platform_get()
{
g_assert(singleton_instance);
return singleton_instance;
}
/*****************************************************************************/
void
nm_linux_platform_setup(void)
{
nm_platform_setup(nm_linux_platform_new(FALSE, FALSE));
}

View file

@ -11,7 +11,7 @@
#include "libnm-glib-aux/nm-dedup-multi.h"
#include "nm-setting-ip-config.h"
#include "nm-setting-ip6-config.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
/*****************************************************************************/
@ -251,4 +251,13 @@ void nm_utils_share_rules_apply(NMUtilsShareRules *self, gboolean shared);
/*****************************************************************************/
void nm_platform_setup(NMPlatform *instance);
NMPlatform *nm_platform_get(void);
#define NM_PLATFORM_GET (nm_platform_get())
void nm_linux_platform_setup(void);
/*****************************************************************************/
#endif /* __NETWORKMANAGER_UTILS_H__ */

View file

@ -11,7 +11,7 @@
#include "nm-setting-adsl.h"
#include "nm-device-adsl.h"
#include "devices/nm-device-factory.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-udev-aux/nm-udev-utils.h"
/*****************************************************************************/

View file

@ -17,7 +17,7 @@
#include "nm-ip4-config.h"
#include "devices/nm-device-private.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "ppp/nm-ppp-manager-call.h"
#include "ppp/nm-ppp-status.h"
#include "nm-setting-adsl.h"

View file

@ -24,7 +24,7 @@
#include "nm-manager.h"
#include "nm-bluez5-dun.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-std-aux/nm-dbus-compat.h"
/*****************************************************************************/

View file

@ -26,7 +26,7 @@
#include "nm-utils.h"
#include "nm-bt-error.h"
#include "nm-ip4-config.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "devices/wwan/nm-modem-manager.h"
#include "devices/wwan/nm-modem.h"

View file

@ -12,7 +12,7 @@
#include <sys/wait.h>
#include <linux/if_ether.h>
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
#include "n-acd/src/n-acd.h"

View file

@ -9,7 +9,7 @@
#include "nm-device-private.h"
#include "settings/nm-settings.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "nm-setting-6lowpan.h"
#include "nm-utils.h"

View file

@ -12,7 +12,7 @@
#include "NetworkManagerUtils.h"
#include "nm-device-private.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "nm-ip4-config.h"

View file

@ -12,7 +12,7 @@
#include "NetworkManagerUtils.h"
#include "nm-device-private.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "libnm-core-intern/nm-core-internal.h"
@ -1033,7 +1033,7 @@ create_and_realize(NMDevice * device,
const char * iface = nm_device_get_iface(device);
const char * hwaddr;
gs_free char * hwaddr_cloned = NULL;
guint8 mac_address[NM_UTILS_HWADDR_LEN_MAX];
guint8 mac_address[_NM_UTILS_HWADDR_LEN_MAX];
NMPlatformLnkBridge props;
int r;
guint32 mtu = 0;

View file

@ -13,7 +13,7 @@
#include "nm-act-request.h"
#include "nm-device-private.h"
#include "nm-ip4-config.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "nm-setting-dummy.h"
#include "libnm-core-intern/nm-core-internal.h"

View file

@ -24,7 +24,7 @@
#include "ppp/nm-ppp-manager.h"
#include "ppp/nm-ppp-manager-call.h"
#include "ppp/nm-ppp-status.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nm-platform-utils.h"
#include "nm-dcb.h"
#include "settings/nm-settings-connection.h"

View file

@ -11,7 +11,7 @@
#include <sys/stat.h>
#include <gmodule.h>
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-utils.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "nm-setting-bluetooth.h"

View file

@ -8,7 +8,7 @@
#include "nm-device-generic.h"
#include "nm-device-private.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-core-intern/nm-core-internal.h"
/*****************************************************************************/

View file

@ -14,7 +14,7 @@
#include "nm-device-private.h"
#include "nm-act-request.h"
#include "nm-ip4-config.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "libnm-core-intern/nm-core-internal.h"

View file

@ -16,7 +16,7 @@
#include "nm-device-private.h"
#include "nm-manager.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "settings/nm-settings.h"

View file

@ -11,7 +11,7 @@
#include "nm-act-request.h"
#include "nm-device-private.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "nm-manager.h"
#include "nm-setting-macsec.h"

View file

@ -13,7 +13,7 @@
#include "settings/nm-settings.h"
#include "nm-act-request.h"
#include "nm-manager.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "nm-setting-macvlan.h"
#include "nm-setting-wired.h"

View file

@ -13,7 +13,7 @@
#include "nm-device-private.h"
#include "nm-manager.h"
#include "nm-setting-pppoe.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "ppp/nm-ppp-manager.h"
#include "ppp/nm-ppp-manager-call.h"
#include "ppp/nm-ppp-status.h"

View file

@ -14,7 +14,7 @@
#include "nm-act-request.h"
#include "nm-device-private.h"
#include "nm-ip4-config.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "nm-setting-tun.h"
#include "libnm-core-intern/nm-core-internal.h"

View file

@ -11,7 +11,7 @@
#include "nm-device-veth.h"
#include "nm-device-private.h"
#include "nm-manager.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "nm-setting-veth.h"

View file

@ -16,11 +16,12 @@
#include "settings/nm-settings.h"
#include "nm-act-request.h"
#include "nm-ip4-config.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "nm-manager.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nmp-object.h"
#include "libnm-platform/nm-platform-utils.h"
#define _NMLOG_DEVICE_TYPE NMDeviceVlan
#include "nm-device-logging.h"
@ -436,7 +437,7 @@ update_connection(NMDevice *device, NMConnection *connection)
const NMPlatformLink *plink;
const NMPObject * polnk;
guint vlan_id;
guint vlan_flags;
_NMVlanFlags vlan_flags;
if (!s_vlan) {
s_vlan = (NMSettingVlan *) nm_setting_vlan_new();
@ -463,9 +464,9 @@ update_connection(NMDevice *device, NMConnection *connection)
if (polnk)
vlan_flags = polnk->lnk_vlan.flags;
else
vlan_flags = NM_VLAN_FLAG_REORDER_HEADERS;
if (vlan_flags != nm_setting_vlan_get_flags(s_vlan))
g_object_set(s_vlan, NM_SETTING_VLAN_FLAGS, (NMVlanFlags) vlan_flags, NULL);
vlan_flags = _NM_VLAN_FLAG_REORDER_HEADERS;
if (NM_VLAN_FLAGS_CAST(vlan_flags) != nm_setting_vlan_get_flags(s_vlan))
g_object_set(s_vlan, NM_SETTING_VLAN_FLAGS, NM_VLAN_FLAGS_CAST(vlan_flags), NULL);
if (polnk) {
_nm_setting_vlan_set_priorities(s_vlan,
@ -507,7 +508,7 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
nm_platform_link_vlan_change(nm_device_get_platform(device),
nm_device_get_ifindex(device),
NM_VLAN_FLAGS_ALL,
_NM_VLAN_FLAGS_ALL,
nm_setting_vlan_get_flags(s_vlan),
TRUE,
ingress_map,
@ -674,7 +675,7 @@ get_connection_iface(NMDeviceFactory *factory, NMConnection *connection, const c
* device, we create one for it using the VLAN ID and the parent
* interface's name.
*/
return nm_utils_new_vlan_name(parent_iface, nm_setting_vlan_get_id(s_vlan));
return nmp_utils_new_vlan_name(parent_iface, nm_setting_vlan_get_id(s_vlan));
}
NM_DEVICE_FACTORY_DEFINE_INTERNAL(

View file

@ -9,7 +9,7 @@
#include "nm-device-private.h"
#include "nm-manager.h"
#include "nm-setting-vrf.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "settings/nm-settings.h"
#define _NMLOG_DEVICE_TYPE NMDeviceVrf

View file

@ -9,7 +9,7 @@
#include "nm-device-private.h"
#include "nm-manager.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-utils.h"
#include "nm-device-factory.h"
#include "nm-setting-vxlan.h"

View file

@ -14,9 +14,9 @@
#include "libnm-core-intern/nm-core-internal.h"
#include "libnm-glib-aux/nm-secret-utils.h"
#include "nm-device-private.h"
#include "platform/nm-platform.h"
#include "platform/nmp-object.h"
#include "platform/nmp-rules-manager.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-object.h"
#include "libnm-platform/nmp-rules-manager.h"
#include "nm-device-factory.h"
#include "nm-active-connection.h"
#include "nm-act-request.h"

View file

@ -15,7 +15,7 @@
#include "nm-act-request.h"
#include "nm-device-private.h"
#include "nm-ip4-config.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-device-factory.h"
#include "nm-setting-wpan.h"
#include "libnm-core-intern/nm-core-internal.h"

View file

@ -35,10 +35,10 @@
#include "nm-l3-config-data.h"
#include "NetworkManagerUtils.h"
#include "nm-manager.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nm-platform-utils.h"
#include "platform/nmp-object.h"
#include "platform/nmp-rules-manager.h"
#include "libnm-platform/nmp-object.h"
#include "libnm-platform/nmp-rules-manager.h"
#include "ndisc/nm-ndisc.h"
#include "ndisc/nm-lndp-ndisc.h"
#include "dhcp/nm-dhcp-manager.h"
@ -1567,7 +1567,7 @@ _prop_get_ipvx_dhcp_iaid(NMDevice * self,
iaid = unaligned_read_be32(&pllink->l_address.data[pllink->l_address.len - 4]);
goto out_good;
} else if (nm_streq0(iaid_str, NM_IAID_PERM_MAC)) {
guint8 hwaddr_buf[NM_UTILS_HWADDR_LEN_MAX];
guint8 hwaddr_buf[_NM_UTILS_HWADDR_LEN_MAX];
const char *hwaddr_str;
gsize hwaddr_len;
@ -1729,7 +1729,7 @@ _prop_get_ipv4_dhcp_client_id(NMDevice *self, NMConnection *connection, GBytes *
gs_free char * client_id_default = NULL;
guint8 * client_id_buf;
const char * fail_reason;
guint8 hwaddr_bin_buf[NM_UTILS_HWADDR_LEN_MAX];
guint8 hwaddr_bin_buf[_NM_UTILS_HWADDR_LEN_MAX];
const guint8 * hwaddr_bin;
int arp_type;
gsize hwaddr_len;
@ -5216,11 +5216,11 @@ ndisc_set_router_config(NMNDisc *ndisc, NMDevice *self)
if (addr->plen != 64)
continue;
lifetime = nm_utils_lifetime_get(addr->timestamp,
addr->lifetime,
addr->preferred,
NM_NDISC_EXPIRY_BASE_TIMESTAMP / 1000,
&preferred);
lifetime = nmp_utils_lifetime_get(addr->timestamp,
addr->lifetime,
addr->preferred,
NM_NDISC_EXPIRY_BASE_TIMESTAMP / 1000,
&preferred);
if (!lifetime)
continue;
@ -11634,7 +11634,7 @@ share_init(NMDevice *self, GError **error)
}
for (i = 0; i < G_N_ELEMENTS(modules); i++)
nm_utils_modprobe(NULL, FALSE, modules[i], NULL);
nmp_utils_modprobe(NULL, FALSE, modules[i], NULL);
return TRUE;
}
@ -16821,7 +16821,7 @@ const char *
nm_device_get_hw_address(NMDevice *self)
{
NMDevicePrivate *priv;
char buf[NM_UTILS_HWADDR_LEN_MAX];
char buf[_NM_UTILS_HWADDR_LEN_MAX];
gsize l;
g_return_val_if_fail(NM_IS_DEVICE(self), NULL);
@ -16915,7 +16915,7 @@ void
nm_device_update_permanent_hw_address(NMDevice *self, gboolean force_freeze)
{
NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self);
guint8 buf[NM_UTILS_HWADDR_LEN_MAX];
guint8 buf[_NM_UTILS_HWADDR_LEN_MAX];
size_t len = 0;
gboolean success_read;
int ifindex;
@ -17033,7 +17033,7 @@ _hw_addr_set(NMDevice * self,
NMDevicePrivate *priv;
gboolean success = FALSE;
int r;
guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX];
guint8 addr_bytes[_NM_UTILS_HWADDR_LEN_MAX];
gsize addr_len;
gboolean was_taken_down = FALSE;
gboolean retry_down;
@ -18216,7 +18216,7 @@ constructor(GType type, guint n_construct_params, GObjectConstructParam *constru
}
if (priv->hw_addr_perm) {
guint8 buf[NM_UTILS_HWADDR_LEN_MAX];
guint8 buf[_NM_UTILS_HWADDR_LEN_MAX];
gsize l;
if (!_nm_utils_hwaddr_aton(priv->hw_addr_perm, buf, sizeof(buf), &l)) {

View file

@ -9,8 +9,11 @@
#include <net/ethernet.h>
#include "NetworkManagerUtils.h"
#include "libnm-core-public/nm-errors.h"
#include "libnm-glib-aux/nm-time-utils.h"
#include "libnm-std-aux/unaligned.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-glib-aux/nm-c-list.h"
#include "nm-utils.h"

View file

@ -10,7 +10,7 @@
#include "nm-device-ovs-interface.h"
#include "nm-device-ovs-port.h"
#include "nm-device-ovs-bridge.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "settings/nm-settings.h"
#include "devices/nm-device-factory.h"

View file

@ -18,7 +18,7 @@
#include "libnm-glib-aux/nm-jansson.h"
#include "NetworkManagerUtils.h"
#include "devices/nm-device-private.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-config.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "nm-dbus-manager.h"

View file

@ -10,7 +10,7 @@
#include "nm-manager.h"
#include "devices/nm-device-factory.h"
#include "nm-device-team.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-core-intern/nm-core-internal.h"
/*****************************************************************************/

View file

@ -55,7 +55,7 @@ typedef struct {
CList aps_lst_head;
NMWifiAP * current_ap;
GCancellable * cancellable;
NMDeviceWifiCapabilities capabilities;
_NMDeviceWifiCapabilities capabilities;
NMActRequestGetSecretsCallId *wifi_secrets_id;
guint periodic_scan_id;
guint periodic_update_id;
@ -265,7 +265,7 @@ ap_from_network(NMDeviceIwd *self,
.bss_path = bss_path,
.last_seen_msec = last_seen_msec,
.bssid_valid = TRUE,
.mode = NM_802_11_MODE_INFRA,
.mode = _NM_802_11_MODE_INFRA,
.rsn_flags = ap_security_flags_from_network_type(type),
.ssid = ssid,
.signal_percent = nm_wifi_utils_level_to_quality(signal / 100),
@ -801,7 +801,7 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError *
NMSettingWirelessSecurity *s_wireless_sec =
nm_connection_get_setting_wireless_security(connection);
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_AP)) {
if (!(priv->capabilities & _NM_WIFI_DEVICE_CAP_AP)) {
nm_utils_error_set_literal(error,
NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE,
"device does not support Access Point mode");
@ -819,7 +819,7 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError *
NMSettingWirelessSecurity *s_wireless_sec =
nm_connection_get_setting_wireless_security(connection);
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_ADHOC)) {
if (!(priv->capabilities & _NM_WIFI_DEVICE_CAP_ADHOC)) {
nm_utils_error_set_literal(error,
NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE,
"device does not support Ad-Hoc mode");
@ -2610,9 +2610,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
switch (prop_id) {
case PROP_MODE:
if (!priv->current_ap)
g_value_set_uint(value, NM_802_11_MODE_UNKNOWN);
g_value_set_uint(value, _NM_802_11_MODE_UNKNOWN);
else if (nm_wifi_ap_is_hotspot(priv->current_ap))
g_value_set_uint(value, NM_802_11_MODE_AP);
g_value_set_uint(value, _NM_802_11_MODE_AP);
else
g_value_set_uint(value, nm_wifi_ap_get_mode(priv->current_ap));
@ -3034,7 +3034,7 @@ nm_device_iwd_set_dbus_object(NMDeviceIwd *self, GDBusObject *object)
GVariantIter * iter;
const char * mode;
gboolean powered;
NMDeviceWifiCapabilities capabilities;
_NMDeviceWifiCapabilities capabilities;
if (!nm_g_object_ref_set(&priv->dbus_obj, object))
return;
@ -3096,14 +3096,14 @@ nm_device_iwd_set_dbus_object(NMDeviceIwd *self, GDBusObject *object)
goto error;
}
capabilities = NM_WIFI_DEVICE_CAP_CIPHER_CCMP | NM_WIFI_DEVICE_CAP_RSN;
capabilities = _NM_WIFI_DEVICE_CAP_CIPHER_CCMP | _NM_WIFI_DEVICE_CAP_RSN;
g_variant_get(value, "as", &iter);
while (g_variant_iter_next(iter, "&s", &mode)) {
if (nm_streq(mode, "ap"))
capabilities |= NM_WIFI_DEVICE_CAP_AP;
capabilities |= _NM_WIFI_DEVICE_CAP_AP;
else if (nm_streq(mode, "ad-hoc"))
capabilities |= NM_WIFI_DEVICE_CAP_ADHOC;
capabilities |= _NM_WIFI_DEVICE_CAP_ADHOC;
}
g_variant_iter_free(iter);
@ -3452,9 +3452,9 @@ nm_device_iwd_class_init(NMDeviceIwdClass *klass)
obj_properties[PROP_MODE] = g_param_spec_uint(NM_DEVICE_IWD_MODE,
"",
"",
NM_802_11_MODE_UNKNOWN,
NM_802_11_MODE_AP,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_UNKNOWN,
_NM_802_11_MODE_AP,
_NM_802_11_MODE_INFRA,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_BITRATE] = g_param_spec_uint(NM_DEVICE_IWD_BITRATE,
@ -3485,7 +3485,7 @@ nm_device_iwd_class_init(NMDeviceIwdClass *klass)
"",
0,
G_MAXUINT32,
NM_WIFI_DEVICE_CAP_NONE,
_NM_WIFI_DEVICE_CAP_NONE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_SCANNING] = g_param_spec_boolean(NM_DEVICE_IWD_SCANNING,

View file

@ -28,7 +28,7 @@
#include "nm-setting-connection.h"
#include "nm-setting-olpc-mesh.h"
#include "nm-manager.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#define _NMLOG_DEVICE_TYPE NMDeviceOlpcMesh
#include "devices/nm-device-logging.h"

View file

@ -23,8 +23,8 @@
#include "nm-setting-wifi-p2p.h"
#include "nm-utils.h"
#include "nm-wifi-p2p-peer.h"
#include "platform/nm-platform.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-object.h"
#include "settings/nm-settings.h"
#define _NMLOG_DEVICE_TYPE NMDeviceWifiP2P

View file

@ -33,7 +33,7 @@
#include "nm-setting-ip4-config.h"
#include "nm-ip4-config.h"
#include "nm-setting-ip6-config.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-auth-utils.h"
#include "settings/nm-settings-connection.h"
#include "settings/nm-settings.h"
@ -114,11 +114,11 @@ typedef struct {
guint wps_timeout_id;
guint sup_timeout_id; /* supplicant association timeout */
NMDeviceWifiCapabilities capabilities;
NMSettingWirelessWakeOnWLan wowlan_restore;
_NMDeviceWifiCapabilities capabilities;
_NMSettingWirelessWakeOnWLan wowlan_restore;
NMDeviceWifiP2P *p2p_device;
NM80211Mode mode;
_NM80211Mode mode;
guint32 failed_iface_count;
gint32 hw_addr_scan_expire;
@ -487,7 +487,7 @@ _scan_notify_allowed(NMDeviceWifi *self, NMTernary do_kickoff)
if (!c_list_is_empty(&priv->scanning_prohibited_lst_head)) {
/* something prohibits scanning. */
} else if (NM_IN_SET(priv->mode, NM_802_11_MODE_ADHOC, NM_802_11_MODE_AP)) {
} else if (NM_IN_SET(priv->mode, _NM_802_11_MODE_ADHOC, _NM_802_11_MODE_AP)) {
/* Don't scan when a an AP or Ad-Hoc connection is active as it will
* disrupt connected clients or peers. */
} else if (NM_IN_SET(state, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_FAILED)) {
@ -678,7 +678,7 @@ update_seen_bssids_cache(NMDeviceWifi *self, NMWifiAP *ap)
return;
/* Don't cache the BSSID for Ad-Hoc APs */
if (nm_wifi_ap_get_mode(ap) != NM_802_11_MODE_INFRA)
if (nm_wifi_ap_get_mode(ap) != _NM_802_11_MODE_INFRA)
return;
if (nm_device_get_state(NM_DEVICE(self)) == NM_DEVICE_STATE_ACTIVATED
@ -712,10 +712,11 @@ set_current_ap(NMDeviceWifi *self, NMWifiAP *new_ap, gboolean recheck_available_
priv->current_ap = NULL;
if (old_ap) {
NM80211Mode mode = nm_wifi_ap_get_mode(old_ap);
_NM80211Mode mode = nm_wifi_ap_get_mode(old_ap);
/* Remove any AP from the internal list if it was created by NM or isn't known to the supplicant */
if (NM_IN_SET(mode, NM_802_11_MODE_ADHOC, NM_802_11_MODE_AP) || nm_wifi_ap_get_fake(old_ap))
if (NM_IN_SET(mode, _NM_802_11_MODE_ADHOC, _NM_802_11_MODE_AP)
|| nm_wifi_ap_get_fake(old_ap))
ap_add_remove(self, FALSE, old_ap, recheck_available_connections);
g_object_unref(old_ap);
}
@ -750,7 +751,7 @@ periodic_update(NMDeviceWifi *self)
return;
}
if (priv->mode == NM_802_11_MODE_AP) {
if (priv->mode == _NM_802_11_MODE_AP) {
/* In AP mode we currently have nothing to do. */
return;
}
@ -845,14 +846,14 @@ remove_all_aps(NMDeviceWifi *self)
static gboolean
wake_on_wlan_restore(NMDeviceWifi *self)
{
NMDeviceWifiPrivate * priv = NM_DEVICE_WIFI_GET_PRIVATE(self);
NMSettingWirelessWakeOnWLan w;
NMDeviceWifiPrivate * priv = NM_DEVICE_WIFI_GET_PRIVATE(self);
_NMSettingWirelessWakeOnWLan w;
w = priv->wowlan_restore;
if (w == NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE)
if (w == _NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE)
return TRUE;
priv->wowlan_restore = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
priv->wowlan_restore = _NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
return nm_platform_wifi_set_wake_on_wlan(NM_PLATFORM_GET,
nm_device_get_ifindex(NM_DEVICE(self)),
w);
@ -937,14 +938,14 @@ deactivate(NMDevice *device)
* (usually older ones) don't scan well in adhoc mode.
*/
if (nm_platform_wifi_get_mode(nm_device_get_platform(device), ifindex)
!= NM_802_11_MODE_INFRA) {
!= _NM_802_11_MODE_INFRA) {
nm_device_take_down(NM_DEVICE(self), TRUE);
nm_platform_wifi_set_mode(nm_device_get_platform(device), ifindex, NM_802_11_MODE_INFRA);
nm_platform_wifi_set_mode(nm_device_get_platform(device), ifindex, _NM_802_11_MODE_INFRA);
nm_device_bring_up(NM_DEVICE(self), TRUE, NULL);
}
if (priv->mode != NM_802_11_MODE_INFRA) {
priv->mode = NM_802_11_MODE_INFRA;
if (priv->mode != _NM_802_11_MODE_INFRA) {
priv->mode = _NM_802_11_MODE_INFRA;
_notify(self, PROP_MODE);
}
@ -1010,14 +1011,14 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError *
/* Early exit if supplicant or device doesn't support requested mode */
mode = nm_setting_wireless_get_mode(s_wireless);
if (g_strcmp0(mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0) {
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_ADHOC)) {
if (!(priv->capabilities & _NM_WIFI_DEVICE_CAP_ADHOC)) {
nm_utils_error_set_literal(error,
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
"the device does not support Ad-Hoc networks");
return FALSE;
}
} else if (g_strcmp0(mode, NM_SETTING_WIRELESS_MODE_AP) == 0) {
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_AP)) {
if (!(priv->capabilities & _NM_WIFI_DEVICE_CAP_AP)) {
nm_utils_error_set_literal(error,
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
"the device does not support Access Point mode");
@ -1034,7 +1035,7 @@ check_connection_compatible(NMDevice *device, NMConnection *connection, GError *
}
}
} else if (g_strcmp0(mode, NM_SETTING_WIRELESS_MODE_MESH) == 0) {
if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_MESH)) {
if (!(priv->capabilities & _NM_WIFI_DEVICE_CAP_MESH)) {
nm_utils_error_set_literal(error,
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
"the device does not support Mesh mode");
@ -1822,7 +1823,7 @@ _scan_kickoff(NMDeviceWifi *self)
strv = g_new(char *, ssids->len + 1u);
for (i = 0; i < ssids->len; i++)
strv[i] = _nm_utils_ssid_to_string(ssids->pdata[i]);
strv[i] = _nm_utils_ssid_to_string_gbytes(ssids->pdata[i]);
strv[i] = NULL;
nm_assert(ssids->len > 0);
@ -1986,19 +1987,19 @@ supplicant_iface_bss_changed_cb(NMSupplicantInterface *iface,
/* Let the manager try to fill in the SSID from seen-bssids lists */
ssid = nm_wifi_ap_get_ssid(ap);
if (!ssid || _nm_utils_is_empty_ssid(ssid)) {
if (!ssid || _nm_utils_is_empty_ssid_gbytes(ssid)) {
/* Try to fill the SSID from the AP database */
try_fill_ssid_for_hidden_ap(self, ap);
ssid = nm_wifi_ap_get_ssid(ap);
if (ssid && !_nm_utils_is_empty_ssid(ssid)) {
if (ssid && !_nm_utils_is_empty_ssid_gbytes(ssid)) {
gs_free char *s = NULL;
/* Yay, matched it, no longer treat as hidden */
_LOGD(LOGD_WIFI,
"matched hidden AP %s => %s",
nm_wifi_ap_get_address(ap),
(s = _nm_utils_ssid_to_string(ssid)));
(s = _nm_utils_ssid_to_string_gbytes(ssid)));
} else {
/* Didn't have an entry for this AP in the database */
_LOGD(LOGD_WIFI, "failed to match hidden AP %s", nm_wifi_ap_get_address(ap));
@ -2481,9 +2482,9 @@ supplicant_iface_state(NMDeviceWifi * self,
_LOGI(LOGD_DEVICE | LOGD_WIFI,
"Activation: (wifi) Stage 2 of 5 (Device Configure) successful. %s %s",
priv->mode == NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot"
: "Connected to wireless network",
(ssid_str = _nm_utils_ssid_to_string(ssid)));
priv->mode == _NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot"
: "Connected to wireless network",
(ssid_str = _nm_utils_ssid_to_string_gbytes(ssid)));
nm_device_activate_schedule_stage3_ip_config_start(device);
} else if (devstate == NM_DEVICE_STATE_ACTIVATED)
periodic_update(self);
@ -2599,9 +2600,9 @@ supplicant_iface_notify_current_bss(NMSupplicantInterface *iface,
_LOGD(LOGD_WIFI,
"roamed from BSSID %s (%s) to %s (%s)",
old_bssid ?: "(none)",
(old_ssid_s = _nm_utils_ssid_to_string(old_ssid)),
(old_ssid_s = _nm_utils_ssid_to_string_gbytes(old_ssid)),
new_bssid ?: "(none)",
(new_ssid_s = _nm_utils_ssid_to_string(new_ssid)));
(new_ssid_s = _nm_utils_ssid_to_string_gbytes(new_ssid)));
if (new_bssid) {
/* The new AP could be in a different layer 3 network
@ -2790,21 +2791,21 @@ supplicant_connection_timeout_cb(gpointer user_data)
connection = nm_act_request_get_applied_connection(req);
g_assert(connection);
if (NM_IN_SET(priv->mode, NM_802_11_MODE_ADHOC, NM_802_11_MODE_MESH, NM_802_11_MODE_AP)) {
if (NM_IN_SET(priv->mode, _NM_802_11_MODE_ADHOC, _NM_802_11_MODE_MESH, _NM_802_11_MODE_AP)) {
/* In Ad-Hoc and AP modes there's nothing to check the encryption key
* (if any), so supplicant timeouts here are almost certainly the wifi
* driver being really stupid.
*/
_LOGW(LOGD_DEVICE | LOGD_WIFI,
"Activation: (wifi) %s network creation took too long, failing activation",
priv->mode == NM_802_11_MODE_ADHOC ? "Ad-Hoc" : "Hotspot");
priv->mode == _NM_802_11_MODE_ADHOC ? "Ad-Hoc" : "Hotspot");
nm_device_state_changed(device,
NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT);
return FALSE;
}
g_assert(priv->mode == NM_802_11_MODE_INFRA);
g_assert(priv->mode == _NM_802_11_MODE_INFRA);
if (priv->ssid_found && nm_connection_get_setting_wireless_security(connection)) {
guint64 timestamp = 0;
@ -2956,9 +2957,10 @@ error:
static gboolean
wake_on_wlan_enable(NMDeviceWifi *self)
{
NMDeviceWifiPrivate * priv = NM_DEVICE_WIFI_GET_PRIVATE(self);
NMSettingWirelessWakeOnWLan wowl;
NMSettingWireless * s_wireless;
NMDeviceWifiPrivate * priv = NM_DEVICE_WIFI_GET_PRIVATE(self);
NMSettingWirelessWakeOnWLan wowl;
_NMSettingWirelessWakeOnWLan wowl2;
NMSettingWireless * s_wireless;
s_wireless = nm_device_get_applied_setting(NM_DEVICE(self), NM_TYPE_SETTING_WIRELESS);
if (s_wireless) {
@ -2990,9 +2992,11 @@ wake_on_wlan_enable(NMDeviceWifi *self)
goto found;
wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
found:
if (wowl == NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE) {
priv->wowlan_restore = wowl;
wowl2 = _NM_SETTING_WIRELESS_WAKE_ON_WLAN_CAST(wowl);
if (wowl2 == _NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE) {
priv->wowlan_restore = wowl2;
return TRUE;
}
@ -3001,7 +3005,7 @@ found:
return nm_platform_wifi_set_wake_on_wlan(NM_PLATFORM_GET,
nm_device_get_ifindex(NM_DEVICE(self)),
wowl);
wowl2);
}
static NMActStageReturn
@ -3030,16 +3034,16 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
mode = nm_setting_wireless_get_mode(s_wireless);
if (g_strcmp0(mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0)
priv->mode = NM_802_11_MODE_INFRA;
priv->mode = _NM_802_11_MODE_INFRA;
else if (g_strcmp0(mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0)
priv->mode = NM_802_11_MODE_ADHOC;
priv->mode = _NM_802_11_MODE_ADHOC;
else if (g_strcmp0(mode, NM_SETTING_WIRELESS_MODE_AP) == 0) {
priv->mode = NM_802_11_MODE_AP;
priv->mode = _NM_802_11_MODE_AP;
/* Scanning not done in AP mode; clear the scan list */
remove_all_aps(self);
} else if (g_strcmp0(mode, NM_SETTING_WIRELESS_MODE_MESH) == 0)
priv->mode = NM_802_11_MODE_MESH;
priv->mode = _NM_802_11_MODE_MESH;
_notify(self, PROP_MODE);
/* expire the temporary MAC address used during scanning */
@ -3052,7 +3056,7 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
}
/* AP and Mesh modes never use a specific object or existing scanned AP */
if (!NM_IN_SET(priv->mode, NM_802_11_MODE_AP, NM_802_11_MODE_MESH)) {
if (!NM_IN_SET(priv->mode, _NM_802_11_MODE_AP, _NM_802_11_MODE_MESH)) {
ap_path = nm_active_connection_get_specific_object(NM_ACTIVE_CONNECTION(req));
ap = ap_path ? nm_wifi_ap_lookup_for_device(NM_DEVICE(self), ap_path) : NULL;
}
@ -3154,7 +3158,7 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason)
NMDeviceWifi * self = NM_DEVICE_WIFI(device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE(self);
gs_unref_object NMSupplicantConfig *config = NULL;
NM80211Mode ap_mode;
_NM80211Mode ap_mode;
NMActRequest * req;
NMWifiAP * ap;
NMConnection * connection;
@ -3221,10 +3225,11 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason)
* if the user didn't specify one and we didn't find an AP that matched
* the connection, just pick a frequency the device supports.
*/
if (NM_IN_SET(ap_mode, NM_802_11_MODE_ADHOC, NM_802_11_MODE_MESH) || nm_wifi_ap_is_hotspot(ap))
if (NM_IN_SET(ap_mode, _NM_802_11_MODE_ADHOC, _NM_802_11_MODE_MESH)
|| nm_wifi_ap_is_hotspot(ap))
ensure_hotspot_frequency(self, s_wireless, ap);
if (ap_mode == NM_802_11_MODE_INFRA)
if (ap_mode == _NM_802_11_MODE_INFRA)
set_powersave(device);
/* Build up the supplicant configuration */
@ -3341,7 +3346,7 @@ act_stage4_ip_config_timeout(NMDevice * device,
s_ip = nm_connection_get_setting_ip_config(connection, addr_family);
may_fail = nm_setting_ip_config_get_may_fail(s_ip);
if (priv->mode == NM_802_11_MODE_AP)
if (priv->mode == _NM_802_11_MODE_AP)
goto call_parent;
if (may_fail || !is_static_wep(connection)) {
@ -3694,8 +3699,8 @@ nm_device_wifi_init(NMDeviceWifi *self)
priv->scan_last_request_started_at_msec = G_MININT64;
priv->hidden_probe_scan_warn = TRUE;
priv->mode = NM_802_11_MODE_INFRA;
priv->wowlan_restore = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
priv->mode = _NM_802_11_MODE_INFRA;
priv->wowlan_restore = _NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
}
static void
@ -3706,7 +3711,7 @@ constructed(GObject *object)
G_OBJECT_CLASS(nm_device_wifi_parent_class)->constructed(object);
if (priv->capabilities & NM_WIFI_DEVICE_CAP_AP)
if (priv->capabilities & _NM_WIFI_DEVICE_CAP_AP)
_LOGI(LOGD_PLATFORM | LOGD_WIFI, "driver supports Access Point (AP) mode");
/* Connect to the supplicant manager */
@ -3714,7 +3719,7 @@ constructed(GObject *object)
}
NMDevice *
nm_device_wifi_new(const char *iface, NMDeviceWifiCapabilities capabilities)
nm_device_wifi_new(const char *iface, _NMDeviceWifiCapabilities capabilities)
{
return g_object_new(NM_TYPE_DEVICE_WIFI,
NM_DEVICE_IFACE,
@ -3822,9 +3827,9 @@ nm_device_wifi_class_init(NMDeviceWifiClass *klass)
obj_properties[PROP_MODE] = g_param_spec_uint(NM_DEVICE_WIFI_MODE,
"",
"",
NM_802_11_MODE_UNKNOWN,
NM_802_11_MODE_AP,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_UNKNOWN,
_NM_802_11_MODE_AP,
_NM_802_11_MODE_INFRA,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_BITRATE] = g_param_spec_uint(NM_DEVICE_WIFI_BITRATE,
@ -3855,7 +3860,7 @@ nm_device_wifi_class_init(NMDeviceWifiClass *klass)
"",
0,
G_MAXUINT32,
NM_WIFI_DEVICE_CAP_NONE,
_NM_WIFI_DEVICE_CAP_NONE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_SCANNING] = g_param_spec_boolean(NM_DEVICE_WIFI_SCANNING,

View file

@ -33,7 +33,7 @@ typedef struct _NMDeviceWifiClass NMDeviceWifiClass;
GType nm_device_wifi_get_type(void);
NMDevice *nm_device_wifi_new(const char *iface, NMDeviceWifiCapabilities capabilities);
NMDevice *nm_device_wifi_new(const char *iface, _NMDeviceWifiCapabilities capabilities);
const CList *_nm_device_wifi_get_aps(NMDeviceWifi *self);

View file

@ -19,7 +19,7 @@
#include "nm-setting-wireless.h"
#include "nm-utils.h"
#include "nm-wifi-utils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "supplicant/nm-supplicant-interface.h"
#define PROTO_WPA "wpa"
@ -41,12 +41,12 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMWifiAP,
struct _NMWifiAPPrivate {
/* Scanned or cached values */
GBytes * ssid;
char * address;
NM80211Mode mode;
guint8 strength;
guint32 freq; /* Frequency in MHz; ie 2412 (== 2.412 GHz) */
guint32 max_bitrate; /* Maximum bitrate of the AP in Kbit/s (ie 54000 Kb/s == 54Mbit/s) */
GBytes * ssid;
char * address;
_NM80211Mode mode;
guint8 strength;
guint32 freq; /* Frequency in MHz; ie 2412 (== 2.412 GHz) */
guint32 max_bitrate; /* Maximum bitrate of the AP in Kbit/s (ie 54000 Kb/s == 54Mbit/s) */
gint64
last_seen_msec; /* Timestamp when the AP was seen lastly (in nm_utils_get_monotonic_timestamp_*() scale).
@ -191,24 +191,24 @@ nm_wifi_ap_set_address(NMWifiAP *ap, const char *addr)
return nm_wifi_ap_set_address_bin(ap, &addr_buf);
}
NM80211Mode
_NM80211Mode
nm_wifi_ap_get_mode(NMWifiAP *ap)
{
g_return_val_if_fail(NM_IS_WIFI_AP(ap), NM_802_11_MODE_UNKNOWN);
g_return_val_if_fail(NM_IS_WIFI_AP(ap), _NM_802_11_MODE_UNKNOWN);
return NM_WIFI_AP_GET_PRIVATE(ap)->mode;
}
static gboolean
nm_wifi_ap_set_mode(NMWifiAP *ap, NM80211Mode mode)
nm_wifi_ap_set_mode(NMWifiAP *ap, _NM80211Mode mode)
{
NMWifiAPPrivate *priv = NM_WIFI_AP_GET_PRIVATE(ap);
nm_assert(NM_IN_SET(mode,
NM_802_11_MODE_UNKNOWN,
NM_802_11_MODE_ADHOC,
NM_802_11_MODE_INFRA,
NM_802_11_MODE_MESH));
_NM_802_11_MODE_UNKNOWN,
_NM_802_11_MODE_ADHOC,
_NM_802_11_MODE_INFRA,
_NM_802_11_MODE_MESH));
if (priv->mode != mode) {
priv->mode = mode;
@ -513,34 +513,35 @@ nm_wifi_ap_to_string(const NMWifiAP *self, char *str_buf, gulong buf_len, gint64
nm_utils_get_monotonic_timestamp_msec_cached(&now_msec);
g_snprintf(str_buf,
buf_len,
"%17s %-35s [ %c %3u %3u%% %c%c %c%c W:%04X R:%04X ] %s sup:%s [nm:%s]",
priv->address ?: "(none)",
(ssid_to_free = _nm_utils_ssid_to_string(priv->ssid)),
(priv->mode == NM_802_11_MODE_ADHOC
? '*'
: (priv->hotspot
? '#'
: (priv->fake ? 'f' : (priv->mode == NM_802_11_MODE_MESH ? 'm' : 'a')))),
chan,
priv->strength,
priv->flags & NM_802_11_AP_FLAGS_PRIVACY ? 'P' : '_',
priv->metered ? 'M' : '_',
priv->flags & NM_802_11_AP_FLAGS_WPS ? 'W' : '_',
priv->flags & NM_802_11_AP_FLAGS_WPS_PIN
? 'p'
: (priv->flags & NM_802_11_AP_FLAGS_WPS_PBC ? '#' : '_'),
priv->wpa_flags & 0xFFFF,
priv->rsn_flags & 0xFFFF,
priv->last_seen_msec != G_MININT64
? nm_sprintf_buf(str_buf_ts,
"%3u.%03us",
(guint)((now_msec - priv->last_seen_msec) / 1000),
(guint)((now_msec - priv->last_seen_msec) % 1000))
: " ",
supplicant_id,
export_path);
g_snprintf(
str_buf,
buf_len,
"%17s %-35s [ %c %3u %3u%% %c%c %c%c W:%04X R:%04X ] %s sup:%s [nm:%s]",
priv->address ?: "(none)",
(ssid_to_free = _nm_utils_ssid_to_string_gbytes(priv->ssid)),
(priv->mode == _NM_802_11_MODE_ADHOC
? '*'
: (priv->hotspot
? '#'
: (priv->fake ? 'f' : (priv->mode == _NM_802_11_MODE_MESH ? 'm' : 'a')))),
chan,
priv->strength,
priv->flags & NM_802_11_AP_FLAGS_PRIVACY ? 'P' : '_',
priv->metered ? 'M' : '_',
priv->flags & NM_802_11_AP_FLAGS_WPS ? 'W' : '_',
priv->flags & NM_802_11_AP_FLAGS_WPS_PIN
? 'p'
: (priv->flags & NM_802_11_AP_FLAGS_WPS_PBC ? '#' : '_'),
priv->wpa_flags & 0xFFFF,
priv->rsn_flags & 0xFFFF,
priv->last_seen_msec != G_MININT64
? nm_sprintf_buf(str_buf_ts,
"%3u.%03us",
(guint)((now_msec - priv->last_seen_msec) / 1000),
(guint)((now_msec - priv->last_seen_msec) % 1000))
: " ",
supplicant_id,
export_path);
return str_buf;
}
@ -589,13 +590,13 @@ nm_wifi_ap_check_compatible(NMWifiAP *self, NMConnection *connection)
mode = nm_setting_wireless_get_mode(s_wireless);
if (mode) {
if (!strcmp(mode, "infrastructure") && (priv->mode != NM_802_11_MODE_INFRA))
if (!strcmp(mode, "infrastructure") && (priv->mode != _NM_802_11_MODE_INFRA))
return FALSE;
if (!strcmp(mode, "adhoc") && (priv->mode != NM_802_11_MODE_ADHOC))
if (!strcmp(mode, "adhoc") && (priv->mode != _NM_802_11_MODE_ADHOC))
return FALSE;
if (!strcmp(mode, "ap") && (priv->mode != NM_802_11_MODE_INFRA || priv->hotspot != TRUE))
if (!strcmp(mode, "ap") && (priv->mode != _NM_802_11_MODE_INFRA || priv->hotspot != TRUE))
return FALSE;
if (!strcmp(mode, "mesh") && (priv->mode != NM_802_11_MODE_MESH))
if (!strcmp(mode, "mesh") && (priv->mode != _NM_802_11_MODE_MESH))
return FALSE;
}
@ -624,7 +625,7 @@ nm_wifi_ap_check_compatible(NMWifiAP *self, NMConnection *connection)
priv->flags,
priv->wpa_flags,
priv->rsn_flags,
priv->mode);
NM_802_11_MODE_CAST(priv->mode));
}
gboolean
@ -713,7 +714,7 @@ nm_wifi_ap_init(NMWifiAP *self)
c_list_init(&self->aps_lst);
priv->mode = NM_802_11_MODE_INFRA;
priv->mode = _NM_802_11_MODE_INFRA;
priv->flags = NM_802_11_AP_FLAGS_NONE;
priv->wpa_flags = NM_802_11_AP_SEC_NONE;
priv->rsn_flags = NM_802_11_AP_SEC_NONE;
@ -758,19 +759,19 @@ nm_wifi_ap_new_fake_from_connection(NMConnection *connection)
mode = nm_setting_wireless_get_mode(s_wireless);
if (mode) {
if (!strcmp(mode, "infrastructure"))
nm_wifi_ap_set_mode(ap, NM_802_11_MODE_INFRA);
nm_wifi_ap_set_mode(ap, _NM_802_11_MODE_INFRA);
else if (!strcmp(mode, "adhoc")) {
nm_wifi_ap_set_mode(ap, NM_802_11_MODE_ADHOC);
nm_wifi_ap_set_mode(ap, _NM_802_11_MODE_ADHOC);
adhoc = TRUE;
} else if (!strcmp(mode, "mesh"))
nm_wifi_ap_set_mode(ap, NM_802_11_MODE_MESH);
nm_wifi_ap_set_mode(ap, _NM_802_11_MODE_MESH);
else if (!strcmp(mode, "ap")) {
nm_wifi_ap_set_mode(ap, NM_802_11_MODE_INFRA);
nm_wifi_ap_set_mode(ap, _NM_802_11_MODE_INFRA);
NM_WIFI_AP_GET_PRIVATE(ap)->hotspot = TRUE;
} else
goto error;
} else {
nm_wifi_ap_set_mode(ap, NM_802_11_MODE_INFRA);
nm_wifi_ap_set_mode(ap, _NM_802_11_MODE_INFRA);
}
band = nm_setting_wireless_get_band(s_wireless);
@ -955,9 +956,9 @@ nm_wifi_ap_class_init(NMWifiAPClass *ap_class)
obj_properties[PROP_MODE] = g_param_spec_uint(NM_WIFI_AP_MODE,
"",
"",
NM_802_11_MODE_ADHOC,
NM_802_11_MODE_INFRA,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_ADHOC,
_NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_MAX_BITRATE] = g_param_spec_uint(NM_WIFI_AP_MAX_BITRATE,

View file

@ -10,6 +10,7 @@
#include "nm-dbus-object.h"
#include "nm-dbus-interface.h"
#include "nm-connection.h"
#include "libnm-base/nm-base.h"
#define NM_TYPE_WIFI_AP (nm_wifi_ap_get_type())
#define NM_WIFI_AP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_WIFI_AP, NMWifiAP))
@ -69,7 +70,7 @@ gboolean nm_wifi_ap_set_ssid(NMWifiAP *ap, GBytes *ssid);
const char * nm_wifi_ap_get_address(const NMWifiAP *ap);
gboolean nm_wifi_ap_set_address(NMWifiAP *ap, const char *addr);
gboolean nm_wifi_ap_set_address_bin(NMWifiAP *ap, const NMEtherAddr *addr);
NM80211Mode nm_wifi_ap_get_mode(NMWifiAP *ap);
_NM80211Mode nm_wifi_ap_get_mode(NMWifiAP *ap);
gboolean nm_wifi_ap_is_hotspot(NMWifiAP *ap);
gint8 nm_wifi_ap_get_strength(NMWifiAP *ap);
gboolean nm_wifi_ap_set_strength(NMWifiAP *ap, gint8 strength);

View file

@ -15,7 +15,7 @@
#include "nm-device-olpc-mesh.h"
#include "nm-device-iwd.h"
#include "settings/nm-settings-connection.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-config.h"
/*****************************************************************************/
@ -97,9 +97,9 @@ create_device(NMDeviceFactory * factory,
NM_PRINT_FMT_QUOTE_STRING(backend),
WITH_IWD ? " (iwd support enabled)" : "");
if (!backend || !g_ascii_strcasecmp(backend, "wpa_supplicant")) {
NMDevice * device;
NMDeviceWifiCapabilities capabilities;
NM80211Mode mode;
NMDevice * device;
_NMDeviceWifiCapabilities capabilities;
_NM80211Mode mode;
if (!nm_platform_wifi_get_capabilities(NM_PLATFORM_GET, plink->ifindex, &capabilities)) {
nm_log_warn(LOGD_PLATFORM | LOGD_WIFI,
@ -114,7 +114,7 @@ create_device(NMDeviceFactory * factory,
* them if/when they change to a handled type.
*/
mode = nm_platform_wifi_get_mode(NM_PLATFORM_GET, plink->ifindex);
if (mode == NM_802_11_MODE_UNKNOWN) {
if (mode == _NM_802_11_MODE_UNKNOWN) {
*out_ignore = TRUE;
return NULL;
}

View file

@ -18,7 +18,7 @@
#include "nm-setting-wireless.h"
#include "nm-utils.h"
#include "nm-wifi-utils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "supplicant/nm-supplicant-types.h"
/*****************************************************************************/

View file

@ -526,7 +526,7 @@ verify_adhoc(NMSettingWirelessSecurity *s_wsec,
gboolean
nm_wifi_utils_complete_connection(GBytes * ap_ssid,
const char * bssid,
NM80211Mode ap_mode,
_NM80211Mode ap_mode,
guint32 ap_freq,
guint32 ap_flags,
guint32 ap_wpa_flags,
@ -575,14 +575,14 @@ nm_wifi_utils_complete_connection(GBytes * ap_ssid,
/* Make sure the supplied mode matches the AP's */
if (!strcmp(mode, NM_SETTING_WIRELESS_MODE_INFRA)
|| !strcmp(mode, NM_SETTING_WIRELESS_MODE_AP)) {
if (ap_mode == NM_802_11_MODE_INFRA)
if (ap_mode == _NM_802_11_MODE_INFRA)
valid = TRUE;
} else if (!strcmp(mode, NM_SETTING_WIRELESS_MODE_ADHOC)) {
if (ap_mode == NM_802_11_MODE_ADHOC)
if (ap_mode == _NM_802_11_MODE_ADHOC)
valid = TRUE;
adhoc = TRUE;
} else if (!strcmp(mode, NM_SETTING_WIRELESS_MODE_MESH)) {
if (ap_mode == NM_802_11_MODE_MESH)
if (ap_mode == _NM_802_11_MODE_MESH)
valid = TRUE;
mesh = TRUE;
}
@ -600,10 +600,10 @@ nm_wifi_utils_complete_connection(GBytes * ap_ssid,
}
} else {
mode = NM_SETTING_WIRELESS_MODE_INFRA;
if (ap_mode == NM_802_11_MODE_ADHOC) {
if (ap_mode == _NM_802_11_MODE_ADHOC) {
mode = NM_SETTING_WIRELESS_MODE_ADHOC;
adhoc = TRUE;
} else if (ap_mode == NM_802_11_MODE_MESH) {
} else if (ap_mode == _NM_802_11_MODE_MESH) {
mode = NM_SETTING_WIRELESS_MODE_MESH;
mesh = TRUE;
}

View file

@ -11,6 +11,7 @@
#include "nm-setting-wireless.h"
#include "nm-setting-wireless-security.h"
#include "nm-setting-8021x.h"
#include "libnm-base/nm-base.h"
typedef enum {
NM_IWD_NETWORK_SECURITY_OPEN,
@ -21,7 +22,7 @@ typedef enum {
gboolean nm_wifi_utils_complete_connection(GBytes * ssid,
const char * bssid,
NM80211Mode mode,
_NM80211Mode mode,
guint32 ap_freq,
guint32 flags,
guint32 wpa_flags,

View file

@ -49,7 +49,7 @@
static gboolean
complete_connection(const char * ssid,
const char * bssid,
NM80211Mode mode,
_NM80211Mode mode,
guint32 flags,
guint32 wpa_flags,
guint32 rsn_flags,
@ -197,7 +197,7 @@ fill_8021x(NMConnection *connection, const KeyData items[])
}
static NMConnection *
create_basic(const char *ssid, const char *bssid, NM80211Mode mode)
create_basic(const char *ssid, const char *bssid, _NM80211Mode mode)
{
NMConnection * connection;
NMSettingWireless *s_wifi = NULL;
@ -217,9 +217,9 @@ create_basic(const char *ssid, const char *bssid, NM80211Mode mode)
if (bssid)
g_object_set(G_OBJECT(s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL);
if (mode == NM_802_11_MODE_INFRA)
if (mode == _NM_802_11_MODE_INFRA)
g_object_set(G_OBJECT(s_wifi), NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
else if (mode == NM_802_11_MODE_ADHOC)
else if (mode == _NM_802_11_MODE_ADHOC)
g_object_set(G_OBJECT(s_wifi), NM_SETTING_WIRELESS_MODE, "adhoc", NULL);
else
g_assert_not_reached();
@ -241,14 +241,14 @@ test_lock_bssid(void)
src = nm_simple_connection_new();
success = complete_connection(ssid,
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_NONE,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
TRUE,
src,
&error);
expected = create_basic(ssid, bssid, NM_802_11_MODE_INFRA);
expected = create_basic(ssid, bssid, _NM_802_11_MODE_INFRA);
COMPARE(src, expected, success, error, 0, 0);
g_object_unref(src);
@ -273,14 +273,14 @@ test_open_ap_empty_connection(void)
src = nm_simple_connection_new();
success = complete_connection(ssid,
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_NONE,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
FALSE,
src,
&error);
expected = create_basic(ssid, NULL, NM_802_11_MODE_INFRA);
expected = create_basic(ssid, NULL, _NM_802_11_MODE_INFRA);
COMPARE(src, expected, success, error, 0, 0);
g_object_unref(src);
@ -311,7 +311,7 @@ test_open_ap_leap_connection_1(gconstpointer add_wifi)
success = complete_connection("blahblah",
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_NONE,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
@ -345,7 +345,7 @@ test_open_ap_leap_connection_2(void)
success = complete_connection("blahblah",
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_NONE,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
@ -383,7 +383,7 @@ test_open_ap_wep_connection(gconstpointer add_wifi)
fill_wsec(src, src_wsec);
success = complete_connection("blahblah",
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_NONE,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
@ -427,7 +427,7 @@ test_ap_wpa_psk_connection_base(const char * key_mgmt,
fill_wsec(src, both_wsec);
success = complete_connection(ssid,
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
flags,
wpa_flags,
rsn_flags,
@ -553,7 +553,7 @@ test_ap_wpa_eap_connection_base(const char *key_mgmt,
fill_8021x(src, src_empty);
success = complete_connection("blahblah",
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
flags,
wpa_flags,
rsn_flags,
@ -751,7 +751,7 @@ test_priv_ap_empty_connection(void)
src = nm_simple_connection_new();
success = complete_connection(ssid,
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
@ -760,7 +760,7 @@ test_priv_ap_empty_connection(void)
&error);
/* Static WEP connection expected */
expected = create_basic(ssid, NULL, NM_802_11_MODE_INFRA);
expected = create_basic(ssid, NULL, _NM_802_11_MODE_INFRA);
fill_wsec(expected, exp_wsec);
COMPARE(src, expected, success, error, 0, 0);
@ -798,7 +798,7 @@ test_priv_ap_leap_connection_1(gconstpointer add_wifi)
fill_wsec(src, src_wsec);
success = complete_connection(ssid,
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
@ -809,7 +809,7 @@ test_priv_ap_leap_connection_1(gconstpointer add_wifi)
* there's no way to determine from the AP's beacon whether it's static WEP,
* dynamic WEP, or LEAP.
*/
expected = create_basic(ssid, NULL, NM_802_11_MODE_INFRA);
expected = create_basic(ssid, NULL, _NM_802_11_MODE_INFRA);
fill_wsec(expected, exp_wsec);
COMPARE(src, expected, success, error, 0, 0);
@ -840,7 +840,7 @@ test_priv_ap_leap_connection_2(void)
fill_wsec(src, src_wsec);
success = complete_connection("blahblah",
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
@ -885,7 +885,7 @@ test_priv_ap_dynamic_wep_1(void)
fill_8021x(src, both_8021x);
success = complete_connection(ssid,
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
@ -894,7 +894,7 @@ test_priv_ap_dynamic_wep_1(void)
&error);
/* We expect a completed Dynamic WEP connection */
expected = create_basic(ssid, NULL, NM_802_11_MODE_INFRA);
expected = create_basic(ssid, NULL, _NM_802_11_MODE_INFRA);
fill_wsec(expected, exp_wsec);
fill_8021x(expected, both_8021x);
COMPARE(src, expected, success, error, 0, 0);
@ -933,7 +933,7 @@ test_priv_ap_dynamic_wep_2(void)
fill_8021x(src, both_8021x);
success = complete_connection(ssid,
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
@ -942,7 +942,7 @@ test_priv_ap_dynamic_wep_2(void)
&error);
/* We expect a completed Dynamic WEP connection */
expected = create_basic(ssid, NULL, NM_802_11_MODE_INFRA);
expected = create_basic(ssid, NULL, _NM_802_11_MODE_INFRA);
fill_wsec(expected, exp_wsec);
fill_8021x(expected, both_8021x);
COMPARE(src, expected, success, error, 0, 0);
@ -976,7 +976,7 @@ test_priv_ap_dynamic_wep_3(void)
fill_8021x(src, src_8021x);
success = complete_connection("blahblah",
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
NM_802_11_AP_SEC_NONE,
NM_802_11_AP_SEC_NONE,
@ -1102,7 +1102,7 @@ test_wpa_ap_empty_connection(gconstpointer data)
src = nm_simple_connection_new();
success = complete_connection(ssid,
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
wpa_flags_for_idx(idx),
rsn_flags_for_idx(idx),
@ -1111,7 +1111,7 @@ test_wpa_ap_empty_connection(gconstpointer data)
&error);
/* WPA connection expected */
expected = create_basic(ssid, NULL, NM_802_11_MODE_INFRA);
expected = create_basic(ssid, NULL, _NM_802_11_MODE_INFRA);
fill_wsec(expected, exp_wsec);
COMPARE(src, expected, success, error, 0, 0);
@ -1144,7 +1144,7 @@ test_wpa_ap_leap_connection_1(gconstpointer data)
fill_wsec(src, src_wsec);
success = complete_connection(ssid,
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
wpa_flags_for_idx(idx),
rsn_flags_for_idx(idx),
@ -1180,7 +1180,7 @@ test_wpa_ap_leap_connection_2(gconstpointer data)
fill_wsec(src, src_wsec);
success = complete_connection("blahblah",
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
wpa_flags_for_idx(idx),
rsn_flags_for_idx(idx),
@ -1214,7 +1214,7 @@ test_wpa_ap_dynamic_wep_connection(gconstpointer data)
fill_wsec(src, src_wsec);
success = complete_connection("blahblah",
bssid,
NM_802_11_MODE_INFRA,
_NM_802_11_MODE_INFRA,
NM_802_11_AP_FLAGS_PRIVACY,
wpa_flags_for_idx(idx),
rsn_flags_for_idx(idx),

View file

@ -14,7 +14,7 @@
#include "libnm-core-intern/nm-core-internal.h"
#include "NetworkManagerUtils.h"
#include "devices/nm-device-private.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"

View file

@ -10,7 +10,7 @@
#include "libnm-core-intern/nm-core-internal.h"
#include "devices/nm-device-private.h"
#include "nm-modem.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-ip4-config.h"
#define VARIANT_IS_OF_TYPE_BOOLEAN(v) \

View file

@ -13,7 +13,7 @@
#include <linux/rtnetlink.h>
#include "libnm-core-intern/nm-core-internal.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-setting-connection.h"
#include "NetworkManagerUtils.h"
#include "devices/nm-device-private.h"

View file

@ -12,7 +12,7 @@
#include "nm-setting-cdma.h"
#include "nm-modem-manager.h"
#include "nm-device-modem.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
/*****************************************************************************/

View file

@ -21,7 +21,7 @@
#include "nm-utils.h"
#include "nm-dhcp-utils.h"
#include "nm-dhcp-options.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-dhcp-client-logging.h"

View file

@ -17,7 +17,7 @@
#include "nm-dhcp-utils.h"
#include "nm-ip4-config.h"
#include "nm-utils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "NetworkManagerUtils.h"
#define TIMEOUT_TAG "timeout "

View file

@ -252,7 +252,7 @@ client_start(NMDhcpManager * self,
}
hwaddr_len = g_bytes_get_size(hwaddr);
if (hwaddr_len == 0 || hwaddr_len > NM_UTILS_HWADDR_LEN_MAX) {
if (hwaddr_len == 0 || hwaddr_len > _NM_UTILS_HWADDR_LEN_MAX) {
nm_utils_error_set(error, NM_UTILS_ERROR_UNKNOWN, "invalid MAC address");
g_return_val_if_reached(NULL);
}

View file

@ -23,7 +23,7 @@
#include "nm-dhcp-options.h"
#include "nm-core-utils.h"
#include "NetworkManagerUtils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-dhcp-client-logging.h"
#include "n-dhcp4/src/n-dhcp4.h"
#include "libnm-systemd-shared/nm-sd-utils-shared.h"

View file

@ -21,7 +21,7 @@
#include "nm-dhcp-options.h"
#include "nm-core-utils.h"
#include "NetworkManagerUtils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-dhcp-client-logging.h"
#include "systemd/nm-sd.h"
#include "systemd/nm-sd-utils-dhcp.h"

View file

@ -17,7 +17,7 @@
#include "nm-utils.h"
#include "nm-config.h"
#include "NetworkManagerUtils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-dhcp-client-logging.h"
#include "libnm-core-intern/nm-core-internal.h"

View file

@ -16,7 +16,7 @@
#include "dhcp/nm-dhcp-utils.h"
#include "nm-utils.h"
#include "nm-ip4-config.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-test-utils-core.h"

View file

@ -14,7 +14,7 @@
#include "dhcp/nm-dhcp-utils.h"
#include "dhcp/nm-dhcp-options.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-test-utils-core.h"

View file

@ -17,7 +17,7 @@
#include "libnm-glib-aux/nm-dbus-aux.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-utils.h"
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"

View file

@ -19,7 +19,7 @@
#include "libnm-glib-aux/nm-c-list.h"
#include "libnm-glib-aux/nm-dbus-aux.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-utils.h"
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"

View file

@ -8,7 +8,7 @@
#include <arpa/inet.h>
#include "nm-dnsmasq-utils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-utils.h"
gboolean

View file

@ -6,7 +6,7 @@
#ifndef __NETWORKMANAGER_DNSMASQ_UTILS_H__
#define __NETWORKMANAGER_DNSMASQ_UTILS_H__
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
gboolean nm_dnsmasq_utils_get_range(const NMPlatformIP4Address *addr,
char * out_first,

View file

@ -18,6 +18,7 @@
#include <linux/if_ether.h>
#include "libnm-core-intern/nm-core-internal.h"
#include "libnm-platform/nm-platform-utils.h"
#include "NetworkManagerUtils.h"
/*****************************************************************************/
@ -92,7 +93,7 @@ nmi_ibft_read(const char *sysfs_dir)
(GDestroyNotify) g_hash_table_unref);
if (!g_file_test(ibft_path, G_FILE_TEST_IS_DIR))
nm_utils_modprobe(NULL, FALSE, "iscsi_ibft", NULL);
nmp_utils_modprobe(NULL, FALSE, "iscsi_ibft", NULL);
if (!g_file_test(ibft_path, G_FILE_TEST_IS_DIR))
return ibft;

View file

@ -20,7 +20,7 @@
#include "nm-dbus-interface.h"
#include "NetworkManagerUtils.h"
#include "nm-manager.h"
#include "platform/nm-linux-platform.h"
#include "libnm-platform/nm-linux-platform.h"
#include "nm-dbus-manager.h"
#include "devices/nm-device.h"
#include "dhcp/nm-dhcp-manager.h"

View file

@ -34,11 +34,6 @@ subdir('systemd')
core_plugins = []
platform_wifi_wext_source = files()
if enable_wext
platform_wifi_wext_source += files('platform/wifi/nm-wifi-utils-wext.c')
endif
libNetworkManagerBase = static_library(
'NetworkManagerBase',
sources: files(
@ -50,13 +45,6 @@ libNetworkManagerBase = static_library(
'dhcp/nm-dhcp-options.c',
'ndisc/nm-lndp-ndisc.c',
'ndisc/nm-ndisc.c',
'platform/wifi/nm-wifi-utils-nl80211.c',
'platform/wifi/nm-wifi-utils.c',
'platform/wpan/nm-wpan-utils.c',
'platform/nm-linux-platform.c',
'platform/nm-platform.c',
'platform/nmp-object.c',
'platform/nmp-rules-manager.c',
'main-utils.c',
'NetworkManagerUtils.c',
'nm-core-utils.c',
@ -69,7 +57,7 @@ libNetworkManagerBase = static_library(
'nm-ip-config.c',
'nm-ip4-config.c',
'nm-ip6-config.c',
) + platform_wifi_wext_source,
),
dependencies: [
core_default_dep,
libnm_core_public_dep,

View file

@ -17,7 +17,7 @@
#include "libnm-systemd-shared/nm-sd-utils-shared.h"
#include "nm-ndisc-private.h"
#include "NetworkManagerUtils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-netns.h"
#define _NMLOG_PREFIX_NAME "ndisc-lndp"

View file

@ -14,7 +14,7 @@
#include "nm-ndisc-private.h"
#include "nm-utils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-netns.h"
#include "nm-l3-config-data.h"

View file

@ -13,8 +13,8 @@
#include "nm-setting-ip6-config.h"
#include "NetworkManagerUtils.h"
#include "platform/nm-platform.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-object.h"
#define NM_RA_TIMEOUT_DEFAULT ((guint32) 0)
#define NM_RA_TIMEOUT_INFINITY ((guint32) G_MAXINT32)

View file

@ -10,7 +10,7 @@
#include "ndisc/nm-ndisc.h"
#include "ndisc/nm-lndp-ndisc.h"
#include "platform/nm-linux-platform.h"
#include "libnm-platform/nm-linux-platform.h"
#include "nm-test-utils-core.h"

View file

@ -6,6 +6,8 @@
#ifndef NM_CONFIG_DATA_H
#define NM_CONFIG_DATA_H
#include "libnm-platform/nmp-base.h"
/*****************************************************************************/
typedef enum {

View file

@ -8,6 +8,7 @@
#define __NETWORKMANAGER_CONNECTIVITY_H__
#include "nm-dbus-interface.h"
#include "libnm-platform/nmp-base.h"
/*****************************************************************************/

View file

@ -22,6 +22,7 @@
#include <net/if_arp.h>
#include <net/ethernet.h>
#include "libnm-platform/nmp-base.h"
#include "libnm-std-aux/unaligned.h"
#include "libnm-glib-aux/nm-random-utils.h"
#include "libnm-glib-aux/nm-io-utils.h"
@ -156,37 +157,6 @@ _nm_singleton_instance_register_destruction(GObject *instance)
/*****************************************************************************/
static double
_exp10(guint16 ex)
{
double v;
if (ex == 0)
return 1.0;
v = _exp10(ex / 2);
v = v * v;
if (ex % 2)
v *= 10;
return v;
}
/*
* nm_utils_exp10:
* @ex: the exponent
*
* Returns: 10^ex, or pow(10, ex), or exp10(ex).
*/
double
nm_utils_exp10(gint16 ex)
{
if (ex >= 0)
return _exp10(ex);
return 1.0 / _exp10(-((gint32) ex));
}
/*****************************************************************************/
gboolean
nm_ether_addr_is_valid(const NMEtherAddr *addr)
{
@ -304,85 +274,6 @@ nm_utils_array_remove_at_indexes(GArray *array, const guint *indexes_to_delete,
g_array_set_size(array, res_length);
}
static const char *
_trunk_first_line(char *str)
{
char *s;
s = strchr(str, '\n');
if (s)
s[0] = '\0';
return str;
}
int
nm_utils_modprobe(GError **error, gboolean suppress_error_logging, const char *arg1, ...)
{
gs_unref_ptrarray GPtrArray *argv = NULL;
int exit_status;
gs_free char * _log_str = NULL;
#define ARGV_TO_STR(argv) \
(_log_str ? _log_str : (_log_str = g_strjoinv(" ", (char **) argv->pdata)))
GError * local = NULL;
va_list ap;
NMLogLevel llevel = suppress_error_logging ? LOGL_DEBUG : LOGL_ERR;
gs_free char *std_out = NULL, *std_err = NULL;
g_return_val_if_fail(!error || !*error, -1);
g_return_val_if_fail(arg1, -1);
/* construct the argument list */
argv = g_ptr_array_sized_new(4);
g_ptr_array_add(argv, "/sbin/modprobe");
g_ptr_array_add(argv, "--use-blacklist");
g_ptr_array_add(argv, (char *) arg1);
va_start(ap, arg1);
while ((arg1 = va_arg(ap, const char *)))
g_ptr_array_add(argv, (char *) arg1);
va_end(ap);
g_ptr_array_add(argv, NULL);
nm_log_dbg(LOGD_CORE, "modprobe: '%s'", ARGV_TO_STR(argv));
if (!g_spawn_sync(NULL,
(char **) argv->pdata,
NULL,
0,
NULL,
NULL,
&std_out,
&std_err,
&exit_status,
&local)) {
nm_log(llevel,
LOGD_CORE,
NULL,
NULL,
"modprobe: '%s' failed: %s",
ARGV_TO_STR(argv),
local->message);
g_propagate_error(error, local);
return -1;
} else if (exit_status != 0) {
nm_log(llevel,
LOGD_CORE,
NULL,
NULL,
"modprobe: '%s' exited with error %d%s%s%s%s%s%s",
ARGV_TO_STR(argv),
exit_status,
std_out && *std_out ? " (" : "",
std_out && *std_out ? _trunk_first_line(std_out) : "",
std_out && *std_out ? ")" : "",
std_err && *std_err ? " (" : "",
std_err && *std_err ? _trunk_first_line(std_err) : "",
std_err && *std_err ? ")" : "");
}
return exit_status;
}
/*****************************************************************************/
typedef struct {
@ -1269,7 +1160,7 @@ typedef struct {
const char *value;
gboolean is_parsed;
guint len;
guint8 bin[NM_UTILS_HWADDR_LEN_MAX];
guint8 bin[_NM_UTILS_HWADDR_LEN_MAX];
} hwaddr;
struct {
const char *value;
@ -2051,65 +1942,6 @@ nm_utils_kernel_cmdline_match_check(const char *const *proc_cmdline,
/*****************************************************************************/
char *
nm_utils_new_vlan_name(const char *parent_iface, guint32 vlan_id)
{
guint id_len;
gsize parent_len;
char *ifname;
g_return_val_if_fail(parent_iface && *parent_iface, NULL);
if (vlan_id < 10)
id_len = 2;
else if (vlan_id < 100)
id_len = 3;
else if (vlan_id < 1000)
id_len = 4;
else {
g_return_val_if_fail(vlan_id < 4095, NULL);
id_len = 5;
}
ifname = g_new(char, IFNAMSIZ);
parent_len = strlen(parent_iface);
parent_len = MIN(parent_len, IFNAMSIZ - 1 - id_len);
memcpy(ifname, parent_iface, parent_len);
g_snprintf(&ifname[parent_len], IFNAMSIZ - parent_len, ".%u", vlan_id);
return ifname;
}
/* nm_utils_new_infiniband_name:
* @name: the output-buffer where the value will be written. Must be
* not %NULL and point to a string buffer of at least IFNAMSIZ bytes.
* @parent_name: the parent interface name
* @p_key: the partition key.
*
* Returns: the infiniband name will be written to @name and @name
* is returned.
*/
const char *
nm_utils_new_infiniband_name(char *name, const char *parent_name, int p_key)
{
g_return_val_if_fail(name, NULL);
g_return_val_if_fail(parent_name && parent_name[0], NULL);
g_return_val_if_fail(strlen(parent_name) < IFNAMSIZ, NULL);
/* technically, p_key of 0x0000 and 0x8000 is not allowed either. But we don't
* want to assert against that in nm_utils_new_infiniband_name(). So be more
* resilient here, and accept those. */
g_return_val_if_fail(p_key >= 0 && p_key <= 0xffff, NULL);
/* If parent+suffix is too long, kernel would just truncate
* the name. We do the same. See ipoib_vlan_add(). */
g_snprintf(name, IFNAMSIZ, "%s.%04x", parent_name, p_key);
return name;
}
/*****************************************************************************/
/**
* nm_utils_cmp_connection_by_autoconnect_priority:
* @a:
@ -2538,134 +2370,6 @@ out:
g_array_free(sorted_hashes, TRUE);
}
#define IPV6_PROPERTY_DIR "/proc/sys/net/ipv6/conf/"
#define IPV4_PROPERTY_DIR "/proc/sys/net/ipv4/conf/"
G_STATIC_ASSERT(sizeof(IPV4_PROPERTY_DIR) == sizeof(IPV6_PROPERTY_DIR));
G_STATIC_ASSERT(NM_STRLEN(IPV6_PROPERTY_DIR) + IFNAMSIZ + 60
== NM_UTILS_SYSCTL_IP_CONF_PATH_BUFSIZE);
/**
* nm_utils_sysctl_ip_conf_path:
* @addr_family: either AF_INET or AF_INET6.
* @buf: the output buffer where to write the path. It
* must be at least NM_UTILS_SYSCTL_IP_CONF_PATH_BUFSIZE bytes
* long.
* @ifname: an interface name
* @property: a property name
*
* Returns: the path to IPv6 property @property on @ifname. Note that
* this returns the input argument @buf.
*/
const char *
nm_utils_sysctl_ip_conf_path(int addr_family, char *buf, const char *ifname, const char *property)
{
int len;
nm_assert(buf);
nm_assert_addr_family(addr_family);
g_assert(nm_utils_ifname_valid_kernel(ifname, NULL));
property = NM_ASSERT_VALID_PATH_COMPONENT(property);
len = g_snprintf(buf,
NM_UTILS_SYSCTL_IP_CONF_PATH_BUFSIZE,
"%s%s/%s",
addr_family == AF_INET6 ? IPV6_PROPERTY_DIR : IPV4_PROPERTY_DIR,
ifname,
property);
g_assert(len < NM_UTILS_SYSCTL_IP_CONF_PATH_BUFSIZE - 1);
return buf;
}
gboolean
nm_utils_sysctl_ip_conf_is_path(int addr_family,
const char *path,
const char *ifname,
const char *property)
{
g_return_val_if_fail(path, FALSE);
NM_ASSERT_VALID_PATH_COMPONENT(property);
g_assert(!ifname || nm_utils_ifname_valid_kernel(ifname, NULL));
if (addr_family == AF_INET) {
if (!g_str_has_prefix(path, IPV4_PROPERTY_DIR))
return FALSE;
path += NM_STRLEN(IPV4_PROPERTY_DIR);
} else if (addr_family == AF_INET6) {
if (!g_str_has_prefix(path, IPV6_PROPERTY_DIR))
return FALSE;
path += NM_STRLEN(IPV6_PROPERTY_DIR);
} else
g_return_val_if_reached(FALSE);
if (ifname) {
if (!g_str_has_prefix(path, ifname))
return FALSE;
path += strlen(ifname);
if (path[0] != '/')
return FALSE;
path++;
} else {
const char *slash;
char buf[IFNAMSIZ];
gsize l;
slash = strchr(path, '/');
if (!slash)
return FALSE;
l = slash - path;
if (l >= IFNAMSIZ)
return FALSE;
memcpy(buf, path, l);
buf[l] = '\0';
if (!nm_utils_ifname_valid_kernel(buf, NULL))
return FALSE;
path = slash + 1;
}
if (!nm_streq(path, property))
return FALSE;
return TRUE;
}
gboolean
nm_utils_is_valid_path_component(const char *name)
{
const char *n;
if (name == NULL || name[0] == '\0')
return FALSE;
if (name[0] == '.') {
if (name[1] == '\0')
return FALSE;
if (name[1] == '.' && name[2] == '\0')
return FALSE;
}
n = name;
do {
if (*n == '/')
return FALSE;
} while (*(++n) != '\0');
return TRUE;
}
const char *
NM_ASSERT_VALID_PATH_COMPONENT(const char *name)
{
if (G_LIKELY(nm_utils_is_valid_path_component(name)))
return name;
nm_log_err(LOGD_CORE,
"Failed asserting path component: %s%s%s",
NM_PRINT_FMT_QUOTED(name, "\"", name, "\"", "(null)"));
g_error("FATAL: Failed asserting path component: %s%s%s",
NM_PRINT_FMT_QUOTED(name, "\"", name, "\"", "(null)"));
g_assert_not_reached();
}
/*****************************************************************************/
typedef struct {
@ -3407,89 +3111,6 @@ nm_utils_get_ipv6_interface_identifier(NMLinkType link_type,
/*****************************************************************************/
/**
* nm_utils_ipv6_addr_set_interface_identifier:
* @addr: output token encoded as %in6_addr
* @iid: %NMUtilsIPv6IfaceId interface identifier
*
* Converts the %NMUtilsIPv6IfaceId to an %in6_addr (suitable for use
* with Linux platform). This only copies the lower 8 bytes, ignoring
* the /64 network prefix which is expected to be all-zero for a valid
* token.
*/
void
nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr *addr, const NMUtilsIPv6IfaceId iid)
{
memcpy(addr->s6_addr + 8, &iid.id_u8, 8);
}
/**
* nm_utils_ipv6_interface_identifier_get_from_addr:
* @iid: output %NMUtilsIPv6IfaceId interface identifier set from the token
* @addr: token encoded as %in6_addr
*
* Converts the %in6_addr encoded token (as used by Linux platform) to
* the interface identifier.
*/
void
nm_utils_ipv6_interface_identifier_get_from_addr(NMUtilsIPv6IfaceId * iid,
const struct in6_addr *addr)
{
memcpy(iid, addr->s6_addr + 8, 8);
}
/**
* nm_utils_ipv6_interface_identifier_get_from_token:
* @iid: output %NMUtilsIPv6IfaceId interface identifier set from the token
* @token: token encoded as string
*
* Converts the %in6_addr encoded token (as used in ip6 settings) to
* the interface identifier.
*
* Returns: %TRUE if the @token is a valid token, %FALSE otherwise
*/
gboolean
nm_utils_ipv6_interface_identifier_get_from_token(NMUtilsIPv6IfaceId *iid, const char *token)
{
struct in6_addr i6_token;
g_return_val_if_fail(token, FALSE);
if (!inet_pton(AF_INET6, token, &i6_token))
return FALSE;
if (!_nm_utils_inet6_is_token(&i6_token))
return FALSE;
nm_utils_ipv6_interface_identifier_get_from_addr(iid, &i6_token);
return TRUE;
}
/**
* nm_utils_inet6_interface_identifier_to_token:
* @iid: %NMUtilsIPv6IfaceId interface identifier
* @buf: the destination buffer of at least %NM_UTILS_INET_ADDRSTRLEN
* bytes.
*
* Converts the interface identifier to a string token.
*
* Returns: the input buffer filled with the id as string.
*/
const char *
nm_utils_inet6_interface_identifier_to_token(NMUtilsIPv6IfaceId iid,
char buf[static INET6_ADDRSTRLEN])
{
struct in6_addr i6_token = {.s6_addr = {
0,
}};
nm_assert(buf);
nm_utils_ipv6_addr_set_interface_identifier(&i6_token, iid);
return _nm_utils_inet6_ntop(&i6_token, buf);
}
/*****************************************************************************/
char *
nm_utils_stable_id_random(void)
{
@ -4269,89 +3890,6 @@ nm_utils_g_value_set_strv(GValue *value, GPtrArray *strings)
/*****************************************************************************/
/**
* Takes a pair @timestamp and @duration, and returns the remaining duration based
* on the new timestamp @now.
*/
guint32
nm_utils_lifetime_rebase_relative_time_on_now(guint32 timestamp, guint32 duration, gint32 now)
{
gint64 t;
nm_assert(now >= 0);
if (duration == NM_PLATFORM_LIFETIME_PERMANENT)
return NM_PLATFORM_LIFETIME_PERMANENT;
if (timestamp == 0) {
/* if the @timestamp is zero, assume it was just left unset and that the relative
* @duration starts counting from @now. This is convenient to construct an address
* and print it in nm_platform_ip4_address_to_string().
*
* In general it does not make sense to set the @duration without anchoring at
* @timestamp because you don't know the absolute expiration time when looking
* at the address at a later moment. */
timestamp = now;
}
/* For timestamp > now, just accept it and calculate the expected(?) result. */
t = (gint64) timestamp + (gint64) duration - (gint64) now;
if (t <= 0)
return 0;
if (t >= NM_PLATFORM_LIFETIME_PERMANENT)
return NM_PLATFORM_LIFETIME_PERMANENT - 1;
return t;
}
guint32
nm_utils_lifetime_get(guint32 timestamp,
guint32 lifetime,
guint32 preferred,
gint32 now,
guint32 *out_preferred)
{
guint32 t_lifetime, t_preferred;
nm_assert(now >= 0);
if (timestamp == 0 && lifetime == 0) {
/* We treat lifetime==0 && timestamp==0 addresses as permanent addresses to allow easy
* creation of such addresses (without requiring to set the lifetime fields to
* NM_PLATFORM_LIFETIME_PERMANENT). The real lifetime==0 addresses (E.g. DHCP6 telling us
* to drop an address will have timestamp set.
*/
NM_SET_OUT(out_preferred, NM_PLATFORM_LIFETIME_PERMANENT);
g_return_val_if_fail(preferred == 0, NM_PLATFORM_LIFETIME_PERMANENT);
return NM_PLATFORM_LIFETIME_PERMANENT;
}
if (now <= 0)
now = nm_utils_get_monotonic_timestamp_sec();
t_lifetime = nm_utils_lifetime_rebase_relative_time_on_now(timestamp, lifetime, now);
if (!t_lifetime) {
NM_SET_OUT(out_preferred, 0);
return 0;
}
t_preferred = nm_utils_lifetime_rebase_relative_time_on_now(timestamp, preferred, now);
NM_SET_OUT(out_preferred, MIN(t_preferred, t_lifetime));
/* Assert that non-permanent addresses have a (positive) @timestamp. nm_utils_lifetime_rebase_relative_time_on_now()
* treats addresses with timestamp 0 as *now*. Addresses passed to _address_get_lifetime() always
* should have a valid @timestamp, otherwise on every re-sync, their lifetime will be extended anew.
*/
g_return_val_if_fail(timestamp != 0
|| (lifetime == NM_PLATFORM_LIFETIME_PERMANENT
&& preferred == NM_PLATFORM_LIFETIME_PERMANENT),
t_lifetime);
g_return_val_if_fail(t_preferred <= t_lifetime, t_lifetime);
return t_lifetime;
}
const char *
nm_utils_dnsmasq_status_to_string(int status, char *dest, gsize size)
{
@ -5102,13 +4640,6 @@ nm_wifi_utils_level_to_quality(int val)
/*****************************************************************************/
NM_UTILS_ENUM2STR_DEFINE(nm_icmpv6_router_pref_to_string,
NMIcmpv6RouterPref,
NM_UTILS_ENUM2STR(NM_ICMPV6_ROUTER_PREF_LOW, "low"),
NM_UTILS_ENUM2STR(NM_ICMPV6_ROUTER_PREF_MEDIUM, "medium"),
NM_UTILS_ENUM2STR(NM_ICMPV6_ROUTER_PREF_HIGH, "high"),
NM_UTILS_ENUM2STR(NM_ICMPV6_ROUTER_PREF_INVALID, "invalid"), );
NM_UTILS_LOOKUP_STR_DEFINE(nm_activation_type_to_string,
NMActivationType,
NM_UTILS_LOOKUP_DEFAULT_WARN("(unknown)"),

View file

@ -16,8 +16,6 @@
/*****************************************************************************/
#define NM_PLATFORM_LIFETIME_PERMANENT G_MAXUINT32
#define NM_DEFINE_SINGLETON_INSTANCE(TYPE) static TYPE *singleton_instance
#define NM_DEFINE_SINGLETON_REGISTER(TYPE) \
@ -98,73 +96,6 @@ void _nm_singleton_instance_register_destruction(GObject *instance);
gboolean nm_ether_addr_is_valid(const NMEtherAddr *addr);
gboolean nm_ether_addr_is_valid_str(const char *str);
gconstpointer
nm_utils_ipx_address_clear_host_address(int family, gpointer dst, gconstpointer src, guint8 plen);
in_addr_t nm_utils_ip4_address_clear_host_address(in_addr_t addr, guint8 plen);
const struct in6_addr *nm_utils_ip6_address_clear_host_address(struct in6_addr * dst,
const struct in6_addr *src,
guint8 plen);
static inline int
nm_utils_ip4_address_same_prefix_cmp(in_addr_t addr_a, in_addr_t addr_b, guint8 plen)
{
NM_CMP_DIRECT(htonl(nm_utils_ip4_address_clear_host_address(addr_a, plen)),
htonl(nm_utils_ip4_address_clear_host_address(addr_b, plen)));
return 0;
}
int nm_utils_ip6_address_same_prefix_cmp(const struct in6_addr *addr_a,
const struct in6_addr *addr_b,
guint8 plen);
static inline int
nm_utils_ip_address_same_prefix_cmp(int addr_family,
gconstpointer addr_a,
gconstpointer addr_b,
guint8 plen)
{
nm_assert_addr_family(addr_family);
NM_CMP_SELF(addr_a, addr_b);
if (NM_IS_IPv4(addr_family)) {
return nm_utils_ip4_address_same_prefix_cmp(*((const in_addr_t *) addr_a),
*((const in_addr_t *) addr_b),
plen);
}
return nm_utils_ip6_address_same_prefix_cmp(addr_a, addr_b, plen);
}
static inline gboolean
nm_utils_ip4_address_same_prefix(in_addr_t addr_a, in_addr_t addr_b, guint8 plen)
{
return nm_utils_ip4_address_same_prefix_cmp(addr_a, addr_b, plen) == 0;
}
static inline gboolean
nm_utils_ip6_address_same_prefix(const struct in6_addr *addr_a,
const struct in6_addr *addr_b,
guint8 plen)
{
return nm_utils_ip6_address_same_prefix_cmp(addr_a, addr_b, plen) == 0;
}
static inline gboolean
nm_utils_ip_address_same_prefix(int addr_family,
gconstpointer addr_a,
gconstpointer addr_b,
guint8 plen)
{
return nm_utils_ip_address_same_prefix_cmp(addr_family, addr_a, addr_b, plen) == 0;
}
#define NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX(a, b, plen) \
NM_CMP_RETURN(nm_utils_ip4_address_same_prefix_cmp((a), (b), (plen)))
#define NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX(a, b, plen) \
NM_CMP_RETURN(nm_utils_ip6_address_same_prefix_cmp((a), (b), (plen)))
static inline void
nm_hash_update_in6addr(NMHashState *h, const struct in6_addr *addr)
{
@ -185,8 +116,6 @@ nm_hash_update_in6addr_prefix(NMHashState *h, const struct in6_addr *addr, guint
nm_hash_update_in6addr(h, &a);
}
double nm_utils_exp10(gint16 e);
/**
* nm_utils_ip6_route_metric_normalize:
* @metric: the route metric
@ -221,9 +150,6 @@ nm_utils_ip_route_metric_penalize(guint32 metric, guint32 penalty)
return G_MAXUINT32;
}
int nm_utils_modprobe(GError **error, gboolean suppress_error_loggin, const char *arg1, ...)
G_GNUC_NULL_TERMINATED;
void nm_utils_kill_process_sync(pid_t pid,
guint64 start_time,
int sig,
@ -291,9 +217,6 @@ gboolean nm_utils_connection_has_default_route(NMConnection *connection,
int addr_family,
gboolean * out_is_never_default);
char * nm_utils_new_vlan_name(const char *parent_iface, guint32 vlan_id);
const char *nm_utils_new_infiniband_name(char *name, const char *parent_name, int p_key);
int nm_utils_cmp_connection_by_autoconnect_priority(NMConnection *a, NMConnection *b);
void nm_utils_log_connection_diff(NMConnection *connection,
@ -304,19 +227,6 @@ void nm_utils_log_connection_diff(NMConnection *connection,
const char * prefix,
const char * dbus_path);
gboolean nm_utils_is_valid_path_component(const char *name);
const char *NM_ASSERT_VALID_PATH_COMPONENT(const char *name);
#define NM_UTILS_SYSCTL_IP_CONF_PATH_BUFSIZE 100
const char *
nm_utils_sysctl_ip_conf_path(int addr_family, char *buf, const char *ifname, const char *property);
gboolean nm_utils_sysctl_ip_conf_is_path(int addr_family,
const char *path,
const char *ifname,
const char *property);
gboolean nm_utils_is_specific_hostname(const char *name);
struct _NMUuid;
@ -344,49 +254,6 @@ nm_utils_arp_type_get_hwaddr_relevant_part(int arp_type, const guint8 **hwaddr,
/*****************************************************************************/
/* IPv6 Interface Identifier helpers */
/**
* NMUtilsIPv6IfaceId:
* @id: convenience member for validity checking; never use directly
* @id_u8: the 64-bit Interface Identifier
*
* Holds a 64-bit IPv6 Interface Identifier. The IID is a sequence of bytes
* and should not normally be treated as a %guint64, but this is done for
* convenience of validity checking and initialization.
*/
struct _NMUtilsIPv6IfaceId {
union {
guint64 id;
guint8 id_u8[8];
};
};
#define NM_UTILS_IPV6_IFACE_ID_INIT \
{ \
{ \
.id = 0 \
} \
}
void nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr * addr,
const NMUtilsIPv6IfaceId iid);
void nm_utils_ipv6_interface_identifier_get_from_addr(NMUtilsIPv6IfaceId * iid,
const struct in6_addr *addr);
gboolean nm_utils_ipv6_interface_identifier_get_from_token(NMUtilsIPv6IfaceId *iid,
const char * token);
const char *nm_utils_inet6_interface_identifier_to_token(NMUtilsIPv6IfaceId iid,
char buf[static INET6_ADDRSTRLEN]);
gboolean nm_utils_get_ipv6_interface_identifier(NMLinkType link_type,
const guint8 * hwaddr,
guint len,
guint dev_id,
NMUtilsIPv6IfaceId *out_iid);
typedef enum {
/* The stable type. Note that this value is encoded in the
* generated addresses, thus the numbers MUST not change.
@ -501,33 +368,6 @@ void _nm_utils_set_testing(NMUtilsTestFlags flags);
void nm_utils_g_value_set_strv(GValue *value, GPtrArray *strings);
guint32
nm_utils_lifetime_rebase_relative_time_on_now(guint32 timestamp, guint32 duration, gint32 now);
guint32 nm_utils_lifetime_get(guint32 timestamp,
guint32 lifetime,
guint32 preferred,
gint32 now,
guint32 *out_preferred);
/*****************************************************************************/
#define NM_IPV4LL_NETWORK ((in_addr_t)(htonl(0xA9FE0000lu)))
#define NM_IPV4LL_NETMASK ((in_addr_t)(htonl(0xFFFF0000lu)))
static inline gboolean
nm_utils_ip4_address_is_link_local(in_addr_t addr)
{
return (addr & NM_IPV4LL_NETMASK) == NM_IPV4LL_NETWORK;
}
static inline gboolean
nm_utils_ip4_address_is_zeronet(in_addr_t network)
{
/* Same as ipv4_is_zeronet() from kernel's include/linux/in.h. */
return (network & htonl(0xFF000000u)) == htonl(0x00000000u);
}
/*****************************************************************************/
const char *nm_utils_dnsmasq_status_to_string(int status, char *dest, gsize size);
@ -556,20 +396,6 @@ char * nm_utils_format_con_diff_for_audit(GHashTable *diff);
/*****************************************************************************/
/* this enum is compatible with ICMPV6_ROUTER_PREF_* (from <linux/icmpv6.h>,
* the values for netlink attribute RTA_PREF) and "enum ndp_route_preference"
* from <ndp.h>. */
typedef enum _nm_packed {
NM_ICMPV6_ROUTER_PREF_MEDIUM = 0x0, /* ICMPV6_ROUTER_PREF_MEDIUM */
NM_ICMPV6_ROUTER_PREF_LOW = 0x3, /* ICMPV6_ROUTER_PREF_LOW */
NM_ICMPV6_ROUTER_PREF_HIGH = 0x1, /* ICMPV6_ROUTER_PREF_HIGH */
NM_ICMPV6_ROUTER_PREF_INVALID = 0x2, /* ICMPV6_ROUTER_PREF_INVALID */
} NMIcmpv6RouterPref;
const char *nm_icmpv6_router_pref_to_string(NMIcmpv6RouterPref pref, char *buf, gsize len);
/*****************************************************************************/
const char *nm_activation_type_to_string(NMActivationType activation_type);
/*****************************************************************************/

View file

@ -8,7 +8,7 @@
#include <sys/wait.h>
#include "nm-dcb.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "NetworkManagerUtils.h"
static const char *helper_names[] = {"dcbtool", "fcoeadm"};

View file

@ -20,7 +20,7 @@
#include "nm-ip6-config.h"
#include "nm-manager.h"
#include "settings/nm-settings-connection.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-core-intern/nm-core-internal.h"
#define CALL_TIMEOUT (1000 * 60 * 10) /* 10 minutes for all scripts */

View file

@ -20,7 +20,7 @@
#include "main-utils.h"
#include "NetworkManagerUtils.h"
#include "platform/nm-linux-platform.h"
#include "libnm-platform/nm-linux-platform.h"
#include "libnm-platform/nm-platform-utils.h"
#include "dhcp/nm-dhcp-manager.h"
#include "ndisc/nm-ndisc.h"

View file

@ -15,8 +15,8 @@
#include "libnm-glib-aux/nm-dedup-multi.h"
#include "nm-utils.h"
#include "platform/nmp-object.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nmp-object.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nm-platform-utils.h"
#include "NetworkManagerUtils.h"
#include "libnm-core-intern/nm-core-internal.h"

View file

@ -11,7 +11,7 @@
#include "nm-setting-ip4-config.h"
#include "libnm-glib-aux/nm-dedup-multi.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nmp-object.h"
#include "nm-ip-config.h"
/*****************************************************************************/

View file

@ -16,8 +16,8 @@
#include "libnm-glib-aux/nm-dedup-multi.h"
#include "nm-utils.h"
#include "platform/nmp-object.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nmp-object.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nm-platform-utils.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "NetworkManagerUtils.h"

View file

@ -11,7 +11,7 @@
#include "nm-setting-ip6-config.h"
#include "libnm-glib-aux/nm-dedup-multi.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nmp-object.h"
#include "nm-ip-config.h"
/*****************************************************************************/

View file

@ -10,9 +10,9 @@
#include "libnm-glib-aux/nm-enum-utils.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nm-platform-utils.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nmp-object.h"
#include "NetworkManagerUtils.h"
/*****************************************************************************/

View file

@ -6,8 +6,8 @@
#include "libnm-glib-aux/nm-dedup-multi.h"
#include "nm-setting-connection.h"
#include "nm-setting-ip6-config.h"
#include "platform/nm-platform.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-object.h"
typedef enum {
NM_L3_CONFIG_DAT_FLAGS_NONE = 0,

View file

@ -9,8 +9,9 @@
#include <linux/if_ether.h>
#include <linux/rtnetlink.h>
#include "platform/nm-platform.h"
#include "platform/nmp-object.h"
#include "libnm-glib-aux/nm-time-utils.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-object.h"
#include "nm-netns.h"
#include "n-acd/src/n-acd.h"
#include "nm-l3-ipv4ll.h"

View file

@ -3,7 +3,7 @@
#ifndef __NM_L3CFG_H__
#define __NM_L3CFG_H__
#include "platform/nmp-object.h"
#include "libnm-platform/nmp-object.h"
#include "nm-l3-config-data.h"
#define NM_L3CFG_CONFIG_PRIORITY_IPV4LL 0

View file

@ -23,8 +23,8 @@
#include "vpn/nm-vpn-manager.h"
#include "devices/nm-device.h"
#include "devices/nm-device-generic.h"
#include "platform/nm-platform.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-object.h"
#include "nm-hostname-manager.h"
#include "nm-keep-alive.h"
#include "nm-rfkill-manager.h"
@ -1305,7 +1305,7 @@ find_device_by_permanent_hw_addr(NMManager *self, const char *hwaddr)
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
NMDevice * device;
const char * device_addr;
guint8 hwaddr_bin[NM_UTILS_HWADDR_LEN_MAX];
guint8 hwaddr_bin[_NM_UTILS_HWADDR_LEN_MAX];
gsize hwaddr_len;
g_return_val_if_fail(hwaddr != NULL, NULL);

View file

@ -13,9 +13,9 @@
#include "NetworkManagerUtils.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "nm-l3cfg.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-netns.h"
#include "platform/nmp-rules-manager.h"
#include "libnm-platform/nmp-rules-manager.h"
/*****************************************************************************/

View file

@ -19,13 +19,15 @@
typedef struct _NMNetnsClass NMNetnsClass;
struct _NMPlatform;
GType nm_netns_get_type(void);
NMNetns *nm_netns_get(void);
NMNetns *nm_netns_new(NMPlatform *platform);
NMNetns *nm_netns_new(struct _NMPlatform *platform);
NMPlatform *nm_netns_get_platform(NMNetns *self);
NMPNetns * nm_netns_get_platform_netns(NMNetns *self);
struct _NMPlatform *nm_netns_get_platform(NMNetns *self);
NMPNetns * nm_netns_get_platform_netns(NMNetns *self);
struct _NMPRulesManager *nm_netns_get_rules_manager(NMNetns *self);

View file

@ -9,7 +9,7 @@
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "nm-dbus-manager.h"
#include "nm-proxy-config.h"
#include "nm-ip4-config.h"

View file

@ -17,7 +17,7 @@
#include "devices/nm-device.h"
#include "nm-setting-ip4-config.h"
#include "nm-setting-connection.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "dns/nm-dns-manager.h"
#include "vpn/nm-vpn-manager.h"
#include "nm-auth-utils.h"

View file

@ -77,147 +77,6 @@ typedef enum {
NM_ACTIVATION_REASON_USER_REQUEST,
} NMActivationReason;
/* platform */
typedef struct _NMPlatform NMPlatform;
typedef struct _NMPlatformObject NMPlatformObject;
typedef struct _NMPlatformObjWithIfindex NMPlatformObjWithIfindex;
typedef struct _NMPlatformIP4Address NMPlatformIP4Address;
typedef struct _NMPlatformIP4Route NMPlatformIP4Route;
typedef struct _NMPlatformIP6Address NMPlatformIP6Address;
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,
#define NMP_OBJECT_TYPE_IP_ADDRESS(is_ipv4) \
((is_ipv4) ? NMP_OBJECT_TYPE_IP4_ADDRESS : NMP_OBJECT_TYPE_IP6_ADDRESS)
NMP_OBJECT_TYPE_IP4_ADDRESS,
NMP_OBJECT_TYPE_IP6_ADDRESS,
#define NMP_OBJECT_TYPE_IP_ROUTE(is_ipv4) \
((is_ipv4) ? NMP_OBJECT_TYPE_IP4_ROUTE : NMP_OBJECT_TYPE_IP6_ROUTE)
NMP_OBJECT_TYPE_IP4_ROUTE,
NMP_OBJECT_TYPE_IP6_ROUTE,
NMP_OBJECT_TYPE_ROUTING_RULE,
NMP_OBJECT_TYPE_QDISC,
NMP_OBJECT_TYPE_TFILTER,
NMP_OBJECT_TYPE_LNK_BRIDGE,
NMP_OBJECT_TYPE_LNK_GRE,
NMP_OBJECT_TYPE_LNK_GRETAP,
NMP_OBJECT_TYPE_LNK_INFINIBAND,
NMP_OBJECT_TYPE_LNK_IP6TNL,
NMP_OBJECT_TYPE_LNK_IP6GRE,
NMP_OBJECT_TYPE_LNK_IP6GRETAP,
NMP_OBJECT_TYPE_LNK_IPIP,
NMP_OBJECT_TYPE_LNK_MACSEC,
NMP_OBJECT_TYPE_LNK_MACVLAN,
NMP_OBJECT_TYPE_LNK_MACVTAP,
NMP_OBJECT_TYPE_LNK_SIT,
NMP_OBJECT_TYPE_LNK_TUN,
NMP_OBJECT_TYPE_LNK_VLAN,
NMP_OBJECT_TYPE_LNK_VRF,
NMP_OBJECT_TYPE_LNK_VXLAN,
NMP_OBJECT_TYPE_LNK_WIREGUARD,
__NMP_OBJECT_TYPE_LAST,
NMP_OBJECT_TYPE_MAX = __NMP_OBJECT_TYPE_LAST - 1,
} NMPObjectType;
static inline guint32
nmp_object_type_to_flags(NMPObjectType obj_type)
{
G_STATIC_ASSERT_EXPR(NMP_OBJECT_TYPE_MAX < 32);
nm_assert(_NM_INT_NOT_NEGATIVE(obj_type));
nm_assert(obj_type < NMP_OBJECT_TYPE_MAX);
return ((guint32) 1u) << obj_type;
}
/**
* NMIPConfigMergeFlags:
* @NM_IP_CONFIG_MERGE_DEFAULT: no flags set
@ -236,32 +95,12 @@ typedef enum {
NM_IP_CONFIG_MERGE_EXTERNAL = (1LL << 3),
} NMIPConfigMergeFlags;
/**
* NMIPRouteTableSyncMode:
* @NM_IP_ROUTE_TABLE_SYNC_MODE_NONE: indicate an invalid setting.
* @NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN: only the main table is synced. For all
* other tables, NM won't delete any extra routes.
* @NM_IP_ROUTE_TABLE_SYNC_MODE_FULL: NM will sync all tables, except the
* local table (255).
* @NM_IP_ROUTE_TABLE_SYNC_MODE_ALL: NM will sync all tables, including the
* local table (255).
*/
typedef enum {
NM_IP_ROUTE_TABLE_SYNC_MODE_NONE = 0,
NM_IP_ROUTE_TABLE_SYNC_MODE_MAIN = 1,
NM_IP_ROUTE_TABLE_SYNC_MODE_FULL = 2,
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL = 3,
} NMIPRouteTableSyncMode;
/* settings */
typedef struct _NMAgentManager NMAgentManager;
typedef struct _NMSecretAgent NMSecretAgent;
typedef struct _NMSettings NMSettings;
typedef struct _NMSettingsConnection NMSettingsConnection;
/* utils */
typedef struct _NMUtilsIPv6IfaceId NMUtilsIPv6IfaceId;
#define NM_SETTING_CONNECTION_MDNS_UNKNOWN ((NMSettingConnectionMdns) -42)
#endif /* NM_TYPES_H */

View file

@ -13,12 +13,9 @@
#include <linux/if.h>
#include <linux/rtnetlink.h>
#include "nm-utils.h"
#include "nm-core-utils.h"
#include "libnm-platform/nm-platform-utils.h"
#include "nm-platform-private.h"
#include "nmp-object.h"
#include "libnm-platform/nm-platform-private.h"
#include "libnm-platform/nmp-object.h"
#include "nm-test-utils-core.h"
@ -608,7 +605,7 @@ link_set_address(NMPlatform *platform, int ifindex, gconstpointer addr, size_t l
NMFakePlatformLink *device = link_get(platform, ifindex);
nm_auto_nmpobj NMPObject *obj_tmp = NULL;
if (len == 0 || len > NM_UTILS_HWADDR_LEN_MAX || !addr)
if (len == 0 || len > _NM_UTILS_HWADDR_LEN_MAX || !addr)
g_return_val_if_reached(-NME_BUG);
if (!device)
@ -749,8 +746,8 @@ link_release(NMPlatform *platform, int master_idx, int slave_idx)
static gboolean
link_vlan_change(NMPlatform * platform,
int ifindex,
NMVlanFlags flags_mask,
NMVlanFlags flags_set,
_NMVlanFlags flags_mask,
_NMVlanFlags flags_set,
gboolean ingress_reset_all,
const NMVlanQosMapping *ingress_map,
gsize n_ingress_map,
@ -799,7 +796,7 @@ infiniband_partition_add(NMPlatform * platform,
parent_device = link_get(platform, parent);
g_return_val_if_fail(parent_device != NULL, FALSE);
nm_utils_new_infiniband_name(name, parent_device->obj->link.name, p_key);
nmp_utils_new_infiniband_name(name, parent_device->obj->link.name, p_key);
link_add_one(platform, name, NM_LINK_TYPE_INFINIBAND, _infiniband_add_prepare, &d, out_link);
return TRUE;
@ -814,12 +811,12 @@ infiniband_partition_delete(NMPlatform *platform, int parent, int p_key)
parent_device = link_get(platform, parent);
g_return_val_if_fail(parent_device != NULL, FALSE);
nm_utils_new_infiniband_name(name, parent_device->obj->link.name, p_key);
nmp_utils_new_infiniband_name(name, parent_device->obj->link.name, p_key);
return link_delete(platform, nm_platform_link_get_ifindex(platform, name));
}
static gboolean
wifi_get_capabilities(NMPlatform *platform, int ifindex, NMDeviceWifiCapabilities *caps)
wifi_get_capabilities(NMPlatform *platform, int ifindex, _NMDeviceWifiCapabilities *caps)
{
NMFakePlatformLink *device = link_get(platform, ifindex);
@ -829,10 +826,10 @@ wifi_get_capabilities(NMPlatform *platform, int ifindex, NMDeviceWifiCapabilitie
return FALSE;
if (caps) {
*caps = (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104
| NM_WIFI_DEVICE_CAP_CIPHER_TKIP | NM_WIFI_DEVICE_CAP_CIPHER_CCMP
| NM_WIFI_DEVICE_CAP_WPA | NM_WIFI_DEVICE_CAP_RSN | NM_WIFI_DEVICE_CAP_AP
| NM_WIFI_DEVICE_CAP_ADHOC);
*caps = (_NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | _NM_WIFI_DEVICE_CAP_CIPHER_WEP104
| _NM_WIFI_DEVICE_CAP_CIPHER_TKIP | _NM_WIFI_DEVICE_CAP_CIPHER_CCMP
| _NM_WIFI_DEVICE_CAP_WPA | _NM_WIFI_DEVICE_CAP_RSN | _NM_WIFI_DEVICE_CAP_AP
| _NM_WIFI_DEVICE_CAP_ADHOC);
}
return TRUE;
}
@ -861,14 +858,14 @@ wifi_get_rate(NMPlatform *platform, int ifindex)
return 0;
}
static NM80211Mode
static _NM80211Mode
wifi_get_mode(NMPlatform *platform, int ifindex)
{
return NM_802_11_MODE_UNKNOWN;
return _NM_802_11_MODE_UNKNOWN;
}
static void
wifi_set_mode(NMPlatform *platform, int ifindex, NM80211Mode mode)
wifi_set_mode(NMPlatform *platform, int ifindex, _NM80211Mode mode)
{
;
}

View file

@ -6,7 +6,7 @@
#ifndef __NETWORKMANAGER_FAKE_PLATFORM_H__
#define __NETWORKMANAGER_FAKE_PLATFORM_H__
#include "nm-platform.h"
#include "libnm-platform/nm-platform.h"
#define NM_TYPE_FAKE_PLATFORM (nm_fake_platform_get_type())
#define NM_FAKE_PLATFORM(obj) \

View file

@ -8,7 +8,7 @@
#include <stdlib.h>
#include <syslog.h>
#include "platform/nm-linux-platform.h"
#include "libnm-platform/nm-linux-platform.h"
#include "nm-test-utils-core.h"

View file

@ -11,10 +11,10 @@
#include <linux/if_link.h>
#include <linux/ip6_tunnel.h>
#include "platform/nm-platform.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-object.h"
#include "platform/nm-fake-platform.h"
#include "platform/nm-linux-platform.h"
#include "libnm-platform/nm-linux-platform.h"
#include "nm-test-utils-core.h"

View file

@ -13,7 +13,7 @@
#include "libnm-glib-aux/nm-io-utils.h"
#include "libnm-base/nm-ethtool-base.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nmp-object.h"
#include "libnm-platform/nmp-netns.h"
#include "libnm-platform/nm-platform-utils.h"
@ -1303,7 +1303,7 @@ test_software_detect(gconstpointer user_data)
if (!nm_platform_link_get_by_ifname(NM_PLATFORM_GET, "gre0")) {
/* Seems that the ip_gre module is not loaded... try to load it. */
gracefully_skip = nm_utils_modprobe(NULL, TRUE, "ip_gre", NULL) != 0;
gracefully_skip = nmp_utils_modprobe(NULL, TRUE, "ip_gre", NULL) != 0;
}
if (!nmtstp_link_gre_add(NULL, ext, DEVICE_NAME, &lnk_gre)) {
@ -1330,7 +1330,7 @@ test_software_detect(gconstpointer user_data)
if (!nm_platform_link_get_by_ifname(NM_PLATFORM_GET, "gretap0")) {
/* Seems that the ip_gre module is not loaded... try to load it. */
gracefully_skip = nm_utils_modprobe(NULL, TRUE, "ip_gre", NULL) != 0;
gracefully_skip = nmp_utils_modprobe(NULL, TRUE, "ip_gre", NULL) != 0;
}
if (!nmtstp_link_gre_add(NULL, ext, DEVICE_NAME, &lnk_gre)) {
@ -1350,7 +1350,7 @@ test_software_detect(gconstpointer user_data)
if (!nm_platform_link_get_by_ifname(NM_PLATFORM_GET, "tunl0")) {
/* Seems that the ipip module is not loaded... try to load it. */
gracefully_skip = nm_utils_modprobe(NULL, TRUE, "ipip", NULL) != 0;
gracefully_skip = nmp_utils_modprobe(NULL, TRUE, "ipip", NULL) != 0;
}
lnk_ipip.local = nmtst_inet4_from_string("1.2.3.4");
@ -1376,7 +1376,7 @@ test_software_detect(gconstpointer user_data)
if (!nm_platform_link_get_by_ifname(NM_PLATFORM_GET, "ip6tnl0")) {
/* Seems that the ip6_tunnel module is not loaded... try to load it. */
gracefully_skip = nm_utils_modprobe(NULL, TRUE, "ip6_tunnel", NULL) != 0;
gracefully_skip = nmp_utils_modprobe(NULL, TRUE, "ip6_tunnel", NULL) != 0;
}
switch (test_data->test_mode) {
@ -1418,7 +1418,7 @@ test_software_detect(gconstpointer user_data)
if (!nm_platform_link_get_by_ifname(NM_PLATFORM_GET, "ip6gre0")) {
/* Seems that the ip6_tunnel module is not loaded... try to load it. */
gracefully_skip = nm_utils_modprobe(NULL, TRUE, "ip6_gre", NULL) != 0;
gracefully_skip = nmp_utils_modprobe(NULL, TRUE, "ip6_gre", NULL) != 0;
}
lnk_ip6tnl.local = *nmtst_inet6_from_string("fd01::42");
@ -1445,7 +1445,7 @@ test_software_detect(gconstpointer user_data)
if (!nm_platform_link_get_by_ifname(NM_PLATFORM_GET, "ip6gre0")) {
/* Seems that the ip6_tunnel module is not loaded... try to load it. */
gracefully_skip = nm_utils_modprobe(NULL, TRUE, "ip6_gre", NULL) != 0;
gracefully_skip = nmp_utils_modprobe(NULL, TRUE, "ip6_gre", NULL) != 0;
}
lnk_ip6tnl.local = *nmtst_inet6_from_string("fe80::abcd");
@ -1526,7 +1526,7 @@ test_software_detect(gconstpointer user_data)
if (!nm_platform_link_get_by_ifname(NM_PLATFORM_GET, "sit0")) {
/* Seems that the sit module is not loaded... try to load it. */
gracefully_skip = nm_utils_modprobe(NULL, TRUE, "sit", NULL) != 0;
gracefully_skip = nmp_utils_modprobe(NULL, TRUE, "sit", NULL) != 0;
}
if (!nmtstp_link_sit_add(NULL, ext, DEVICE_NAME, &lnk_sit)) {
@ -2049,7 +2049,7 @@ _assert_xgress_qos_mappings_impl(int ifindex, gboolean is_ingress_map, int n_ent
_assert_xgress_qos_mappings(ifindex, FALSE, n_entries, __VA_ARGS__)
static void
_assert_vlan_flags(int ifindex, NMVlanFlags flags)
_assert_vlan_flags(int ifindex, _NMVlanFlags flags)
{
const NMPlatformLnkVlan *plnk;
@ -2362,8 +2362,8 @@ test_vlan_set_xgress(void)
g_assert(nm_platform_link_vlan_change(NM_PLATFORM_GET,
ifindex,
NM_VLAN_FLAG_REORDER_HEADERS | NM_VLAN_FLAG_GVRP,
NM_VLAN_FLAG_REORDER_HEADERS,
_NM_VLAN_FLAG_REORDER_HEADERS | _NM_VLAN_FLAG_GVRP,
_NM_VLAN_FLAG_REORDER_HEADERS,
TRUE,
ingress_map,
G_N_ELEMENTS(ingress_map),
@ -2372,7 +2372,7 @@ test_vlan_set_xgress(void)
G_N_ELEMENTS(egress_map)));
_assert_ingress_qos_mappings(ifindex, 2, 4, 1, 6, 12);
_assert_egress_qos_mappings(ifindex, 2, 1, 5, 3232, 7);
_assert_vlan_flags(ifindex, NM_VLAN_FLAG_REORDER_HEADERS);
_assert_vlan_flags(ifindex, _NM_VLAN_FLAG_REORDER_HEADERS);
}
{
@ -2393,8 +2393,8 @@ test_vlan_set_xgress(void)
g_assert(nm_platform_link_vlan_change(NM_PLATFORM_GET,
ifindex,
NM_VLAN_FLAG_GVRP,
NM_VLAN_FLAG_GVRP,
_NM_VLAN_FLAG_GVRP,
_NM_VLAN_FLAG_GVRP,
FALSE,
ingress_map,
G_N_ELEMENTS(ingress_map),
@ -2403,7 +2403,7 @@ test_vlan_set_xgress(void)
G_N_ELEMENTS(egress_map)));
_assert_ingress_qos_mappings(ifindex, 2, 4, 1, 6, 12);
_assert_egress_qos_mappings(ifindex, 2, 1, 7, 64, 4);
_assert_vlan_flags(ifindex, NM_VLAN_FLAG_REORDER_HEADERS | NM_VLAN_FLAG_GVRP);
_assert_vlan_flags(ifindex, _NM_VLAN_FLAG_REORDER_HEADERS | _NM_VLAN_FLAG_GVRP);
}
nmtstp_link_delete(NULL, -1, ifindex, DEVICE_NAME, TRUE);

View file

@ -8,7 +8,7 @@
#include <libudev.h>
#include <linux/pkt_sched.h>
#include "platform/nmp-object.h"
#include "libnm-platform/nmp-object.h"
#include "libnm-udev-aux/nm-udev-utils.h"
#include "nm-test-utils-core.h"

View file

@ -8,7 +8,7 @@
#include <linux/rtnetlink.h>
#include "libnm-platform/nm-platform-utils.h"
#include "platform/nm-linux-platform.h"
#include "libnm-platform/nm-linux-platform.h"
#include "nm-test-utils-core.h"

View file

@ -10,7 +10,7 @@
#include "nm-core-utils.h"
#include "libnm-platform/nm-platform-utils.h"
#include "platform/nmp-rules-manager.h"
#include "libnm-platform/nmp-rules-manager.h"
#include "test-common.h"

View file

@ -5,7 +5,7 @@
#include <linux/pkt_sched.h>
#include "nm-test-utils-core.h"
#include "platform/nmp-object.h"
#include "libnm-platform/nmp-object.h"
#include "libnm-platform/nmp-netns.h"
#include "libnm-platform/nm-platform-utils.h"
#include "test-common.h"

View file

@ -28,7 +28,8 @@
#include <linux/rtnetlink.h>
#include "NetworkManagerUtils.h"
#include "platform/nm-platform.h"
#include "libnm-platform/nm-platform.h"
#include "libnm-platform/nm-platform-utils.h"
#include "libnm-core-intern/nm-core-internal.h"
#include "nm-act-request.h"
#include "nm-ip4-config.h"
@ -998,7 +999,7 @@ _ppp_manager_start(NMPPPManager *self,
/* Make sure /dev/ppp exists (bgo #533064) */
if (stat("/dev/ppp", &st) || !S_ISCHR(st.st_mode))
nm_utils_modprobe(NULL, FALSE, "ppp_generic", NULL);
nmp_utils_modprobe(NULL, FALSE, "ppp_generic", NULL);
connection = nm_act_request_get_applied_connection(req);
g_return_val_if_fail(connection, FALSE);

Some files were not shown because too many files have changed in this diff Show more