mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 17:40:38 +01:00
release: bump version to 1.37.1 (development)
This commit is contained in:
commit
2c9d3ef6c7
98 changed files with 1805 additions and 14016 deletions
|
|
@ -7,7 +7,7 @@
|
|||
########################################
|
||||
|
||||
|
||||
.templates_sha: &template_sha 14731f78c23c7b523a85a26a068ade9ac1ecd2f3 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
|
||||
.templates_sha: &template_sha 3e66ea37e5672bb8f48e3056ba92915b5fc5b888 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
|
||||
|
||||
include:
|
||||
# Alpine container builder template
|
||||
|
|
@ -47,11 +47,11 @@ variables:
|
|||
#
|
||||
# This is done by running `ci-fairy generate-template` and possibly bump
|
||||
# ".default_tag".
|
||||
FEDORA_TAG: '2021-11-09.0-9dd1e1db773a'
|
||||
UBUNTU_TAG: '2021-11-09.0-577176f5eb6c'
|
||||
DEBIAN_TAG: '2021-11-09.0-577176f5eb6c'
|
||||
CENTOS_TAG: '2021-11-09.0-9dd1e1db773a'
|
||||
ALPINE_TAG: '2021-11-09.0-a28badea28eb'
|
||||
FEDORA_TAG: '2022-02-21.0-f42312ef8cae'
|
||||
UBUNTU_TAG: '2022-02-21.0-ab561a08b357'
|
||||
DEBIAN_TAG: '2022-02-21.0-ab561a08b357'
|
||||
CENTOS_TAG: '2022-02-21.0-f42312ef8cae'
|
||||
ALPINE_TAG: '2022-02-21.0-bad60eeb6900'
|
||||
|
||||
FEDORA_EXEC: 'bash .gitlab-ci/fedora-install.sh'
|
||||
UBUNTU_EXEC: 'bash .gitlab-ci/debian-install.sh'
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
########################################
|
||||
|
||||
|
||||
.templates_sha: &template_sha 14731f78c23c7b523a85a26a068ade9ac1ecd2f3 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
|
||||
.templates_sha: &template_sha 3e66ea37e5672bb8f48e3056ba92915b5fc5b888 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
|
||||
|
||||
include:
|
||||
{% for distro in distributions|sort(attribute="name") %}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#
|
||||
|
||||
# We're happy to rebuild all containers when one changes.
|
||||
.default_tag: &default_tag '2021-11-09.0'
|
||||
.default_tag: &default_tag '2022-02-21.0'
|
||||
|
||||
|
||||
# The list of all distributions we want to create job for.
|
||||
|
|
|
|||
|
|
@ -5,13 +5,18 @@ set -ex
|
|||
IS_FEDORA=0
|
||||
IS_CENTOS=0
|
||||
IS_CENTOS_7=0
|
||||
IS_CENTOS_8=0
|
||||
grep -q '^NAME=.*\(CentOS\)' /etc/os-release && IS_CENTOS=1
|
||||
grep -q '^NAME=.*\(Fedora\)' /etc/os-release && IS_FEDORA=1
|
||||
if [ $IS_CENTOS = 1 ]; then
|
||||
grep -q '^VERSION_ID=.*\<7\>' /etc/os-release && IS_CENTOS_7=1
|
||||
if grep -q '^VERSION_ID=.*\<7\>' /etc/os-release ; then
|
||||
IS_CENTOS_7=1
|
||||
elif grep -q '^VERSION_ID=.*\<8\>' /etc/os-release ; then
|
||||
IS_CENTOS_8=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $IS_CENTOS = 1 ]; then
|
||||
if [ $IS_CENTOS = 1 ]; then
|
||||
if [ $IS_CENTOS_7 = 1 ]; then
|
||||
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
|
||||
yum install -y glibc-common
|
||||
|
|
@ -19,6 +24,13 @@ if [ $IS_CENTOS = 1 ]; then
|
|||
locale -a
|
||||
yum install -y python36-dbus python36-gobject-base
|
||||
else
|
||||
if [ $IS_CENTOS_8 = 1 ]; then
|
||||
# CentOS Linux 8 is now EOF and plain `dnf upgrade` does not work. We need
|
||||
# to patch the mirror list.
|
||||
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
|
||||
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
|
||||
fi
|
||||
|
||||
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
|
||||
dnf install -y 'dnf-command(config-manager)'
|
||||
dnf config-manager --set-enabled powertools || \
|
||||
|
|
|
|||
18
Makefile.am
18
Makefile.am
|
|
@ -1471,6 +1471,24 @@ src_libnm_core_impl_libnm_crypto_nss_la_LIBADD = \
|
|||
$(NSS_LIBS)
|
||||
endif
|
||||
|
||||
if !WITH_GNUTLS
|
||||
if !WITH_NSS
|
||||
libnm_crypto_lib = src/libnm-core-impl/libnm-crypto-null.la
|
||||
else
|
||||
check_ltlibraries += src/libnm-core-impl/libnm-crypto-null.la
|
||||
endif
|
||||
else
|
||||
check_ltlibraries += src/libnm-core-impl/libnm-crypto-null.la
|
||||
endif
|
||||
|
||||
src_libnm_core_impl_libnm_crypto_null_la_SOURCES = src/libnm-core-impl/nm-crypto-null.c
|
||||
src_libnm_core_impl_libnm_crypto_null_la_CPPFLAGS = \
|
||||
$(src_libnm_core_impl_libnm_core_impl_la_CPPFLAGS)
|
||||
src_libnm_core_impl_libnm_crypto_null_la_LDFLAGS = \
|
||||
$(src_libnm_core_impl_libnm_core_impl_la_LDFLAGS)
|
||||
src_libnm_core_impl_libnm_crypto_null_la_LIBADD = \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
noinst_LTLIBRARIES += $(libnm_crypto_lib)
|
||||
|
||||
###############################################################################
|
||||
|
|
|
|||
16
NEWS
16
NEWS
|
|
@ -1,3 +1,19 @@
|
|||
=============================================
|
||||
NetworkManager-1.38
|
||||
Overview of changes since NetworkManager-1.36
|
||||
=============================================
|
||||
|
||||
This is a snapshot of NetworkManager development. The API is
|
||||
subject to change and not guaranteed to be compatible with
|
||||
the later release.
|
||||
USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE!
|
||||
|
||||
* Wi-Fi hotspots will use a (stable) random channel number unless one is
|
||||
chosen manually.
|
||||
* libnm: add new dummy crypto backend "null" that does nothing.
|
||||
* Veth devices with name "eth*" are now managed by default via the
|
||||
udev rule. This is to support managing the network in LXD containers.
|
||||
|
||||
=============================================
|
||||
NetworkManager-1.36
|
||||
Overview of changes since NetworkManager-1.34
|
||||
|
|
|
|||
123
TODO
123
TODO
|
|
@ -2,7 +2,107 @@ So you're interested in hacking on NetworkManager? Here's some cool
|
|||
stuff you could do...
|
||||
|
||||
|
||||
* Use netlink API instead of ioctl based ethtool.
|
||||
Improve Shutdown of NetworkManager
|
||||
==================================
|
||||
|
||||
NetworkManager quits when receiving SIGTERM.
|
||||
|
||||
Currently, it stops iterating the GMainContext (g_main_loop_quit()) and performs
|
||||
some synchronous cleanup actions.
|
||||
|
||||
That is problematic for the following reasons.
|
||||
|
||||
- We generally avoid blocking operations in NetworkManager (except currently during shutdown).
|
||||
Hence it's normal at any time to have async operations pending. Async operations
|
||||
with glib basically mean that we will receive a callback from the mainloop. For that
|
||||
to work, we need to keep iterating the GMainContext. If we stop iterating,
|
||||
we cannot cleanup the pending operations and leak resources. It's not possible
|
||||
to free all resources, unless we iterate as long as we have pending operations.
|
||||
|
||||
That is because even if you g_cancellable_cancel() an sync operation, you still
|
||||
get a callback. The fact that an async operation will always get (one) callback
|
||||
invocation is an important guarantee in glib. If we no longer have that guarantee,
|
||||
it would be effectively impossible to implement cancellation and proper cleanup
|
||||
and it would require to do that for all async operations (changing the guaranteed
|
||||
semantics of all async operations).
|
||||
|
||||
Often it wouldn't matter whether we free all resources during shutdown. However,
|
||||
unless we have a strict policy and method for freeing all, we will inevitably
|
||||
leak resources where it does matter.
|
||||
|
||||
It's anyway hard to move from a "running" state to a "shutdown" state. It's
|
||||
impossible to get right, if we have pending async operations that no longer can
|
||||
complete.
|
||||
|
||||
- Once we stop iterating the mainloop, we also cannot make async operations anymore.
|
||||
This reduces our shutdown to blocking operations (or a string of async operations that
|
||||
get chained together to one blocking operation, e.g. by using a separate GMainContext).
|
||||
This is very limiting, also because it's getting really hard to do things in
|
||||
parallel (unless you strongly intertwine them or essentially re-implement a
|
||||
main loop). Doing things in parallel will be necessary, for example if deactivate
|
||||
two devices, then both should shutdown in parallel.
|
||||
|
||||
The real problem is that our shutdown is really messy due to this. And this is a
|
||||
fundamental limitation of the current implementation.
|
||||
|
||||
The solution will be the following.
|
||||
|
||||
When we receive SIGTERM we go into shutdown mode. This may mean to reject new D-Bus
|
||||
requests and in general to move into a shutdown state. All the while we keep iterating
|
||||
the GMainContext, but we also start to tear down and cancel/complete pending operations.
|
||||
While we do that, we may need to start new async operations. For example, during
|
||||
shutdown we may want to kill dnsmasq, which itself is a new asynchronous operation.
|
||||
|
||||
The API nm_shutdown_wait_obj_register_object() and family allow for things to register
|
||||
themselves to block shutdown. This works using weak pointers. Basically, NetworkManager will
|
||||
keep iterating the GMainContext as long as we have objects registered there. While shutting
|
||||
down, we expect those objects to complete and unregister themselves.
|
||||
|
||||
Currently, our singleton objects (NM_DEFINE_SINGLETON_REGISTER) get unrefed after
|
||||
the `main()` functions. For some/all of those singletons, during SIGTERM we may
|
||||
want to register them as nm_shutdown_wait_obj_register_object() and unref them when
|
||||
we initiate the shutdown.
|
||||
Singletons also use weak pointers and can work together with nm_shutdown_wait_obj_register_object().
|
||||
For that to work, we need that nobody is calling the singleton getter *after* shutdown
|
||||
starts. That means, instead of using the singleton getter, you need to get the reference
|
||||
from somebody. For example, NMDevice has a reference to a NMNetns and NMPlatform
|
||||
and should use those instead of NM_PLATFORM_GET(). For those singeltons that works
|
||||
this way (maybe all of them), the singleton getters only works reliably before
|
||||
shutdown starts. And no singleton getters work reliably after the main() function
|
||||
because singletons unref themselves. In general, avoid singleton getters and see
|
||||
that somebody hands you a reference.
|
||||
|
||||
After NM_SHUTDOWN_TIMEOUT_MAX_MSEC we loose patience that it's taking too long.
|
||||
We now log a debug message about who is still blocking shutdown.
|
||||
We also cancel the cancellables from nm_shutdown_wait_obj_register_cancellable()
|
||||
and give NM_SHUTDOWN_TIMEOUT_ADDITIONAL_MSEC more time. If we then are still
|
||||
not complete, we log an error message about who is still blocking shutdown,
|
||||
and just exit with an assertion failure. We encountered a bug.
|
||||
|
||||
This means, *all* async operations in NetworkManager must either be cancellable (and
|
||||
afterwards complete fast) or they must not take long to begin with. In particular,
|
||||
every individual async operation must be completed in at most NM_SHUTDOWN_TIMEOUT_MAX_MSEC,
|
||||
and all async cleanup operations must complete in NM_SHUTDOWN_TIMEOUT_MAX_MSEC too.
|
||||
|
||||
So if you make an async operation not cancellable, but guarantee that you don't take
|
||||
longer than NM_SHUTDOWN_TIMEOUT_MAX_MSEC you are mostly fine (better would be to actually
|
||||
complete fast, if you can). That's why reaching NM_SHUTDOWN_TIMEOUT_MAX_MSEC timeout is
|
||||
still not a bug scenario. But reaching NM_SHUTDOWN_TIMEOUT_MAX_MSEC+NM_SHUTDOWN_TIMEOUT_ADDITIONAL_MSEC
|
||||
is a bug.
|
||||
|
||||
As NM_SHUTDOWN_TIMEOUT_MAX_MSEC and nm_shutdown_wait_obj_register_object() API already exists,
|
||||
the first step is to ensure that all parts of NetworkManager can be shutdown and be terminated
|
||||
in a timely manner.
|
||||
|
||||
The second step is to replace the current sync cleanup operations with iterating the
|
||||
GMainContext. This is gonna be difficult.
|
||||
|
||||
Search for `FIXME(shutdown` for places that are related to this effort and that need
|
||||
consideration.
|
||||
|
||||
|
||||
Use netlink API instead of ioctl based ethtool
|
||||
==============================================
|
||||
|
||||
NetworkManager uses ethtool API to set/obtain certain settings of network
|
||||
devices. This is an ioctl based API and implmented in "src/platform/nm-platform-utils.c".
|
||||
|
|
@ -15,14 +115,16 @@ also implements this API, however it is under an incompatible license,
|
|||
so better don't look and make sure not to use the code.
|
||||
|
||||
|
||||
* Add 802-1x capability to nmtui.
|
||||
Add 802-1x capability to nmtui
|
||||
==============================
|
||||
|
||||
Add dialogs to nmtui for 802-1x. This will be useful for ethernet (with 802-1x
|
||||
port authentication), enterprise Wi-Fi and MACSec. From the GUI and dialog design,
|
||||
possibly get inspired by nm-connection-editor.
|
||||
|
||||
|
||||
* Ethernet Network Auto-detection
|
||||
Ethernet Network Auto-detection
|
||||
===============================
|
||||
|
||||
There are various methods we can use to autodetect which wired network connection
|
||||
to use if the user connects to more than one wired network on a frequent basis.
|
||||
|
|
@ -80,7 +182,8 @@ un-authenticated connections and that additional credentials are required to
|
|||
successfully connect to this network.
|
||||
|
||||
|
||||
* VPN re-connect (bgo #349151)
|
||||
VPN re-connect (bgo #349151)
|
||||
============================
|
||||
|
||||
NM should remember whether a VPN was connected if a connection disconnects
|
||||
(like Wi-Fi drops out or short carrier drop) or if the laptop goes to sleep.
|
||||
|
|
@ -90,7 +193,8 @@ the VPN because Wi-Fi choked for 10 seconds, but reconnect the VPN if it was
|
|||
connected before the drop.
|
||||
|
||||
|
||||
* VPN IP Methods
|
||||
VPN IP Methods
|
||||
==============
|
||||
|
||||
Some VPNs (openvpn with TAP for example) require that DHCP is run on a
|
||||
pseudo-ethernet device to obtain addressing information. Currenty, this is not
|
||||
|
|
@ -133,7 +237,8 @@ failure of the VPN connection, just like DHCP timeouts and lease-renewal
|
|||
failures do for other devices (see dhcp_state_changed() in nm-device.c).
|
||||
|
||||
|
||||
* VPN Service Daemon Secret Requests
|
||||
VPN Service Daemon Secret Requests
|
||||
==================================
|
||||
|
||||
In addition to NM asking the service daemons whether more secrets are required,
|
||||
VPN service daemons (like nm-vpnc-service, nm-openvpn-service, etc) should be
|
||||
|
|
@ -171,7 +276,8 @@ challenge-response and does not use the "--non-inter" flag which suppresses that
|
|||
behavior.
|
||||
|
||||
|
||||
* WPS
|
||||
WPS
|
||||
===
|
||||
|
||||
wpa_supplicant has support for WPS (Wifi Protected Setup, basically Bluetooth-
|
||||
like PIN codes for setting up a wifi connection) and we should add support for
|
||||
|
|
@ -215,7 +321,8 @@ because the user has no physical access to the router itself, but has been given
|
|||
as passphrase/PSK instead.
|
||||
|
||||
|
||||
* Better Tablet/Mobile Behavior
|
||||
Better Tablet/Mobile Behavior
|
||||
=============================
|
||||
|
||||
There are a few components to this:
|
||||
|
||||
|
|
|
|||
12
configure.ac
12
configure.ac
|
|
@ -7,8 +7,8 @@ dnl - add corresponding NM_VERSION_x_y_z macros in
|
|||
dnl "shared/nm-version-macros.h.in"
|
||||
dnl - update number in meson.build
|
||||
m4_define([nm_major_version], [1])
|
||||
m4_define([nm_minor_version], [36])
|
||||
m4_define([nm_micro_version], [0])
|
||||
m4_define([nm_minor_version], [37])
|
||||
m4_define([nm_micro_version], [1])
|
||||
m4_define([nm_version],
|
||||
[nm_major_version.nm_minor_version.nm_micro_version])
|
||||
|
||||
|
|
@ -321,7 +321,7 @@ AC_ARG_WITH([systemdsystemunitdir],
|
|||
[Directory for systemd service files]))
|
||||
# default location
|
||||
AS_IF([test -z "$with_systemdsystemunitdir" && $PKG_CONFIG systemd],
|
||||
with_systemdsystemunitdir="\$(prefix)/lib/systemd/system")
|
||||
with_systemdsystemunitdir=`$PKG_CONFIG systemd '--define-variable=prefix=${prefix}' '--define-variable=root_prefix=${prefix}' --variable systemdsystemunitdir`)
|
||||
AS_IF([test -z "$with_systemdsystemunitdir"], with_systemdsystemunitdir=no)
|
||||
# add conditional and subst
|
||||
AM_CONDITIONAL(HAVE_SYSTEMD, [test "$with_systemdsystemunitdir" != no])
|
||||
|
|
@ -716,7 +716,7 @@ AM_CONDITIONAL(HAVE_CRYPTO_GNUTLS, test "${have_crypto_gnutls}" = 'yes')
|
|||
AM_CONDITIONAL(HAVE_CRYPTO_NSS, test "${have_crypto_nss}" = 'yes')
|
||||
|
||||
AC_ARG_WITH(crypto,
|
||||
AS_HELP_STRING([--with-crypto=nss|gnutls],
|
||||
AS_HELP_STRING([--with-crypto=nss|gnutls|null],
|
||||
[Cryptography library to use for certificate and key operations]),
|
||||
with_crypto=$withval,
|
||||
with_crypto=nss)
|
||||
|
|
@ -728,8 +728,10 @@ elif test "$with_crypto" = 'gnutls'; then
|
|||
if test "${have_crypto_gnutls}" != "yes"; then
|
||||
AC_MSG_ERROR([No usable gnutls found for --with-crypto=gnutls])
|
||||
fi
|
||||
elif test "$with_crypto" = 'null'; then
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([Please choose either 'nss' or 'gnutls' for certificate and crypto operations])
|
||||
AC_MSG_ERROR([Please choose either 'nss', 'gnutls' or 'null' for certificate and crypto operations])
|
||||
fi
|
||||
AM_CONDITIONAL(WITH_NSS, test "$with_crypto" = 'nss')
|
||||
AM_CONDITIONAL(WITH_GNUTLS, test "$with_crypto" = 'gnutls')
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@
|
|||
%global obsoletes_ppp_plugin 1:1.5.3
|
||||
%global obsoletes_initscripts_updown 1:1.35.4
|
||||
|
||||
%global systemd_dir %{_prefix}/lib/systemd/system
|
||||
%global sysctl_dir %{_prefix}/lib/sysctl.d
|
||||
%global nmlibdir %{_prefix}/lib/%{name}
|
||||
%global nmplugindir %{_libdir}/%{name}/%{version}-%{release}
|
||||
|
||||
|
|
@ -685,7 +683,6 @@ Preferably use nmcli instead.
|
|||
%endif
|
||||
-Dsession_tracking=systemd \
|
||||
-Dsuspend_resume=systemd \
|
||||
-Dsystemdsystemunitdir=%{systemd_dir} \
|
||||
-Dsystem_ca_path=/etc/pki/tls/cert.pem \
|
||||
-Ddbus_conf_dir=%{dbus_sys_dir} \
|
||||
-Dtests=yes \
|
||||
|
|
@ -821,7 +818,6 @@ intltoolize --automake --copy --force
|
|||
--with-ebpf=%{ebpf_enabled} \
|
||||
--with-session-tracking=systemd \
|
||||
--with-suspend-resume=systemd \
|
||||
--with-systemdsystemunitdir=%{systemd_dir} \
|
||||
--with-system-ca-path=/etc/pki/tls/cert.pem \
|
||||
--with-dbus-sys-dir=%{dbus_sys_dir} \
|
||||
--with-tests=yes \
|
||||
|
|
@ -914,7 +910,7 @@ make -k %{?_smp_mflags} check || :
|
|||
|
||||
|
||||
%pre
|
||||
if [ -f "%{systemd_dir}/network-online.target.wants/NetworkManager-wait-online.service" ] ; then
|
||||
if [ -f "%{_unitdir}/network-online.target.wants/NetworkManager-wait-online.service" ] ; then
|
||||
# older versions used to install this file, effectively always enabling
|
||||
# NetworkManager-wait-online.service. We no longer do that and rely on
|
||||
# preset.
|
||||
|
|
@ -1053,10 +1049,10 @@ fi
|
|||
%{_prefix}/lib/firewalld/zones/nm-shared.xml
|
||||
%endif
|
||||
# systemd stuff
|
||||
%{systemd_dir}/NetworkManager.service
|
||||
%{systemd_dir}/NetworkManager-wait-online.service
|
||||
%{systemd_dir}/NetworkManager-dispatcher.service
|
||||
%{systemd_dir}/nm-priv-helper.service
|
||||
%{_unitdir}/NetworkManager.service
|
||||
%{_unitdir}/NetworkManager-wait-online.service
|
||||
%{_unitdir}/NetworkManager-dispatcher.service
|
||||
%{_unitdir}/nm-priv-helper.service
|
||||
%dir %{_datadir}/doc/NetworkManager/examples
|
||||
%{_datadir}/doc/NetworkManager/examples/server.conf
|
||||
%doc NEWS AUTHORS README CONTRIBUTING.md TODO
|
||||
|
|
@ -1101,7 +1097,7 @@ fi
|
|||
%if %{with ovs}
|
||||
%files ovs
|
||||
%{nmplugindir}/libnm-device-plugin-ovs.so
|
||||
%{systemd_dir}/NetworkManager.service.d/NetworkManager-ovs.conf
|
||||
%{_unitdir}/NetworkManager.service.d/NetworkManager-ovs.conf
|
||||
%{_mandir}/man7/nm-openvswitch.7*
|
||||
%endif
|
||||
|
||||
|
|
@ -1175,8 +1171,8 @@ fi
|
|||
%if %{with nm_cloud_setup}
|
||||
%files cloud-setup
|
||||
%{_libexecdir}/nm-cloud-setup
|
||||
%{systemd_dir}/nm-cloud-setup.service
|
||||
%{systemd_dir}/nm-cloud-setup.timer
|
||||
%{_unitdir}/nm-cloud-setup.service
|
||||
%{_unitdir}/nm-cloud-setup.timer
|
||||
%{nmlibdir}/dispatcher.d/90-nm-cloud-setup.sh
|
||||
%{nmlibdir}/dispatcher.d/no-wait.d/90-nm-cloud-setup.sh
|
||||
%{_mandir}/man8/nm-cloud-setup.8*
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ NM-colorize() {
|
|||
GREP_COLOR='01;31' grep -a --color=always '^\|^\(.* \)\?<\(warn> \|error>\) \[[0-9.]*\]' | \
|
||||
GREP_COLOR='01;33' grep -a --color=always '^\|^\(.* \)\?<info> \[[0-9.]*\]\( .*\<is starting\>.*$\)\?' | \
|
||||
GREP_COLOR='01;37' grep -a --color=always '^\|\<platform:\( (.*)\)\? signal: .*$' | \
|
||||
GREP_COLOR='01;34' grep -a --color=always '^\|\<platform\(-linux\)\?:\( (.*)\)\? link: \(add\|adding\|change\|setting\|deleting\|enslaving to master\)\>\|\<platform: routing-rule: \(adding or updating:\|delete \)\|\<platform:\( (.*)\)\? address: \(deleting\|adding or updating\) IPv. address:\? \|\<platform:\( (.*)\)\? \(route\|ip4-route\|ip6-route\|qdisc\|tfilter\): \([a-z]\+\|adding or updating\|new\[0x[0-9A-Za-z]*\]\) \|\<platform-linux: sysctl: setting ' | \
|
||||
GREP_COLOR='01;34' grep -a --color=always '^\|\<platform\(-linux\)\?:\( (.*)\)\? link: \(add\|adding\|change\|setting\|deleting\|enslaving to master\|releasing \([0-9]\+ \)\?from master\)\>\|\<platform: routing-rule: \(adding or updating:\|delete \)\|\<platform:\( (.*)\)\? address: \(deleting\|adding or updating\) IPv. address:\? \|\<platform:\( (.*)\)\? \(route\|ip4-route\|ip6-route\|qdisc\|tfilter\): \([a-z]\+\|adding or updating\|new\[0x[0-9A-Za-z]*\]\) \|\<platform-linux: sysctl: setting ' | \
|
||||
GREP_COLOR='01;35' grep -a --color=always '^\|\<audit: .*$' | \
|
||||
GREP_COLOR='01;32' grep -a --color=always '^\|\<device (.*): state change: ' |
|
||||
if [[ "$NM_LOG_GREP" != "" ]]; then
|
||||
|
|
|
|||
|
|
@ -24,7 +24,11 @@ ATTR{address}=="00:1c:42:*", ENV{INTERFACE}=="vnic[0-9]*", ENV{NM_UNMANAGED}="1"
|
|||
|
||||
# Virtual Ethernet device pair. Often used to communicate with a peer interface
|
||||
# in another net namespace and managed by libvirt, Docker or the like.
|
||||
ENV{ID_NET_DRIVER}=="veth", ENV{NM_UNMANAGED}="1"
|
||||
# Generally we don't want to mess with those. One exception would be the
|
||||
# full system containers, like LXC or LXD. LXC containers run via libvirt
|
||||
# don't use udev, so this doesn't apply. LXD does, though. To deal with the
|
||||
# LXD situation, let's treat the devices called eth* as regular ethernet.
|
||||
ENV{ID_NET_DRIVER}=="veth", ENV{INTERFACE}!="eth[0-9]*", ENV{NM_UNMANAGED}="1"
|
||||
|
||||
# USB gadget device. Unmanage by default, since whatever created it
|
||||
# might want to set it up itself (e.g. activate an ipv4.method=shared
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
import gi
|
||||
|
||||
|
|
@ -21,10 +22,11 @@ def usage():
|
|||
print(
|
||||
" create TIMEOUT [--destroy-all|--delete-new-connections|--disconnect-new-devices|--allow-overlapping|DEV]..."
|
||||
)
|
||||
print(" destroy PATH|NUMBER")
|
||||
print(" rollback PATH|NUMBER")
|
||||
print(" adjust-rollback-timeout PATH|NUMBER TIMEOUT")
|
||||
print(" destroy ['--last'|PATH|NUMBER[")
|
||||
print(" rollback ['--last'|PATH|NUMBER]")
|
||||
print(" adjust-rollback-timeout '--last'|PATH|NUMBER TIMEOUT")
|
||||
print("")
|
||||
print(" For destroy|rollback, when omitted then '--last' is the default.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
|
@ -54,32 +56,65 @@ def show(c, ts=None):
|
|||
)
|
||||
|
||||
|
||||
def find_checkpoint(client, path):
|
||||
for c in client.get_checkpoints():
|
||||
def checkpoint_path_to_num(path):
|
||||
m = re.match(r"^/org/freedesktop/NetworkManager/Checkpoint/([1-9][0-9]*)$", path)
|
||||
if m:
|
||||
return int(m.group(1))
|
||||
raise Exception(f'Unexpected D-Bus path "{path}"for checkpoint')
|
||||
|
||||
|
||||
def find_checkpoint(nmc, path):
|
||||
for c in nmc.get_checkpoints():
|
||||
if c.get_path() == path:
|
||||
return c
|
||||
return None
|
||||
|
||||
|
||||
def validate_path(path, client):
|
||||
def find_checkpoint_last(nmc):
|
||||
l = [c.get_path() for c in nmc.get_checkpoints()]
|
||||
if not l:
|
||||
return None
|
||||
l.sort(key=checkpoint_path_to_num)
|
||||
return l[-1]
|
||||
|
||||
|
||||
def validate_path(path, nmc):
|
||||
if path == "--last":
|
||||
path = find_checkpoint_last(nmc)
|
||||
if path is None:
|
||||
sys.exit("Has no checkpoint")
|
||||
return path
|
||||
|
||||
try:
|
||||
num = int(path)
|
||||
path = "/org/freedesktop/NetworkManager/Checkpoint/%u" % (num)
|
||||
path = f"/org/freedesktop/NetworkManager/Checkpoint/{num}"
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
if not path or path[0] != "/":
|
||||
sys.exit('Invalid checkpoint path "%s"' % (path))
|
||||
|
||||
if client is not None:
|
||||
checkpoint = find_checkpoint(client, path)
|
||||
if nmc is not None:
|
||||
checkpoint = find_checkpoint(nmc, path)
|
||||
if checkpoint is None:
|
||||
print('WARNING: no checkpoint with path "%s" found' % (path))
|
||||
|
||||
return path
|
||||
|
||||
|
||||
def do_create(client):
|
||||
def validate_path_from_argv(nmc):
|
||||
assert len(sys.argv) >= 2
|
||||
if len(sys.argv) == 2:
|
||||
path = "--last"
|
||||
elif len(sys.argv) > 3:
|
||||
sys.exit("Failed: invalid extra argument")
|
||||
else:
|
||||
path = sys.argv[2]
|
||||
|
||||
return validate_path(path, nmc)
|
||||
|
||||
|
||||
def do_create(nmc):
|
||||
flags = NM.CheckpointCreateFlags.NONE
|
||||
if len(sys.argv) < 3:
|
||||
sys.exit("Failed: missing argument timeout")
|
||||
|
|
@ -96,50 +131,44 @@ def do_create(client):
|
|||
elif arg == "--allow-overlapping":
|
||||
flags |= NM.CheckpointCreateFlags.ALLOW_OVERLAPPING
|
||||
else:
|
||||
d = client.get_device_by_iface(arg)
|
||||
d = nmc.get_device_by_iface(arg)
|
||||
if d is None:
|
||||
sys.exit("Unknown device %s" % arg)
|
||||
devices.append(d)
|
||||
|
||||
def create_cb(client, result, data):
|
||||
def create_cb(nmc, result, data):
|
||||
try:
|
||||
checkpoint = client.checkpoint_create_finish(result)
|
||||
checkpoint = nmc.checkpoint_create_finish(result)
|
||||
print("%s" % checkpoint.get_path())
|
||||
except Exception as e:
|
||||
sys.stderr.write("Failed: %s\n" % e.message)
|
||||
main_loop.quit()
|
||||
|
||||
client.checkpoint_create(devices, timeout, flags, None, create_cb, None)
|
||||
nmc.checkpoint_create(devices, timeout, flags, None, create_cb, None)
|
||||
|
||||
|
||||
def do_destroy(client):
|
||||
if len(sys.argv) < 3:
|
||||
sys.exit("Missing checkpoint path")
|
||||
def do_destroy(nmc):
|
||||
path = validate_path_from_argv(nmc)
|
||||
|
||||
path = validate_path(sys.argv[2], client)
|
||||
|
||||
def destroy_cb(client, result, data):
|
||||
def destroy_cb(nmc, result, data):
|
||||
try:
|
||||
if client.checkpoint_destroy_finish(result) == True:
|
||||
if nmc.checkpoint_destroy_finish(result) == True:
|
||||
print("Success")
|
||||
except Exception as e:
|
||||
sys.stderr.write("Failed: %s\n" % e.message)
|
||||
main_loop.quit()
|
||||
|
||||
client.checkpoint_destroy(path, None, destroy_cb, None)
|
||||
nmc.checkpoint_destroy(path, None, destroy_cb, None)
|
||||
|
||||
|
||||
def do_rollback(client):
|
||||
if len(sys.argv) < 3:
|
||||
sys.exit("Missing checkpoint path")
|
||||
def do_rollback(nmc):
|
||||
path = validate_path_from_argv(nmc)
|
||||
|
||||
path = validate_path(sys.argv[2], client)
|
||||
|
||||
def rollback_cb(client, result, data):
|
||||
def rollback_cb(nmc, result, data):
|
||||
try:
|
||||
res = client.checkpoint_rollback_finish(result)
|
||||
res = nmc.checkpoint_rollback_finish(result)
|
||||
for path in res:
|
||||
d = client.get_device_by_path(path)
|
||||
d = nmc.get_device_by_path(path)
|
||||
if d is None:
|
||||
iface = path
|
||||
else:
|
||||
|
|
@ -149,10 +178,10 @@ def do_rollback(client):
|
|||
sys.stderr.write("Failed: %s\n" % e.message)
|
||||
main_loop.quit()
|
||||
|
||||
client.checkpoint_rollback(path, None, rollback_cb, None)
|
||||
nmc.checkpoint_rollback(path, None, rollback_cb, None)
|
||||
|
||||
|
||||
def do_adjust_rollback_timeout(client):
|
||||
def do_adjust_rollback_timeout(nmc):
|
||||
if len(sys.argv) < 3:
|
||||
sys.exit("Missing checkpoint path")
|
||||
if len(sys.argv) < 4:
|
||||
|
|
@ -162,42 +191,42 @@ def do_adjust_rollback_timeout(client):
|
|||
except Exception:
|
||||
sys.exit("Invalid timeout")
|
||||
|
||||
path = validate_path(sys.argv[2], client)
|
||||
path = validate_path(sys.argv[2], nmc)
|
||||
|
||||
def adjust_rollback_timeout_cb(client, result, data):
|
||||
def adjust_rollback_timeout_cb(nmc, result, data):
|
||||
try:
|
||||
client.checkpoint_adjust_rollback_timeout_finish(result)
|
||||
nmc.checkpoint_adjust_rollback_timeout_finish(result)
|
||||
print("Success")
|
||||
except Exception as e:
|
||||
sys.stderr.write("Failed: %s\n" % e.message)
|
||||
main_loop.quit()
|
||||
|
||||
client.checkpoint_adjust_rollback_timeout(
|
||||
nmc.checkpoint_adjust_rollback_timeout(
|
||||
path, add_timeout, None, adjust_rollback_timeout_cb, None
|
||||
)
|
||||
|
||||
|
||||
def do_show(client):
|
||||
def do_show(nmc):
|
||||
ts = NM.utils_get_timestamp_msec()
|
||||
for c in client.get_checkpoints():
|
||||
for c in nmc.get_checkpoints():
|
||||
show(c, ts)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
nm_client = NM.Client.new(None)
|
||||
nmc = NM.Client.new(None)
|
||||
main_loop = GLib.MainLoop()
|
||||
|
||||
if len(sys.argv) < 2 or sys.argv[1] == "show":
|
||||
do_show(nm_client)
|
||||
do_show(nmc)
|
||||
sys.exit(0)
|
||||
elif sys.argv[1] == "create":
|
||||
do_create(nm_client)
|
||||
do_create(nmc)
|
||||
elif sys.argv[1] == "destroy":
|
||||
do_destroy(nm_client)
|
||||
do_destroy(nmc)
|
||||
elif sys.argv[1] == "rollback":
|
||||
do_rollback(nm_client)
|
||||
do_rollback(nmc)
|
||||
elif sys.argv[1] == "adjust-rollback-timeout":
|
||||
do_adjust_rollback_timeout(nm_client)
|
||||
do_adjust_rollback_timeout(nmc)
|
||||
else:
|
||||
usage()
|
||||
|
||||
|
|
|
|||
|
|
@ -15,23 +15,23 @@ main_loop = None
|
|||
|
||||
|
||||
def handle_config(config):
|
||||
print " ---- new configuration ----"
|
||||
print(" ---- new configuration ----")
|
||||
for entry in config:
|
||||
print " * servers: %s" % ", ".join(map(str, entry.get_nameservers()))
|
||||
print(" * servers: %s" % ", ".join(map(str, entry.get_nameservers())))
|
||||
|
||||
domains = entry.get_domains()
|
||||
if domains and domains[0]:
|
||||
print " domains: %s" % ", ".join(map(str, domains))
|
||||
print(" domains: %s" % ", ".join(map(str, domains)))
|
||||
|
||||
if entry.get_interface():
|
||||
print " interface: %s" % entry.get_interface()
|
||||
print(" interface: %s" % entry.get_interface())
|
||||
|
||||
print " priority: %d" % entry.get_priority()
|
||||
print(" priority: %d" % entry.get_priority())
|
||||
|
||||
if entry.get_vpn():
|
||||
print " vpn: yes"
|
||||
print(" vpn: yes")
|
||||
|
||||
print ""
|
||||
print("")
|
||||
|
||||
|
||||
def dns_config_changed(self, property):
|
||||
|
|
|
|||
|
|
@ -15,22 +15,28 @@ if __name__ == "__main__":
|
|||
client = NM.Client.new(None)
|
||||
devices = client.get_all_devices()
|
||||
|
||||
print "Real devices"
|
||||
print "------------"
|
||||
print("Real devices")
|
||||
print("------------")
|
||||
for d in devices:
|
||||
if d.is_real():
|
||||
print "%s (%s): %s" % (
|
||||
d.get_iface(),
|
||||
d.get_type_description(),
|
||||
d.get_state(),
|
||||
print(
|
||||
"%s (%s): %s"
|
||||
% (
|
||||
d.get_iface(),
|
||||
d.get_type_description(),
|
||||
d.get_state(),
|
||||
)
|
||||
)
|
||||
|
||||
print "\nUnrealized/placeholder devices"
|
||||
print "------------------------------"
|
||||
print("\nUnrealized/placeholder devices")
|
||||
print("------------------------------")
|
||||
for d in devices:
|
||||
if not d.is_real():
|
||||
print "%s (%s): %s" % (
|
||||
d.get_iface(),
|
||||
d.get_type_description(),
|
||||
d.get_state(),
|
||||
print(
|
||||
"%s (%s): %s"
|
||||
% (
|
||||
d.get_iface(),
|
||||
d.get_type_description(),
|
||||
d.get_state(),
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ if __name__ == "__main__":
|
|||
for neighbor in neighbors:
|
||||
ret, chassis = neighbor.get_attr_string_value("chassis-id")
|
||||
ret, port = neighbor.get_attr_string_value("port-id")
|
||||
print "Neighbor: %s - %s" % (chassis, port)
|
||||
print("Neighbor: %s - %s" % (chassis, port))
|
||||
for attr in neighbor.get_attr_names():
|
||||
attr_type = neighbor.get_attr_type(attr)
|
||||
if attr_type.equal(GLib.VariantType.new("s")):
|
||||
ret, value = neighbor.get_attr_string_value(attr)
|
||||
print " %-32s: %s" % (attr, value)
|
||||
print(" %-32s: %s" % (attr, value))
|
||||
elif attr_type.equal(GLib.VariantType.new("u")):
|
||||
ret, value = neighbor.get_attr_uint_value(attr)
|
||||
print " %-32s: %u" % (attr, value)
|
||||
print(" %-32s: %u" % (attr, value))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ project(
|
|||
# - add corresponding NM_VERSION_x_y_z macros in
|
||||
# "src/libnm-core-public/nm-version-macros.h.in"
|
||||
# - update number in configure.ac
|
||||
version: '1.36.0',
|
||||
version: '1.37.1',
|
||||
license: 'GPL2+',
|
||||
default_options: [
|
||||
'buildtype=debugoptimized',
|
||||
|
|
@ -551,10 +551,11 @@ crypto = get_option('crypto')
|
|||
if crypto == 'nss'
|
||||
assert(crypto_nss_dep.found(), 'Requires nss crypto support')
|
||||
crypto_dep = crypto_nss_dep
|
||||
else
|
||||
assert(crypto == 'gnutls', 'Unexpected setting "crypto=' + crypto + '"')
|
||||
elif crypto == 'gnutls'
|
||||
assert(crypto_gnutls_dep.found(), 'Requires gnutls crypto support')
|
||||
crypto_dep = crypto_gnutls_dep
|
||||
else
|
||||
assert(crypto == 'null', 'Unexpected setting "crypto=' + crypto + '"')
|
||||
endif
|
||||
|
||||
dbus_conf_dir = get_option('dbus_conf_dir')
|
||||
|
|
|
|||
|
|
@ -71,6 +71,6 @@ option('valgrind', type: 'array', value: ['no'], description: 'Use valgrind to m
|
|||
option('valgrind_suppressions', type: 'string', value: '', description: 'Use specific valgrind suppression file')
|
||||
option('ld_gc', type: 'boolean', value: true, description: 'Enable garbage collection of unused symbols on linking')
|
||||
option('libpsl', type: 'boolean', value: true, description: 'Link against libpsl')
|
||||
option('crypto', type: 'combo', choices: ['nss', 'gnutls'], value: 'nss', description: 'Cryptography library to use for certificate and key operations')
|
||||
option('crypto', type: 'combo', choices: ['nss', 'gnutls', 'null'], value: 'nss', description: 'Cryptography library to use for certificate and key operations')
|
||||
option('qt', type: 'boolean', value: true, description: 'enable Qt examples')
|
||||
option('readline', type: 'combo', choices: ['auto', 'libreadline', 'libedit', 'none'], description: 'Using readline (auto) or libedit)')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# please keep this list sorted alphabetically
|
||||
#
|
||||
ar
|
||||
as
|
||||
be@latin
|
||||
bg
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ src/libnm-core-aux-intern/nm-libnm-core-utils.c
|
|||
src/libnm-core-impl/nm-connection.c
|
||||
src/libnm-core-impl/nm-crypto-gnutls.c
|
||||
src/libnm-core-impl/nm-crypto-nss.c
|
||||
src/libnm-core-impl/nm-crypto-null.c
|
||||
src/libnm-core-impl/nm-crypto.c
|
||||
src/libnm-core-impl/nm-dbus-utils.c
|
||||
src/libnm-core-impl/nm-keyfile-utils.c
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@
|
|||
* @NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_CAN_ADD: whether the plugin can
|
||||
* add a new connection for the given service-type.
|
||||
**/
|
||||
typedef enum { /*< skip >*/
|
||||
NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_NONE = 0x00,
|
||||
NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_CAN_ADD = 0x01,
|
||||
typedef enum /*< skip >*/ {
|
||||
NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_NONE = 0x00,
|
||||
NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_CAN_ADD = 0x01,
|
||||
} NMVpnEditorPluginServiceFlags;
|
||||
|
||||
struct _NMVpnEditorPluginVT {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
G_STATIC_ASSERT(NM_SHUTDOWN_TIMEOUT_1500_MSEC <= NM_SHUTDOWN_TIMEOUT_MAX_MSEC);
|
||||
G_STATIC_ASSERT(NM_SHUTDOWN_TIMEOUT_5000_MSEC <= NM_SHUTDOWN_TIMEOUT_MAX_MSEC);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_utils_get_shared_wifi_permission:
|
||||
* @connection: the NMConnection to lookup the permission.
|
||||
|
|
@ -1037,7 +1042,7 @@ _shutdown_waitobj_cb(gpointer user_data, GObject *where_the_object_was)
|
|||
* is still used.
|
||||
*
|
||||
* If @wait_type is %NM_SHUTDOWN_WAIT_TYPE_CANCELLABLE, then during shutdown
|
||||
* (after %NM_SHUTDOWN_TIMEOUT_MS), the cancellable will be cancelled to notify
|
||||
* (after %NM_SHUTDOWN_TIMEOUT_MAX_MSEC), the cancellable will be cancelled to notify
|
||||
* the source of the shutdown. Note that otherwise, in this mode also @watched_obj
|
||||
* is only tracked with a weak-pointer. Especially, it does not register to the
|
||||
* "cancelled" signal to automatically unregister (otherwise, you would never
|
||||
|
|
@ -1046,7 +1051,7 @@ _shutdown_waitobj_cb(gpointer user_data, GObject *where_the_object_was)
|
|||
* FIXME(shutdown): proper shutdown is not yet implemented, and registering
|
||||
* an object (currently) has no effect.
|
||||
*
|
||||
* FIXME(shutdown): during shutdown, after %NM_SHUTDOWN_TIMEOUT_MS timeout, cancel
|
||||
* FIXME(shutdown): during shutdown, after %NM_SHUTDOWN_TIMEOUT_MAX_MSEC timeout, cancel
|
||||
* all remaining %NM_SHUTDOWN_WAIT_TYPE_CANCELLABLE instances. Also, when somebody
|
||||
* enqueues a cancellable after that point, cancel it right away on an idle handler.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -103,23 +103,37 @@ NMPlatformRoutingRule *nm_ip_routing_rule_to_platform(const NMIPRoutingRule *rul
|
|||
/*****************************************************************************/
|
||||
|
||||
/* during shutdown, there are two relevant timeouts. One is
|
||||
* NM_SHUTDOWN_TIMEOUT_MS which is plenty of time, that we give for all
|
||||
* NM_SHUTDOWN_TIMEOUT_MAX_MSEC which is plenty of time, that we give for all
|
||||
* actions to complete. Of course, during shutdown components should hurry
|
||||
* to cleanup.
|
||||
*
|
||||
* When we initiate shutdown, we should start killing child processes
|
||||
* with SIGTERM. If they don't complete within NM_SHUTDOWN_TIMEOUT_MS, we send
|
||||
* with SIGTERM. If they don't complete within NM_SHUTDOWN_TIMEOUT_MAX_MSEC, we send
|
||||
* SIGKILL.
|
||||
*
|
||||
* After NM_SHUTDOWN_TIMEOUT_MS, NetworkManager will however not yet terminate right
|
||||
* away. It iterates the mainloop for another NM_SHUTDOWN_TIMEOUT_MS_WATCHDOG. This
|
||||
* After NM_SHUTDOWN_TIMEOUT_MAX_MSEC, NetworkManager will however not yet terminate right
|
||||
* away. It iterates the mainloop for another NM_SHUTDOWN_TIMEOUT_ADDITIONAL_MSEC. This
|
||||
* should give time to reap the child process (after SIGKILL).
|
||||
*
|
||||
* So, the maximum time we should wait before sending SIGKILL should be at most
|
||||
* NM_SHUTDOWN_TIMEOUT_MS.
|
||||
* NM_SHUTDOWN_TIMEOUT_MAX_MSEC.
|
||||
*/
|
||||
#define NM_SHUTDOWN_TIMEOUT_MS 1500
|
||||
#define NM_SHUTDOWN_TIMEOUT_MS_WATCHDOG 500
|
||||
#define NM_SHUTDOWN_TIMEOUT_MAX_MSEC 5000
|
||||
#define NM_SHUTDOWN_TIMEOUT_ADDITIONAL_MSEC 500
|
||||
|
||||
/**
|
||||
* NM_SHUTDOWN_TIMEOUT_1500_MSEC: this is just 1500 msec. The special
|
||||
* thing about the define is that you are guaranteed that this is not
|
||||
* longer than NM_SHUTDOWN_TIMEOUT_MAX_MSEC.
|
||||
* When you perform an async operation, it must either be cancellable
|
||||
* (and complete fast) or never take longer than NM_SHUTDOWN_TIMEOUT_MAX_MSEC.
|
||||
* The usage of this macro makes that relation to NM_SHUTDOWN_TIMEOUT_MAX_MSEC
|
||||
* explicit.
|
||||
*/
|
||||
#define NM_SHUTDOWN_TIMEOUT_1500_MSEC 1500
|
||||
|
||||
/* See NM_SHUTDOWN_TIMEOUT_1500_MSEC. */
|
||||
#define NM_SHUTDOWN_TIMEOUT_5000_MSEC 5000
|
||||
|
||||
typedef enum {
|
||||
/* There is no watched_obj argument, and the shutdown is delayed until the user
|
||||
|
|
@ -131,7 +145,7 @@ typedef enum {
|
|||
NM_SHUTDOWN_WAIT_TYPE_OBJECT,
|
||||
|
||||
/* The watched_obj argument is a GCancellable, and shutdown is delayed until the object
|
||||
* gets destroyed (or unregistered). Note that after NM_SHUTDOWN_TIMEOUT_MS, the
|
||||
* gets destroyed (or unregistered). Note that after NM_SHUTDOWN_TIMEOUT_MAX_MSEC, the
|
||||
* cancellable will be cancelled to notify listeners about the shutdown. */
|
||||
NM_SHUTDOWN_WAIT_TYPE_CANCELLABLE,
|
||||
} NMShutdownWaitType;
|
||||
|
|
|
|||
|
|
@ -1014,7 +1014,7 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
* get confused and fail to negotiate the new connection. (rh #1023503)
|
||||
*
|
||||
* FIXME(shutdown): when exiting, we also need to wait before quitting,
|
||||
* at least for additional NM_SHUTDOWN_TIMEOUT_MS seconds because
|
||||
* at least for additional NM_SHUTDOWN_TIMEOUT_MAX_MSEC seconds because
|
||||
* otherwise after restart the device won't work for the first seconds.
|
||||
*/
|
||||
if (priv->ppp_data.last_pppoe_time_msec != 0) {
|
||||
|
|
|
|||
|
|
@ -361,7 +361,6 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDevice,
|
|||
PROP_FIRMWARE_MISSING,
|
||||
PROP_NM_PLUGIN_MISSING,
|
||||
PROP_TYPE_DESC,
|
||||
PROP_RFKILL_TYPE,
|
||||
PROP_IFINDEX,
|
||||
PROP_AVAILABLE_CONNECTIONS,
|
||||
PROP_PHYSICAL_PORT_ID,
|
||||
|
|
@ -473,7 +472,6 @@ typedef struct _NMDevicePrivate {
|
|||
char *driver;
|
||||
char *driver_version;
|
||||
char *firmware_version;
|
||||
RfKillType rfkill_type;
|
||||
bool firmware_missing : 1;
|
||||
bool nm_plugin_missing : 1;
|
||||
bool
|
||||
|
|
@ -5158,12 +5156,17 @@ nm_device_get_applied_setting(NMDevice *self, GType setting_type)
|
|||
return connection ? nm_connection_get_setting(connection, setting_type) : NULL;
|
||||
}
|
||||
|
||||
RfKillType
|
||||
NMRfkillType
|
||||
nm_device_get_rfkill_type(NMDevice *self)
|
||||
{
|
||||
NMRfkillType t;
|
||||
|
||||
g_return_val_if_fail(NM_IS_DEVICE(self), FALSE);
|
||||
|
||||
return NM_DEVICE_GET_PRIVATE(self)->rfkill_type;
|
||||
t = NM_DEVICE_GET_CLASS(self)->rfkill_type;
|
||||
|
||||
nm_assert(NM_IN_SET(t, NM_RFKILL_TYPE_UNKNOWN, NM_RFKILL_TYPE_WLAN, NM_RFKILL_TYPE_WWAN));
|
||||
return t;
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
@ -7000,7 +7003,7 @@ sriov_op_queue(NMDevice *self,
|
|||
*
|
||||
* FIXME(shutdown): However, during shutdown we don't have a follow-up write request to cancel
|
||||
* this operation and we have to give it at least some time to complete. The solution is that
|
||||
* we register a way to abort the last call during shutdown, and after NM_SHUTDOWN_TIMEOUT_MS
|
||||
* we register a way to abort the last call during shutdown, and after NM_SHUTDOWN_TIMEOUT_MAX_MSEC
|
||||
* grace period we pull the plug and cancel it. */
|
||||
|
||||
op = g_slice_new(SriovOp);
|
||||
|
|
@ -17001,9 +17004,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
case PROP_TYPE_DESC:
|
||||
g_value_set_string(value, priv->type_desc);
|
||||
break;
|
||||
case PROP_RFKILL_TYPE:
|
||||
g_value_set_uint(value, priv->rfkill_type);
|
||||
break;
|
||||
case PROP_AVAILABLE_CONNECTIONS:
|
||||
nm_dbus_utils_g_value_set_object_path_from_hash(value, priv->available_connections, TRUE);
|
||||
break;
|
||||
|
|
@ -17139,10 +17139,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
/* construct-only */
|
||||
priv->type_desc = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_RFKILL_TYPE:
|
||||
/* construct-only */
|
||||
priv->rfkill_type = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_PERM_HW_ADDRESS:
|
||||
/* construct-only */
|
||||
priv->hw_addr_perm = g_value_dup_string(value);
|
||||
|
|
@ -17192,7 +17188,6 @@ nm_device_init(NMDevice *self)
|
|||
priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED;
|
||||
priv->state = NM_DEVICE_STATE_UNMANAGED;
|
||||
priv->state_reason = NM_DEVICE_STATE_REASON_NONE;
|
||||
priv->rfkill_type = RFKILL_TYPE_UNKNOWN;
|
||||
priv->unmanaged_flags = NM_UNMANAGED_PLATFORM_INIT;
|
||||
priv->unmanaged_mask = priv->unmanaged_flags;
|
||||
priv->available_connections = g_hash_table_new_full(nm_direct_hash, NULL, g_object_unref, NULL);
|
||||
|
|
@ -17595,6 +17590,8 @@ nm_device_class_init(NMDeviceClass *klass)
|
|||
klass->reapply_connection = reapply_connection;
|
||||
klass->set_platform_mtu = set_platform_mtu;
|
||||
|
||||
klass->rfkill_type = NM_RFKILL_TYPE_UNKNOWN;
|
||||
|
||||
obj_properties[PROP_UDI] =
|
||||
g_param_spec_string(NM_DEVICE_UDI,
|
||||
"",
|
||||
|
|
@ -17752,14 +17749,6 @@ nm_device_class_init(NMDeviceClass *klass)
|
|||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_RFKILL_TYPE] =
|
||||
g_param_spec_uint(NM_DEVICE_RFKILL_TYPE,
|
||||
"",
|
||||
"",
|
||||
RFKILL_TYPE_WLAN,
|
||||
RFKILL_TYPE_MAX,
|
||||
RFKILL_TYPE_UNKNOWN,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_IFINDEX] = g_param_spec_int(NM_DEVICE_IFINDEX,
|
||||
"",
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@
|
|||
#define NM_DEVICE_SLAVES "slaves" /* partially internal */
|
||||
|
||||
#define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */
|
||||
#define NM_DEVICE_RFKILL_TYPE "rfkill-type" /* Internal only */
|
||||
#define NM_DEVICE_IFINDEX "ifindex" /* Internal only */
|
||||
#define NM_DEVICE_MASTER "master" /* Internal only */
|
||||
#define NM_DEVICE_HAS_PENDING_ACTION "has-pending-action" /* Internal only */
|
||||
|
|
@ -105,38 +104,38 @@ typedef enum NMActStageReturn NMActStageReturn;
|
|||
* a condition, so that adding a flag might make a connection available that would
|
||||
* not be available otherwise. Adding a flag should never make a connection
|
||||
* not available if it would be available otherwise. */
|
||||
typedef enum { /*< skip >*/
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_NONE = 0,
|
||||
typedef enum {
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_NONE = 0,
|
||||
|
||||
/* since NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST is a collection of flags with more fine grained
|
||||
/* since NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST is a collection of flags with more fine grained
|
||||
* parts, this flag in general indicates that this is a user-request. */
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST = (1L << 0),
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST = (1L << 0),
|
||||
|
||||
/* we also consider devices which have no carrier but are still waiting for the driver
|
||||
/* we also consider devices which have no carrier but are still waiting for the driver
|
||||
* to detect carrier. Usually, such devices are not yet available, however for a user-request
|
||||
* they are. They might fail later if carrier doesn't come. */
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER = (1L << 1),
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER = (1L << 1),
|
||||
|
||||
/* usually, a profile is only available if the Wi-Fi AP is in range. For an
|
||||
/* usually, a profile is only available if the Wi-Fi AP is in range. For an
|
||||
* explicit user request, we also consider profiles for APs that are not (yet)
|
||||
* visible. */
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP = (1L << 2),
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP = (1L << 2),
|
||||
|
||||
/* a device can be marked as unmanaged for various reasons. Some of these reasons
|
||||
/* a device can be marked as unmanaged for various reasons. Some of these reasons
|
||||
* are authoritative, others not. Non-authoritative reasons can be overruled by
|
||||
* `nmcli device set $DEVICE managed yes`. Also, for an explicit user activation
|
||||
* request we may want to consider the device as managed. This flag makes devices
|
||||
* that are unmanaged appear available. */
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED = (1L << 3),
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED = (1L << 3),
|
||||
|
||||
/* a collection of flags, that are commonly set for an explicit user-request. */
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST =
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED,
|
||||
/* a collection of flags, that are commonly set for an explicit user-request. */
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST =
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED,
|
||||
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_ALL = (1L << 4) - 1,
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_ALL = (1L << 4) - 1,
|
||||
} NMDeviceCheckConAvailableFlags;
|
||||
|
||||
struct _NMDevicePrivate;
|
||||
|
|
@ -149,19 +148,18 @@ struct _NMDevice {
|
|||
|
||||
/* The flags have an relaxing meaning, that means, specifying more flags, can make
|
||||
* a device appear more available. It can never make a device less available. */
|
||||
typedef enum { /*< skip >*/
|
||||
NM_DEVICE_CHECK_DEV_AVAILABLE_NONE = 0,
|
||||
typedef enum {
|
||||
NM_DEVICE_CHECK_DEV_AVAILABLE_NONE = 0,
|
||||
|
||||
/* the device is considered available, even if it has no carrier.
|
||||
/* the device is considered available, even if it has no carrier.
|
||||
*
|
||||
* For various device types (software devices) we ignore carrier based
|
||||
* on the type. So, for them, this flag has no effect anyway. */
|
||||
_NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER = (1L << 0),
|
||||
_NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER = (1L << 0),
|
||||
|
||||
NM_DEVICE_CHECK_DEV_AVAILABLE_FOR_USER_REQUEST =
|
||||
_NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER,
|
||||
NM_DEVICE_CHECK_DEV_AVAILABLE_FOR_USER_REQUEST = _NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER,
|
||||
|
||||
NM_DEVICE_CHECK_DEV_AVAILABLE_ALL = (1L << 1) - 1,
|
||||
NM_DEVICE_CHECK_DEV_AVAILABLE_ALL = (1L << 1) - 1,
|
||||
} NMDeviceCheckDevAvailableFlags;
|
||||
|
||||
typedef void (*NMDeviceDeactivateCallback)(NMDevice *self, GError *error, gpointer user_data);
|
||||
|
|
@ -209,6 +207,8 @@ typedef struct _NMDeviceClass {
|
|||
|
||||
bool can_reapply_change_ovs_external_ids : 1;
|
||||
|
||||
NMRfkillType rfkill_type : 4;
|
||||
|
||||
void (*state_changed)(NMDevice *device,
|
||||
NMDeviceState new_state,
|
||||
NMDeviceState old_state,
|
||||
|
|
@ -410,7 +410,6 @@ typedef struct _NMDeviceClass {
|
|||
gboolean (*set_platform_mtu)(NMDevice *self, guint32 mtu);
|
||||
|
||||
const char *(*get_dhcp_anycast_address)(NMDevice *self);
|
||||
|
||||
} NMDeviceClass;
|
||||
|
||||
GType nm_device_get_type(void);
|
||||
|
|
@ -536,7 +535,7 @@ gboolean nm_device_get_enabled(NMDevice *device);
|
|||
|
||||
void nm_device_set_enabled(NMDevice *device, gboolean enabled);
|
||||
|
||||
RfKillType nm_device_get_rfkill_type(NMDevice *device);
|
||||
NMRfkillType nm_device_get_rfkill_type(NMDevice *device);
|
||||
|
||||
/* IPv6 prefix delegation */
|
||||
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ typedef struct {
|
|||
OvsdbMethodCallback callback;
|
||||
gpointer user_data;
|
||||
OvsdbMethodPayload payload;
|
||||
GObject *shutdown_wait_obj;
|
||||
} OvsdbMethodCall;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -245,6 +246,8 @@ static NM_UTILS_LOOKUP_STR_DEFINE(_device_type_to_table,
|
|||
static void
|
||||
_call_complete(OvsdbMethodCall *call, json_t *response, GError *error)
|
||||
{
|
||||
g_clear_object(&call->shutdown_wait_obj);
|
||||
|
||||
if (response) {
|
||||
gs_free char *str = NULL;
|
||||
|
||||
|
|
@ -378,12 +381,14 @@ ovsdb_call_method(NMOvsdb *self,
|
|||
|
||||
call = g_slice_new(OvsdbMethodCall);
|
||||
*call = (OvsdbMethodCall){
|
||||
.self = self,
|
||||
.call_id = CALL_ID_UNSPEC,
|
||||
.command = command,
|
||||
.callback = callback,
|
||||
.user_data = user_data,
|
||||
.self = self,
|
||||
.call_id = CALL_ID_UNSPEC,
|
||||
.command = command,
|
||||
.callback = callback,
|
||||
.user_data = user_data,
|
||||
.shutdown_wait_obj = g_object_new(G_TYPE_OBJECT, NULL),
|
||||
};
|
||||
nm_shutdown_wait_obj_register_object(call->shutdown_wait_obj, "ovsdb-call");
|
||||
|
||||
if (add_first)
|
||||
c_list_link_front(&priv->calls_lst_head, &call->calls_lst);
|
||||
|
|
|
|||
|
|
@ -1196,8 +1196,6 @@ nm_device_iwd_p2p_new(GDBusObject *dbus_obj)
|
|||
NM_DEVICE_TYPE_WIFI_P2P,
|
||||
NM_DEVICE_LINK_TYPE,
|
||||
NM_LINK_TYPE_WIFI,
|
||||
NM_DEVICE_RFKILL_TYPE,
|
||||
RFKILL_TYPE_WLAN,
|
||||
NULL);
|
||||
|
||||
if (!self || !nm_device_iwd_p2p_set_dbus_obj(self, dbus_obj))
|
||||
|
|
@ -1252,6 +1250,8 @@ nm_device_iwd_p2p_class_init(NMDeviceIwdP2PClass *klass)
|
|||
|
||||
device_class->state_changed = device_state_changed;
|
||||
|
||||
device_class->rfkill_type = NM_RFKILL_TYPE_WLAN;
|
||||
|
||||
obj_properties[PROP_PEERS] = g_param_spec_boxed(NM_DEVICE_IWD_P2P_PEERS,
|
||||
"",
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -3426,8 +3426,6 @@ nm_device_iwd_new(const char *iface)
|
|||
NM_DEVICE_TYPE_WIFI,
|
||||
NM_DEVICE_LINK_TYPE,
|
||||
NM_LINK_TYPE_WIFI,
|
||||
NM_DEVICE_RFKILL_TYPE,
|
||||
RFKILL_TYPE_WLAN,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -3490,6 +3488,8 @@ nm_device_iwd_class_init(NMDeviceIwdClass *klass)
|
|||
|
||||
device_class->state_changed = device_state_changed;
|
||||
|
||||
device_class->rfkill_type = NM_RFKILL_TYPE_WLAN;
|
||||
|
||||
obj_properties[PROP_MODE] = g_param_spec_uint(NM_DEVICE_IWD_MODE,
|
||||
"",
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -1229,8 +1229,6 @@ nm_device_wifi_p2p_new(const char *iface)
|
|||
NM_DEVICE_TYPE_WIFI_P2P,
|
||||
NM_DEVICE_LINK_TYPE,
|
||||
NM_LINK_TYPE_WIFI,
|
||||
NM_DEVICE_RFKILL_TYPE,
|
||||
RFKILL_TYPE_WLAN,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1293,6 +1291,8 @@ nm_device_wifi_p2p_class_init(NMDeviceWifiP2PClass *klass)
|
|||
|
||||
device_class->state_changed = device_state_changed;
|
||||
|
||||
device_class->rfkill_type = NM_RFKILL_TYPE_WLAN;
|
||||
|
||||
obj_properties[PROP_PEERS] = g_param_spec_boxed(NM_DEVICE_WIFI_P2P_PEERS,
|
||||
"",
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -3103,28 +3103,75 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
static void
|
||||
ensure_hotspot_frequency(NMDeviceWifi *self, NMSettingWireless *s_wifi, NMWifiAP *ap)
|
||||
{
|
||||
NMDevice *device = NM_DEVICE(self);
|
||||
const char *band = nm_setting_wireless_get_band(s_wifi);
|
||||
const guint32 a_freqs[] = {5180, 5200, 5220, 5745, 5765, 5785, 5805, 0};
|
||||
const guint32 bg_freqs[] = {2412, 2437, 2462, 2472, 0};
|
||||
guint32 freq = 0;
|
||||
guint32 a_freqs[] = {5180, 5200, 5220, 5745, 5765, 5785, 5805, 0};
|
||||
guint32 bg_freqs[] = {2412, 2437, 2462, 2472, 0};
|
||||
guint32 *rnd_freqs;
|
||||
guint rnd_freqs_len;
|
||||
NMDevice *device = NM_DEVICE(self);
|
||||
const char *band = nm_setting_wireless_get_band(s_wifi);
|
||||
guint32 freq;
|
||||
guint64 rnd;
|
||||
guint i;
|
||||
guint l;
|
||||
|
||||
g_assert(ap);
|
||||
nm_assert(ap);
|
||||
nm_assert(NM_IN_STRSET(band, NULL, "a", "bg"));
|
||||
|
||||
if (nm_wifi_ap_get_freq(ap))
|
||||
return;
|
||||
|
||||
if (g_strcmp0(band, "a") == 0)
|
||||
freq = nm_platform_wifi_find_frequency(nm_device_get_platform(device),
|
||||
nm_device_get_ifindex(device),
|
||||
a_freqs);
|
||||
else
|
||||
freq = nm_platform_wifi_find_frequency(nm_device_get_platform(device),
|
||||
nm_device_get_ifindex(device),
|
||||
bg_freqs);
|
||||
{
|
||||
GBytes *ssid;
|
||||
gsize ssid_len;
|
||||
const guint8 *ssid_data;
|
||||
const guint8 random_seed[16] = {0x9a,
|
||||
0xdc,
|
||||
0x86,
|
||||
0x9a,
|
||||
0xa8,
|
||||
0xa2,
|
||||
0x07,
|
||||
0x97,
|
||||
0xbe,
|
||||
0x6d,
|
||||
0xe6,
|
||||
0x99,
|
||||
0x9f,
|
||||
0xa8,
|
||||
0x09,
|
||||
0x2b};
|
||||
|
||||
if (!freq)
|
||||
freq = (g_strcmp0(band, "a") == 0) ? 5180 : 2462;
|
||||
/* Calculate a stable "random" number based on the SSID. */
|
||||
ssid = nm_setting_wireless_get_ssid(s_wifi);
|
||||
ssid_data = g_bytes_get_data(ssid, &ssid_len);
|
||||
rnd = c_siphash_hash(random_seed, ssid_data, ssid_len);
|
||||
}
|
||||
|
||||
if (nm_streq0(band, "a")) {
|
||||
rnd_freqs = a_freqs;
|
||||
rnd_freqs_len = G_N_ELEMENTS(a_freqs) - 1;
|
||||
} else {
|
||||
rnd_freqs = bg_freqs;
|
||||
rnd_freqs_len = G_N_ELEMENTS(bg_freqs) - 1;
|
||||
}
|
||||
|
||||
/* shuffle the frequencies (inplace). The idea is to choose
|
||||
* a different frequency depending on the SSID. */
|
||||
for (i = 0, l = rnd_freqs_len; l > 1; i++, l--) {
|
||||
/* Add an arbitrary chosen (prime) number to rnd, to get more "random"
|
||||
* numbers. Since we only shuffle a handful of elements, that's good
|
||||
* enough (and stable). */
|
||||
rnd += 5630246189u;
|
||||
NM_SWAP(&rnd_freqs[i], &rnd_freqs[i + (rnd % l)]);
|
||||
}
|
||||
|
||||
freq = nm_platform_wifi_find_frequency(nm_device_get_platform(device),
|
||||
nm_device_get_ifindex(device),
|
||||
rnd_freqs);
|
||||
if (freq == 0)
|
||||
freq = rnd_freqs[0];
|
||||
|
||||
_LOGD(LOGD_WIFI, "set frequency for hotspot AP to %u", freq);
|
||||
|
||||
if (nm_wifi_ap_set_freq(ap, freq))
|
||||
_ap_dump(self, LOGL_DEBUG, ap, "updated", 0);
|
||||
|
|
@ -3663,8 +3710,6 @@ nm_device_wifi_new(const char *iface, _NMDeviceWifiCapabilities capabilities)
|
|||
NM_DEVICE_TYPE_WIFI,
|
||||
NM_DEVICE_LINK_TYPE,
|
||||
NM_LINK_TYPE_WIFI,
|
||||
NM_DEVICE_RFKILL_TYPE,
|
||||
RFKILL_TYPE_WLAN,
|
||||
NM_DEVICE_WIFI_CAPABILITIES,
|
||||
(guint) capabilities,
|
||||
NULL);
|
||||
|
|
@ -3756,6 +3801,8 @@ nm_device_wifi_class_init(NMDeviceWifiClass *klass)
|
|||
|
||||
device_class->state_changed = device_state_changed;
|
||||
|
||||
device_class->rfkill_type = NM_RFKILL_TYPE_WLAN;
|
||||
|
||||
obj_properties[PROP_MODE] = g_param_spec_uint(NM_DEVICE_WIFI_MODE,
|
||||
"",
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -757,8 +757,6 @@ nm_device_modem_new(NMModem *modem)
|
|||
"Broadband",
|
||||
NM_DEVICE_DEVICE_TYPE,
|
||||
NM_DEVICE_TYPE_MODEM,
|
||||
NM_DEVICE_RFKILL_TYPE,
|
||||
RFKILL_TYPE_WWAN,
|
||||
NM_DEVICE_MODEM_MODEM,
|
||||
modem,
|
||||
NM_DEVICE_MODEM_CAPABILITIES,
|
||||
|
|
@ -840,6 +838,8 @@ nm_device_modem_class_init(NMDeviceModemClass *klass)
|
|||
|
||||
device_class->state_changed = device_state_changed;
|
||||
|
||||
device_class->rfkill_type = NM_RFKILL_TYPE_WWAN;
|
||||
|
||||
obj_properties[PROP_MODEM] =
|
||||
g_param_spec_object(NM_DEVICE_MODEM_MODEM,
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@
|
|||
#define _NMLOG(level, ...) __NMLOG_DEFAULT(level, _NMLOG_DOMAIN, "dnsmasq", __VA_ARGS__)
|
||||
|
||||
#define WAIT_MSEC_AFTER_SIGTERM 1000
|
||||
G_STATIC_ASSERT(WAIT_MSEC_AFTER_SIGTERM <= NM_SHUTDOWN_TIMEOUT_MS);
|
||||
G_STATIC_ASSERT(WAIT_MSEC_AFTER_SIGTERM <= NM_SHUTDOWN_TIMEOUT_MAX_MSEC);
|
||||
|
||||
#define WAIT_MSEC_AFTER_SIGKILL 400
|
||||
G_STATIC_ASSERT(WAIT_MSEC_AFTER_SIGKILL + 100 <= NM_SHUTDOWN_TIMEOUT_MS_WATCHDOG);
|
||||
G_STATIC_ASSERT(WAIT_MSEC_AFTER_SIGKILL + 100 <= NM_SHUTDOWN_TIMEOUT_ADDITIONAL_MSEC);
|
||||
|
||||
typedef void (*GlPidSpawnAsyncNotify)(GCancellable *cancellable,
|
||||
GPid pid,
|
||||
|
|
|
|||
|
|
@ -694,6 +694,7 @@ do_curl_request(NMConnectivityCheckHandle *cb_data)
|
|||
curl_easy_setopt(ehandle, CURLOPT_INTERFACE, cb_data->ifspec);
|
||||
curl_easy_setopt(ehandle, CURLOPT_RESOLVE, cb_data->concheck.hosts);
|
||||
curl_easy_setopt(ehandle, CURLOPT_IPRESOLVE, resolve);
|
||||
curl_easy_setopt(ehandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
|
||||
|
||||
curl_multi_add_handle(mhandle, ehandle);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ _fw_nft_call_communicate_cb(GObject *source, GAsyncResult *result, gpointer user
|
|||
nm_g_main_context_push_thread_default_if_necessary(NULL);
|
||||
|
||||
nm_shutdown_wait_obj_register_object(call_data->subprocess, "nft-terminate");
|
||||
G_STATIC_ASSERT_EXPR(200 < NM_SHUTDOWN_TIMEOUT_MS_WATCHDOG * 2 / 3);
|
||||
G_STATIC_ASSERT_EXPR(200 < NM_SHUTDOWN_TIMEOUT_ADDITIONAL_MSEC * 2 / 3);
|
||||
nm_g_subprocess_terminate_in_background(call_data->subprocess, 200);
|
||||
}
|
||||
} else if (g_subprocess_get_successful(call_data->subprocess)) {
|
||||
|
|
@ -546,7 +546,7 @@ _fw_nft_call(GBytes *stdin_buf,
|
|||
call_data);
|
||||
|
||||
call_data->timeout_source =
|
||||
nm_g_source_attach(nm_g_timeout_source_new((NM_SHUTDOWN_TIMEOUT_MS * 2) / 3,
|
||||
nm_g_source_attach(nm_g_timeout_source_new((NM_SHUTDOWN_TIMEOUT_1500_MSEC * 2) / 3,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_fw_nft_call_timeout_cb,
|
||||
call_data,
|
||||
|
|
|
|||
|
|
@ -54,15 +54,16 @@
|
|||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
gboolean user_enabled;
|
||||
gboolean sw_enabled;
|
||||
gboolean hw_enabled;
|
||||
RfKillType rtype;
|
||||
guint prop_id;
|
||||
guint hw_prop_id;
|
||||
NMConfigRunStatePropertyType key;
|
||||
const char *desc;
|
||||
const char *prop;
|
||||
const char *hw_prop;
|
||||
} RadioState;
|
||||
} RfkillTypeDesc;
|
||||
|
||||
typedef struct {
|
||||
bool user_enabled : 1;
|
||||
bool sw_enabled : 1;
|
||||
bool hw_enabled : 1;
|
||||
} RfkillRadioState;
|
||||
|
||||
typedef enum {
|
||||
ASYNC_OP_TYPE_AC_AUTH_ACTIVATE_INTERNAL,
|
||||
|
|
@ -169,7 +170,8 @@ typedef struct {
|
|||
|
||||
NMSettings *settings;
|
||||
|
||||
RadioState radio_states[RFKILL_TYPE_MAX];
|
||||
RfkillRadioState radio_states[NM_RFKILL_TYPE_MAX];
|
||||
|
||||
NMVpnManager *vpn_manager;
|
||||
|
||||
NMSleepMonitor *sleep_monitor;
|
||||
|
|
@ -2276,11 +2278,24 @@ _static_hostname_changed_cb(NMHostnameManager *hostname_manager, GParamSpec *psp
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* General NMManager stuff */
|
||||
/*****************************************************************************/
|
||||
|
||||
static const RfkillTypeDesc _rfkill_type_desc[NM_RFKILL_TYPE_MAX] = {
|
||||
[NM_RFKILL_TYPE_WLAN] =
|
||||
{
|
||||
.prop_id = PROP_WIRELESS_ENABLED,
|
||||
.hw_prop_id = PROP_WIRELESS_HARDWARE_ENABLED,
|
||||
.key = NM_CONFIG_STATE_PROPERTY_WIFI_ENABLED,
|
||||
},
|
||||
[NM_RFKILL_TYPE_WWAN] =
|
||||
{
|
||||
.prop_id = PROP_WWAN_ENABLED,
|
||||
.hw_prop_id = PROP_WWAN_HARDWARE_ENABLED,
|
||||
.key = NM_CONFIG_STATE_PROPERTY_WWAN_ENABLED,
|
||||
},
|
||||
};
|
||||
|
||||
static gboolean
|
||||
radio_enabled_for_rstate(RadioState *rstate, gboolean check_changeable)
|
||||
_rfkill_radio_state_get_enabled(const RfkillRadioState *rstate, gboolean check_changeable)
|
||||
{
|
||||
gboolean enabled;
|
||||
|
||||
|
|
@ -2290,25 +2305,45 @@ radio_enabled_for_rstate(RadioState *rstate, gboolean check_changeable)
|
|||
return enabled;
|
||||
}
|
||||
|
||||
static void
|
||||
_rfkill_radio_state_set_from_manager(NMRfkillManager *rfkill_mgr,
|
||||
NMRfkillType rtype,
|
||||
RfkillRadioState *rstate)
|
||||
{
|
||||
switch (nm_rfkill_manager_get_rfkill_state(rfkill_mgr, rtype)) {
|
||||
case NM_RFKILL_STATE_UNBLOCKED:
|
||||
rstate->sw_enabled = TRUE;
|
||||
rstate->hw_enabled = TRUE;
|
||||
return;
|
||||
case NM_RFKILL_STATE_SOFT_BLOCKED:
|
||||
rstate->sw_enabled = FALSE;
|
||||
rstate->hw_enabled = TRUE;
|
||||
return;
|
||||
case NM_RFKILL_STATE_HARD_BLOCKED:
|
||||
rstate->sw_enabled = FALSE;
|
||||
rstate->hw_enabled = FALSE;
|
||||
return;
|
||||
}
|
||||
nm_assert_not_reached();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
radio_enabled_for_type(NMManager *self, RfKillType rtype, gboolean check_changeable)
|
||||
_rfkill_radio_state_get(NMManager *self, NMRfkillType rtype)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
|
||||
return radio_enabled_for_rstate(&priv->radio_states[rtype], check_changeable);
|
||||
nm_assert(_NM_INT_NOT_NEGATIVE(rtype) && rtype < G_N_ELEMENTS(priv->radio_states));
|
||||
|
||||
return _rfkill_radio_state_get_enabled(&priv->radio_states[rtype], TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
manager_update_radio_enabled(NMManager *self, RadioState *rstate, gboolean enabled)
|
||||
_rfkill_update_devices(NMManager *self, NMRfkillType rtype, gboolean enabled)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
NMDevice *device;
|
||||
|
||||
/* Do nothing for radio types not yet implemented */
|
||||
if (!rstate->prop)
|
||||
return;
|
||||
|
||||
g_object_notify(G_OBJECT(self), rstate->prop);
|
||||
_notify(self, _rfkill_type_desc[rtype].prop_id);
|
||||
|
||||
/* Don't touch devices if asleep/networking disabled */
|
||||
if (manager_sleeping(self))
|
||||
|
|
@ -2316,7 +2351,7 @@ manager_update_radio_enabled(NMManager *self, RadioState *rstate, gboolean enabl
|
|||
|
||||
/* enable/disable wireless devices as required */
|
||||
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
|
||||
if (nm_device_get_rfkill_type(device) == rstate->rtype) {
|
||||
if (nm_device_get_rfkill_type(device) == rtype) {
|
||||
_LOG2D(LOGD_RFKILL,
|
||||
device,
|
||||
"rfkill: setting radio %s",
|
||||
|
|
@ -2327,89 +2362,185 @@ manager_update_radio_enabled(NMManager *self, RadioState *rstate, gboolean enabl
|
|||
}
|
||||
|
||||
static void
|
||||
update_rstate_from_rfkill(NMRfkillManager *rfkill_mgr, RadioState *rstate)
|
||||
_rfkill_update_one_type(NMManager *self, NMRfkillType rtype)
|
||||
{
|
||||
switch (nm_rfkill_manager_get_rfkill_state(rfkill_mgr, rstate->rtype)) {
|
||||
case RFKILL_UNBLOCKED:
|
||||
rstate->sw_enabled = TRUE;
|
||||
rstate->hw_enabled = TRUE;
|
||||
break;
|
||||
case RFKILL_SOFT_BLOCKED:
|
||||
rstate->sw_enabled = FALSE;
|
||||
rstate->hw_enabled = TRUE;
|
||||
break;
|
||||
case RFKILL_HARD_BLOCKED:
|
||||
rstate->sw_enabled = FALSE;
|
||||
rstate->hw_enabled = FALSE;
|
||||
break;
|
||||
default:
|
||||
g_warn_if_reached();
|
||||
break;
|
||||
}
|
||||
}
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
RfkillRadioState *rstate = &priv->radio_states[rtype];
|
||||
gboolean old_enabled;
|
||||
gboolean new_enabled;
|
||||
gboolean old_rfkilled;
|
||||
gboolean new_rfkilled;
|
||||
gboolean old_hwe;
|
||||
|
||||
static void
|
||||
manager_rfkill_update_one_type(NMManager *self, RadioState *rstate, RfKillType rtype)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
gboolean old_enabled, new_enabled, old_rfkilled, new_rfkilled, old_hwe;
|
||||
nm_assert(_NM_INT_NOT_NEGATIVE(rtype) && rtype < G_N_ELEMENTS(priv->radio_states));
|
||||
|
||||
old_enabled = radio_enabled_for_rstate(rstate, TRUE);
|
||||
old_enabled = _rfkill_radio_state_get_enabled(rstate, TRUE);
|
||||
old_rfkilled = rstate->hw_enabled && rstate->sw_enabled;
|
||||
old_hwe = rstate->hw_enabled;
|
||||
|
||||
/* recheck kernel rfkill state */
|
||||
update_rstate_from_rfkill(priv->rfkill_mgr, rstate);
|
||||
_rfkill_radio_state_set_from_manager(priv->rfkill_mgr, rtype, rstate);
|
||||
|
||||
/* Print out all states affecting device enablement */
|
||||
if (rstate->desc) {
|
||||
_LOGD(LOGD_RFKILL,
|
||||
"rfkill: %s hw-enabled %d sw-enabled %d",
|
||||
rstate->desc,
|
||||
rstate->hw_enabled,
|
||||
rstate->sw_enabled);
|
||||
}
|
||||
_LOGD(LOGD_RFKILL,
|
||||
"rfkill: %s hw-enabled %d sw-enabled %d",
|
||||
nm_rfkill_type_to_string(rtype),
|
||||
rstate->hw_enabled,
|
||||
rstate->sw_enabled);
|
||||
|
||||
/* Log new killswitch state */
|
||||
new_rfkilled = rstate->hw_enabled && rstate->sw_enabled;
|
||||
if (old_rfkilled != new_rfkilled) {
|
||||
_LOGI(LOGD_RFKILL,
|
||||
"rfkill: %s now %s by radio killswitch",
|
||||
rstate->desc,
|
||||
nm_rfkill_type_to_string(rtype),
|
||||
new_rfkilled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
/* Send out property changed signal for HW enabled */
|
||||
if (rstate->hw_enabled != old_hwe) {
|
||||
if (rstate->hw_prop)
|
||||
g_object_notify(G_OBJECT(self), rstate->hw_prop);
|
||||
}
|
||||
if (rstate->hw_enabled != old_hwe)
|
||||
_notify(self, _rfkill_type_desc[rtype].hw_prop_id);
|
||||
|
||||
/* And finally update the actual device radio state itself; respect the
|
||||
* daemon state here because this is never called from user-triggered
|
||||
* radio changes and we only want to ignore the daemon enabled state when
|
||||
* handling user radio change requests.
|
||||
*/
|
||||
new_enabled = radio_enabled_for_rstate(rstate, TRUE);
|
||||
new_enabled = _rfkill_radio_state_get_enabled(rstate, TRUE);
|
||||
if (new_enabled != old_enabled)
|
||||
manager_update_radio_enabled(self, rstate, new_enabled);
|
||||
_rfkill_update_devices(self, rtype, new_enabled);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_manager_rfkill_update(NMManager *self, RfKillType rtype)
|
||||
_rfkill_update(NMManager *self, NMRfkillType rtype)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
guint i;
|
||||
guint i;
|
||||
|
||||
if (rtype != RFKILL_TYPE_UNKNOWN)
|
||||
manager_rfkill_update_one_type(self, &priv->radio_states[rtype], rtype);
|
||||
if (rtype != NM_RFKILL_TYPE_UNKNOWN)
|
||||
_rfkill_update_one_type(self, rtype);
|
||||
else {
|
||||
/* Otherwise, sync all radio types */
|
||||
for (i = 0; i < RFKILL_TYPE_MAX; i++)
|
||||
manager_rfkill_update_one_type(self, &priv->radio_states[i], i);
|
||||
for (i = 0; i < NM_RFKILL_TYPE_MAX; i++)
|
||||
_rfkill_update_one_type(self, i);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define KERN_RFKILL_OP_CHANGE_ALL 3
|
||||
#define KERN_RFKILL_TYPE_WLAN 1
|
||||
#define KERN_RFKILL_TYPE_WWAN 5
|
||||
|
||||
struct rfkill_event {
|
||||
uint32_t idx;
|
||||
uint8_t type;
|
||||
uint8_t op;
|
||||
uint8_t soft;
|
||||
uint8_t hard;
|
||||
} _nm_packed;
|
||||
|
||||
static void
|
||||
_rfkill_update_system(NMManager *self, NMRfkillType rtype, gboolean enabled)
|
||||
{
|
||||
nm_auto_close int fd = -1;
|
||||
struct rfkill_event event;
|
||||
ssize_t len;
|
||||
int errsv;
|
||||
|
||||
nm_assert(NM_IN_SET(rtype, NM_RFKILL_TYPE_WLAN, NM_RFKILL_TYPE_WWAN));
|
||||
|
||||
fd = open("/dev/rfkill", O_RDWR | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
if (errno == EACCES)
|
||||
_LOGW(LOGD_RFKILL,
|
||||
"rfkill: (%s): failed to open killswitch device",
|
||||
nm_rfkill_type_to_string(rtype));
|
||||
return;
|
||||
}
|
||||
|
||||
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
|
||||
_LOGW(LOGD_RFKILL,
|
||||
"rfkill: (%s): failed to set killswitch device for "
|
||||
"non-blocking operation",
|
||||
nm_rfkill_type_to_string(rtype));
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&event, 0, sizeof(event));
|
||||
event.op = KERN_RFKILL_OP_CHANGE_ALL;
|
||||
switch (rtype) {
|
||||
case NM_RFKILL_TYPE_WLAN:
|
||||
event.type = KERN_RFKILL_TYPE_WLAN;
|
||||
break;
|
||||
case NM_RFKILL_TYPE_WWAN:
|
||||
event.type = KERN_RFKILL_TYPE_WWAN;
|
||||
break;
|
||||
default:
|
||||
nm_assert_not_reached();
|
||||
}
|
||||
event.soft = enabled ? 0 : 1;
|
||||
|
||||
len = write(fd, &event, sizeof(event));
|
||||
if (len < 0) {
|
||||
errsv = errno;
|
||||
_LOGW(LOGD_RFKILL,
|
||||
"rfkill: (%s): failed to change Wi-Fi killswitch state: (%d) %s",
|
||||
nm_rfkill_type_to_string(rtype),
|
||||
errsv,
|
||||
nm_strerror_native(errsv));
|
||||
} else if (len == sizeof(event)) {
|
||||
_LOGI(LOGD_RFKILL,
|
||||
"rfkill: %s hardware radio set %s",
|
||||
nm_rfkill_type_to_string(rtype),
|
||||
enabled ? "enabled" : "disabled");
|
||||
} else {
|
||||
/* Failed to write full structure */
|
||||
_LOGW(LOGD_RFKILL,
|
||||
"rfkill: (%s): failed to change Wi-Fi killswitch state",
|
||||
nm_rfkill_type_to_string(rtype));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_rfkill_update_from_user(NMManager *self, NMRfkillType rtype, gboolean enabled)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
RfkillRadioState *rstate = &priv->radio_states[rtype];
|
||||
gboolean old_enabled, new_enabled;
|
||||
|
||||
/* Don't touch devices if asleep/networking disabled */
|
||||
if (manager_sleeping(self))
|
||||
return;
|
||||
|
||||
_LOGD(LOGD_RFKILL,
|
||||
"rfkill: (%s): setting radio %s by user",
|
||||
nm_rfkill_type_to_string(rtype),
|
||||
enabled ? "enabled" : "disabled");
|
||||
|
||||
/* Update enabled key in state file */
|
||||
nm_config_state_set(priv->config, TRUE, FALSE, _rfkill_type_desc[rtype].key, enabled);
|
||||
|
||||
/* When the user toggles the radio, their request should override any
|
||||
* daemon (like ModemManager) enabled state that can be changed. For WWAN
|
||||
* for example, we want the WwanEnabled property to reflect the daemon state
|
||||
* too so that users can toggle the modem powered, but we don't want that
|
||||
* daemon state to affect whether or not the user *can* turn it on, which is
|
||||
* what the kernel rfkill state does. So we ignore daemon enabled state
|
||||
* when determining what the new state should be since it shouldn't block
|
||||
* the user's request.
|
||||
*/
|
||||
old_enabled = _rfkill_radio_state_get_enabled(rstate, TRUE);
|
||||
rstate->user_enabled = enabled;
|
||||
new_enabled = _rfkill_radio_state_get_enabled(rstate, FALSE);
|
||||
if (new_enabled != old_enabled) {
|
||||
/* Try to change the kernel rfkill state */
|
||||
_rfkill_update_system(self, rtype, new_enabled);
|
||||
_rfkill_update_devices(self, rtype, new_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
device_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data)
|
||||
{
|
||||
|
|
@ -3207,7 +3338,7 @@ add_device(NMManager *self, NMDevice *device, GError **error)
|
|||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
const char *iface, *type_desc;
|
||||
RfKillType rtype;
|
||||
NMRfkillType rtype;
|
||||
GSList *iter, *remove = NULL;
|
||||
int ifindex;
|
||||
const char *dbus_path;
|
||||
|
|
@ -3294,9 +3425,9 @@ add_device(NMManager *self, NMDevice *device, GError **error)
|
|||
* global state.
|
||||
*/
|
||||
rtype = nm_device_get_rfkill_type(device);
|
||||
if (rtype != RFKILL_TYPE_UNKNOWN) {
|
||||
nm_manager_rfkill_update(self, rtype);
|
||||
nm_device_set_enabled(device, radio_enabled_for_type(self, rtype, TRUE));
|
||||
if (rtype != NM_RFKILL_TYPE_UNKNOWN) {
|
||||
_rfkill_update(self, rtype);
|
||||
nm_device_set_enabled(device, _rfkill_radio_state_get(self, rtype));
|
||||
}
|
||||
|
||||
iface = nm_device_get_iface(device);
|
||||
|
|
@ -3671,12 +3802,14 @@ platform_query_devices(NMManager *self)
|
|||
}
|
||||
|
||||
static void
|
||||
rfkill_manager_rfkill_changed_cb(NMRfkillManager *rfkill_mgr,
|
||||
RfKillType rtype,
|
||||
RfKillState udev_state,
|
||||
gpointer user_data)
|
||||
rfkill_manager_rfkill_changed_cb(NMRfkillManager *rfkill_mgr,
|
||||
/* NMRfkillType */ guint rtype,
|
||||
/* NMRfkillState */ guint udev_state,
|
||||
gpointer user_data)
|
||||
{
|
||||
nm_manager_rfkill_update(NM_MANAGER(user_data), rtype);
|
||||
nm_assert(rtype < NM_RFKILL_TYPE_MAX);
|
||||
|
||||
_rfkill_update(NM_MANAGER(user_data), rtype);
|
||||
}
|
||||
|
||||
const CList *
|
||||
|
|
@ -6313,7 +6446,7 @@ do_sleep_wake(NMManager *self, gboolean sleeping_changed)
|
|||
/* Ensure rfkill state is up-to-date since we don't respond to state
|
||||
* changes during sleep.
|
||||
*/
|
||||
nm_manager_rfkill_update(self, RFKILL_TYPE_UNKNOWN);
|
||||
_rfkill_update(self, NM_RFKILL_TYPE_UNKNOWN);
|
||||
|
||||
/* Re-manage managed devices */
|
||||
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
|
||||
|
|
@ -6330,20 +6463,19 @@ do_sleep_wake(NMManager *self, gboolean sleeping_changed)
|
|||
/* enable/disable wireless devices since that we don't respond
|
||||
* to killswitch changes during sleep.
|
||||
*/
|
||||
for (i = 0; i < RFKILL_TYPE_MAX; i++) {
|
||||
RadioState *rstate = &priv->radio_states[i];
|
||||
gboolean enabled = radio_enabled_for_rstate(rstate, TRUE);
|
||||
for (i = 0; i < NM_RFKILL_TYPE_MAX; i++) {
|
||||
const NMRfkillType rtype = i;
|
||||
const RfkillRadioState *rstate = &priv->radio_states[rtype];
|
||||
gboolean enabled = _rfkill_radio_state_get_enabled(rstate, TRUE);
|
||||
|
||||
if (rstate->desc) {
|
||||
_LOGD(LOGD_RFKILL,
|
||||
"rfkill: %s %s devices (hw_enabled %d, sw_enabled %d, user_enabled %d)",
|
||||
enabled ? "enabling" : "disabling",
|
||||
rstate->desc,
|
||||
rstate->hw_enabled,
|
||||
rstate->sw_enabled,
|
||||
rstate->user_enabled);
|
||||
}
|
||||
if (nm_device_get_rfkill_type(device) == rstate->rtype)
|
||||
_LOGD(LOGD_RFKILL,
|
||||
"rfkill: %s %s devices (hw_enabled %d, sw_enabled %d, user_enabled %d)",
|
||||
enabled ? "enabling" : "disabling",
|
||||
nm_rfkill_type_to_string(rtype),
|
||||
rstate->hw_enabled,
|
||||
rstate->sw_enabled,
|
||||
rstate->user_enabled);
|
||||
if (nm_device_get_rfkill_type(device) == rtype)
|
||||
nm_device_set_enabled(device, enabled);
|
||||
}
|
||||
|
||||
|
|
@ -6929,25 +7061,21 @@ nm_manager_start(NMManager *self, GError **error)
|
|||
nm_device_factory_manager_for_each_factory(start_factory, NULL);
|
||||
|
||||
/* Set initial radio enabled/disabled state */
|
||||
for (i = 0; i < RFKILL_TYPE_MAX; i++) {
|
||||
RadioState *rstate = &priv->radio_states[i];
|
||||
gboolean enabled;
|
||||
|
||||
if (!rstate->desc)
|
||||
continue;
|
||||
for (i = 0; i < NM_RFKILL_TYPE_MAX; i++) {
|
||||
const NMRfkillType rtype = i;
|
||||
RfkillRadioState *rstate = &priv->radio_states[rtype];
|
||||
gboolean enabled;
|
||||
|
||||
/* recheck kernel rfkill state */
|
||||
update_rstate_from_rfkill(priv->rfkill_mgr, rstate);
|
||||
_rfkill_radio_state_set_from_manager(priv->rfkill_mgr, rtype, rstate);
|
||||
|
||||
if (rstate->desc) {
|
||||
_LOGI(LOGD_RFKILL,
|
||||
"rfkill: %s %s by radio killswitch; %s by state file",
|
||||
rstate->desc,
|
||||
(rstate->hw_enabled && rstate->sw_enabled) ? "enabled" : "disabled",
|
||||
rstate->user_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
enabled = radio_enabled_for_rstate(rstate, TRUE);
|
||||
manager_update_radio_enabled(self, rstate, enabled);
|
||||
_LOGI(LOGD_RFKILL,
|
||||
"rfkill: %s %s by radio killswitch; %s by state file",
|
||||
nm_rfkill_type_to_string(rtype),
|
||||
(rstate->hw_enabled && rstate->sw_enabled) ? "enabled" : "disabled",
|
||||
rstate->user_enabled ? "enabled" : "disabled");
|
||||
enabled = _rfkill_radio_state_get_enabled(rstate, TRUE);
|
||||
_rfkill_update_devices(self, rtype, enabled);
|
||||
}
|
||||
|
||||
_LOGI(LOGD_CORE, "Networking is %s by state file", priv->net_enabled ? "enabled" : "disabled");
|
||||
|
|
@ -7588,118 +7716,7 @@ auth_mgr_changed(NMAuthManager *auth_manager, gpointer user_data)
|
|||
"()");
|
||||
}
|
||||
|
||||
#define KERN_RFKILL_OP_CHANGE_ALL 3
|
||||
#define KERN_RFKILL_TYPE_WLAN 1
|
||||
#define KERN_RFKILL_TYPE_WWAN 5
|
||||
struct rfkill_event {
|
||||
uint32_t idx;
|
||||
uint8_t type;
|
||||
uint8_t op;
|
||||
uint8_t soft;
|
||||
uint8_t hard;
|
||||
} _nm_packed;
|
||||
|
||||
static void
|
||||
rfkill_change(NMManager *self, const char *desc, RfKillType rtype, gboolean enabled)
|
||||
{
|
||||
int fd;
|
||||
struct rfkill_event event;
|
||||
ssize_t len;
|
||||
int errsv;
|
||||
|
||||
g_return_if_fail(rtype == RFKILL_TYPE_WLAN || rtype == RFKILL_TYPE_WWAN);
|
||||
|
||||
fd = open("/dev/rfkill", O_RDWR | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
if (errno == EACCES)
|
||||
_LOGW(LOGD_RFKILL, "rfkill: (%s): failed to open killswitch device", desc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
|
||||
_LOGW(LOGD_RFKILL,
|
||||
"rfkill: (%s): failed to set killswitch device for "
|
||||
"non-blocking operation",
|
||||
desc);
|
||||
nm_close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&event, 0, sizeof(event));
|
||||
event.op = KERN_RFKILL_OP_CHANGE_ALL;
|
||||
switch (rtype) {
|
||||
case RFKILL_TYPE_WLAN:
|
||||
event.type = KERN_RFKILL_TYPE_WLAN;
|
||||
break;
|
||||
case RFKILL_TYPE_WWAN:
|
||||
event.type = KERN_RFKILL_TYPE_WWAN;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
event.soft = enabled ? 0 : 1;
|
||||
|
||||
len = write(fd, &event, sizeof(event));
|
||||
if (len < 0) {
|
||||
errsv = errno;
|
||||
_LOGW(LOGD_RFKILL,
|
||||
"rfkill: (%s): failed to change Wi-Fi killswitch state: (%d) %s",
|
||||
desc,
|
||||
errsv,
|
||||
nm_strerror_native(errsv));
|
||||
} else if (len == sizeof(event)) {
|
||||
_LOGI(LOGD_RFKILL,
|
||||
"rfkill: %s hardware radio set %s",
|
||||
desc,
|
||||
enabled ? "enabled" : "disabled");
|
||||
} else {
|
||||
/* Failed to write full structure */
|
||||
_LOGW(LOGD_RFKILL, "rfkill: (%s): failed to change Wi-Fi killswitch state", desc);
|
||||
}
|
||||
|
||||
nm_close(fd);
|
||||
}
|
||||
|
||||
static void
|
||||
manager_radio_user_toggled(NMManager *self, RadioState *rstate, gboolean enabled)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
gboolean old_enabled, new_enabled;
|
||||
|
||||
/* Don't touch devices if asleep/networking disabled */
|
||||
if (manager_sleeping(self))
|
||||
return;
|
||||
|
||||
if (rstate->desc) {
|
||||
_LOGD(LOGD_RFKILL,
|
||||
"rfkill: (%s): setting radio %s by user",
|
||||
rstate->desc,
|
||||
enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
/* Update enabled key in state file */
|
||||
nm_config_state_set(priv->config, TRUE, FALSE, rstate->key, enabled);
|
||||
|
||||
/* When the user toggles the radio, their request should override any
|
||||
* daemon (like ModemManager) enabled state that can be changed. For WWAN
|
||||
* for example, we want the WwanEnabled property to reflect the daemon state
|
||||
* too so that users can toggle the modem powered, but we don't want that
|
||||
* daemon state to affect whether or not the user *can* turn it on, which is
|
||||
* what the kernel rfkill state does. So we ignore daemon enabled state
|
||||
* when determining what the new state should be since it shouldn't block
|
||||
* the user's request.
|
||||
*/
|
||||
old_enabled = radio_enabled_for_rstate(rstate, TRUE);
|
||||
rstate->user_enabled = enabled;
|
||||
new_enabled = radio_enabled_for_rstate(rstate, FALSE);
|
||||
if (new_enabled != old_enabled) {
|
||||
/* Try to change the kernel rfkill state */
|
||||
if (rstate->rtype == RFKILL_TYPE_WLAN || rstate->rtype == RFKILL_TYPE_WWAN)
|
||||
rfkill_change(self, rstate->desc, rstate->rtype, new_enabled);
|
||||
|
||||
manager_update_radio_enabled(self, rstate, new_enabled);
|
||||
}
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
periodic_update_active_connection_timestamps(gpointer user_data)
|
||||
|
|
@ -7876,8 +7893,8 @@ constructed(GObject *object)
|
|||
|
||||
priv->net_enabled = state->net_enabled;
|
||||
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = state->wifi_enabled;
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = state->wwan_enabled;
|
||||
priv->radio_states[NM_RFKILL_TYPE_WLAN].user_enabled = state->wifi_enabled;
|
||||
priv->radio_states[NM_RFKILL_TYPE_WWAN].user_enabled = state->wwan_enabled;
|
||||
|
||||
priv->rfkill_mgr = nm_rfkill_manager_new();
|
||||
g_signal_connect(priv->rfkill_mgr,
|
||||
|
|
@ -7890,21 +7907,18 @@ constructed(GObject *object)
|
|||
* changes to the WirelessEnabled/WWANEnabled properties which toggle kernel
|
||||
* rfkill.
|
||||
*/
|
||||
rfkill_change(self,
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].desc,
|
||||
RFKILL_TYPE_WLAN,
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled);
|
||||
rfkill_change(self,
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].desc,
|
||||
RFKILL_TYPE_WWAN,
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled);
|
||||
_rfkill_update_system(self,
|
||||
NM_RFKILL_TYPE_WLAN,
|
||||
priv->radio_states[NM_RFKILL_TYPE_WLAN].user_enabled);
|
||||
_rfkill_update_system(self,
|
||||
NM_RFKILL_TYPE_WWAN,
|
||||
priv->radio_states[NM_RFKILL_TYPE_WWAN].user_enabled);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_manager_init(NMManager *self)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
guint i;
|
||||
GFile *file;
|
||||
|
||||
c_list_init(&priv->auth_lst_head);
|
||||
|
|
@ -7918,25 +7932,16 @@ nm_manager_init(NMManager *self)
|
|||
|
||||
priv->capabilities = g_array_new(FALSE, FALSE, sizeof(guint32));
|
||||
|
||||
/* Initialize rfkill structures and states */
|
||||
memset(priv->radio_states, 0, sizeof(priv->radio_states));
|
||||
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = TRUE;
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].key = NM_CONFIG_STATE_PROPERTY_WIFI_ENABLED;
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].prop = NM_MANAGER_WIRELESS_ENABLED;
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].hw_prop = NM_MANAGER_WIRELESS_HARDWARE_ENABLED;
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].desc = "Wi-Fi";
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].rtype = RFKILL_TYPE_WLAN;
|
||||
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = TRUE;
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].key = NM_CONFIG_STATE_PROPERTY_WWAN_ENABLED;
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].prop = NM_MANAGER_WWAN_ENABLED;
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].hw_prop = NM_MANAGER_WWAN_HARDWARE_ENABLED;
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].desc = "WWAN";
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].rtype = RFKILL_TYPE_WWAN;
|
||||
|
||||
for (i = 0; i < RFKILL_TYPE_MAX; i++)
|
||||
priv->radio_states[i].hw_enabled = TRUE;
|
||||
priv->radio_states[NM_RFKILL_TYPE_WLAN] = (RfkillRadioState){
|
||||
.user_enabled = TRUE,
|
||||
.sw_enabled = FALSE,
|
||||
.hw_enabled = TRUE,
|
||||
};
|
||||
priv->radio_states[NM_RFKILL_TYPE_WWAN] = (RfkillRadioState){
|
||||
.user_enabled = TRUE,
|
||||
.sw_enabled = FALSE,
|
||||
.hw_enabled = TRUE,
|
||||
};
|
||||
|
||||
priv->sleeping = FALSE;
|
||||
priv->state = NM_STATE_DISCONNECTED;
|
||||
|
|
@ -8008,16 +8013,16 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
g_value_set_boolean(value, priv->net_enabled);
|
||||
break;
|
||||
case PROP_WIRELESS_ENABLED:
|
||||
g_value_set_boolean(value, radio_enabled_for_type(self, RFKILL_TYPE_WLAN, TRUE));
|
||||
g_value_set_boolean(value, _rfkill_radio_state_get(self, NM_RFKILL_TYPE_WLAN));
|
||||
break;
|
||||
case PROP_WIRELESS_HARDWARE_ENABLED:
|
||||
g_value_set_boolean(value, priv->radio_states[RFKILL_TYPE_WLAN].hw_enabled);
|
||||
g_value_set_boolean(value, priv->radio_states[NM_RFKILL_TYPE_WLAN].hw_enabled);
|
||||
break;
|
||||
case PROP_WWAN_ENABLED:
|
||||
g_value_set_boolean(value, radio_enabled_for_type(self, RFKILL_TYPE_WWAN, TRUE));
|
||||
g_value_set_boolean(value, _rfkill_radio_state_get(self, NM_RFKILL_TYPE_WWAN));
|
||||
break;
|
||||
case PROP_WWAN_HARDWARE_ENABLED:
|
||||
g_value_set_boolean(value, priv->radio_states[RFKILL_TYPE_WWAN].hw_enabled);
|
||||
g_value_set_boolean(value, priv->radio_states[NM_RFKILL_TYPE_WWAN].hw_enabled);
|
||||
break;
|
||||
case PROP_WIMAX_ENABLED:
|
||||
g_value_set_boolean(value, FALSE);
|
||||
|
|
@ -8108,14 +8113,14 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_WIRELESS_ENABLED:
|
||||
manager_radio_user_toggled(NM_MANAGER(object),
|
||||
&priv->radio_states[RFKILL_TYPE_WLAN],
|
||||
g_value_get_boolean(value));
|
||||
_rfkill_update_from_user(NM_MANAGER(object),
|
||||
NM_RFKILL_TYPE_WLAN,
|
||||
g_value_get_boolean(value));
|
||||
break;
|
||||
case PROP_WWAN_ENABLED:
|
||||
manager_radio_user_toggled(NM_MANAGER(object),
|
||||
&priv->radio_states[RFKILL_TYPE_WWAN],
|
||||
g_value_get_boolean(value));
|
||||
_rfkill_update_from_user(NM_MANAGER(object),
|
||||
NM_RFKILL_TYPE_WWAN,
|
||||
g_value_get_boolean(value));
|
||||
break;
|
||||
case PROP_WIMAX_ENABLED:
|
||||
/* WIMAX is deprecated. This does nothing. */
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ _call_destroy_proxy_configuration(NMPacrunnerManager *self,
|
|||
g_variant_new("(o)", path),
|
||||
G_VARIANT_TYPE("()"),
|
||||
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
||||
NM_SHUTDOWN_TIMEOUT_MS,
|
||||
NM_SHUTDOWN_TIMEOUT_1500_MSEC,
|
||||
priv->cancellable,
|
||||
_call_destroy_proxy_configuration_cb,
|
||||
conf_id_ref(conf_id));
|
||||
|
|
@ -315,7 +315,7 @@ _call_create_proxy_configuration(NMPacrunnerManager *self,
|
|||
conf_id->parameters,
|
||||
G_VARIANT_TYPE("(o)"),
|
||||
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
||||
NM_SHUTDOWN_TIMEOUT_MS,
|
||||
NM_SHUTDOWN_TIMEOUT_1500_MSEC,
|
||||
priv->cancellable,
|
||||
_call_create_proxy_configuration_cb,
|
||||
conf_id_ref(conf_id));
|
||||
|
|
|
|||
|
|
@ -609,7 +609,10 @@ _set_hostname(NMPolicy *self, const char *new_hostname, const char *msg)
|
|||
_LOGI(LOGD_DNS, "set-hostname: set hostname to '%s' (%s)", name, msg);
|
||||
|
||||
/* Ask NMSettings to update the transient hostname using its
|
||||
* systemd-hostnamed proxy */
|
||||
* systemd-hostnamed proxy.
|
||||
*
|
||||
* FIXME(shutdown): an async request must be cancellable, so we are guaranteed
|
||||
* to tear down in a reasonable time.*/
|
||||
nm_hostname_manager_set_transient_hostname(priv->hostname_manager,
|
||||
name,
|
||||
settings_set_hostname_cb,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <libudev.h>
|
||||
|
||||
#include "c-list/src/c-list.h"
|
||||
#include "libnm-udev-aux/nm-udev-utils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -24,8 +25,9 @@ typedef struct {
|
|||
NMUdevClient *udev_client;
|
||||
|
||||
/* Authoritative rfkill state (RFKILL_* enum) */
|
||||
RfKillState rfkill_states[RFKILL_TYPE_MAX];
|
||||
GSList *killswitches;
|
||||
NMRfkillState rfkill_states[NM_RFKILL_TYPE_MAX];
|
||||
|
||||
CList killswitch_lst_head;
|
||||
} NMRfkillManagerPrivate;
|
||||
|
||||
struct _NMRfkillManager {
|
||||
|
|
@ -45,60 +47,63 @@ G_DEFINE_TYPE(NMRfkillManager, nm_rfkill_manager, G_TYPE_OBJECT)
|
|||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
guint64 seqnum;
|
||||
char *path;
|
||||
char *driver;
|
||||
RfKillType rtype;
|
||||
int state;
|
||||
gboolean platform;
|
||||
CList killswitch_lst;
|
||||
char *name;
|
||||
char *path;
|
||||
char *driver;
|
||||
guint64 seqnum;
|
||||
NMRfkillType rtype;
|
||||
int state;
|
||||
bool platform : 1;
|
||||
} Killswitch;
|
||||
|
||||
RfKillState
|
||||
nm_rfkill_manager_get_rfkill_state(NMRfkillManager *self, RfKillType rtype)
|
||||
NMRfkillState
|
||||
nm_rfkill_manager_get_rfkill_state(NMRfkillManager *self, NMRfkillType rtype)
|
||||
{
|
||||
g_return_val_if_fail(self != NULL, RFKILL_UNBLOCKED);
|
||||
g_return_val_if_fail(rtype < RFKILL_TYPE_MAX, RFKILL_UNBLOCKED);
|
||||
g_return_val_if_fail(self != NULL, NM_RFKILL_STATE_UNBLOCKED);
|
||||
g_return_val_if_fail(rtype < NM_RFKILL_TYPE_MAX, NM_RFKILL_STATE_UNBLOCKED);
|
||||
|
||||
return NM_RFKILL_MANAGER_GET_PRIVATE(self)->rfkill_states[rtype];
|
||||
}
|
||||
|
||||
static const char *
|
||||
rfkill_type_to_desc(RfKillType rtype)
|
||||
const char *
|
||||
nm_rfkill_type_to_string(NMRfkillType type)
|
||||
{
|
||||
if (rtype == 0)
|
||||
switch (type) {
|
||||
case NM_RFKILL_TYPE_WLAN:
|
||||
return "Wi-Fi";
|
||||
else if (rtype == 1)
|
||||
case NM_RFKILL_TYPE_WWAN:
|
||||
return "WWAN";
|
||||
else if (rtype == 2)
|
||||
return "WiMAX";
|
||||
return "unknown";
|
||||
case NM_RFKILL_TYPE_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
return nm_assert_unreachable_val("unknown");
|
||||
}
|
||||
|
||||
static const char *
|
||||
rfkill_state_to_desc(RfKillState rstate)
|
||||
nm_rfkill_state_to_string(NMRfkillState state)
|
||||
{
|
||||
if (rstate == 0)
|
||||
switch (state) {
|
||||
case NM_RFKILL_STATE_UNBLOCKED:
|
||||
return "unblocked";
|
||||
else if (rstate == 1)
|
||||
case NM_RFKILL_STATE_SOFT_BLOCKED:
|
||||
return "soft-blocked";
|
||||
else if (rstate == 2)
|
||||
case NM_RFKILL_STATE_HARD_BLOCKED:
|
||||
return "hard-blocked";
|
||||
return "unknown";
|
||||
}
|
||||
return nm_assert_unreachable_val("unknown");
|
||||
}
|
||||
|
||||
static Killswitch *
|
||||
killswitch_new(struct udev_device *device, RfKillType rtype)
|
||||
killswitch_new(struct udev_device *device, NMRfkillType rtype)
|
||||
{
|
||||
Killswitch *ks;
|
||||
struct udev_device *parent = NULL, *grandparent = NULL;
|
||||
const char *driver, *subsys, *parent_subsys = NULL;
|
||||
|
||||
ks = g_malloc0(sizeof(Killswitch));
|
||||
ks->name = g_strdup(udev_device_get_sysname(device));
|
||||
ks->seqnum = udev_device_get_seqnum(device);
|
||||
ks->path = g_strdup(udev_device_get_syspath(device));
|
||||
ks->rtype = rtype;
|
||||
struct udev_device *parent = NULL;
|
||||
struct udev_device *grandparent = NULL;
|
||||
const char *driver;
|
||||
const char *subsys;
|
||||
const char *parent_subsys = NULL;
|
||||
gboolean platform;
|
||||
|
||||
driver = udev_device_get_property_value(device, "DRIVER");
|
||||
subsys = udev_device_get_subsystem(device);
|
||||
|
|
@ -116,14 +121,23 @@ killswitch_new(struct udev_device *device, RfKillType rtype)
|
|||
driver = udev_device_get_property_value(grandparent, "DRIVER");
|
||||
}
|
||||
}
|
||||
|
||||
if (!driver)
|
||||
driver = "(unknown)";
|
||||
ks->driver = g_strdup(driver);
|
||||
|
||||
if (g_strcmp0(subsys, "platform") == 0 || g_strcmp0(parent_subsys, "platform") == 0
|
||||
|| g_strcmp0(subsys, "acpi") == 0 || g_strcmp0(parent_subsys, "acpi") == 0)
|
||||
ks->platform = TRUE;
|
||||
platform = FALSE;
|
||||
if (nm_streq0(subsys, "platform") || nm_streq0(parent_subsys, "platform")
|
||||
|| nm_streq0(subsys, "acpi") || nm_streq0(parent_subsys, "acpi"))
|
||||
platform = TRUE;
|
||||
|
||||
ks = g_slice_new(Killswitch);
|
||||
*ks = (Killswitch){
|
||||
.name = g_strdup(udev_device_get_sysname(device)),
|
||||
.seqnum = udev_device_get_seqnum(device),
|
||||
.path = g_strdup(udev_device_get_syspath(device)),
|
||||
.rtype = rtype,
|
||||
.driver = g_strdup(driver),
|
||||
.platform = platform,
|
||||
};
|
||||
|
||||
return ks;
|
||||
}
|
||||
|
|
@ -131,54 +145,51 @@ killswitch_new(struct udev_device *device, RfKillType rtype)
|
|||
static void
|
||||
killswitch_destroy(Killswitch *ks)
|
||||
{
|
||||
g_return_if_fail(ks != NULL);
|
||||
|
||||
c_list_unlink_stale(&ks->killswitch_lst);
|
||||
g_free(ks->name);
|
||||
g_free(ks->path);
|
||||
g_free(ks->driver);
|
||||
memset(ks, 0, sizeof(Killswitch));
|
||||
g_free(ks);
|
||||
nm_g_slice_free(ks);
|
||||
}
|
||||
|
||||
static RfKillState
|
||||
static NMRfkillState
|
||||
sysfs_state_to_nm_state(int sysfs_state)
|
||||
{
|
||||
switch (sysfs_state) {
|
||||
case 0:
|
||||
return RFKILL_SOFT_BLOCKED;
|
||||
return NM_RFKILL_STATE_SOFT_BLOCKED;
|
||||
case 1:
|
||||
return RFKILL_UNBLOCKED;
|
||||
return NM_RFKILL_STATE_UNBLOCKED;
|
||||
case 2:
|
||||
return RFKILL_HARD_BLOCKED;
|
||||
return NM_RFKILL_STATE_HARD_BLOCKED;
|
||||
default:
|
||||
nm_log_warn(LOGD_RFKILL, "unhandled rfkill state %d", sysfs_state);
|
||||
break;
|
||||
}
|
||||
return RFKILL_UNBLOCKED;
|
||||
return NM_RFKILL_STATE_UNBLOCKED;
|
||||
}
|
||||
|
||||
static void
|
||||
recheck_killswitches(NMRfkillManager *self)
|
||||
{
|
||||
NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self);
|
||||
GSList *iter;
|
||||
RfKillState poll_states[RFKILL_TYPE_MAX];
|
||||
RfKillState platform_states[RFKILL_TYPE_MAX];
|
||||
gboolean platform_checked[RFKILL_TYPE_MAX];
|
||||
Killswitch *ks;
|
||||
NMRfkillState poll_states[NM_RFKILL_TYPE_MAX];
|
||||
NMRfkillState platform_states[NM_RFKILL_TYPE_MAX];
|
||||
gboolean platform_checked[NM_RFKILL_TYPE_MAX];
|
||||
int i;
|
||||
|
||||
/* Default state is unblocked */
|
||||
for (i = 0; i < RFKILL_TYPE_MAX; i++) {
|
||||
poll_states[i] = RFKILL_UNBLOCKED;
|
||||
platform_states[i] = RFKILL_UNBLOCKED;
|
||||
for (i = 0; i < NM_RFKILL_TYPE_MAX; i++) {
|
||||
poll_states[i] = NM_RFKILL_STATE_UNBLOCKED;
|
||||
platform_states[i] = NM_RFKILL_STATE_UNBLOCKED;
|
||||
platform_checked[i] = FALSE;
|
||||
}
|
||||
|
||||
/* Poll the states of all killswitches */
|
||||
for (iter = priv->killswitches; iter; iter = g_slist_next(iter)) {
|
||||
Killswitch *ks = iter->data;
|
||||
c_list_for_each_entry (ks, &priv->killswitch_lst_head, killswitch_lst) {
|
||||
struct udev_device *device;
|
||||
RfKillState dev_state;
|
||||
NMRfkillState dev_state;
|
||||
int sysfs_state;
|
||||
|
||||
device = udev_device_new_from_subsystem_sysname(nm_udev_client_get_udev(priv->udev_client),
|
||||
|
|
@ -196,7 +207,7 @@ recheck_killswitches(NMRfkillManager *self)
|
|||
|
||||
nm_log_dbg(LOGD_RFKILL,
|
||||
"%s rfkill%s switch %s state now %d/%u",
|
||||
rfkill_type_to_desc(ks->rtype),
|
||||
nm_rfkill_type_to_string(ks->rtype),
|
||||
ks->platform ? " platform" : "",
|
||||
ks->name,
|
||||
sysfs_state,
|
||||
|
|
@ -210,27 +221,32 @@ recheck_killswitches(NMRfkillManager *self)
|
|||
if (dev_state > platform_states[ks->rtype])
|
||||
platform_states[ks->rtype] = dev_state;
|
||||
}
|
||||
|
||||
udev_device_unref(device);
|
||||
}
|
||||
|
||||
/* Log and emit change signal for final rfkill states */
|
||||
for (i = 0; i < RFKILL_TYPE_MAX; i++) {
|
||||
for (i = 0; i < NM_RFKILL_TYPE_MAX; i++) {
|
||||
if (platform_checked[i] == TRUE) {
|
||||
/* blocked platform switch state overrides device state, otherwise
|
||||
* let the device state stand. (bgo #655773)
|
||||
*/
|
||||
if (platform_states[i] != RFKILL_UNBLOCKED)
|
||||
if (platform_states[i] != NM_RFKILL_STATE_UNBLOCKED)
|
||||
poll_states[i] = platform_states[i];
|
||||
}
|
||||
|
||||
if (poll_states[i] != priv->rfkill_states[i]) {
|
||||
nm_log_dbg(LOGD_RFKILL,
|
||||
"%s rfkill state now '%s'",
|
||||
rfkill_type_to_desc(i),
|
||||
rfkill_state_to_desc(poll_states[i]));
|
||||
nm_rfkill_type_to_string(i),
|
||||
nm_rfkill_state_to_string(poll_states[i]));
|
||||
|
||||
priv->rfkill_states[i] = poll_states[i];
|
||||
g_signal_emit(self, signals[RFKILL_CHANGED], 0, i, priv->rfkill_states[i]);
|
||||
g_signal_emit(self,
|
||||
signals[RFKILL_CHANGED],
|
||||
0,
|
||||
(guint) i,
|
||||
(guint) priv->rfkill_states[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -239,52 +255,48 @@ static Killswitch *
|
|||
killswitch_find_by_name(NMRfkillManager *self, const char *name)
|
||||
{
|
||||
NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self);
|
||||
GSList *iter;
|
||||
Killswitch *ks;
|
||||
|
||||
g_return_val_if_fail(name != NULL, NULL);
|
||||
nm_assert(name);
|
||||
|
||||
for (iter = priv->killswitches; iter; iter = g_slist_next(iter)) {
|
||||
Killswitch *candidate = iter->data;
|
||||
|
||||
if (!strcmp(name, candidate->name))
|
||||
return candidate;
|
||||
c_list_for_each_entry (ks, &priv->killswitch_lst_head, killswitch_lst) {
|
||||
if (nm_streq(name, ks->name))
|
||||
return ks;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static RfKillType
|
||||
static NMRfkillType
|
||||
rfkill_type_to_enum(const char *str)
|
||||
{
|
||||
g_return_val_if_fail(str != NULL, RFKILL_TYPE_UNKNOWN);
|
||||
if (str) {
|
||||
if (nm_streq(str, "wlan"))
|
||||
return NM_RFKILL_TYPE_WLAN;
|
||||
if (nm_streq(str, "wwan"))
|
||||
return NM_RFKILL_TYPE_WWAN;
|
||||
}
|
||||
|
||||
if (!strcmp(str, "wlan"))
|
||||
return RFKILL_TYPE_WLAN;
|
||||
else if (!strcmp(str, "wwan"))
|
||||
return RFKILL_TYPE_WWAN;
|
||||
|
||||
return RFKILL_TYPE_UNKNOWN;
|
||||
return NM_RFKILL_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
static void
|
||||
add_one_killswitch(NMRfkillManager *self, struct udev_device *device)
|
||||
{
|
||||
NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self);
|
||||
const char *str_type;
|
||||
RfKillType rtype;
|
||||
NMRfkillType rtype;
|
||||
Killswitch *ks;
|
||||
|
||||
str_type = udev_device_get_property_value(device, "RFKILL_TYPE");
|
||||
rtype = rfkill_type_to_enum(str_type);
|
||||
if (rtype == RFKILL_TYPE_UNKNOWN)
|
||||
rtype = rfkill_type_to_enum(udev_device_get_property_value(device, "RFKILL_TYPE"));
|
||||
if (rtype == NM_RFKILL_TYPE_UNKNOWN)
|
||||
return;
|
||||
|
||||
ks = killswitch_new(device, rtype);
|
||||
priv->killswitches = g_slist_prepend(priv->killswitches, ks);
|
||||
ks = killswitch_new(device, rtype);
|
||||
c_list_link_front(&priv->killswitch_lst_head, &ks->killswitch_lst);
|
||||
|
||||
nm_log_info(LOGD_RFKILL,
|
||||
"%s: found %s radio killswitch (at %s) (%sdriver %s)",
|
||||
ks->name,
|
||||
rfkill_type_to_desc(rtype),
|
||||
nm_rfkill_type_to_string(rtype),
|
||||
ks->path,
|
||||
ks->platform ? "platform " : "",
|
||||
ks->driver ?: "<unknown>");
|
||||
|
|
@ -297,6 +309,7 @@ rfkill_add(NMRfkillManager *self, struct udev_device *device)
|
|||
|
||||
g_return_if_fail(device != NULL);
|
||||
name = udev_device_get_sysname(device);
|
||||
|
||||
g_return_if_fail(name != NULL);
|
||||
|
||||
if (!killswitch_find_by_name(self, name))
|
||||
|
|
@ -307,21 +320,20 @@ static void
|
|||
rfkill_remove(NMRfkillManager *self, struct udev_device *device)
|
||||
{
|
||||
NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self);
|
||||
GSList *iter;
|
||||
Killswitch *ks;
|
||||
const char *name;
|
||||
|
||||
g_return_if_fail(device != NULL);
|
||||
|
||||
name = udev_device_get_sysname(device);
|
||||
|
||||
g_return_if_fail(name != NULL);
|
||||
|
||||
for (iter = priv->killswitches; iter; iter = g_slist_next(iter)) {
|
||||
Killswitch *ks = iter->data;
|
||||
|
||||
if (!strcmp(ks->name, name)) {
|
||||
c_list_for_each_entry (ks, &priv->killswitch_lst_head, killswitch_lst) {
|
||||
if (nm_streq(ks->name, name)) {
|
||||
nm_log_info(LOGD_RFKILL, "radio killswitch %s disappeared", ks->path);
|
||||
priv->killswitches = g_slist_remove(priv->killswitches, ks);
|
||||
killswitch_destroy(ks);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -339,16 +351,16 @@ handle_uevent(NMUdevClient *client, struct udev_device *device, gpointer user_da
|
|||
|
||||
/* A bit paranoid */
|
||||
subsys = udev_device_get_subsystem(device);
|
||||
g_return_if_fail(!g_strcmp0(subsys, "rfkill"));
|
||||
g_return_if_fail(nm_streq0(subsys, "rfkill"));
|
||||
|
||||
nm_log_dbg(LOGD_PLATFORM,
|
||||
"udev rfkill event: action '%s' device '%s'",
|
||||
action,
|
||||
udev_device_get_sysname(device));
|
||||
|
||||
if (!strcmp(action, "add"))
|
||||
if (nm_streq(action, "add"))
|
||||
rfkill_add(self, device);
|
||||
else if (!strcmp(action, "remove"))
|
||||
else if (nm_streq(action, "remove"))
|
||||
rfkill_remove(self, device);
|
||||
|
||||
recheck_killswitches(self);
|
||||
|
|
@ -364,8 +376,10 @@ nm_rfkill_manager_init(NMRfkillManager *self)
|
|||
struct udev_list_entry *iter;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < RFKILL_TYPE_MAX; i++)
|
||||
priv->rfkill_states[i] = RFKILL_UNBLOCKED;
|
||||
c_list_init(&priv->killswitch_lst_head);
|
||||
|
||||
for (i = 0; i < NM_RFKILL_TYPE_MAX; i++)
|
||||
priv->rfkill_states[i] = NM_RFKILL_STATE_UNBLOCKED;
|
||||
|
||||
priv->udev_client = nm_udev_client_new(NM_MAKE_STRV("rfkill"), handle_uevent, self);
|
||||
|
||||
|
|
@ -399,11 +413,10 @@ dispose(GObject *object)
|
|||
{
|
||||
NMRfkillManager *self = NM_RFKILL_MANAGER(object);
|
||||
NMRfkillManagerPrivate *priv = NM_RFKILL_MANAGER_GET_PRIVATE(self);
|
||||
Killswitch *ks;
|
||||
|
||||
if (priv->killswitches) {
|
||||
g_slist_free_full(priv->killswitches, (GDestroyNotify) killswitch_destroy);
|
||||
priv->killswitches = NULL;
|
||||
}
|
||||
while ((ks = c_list_first_entry(&priv->killswitch_lst_head, Killswitch, killswitch_lst)))
|
||||
killswitch_destroy(ks);
|
||||
|
||||
priv->udev_client = nm_udev_client_destroy(priv->udev_client);
|
||||
|
||||
|
|
@ -426,6 +439,6 @@ nm_rfkill_manager_class_init(NMRfkillManagerClass *klass)
|
|||
NULL,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
G_TYPE_UINT,
|
||||
G_TYPE_UINT);
|
||||
G_TYPE_UINT /* NMRfkillType */,
|
||||
G_TYPE_UINT /* NMRfkillState */);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,23 +7,25 @@
|
|||
#ifndef __NM_RFKILL_MANAGER_H__
|
||||
#define __NM_RFKILL_MANAGER_H__
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
RFKILL_UNBLOCKED = 0,
|
||||
RFKILL_SOFT_BLOCKED = 1,
|
||||
RFKILL_HARD_BLOCKED = 2
|
||||
} RfKillState;
|
||||
typedef enum {
|
||||
NM_RFKILL_STATE_UNBLOCKED = 0,
|
||||
NM_RFKILL_STATE_SOFT_BLOCKED = 1,
|
||||
NM_RFKILL_STATE_HARD_BLOCKED = 2,
|
||||
} NMRfkillState;
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
RFKILL_TYPE_WLAN = 0,
|
||||
RFKILL_TYPE_WWAN = 1,
|
||||
typedef enum {
|
||||
NM_RFKILL_TYPE_WLAN = 0,
|
||||
NM_RFKILL_TYPE_WWAN = 1,
|
||||
|
||||
/* UNKNOWN and MAX should always be 1 more than
|
||||
* the last rfkill type since RFKILL_TYPE_MAX is
|
||||
/* UNKNOWN and MAX should always be 1 more than
|
||||
* the last rfkill type since NM_RFKILL_TYPE_MAX is
|
||||
* used as an array size.
|
||||
*/
|
||||
RFKILL_TYPE_UNKNOWN, /* KEEP LAST */
|
||||
RFKILL_TYPE_MAX = RFKILL_TYPE_UNKNOWN
|
||||
} RfKillType;
|
||||
NM_RFKILL_TYPE_UNKNOWN, /* KEEP LAST */
|
||||
NM_RFKILL_TYPE_MAX = NM_RFKILL_TYPE_UNKNOWN,
|
||||
} NMRfkillType;
|
||||
|
||||
const char *nm_rfkill_type_to_string(NMRfkillType rtype);
|
||||
|
||||
#define NM_TYPE_RFKILL_MANAGER (nm_rfkill_manager_get_type())
|
||||
#define NM_RFKILL_MANAGER(obj) \
|
||||
|
|
@ -43,6 +45,6 @@ GType nm_rfkill_manager_get_type(void);
|
|||
|
||||
NMRfkillManager *nm_rfkill_manager_new(void);
|
||||
|
||||
RfKillState nm_rfkill_manager_get_rfkill_state(NMRfkillManager *manager, RfKillType rtype);
|
||||
NMRfkillState nm_rfkill_manager_get_rfkill_state(NMRfkillManager *manager, NMRfkillType rtype);
|
||||
|
||||
#endif /* __NM_RFKILL_MANAGER_H__ */
|
||||
|
|
|
|||
|
|
@ -241,6 +241,7 @@ _nmtstp_platform_ip_addresses_assert(const char *filename,
|
|||
if ((IS_IPv4 ? force_exact_4 : force_exact_6) && nm_g_ptr_array_len(plat_addrs) > 0) {
|
||||
char sbuf[sizeof(_nm_utils_to_string_buffer)];
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("%s:%d: %u IPv%c addresses found on ifindex %d that should not be there (one "
|
||||
"is %s)",
|
||||
filename,
|
||||
|
|
@ -252,6 +253,7 @@ _nmtstp_platform_ip_addresses_assert(const char *filename,
|
|||
NMP_OBJECT_TO_STRING_PUBLIC,
|
||||
sbuf,
|
||||
sizeof(sbuf)));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -580,6 +582,7 @@ _nmtstp_assert_ip4_route_exists(const char *file,
|
|||
if (c != c_exists && c_exists != -1) {
|
||||
char sbuf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("[%s:%u] %s(): The ip4 route %s/%d metric %u tos %u shall exist %u times, but "
|
||||
"platform has it %u times",
|
||||
file,
|
||||
|
|
@ -591,6 +594,7 @@ _nmtstp_assert_ip4_route_exists(const char *file,
|
|||
tos,
|
||||
c_exists,
|
||||
c);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
@ -673,6 +677,7 @@ _nmtstp_assert_ip6_route_exists(const char *file,
|
|||
char s_src[NM_UTILS_INET_ADDRSTRLEN];
|
||||
char s_network[NM_UTILS_INET_ADDRSTRLEN];
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("[%s:%u] %s(): The ip6 route %s/%d metric %u src %s/%d shall exist %u times, but "
|
||||
"platform has it %u times",
|
||||
file,
|
||||
|
|
@ -685,6 +690,7 @@ _nmtstp_assert_ip6_route_exists(const char *file,
|
|||
src_plen,
|
||||
c_exists,
|
||||
c);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
|
|||
|
|
@ -731,15 +731,17 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data)
|
|||
&bin_len);
|
||||
|
||||
if (bin_len != ELM_SIZE * N_ADDRESSES || memcmp(addresses, bin_arr, bin_len) != 0) {
|
||||
char *addresses_str = nm_utils_bin2hexstr(addresses, ELM_SIZE * N_ADDRESSES, -1);
|
||||
gs_free char *addresses_str = NULL;
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error(">>> test_platform_ip_address_pretty_sort_cmp() will fail:\n"
|
||||
">>> addresses[%zu]: %s\n"
|
||||
">>> expected [%zu]: %s\n",
|
||||
ELM_SIZE * N_ADDRESSES,
|
||||
addresses_str,
|
||||
(addresses_str = nm_utils_bin2hexstr(addresses, ELM_SIZE * N_ADDRESSES, -1)),
|
||||
bin_len,
|
||||
EXPECTED_BUFFER[TEST_DATA_I]);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
g_assert_cmpmem(addresses, ELM_SIZE * N_ADDRESSES, bin_arr, bin_len);
|
||||
|
|
|
|||
|
|
@ -1246,7 +1246,7 @@ _ppp_manager_stop(NMPPPManager *self,
|
|||
SIGTERM,
|
||||
LOGD_PPP,
|
||||
"pppd",
|
||||
5000,
|
||||
NM_SHUTDOWN_TIMEOUT_5000_MSEC,
|
||||
_stop_child_cb,
|
||||
handle);
|
||||
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ nm_secret_agent_cancel_call(NMSecretAgent *self, NMSecretAgentCallId *call_id)
|
|||
g_variant_new("(os)", call_id->path, call_id->setting_name),
|
||||
G_VARIANT_TYPE("()"),
|
||||
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
||||
NM_SHUTDOWN_TIMEOUT_MS,
|
||||
NM_SHUTDOWN_TIMEOUT_1500_MSEC,
|
||||
NULL, /* this operation is not cancellable. We rely on the timeout. */
|
||||
_call_cancel_cb,
|
||||
call_id);
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ _assert_expected_content(NMConnection *connection, const char *filename, const c
|
|||
success = g_file_set_contents(expected, content_written, len_written, &error);
|
||||
nmtst_assert_success(success, error);
|
||||
} else {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error(
|
||||
"The content of \"%s\" (%zu) differs from \"%s\" (%zu). Set "
|
||||
"NMTST_IFCFG_RH_UPDATE_EXPECTED=yes (or NM_TEST_REGENERATE=1) to update the files "
|
||||
|
|
@ -231,6 +232,7 @@ _assert_expected_content(NMConnection *connection, const char *filename, const c
|
|||
len_expectd,
|
||||
content_written,
|
||||
content_expectd);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2635,8 +2635,11 @@ _escape_filename(gboolean with_extension, const char *filename, gboolean would_b
|
|||
g_assert(esc && esc[0]);
|
||||
g_assert(!strchr(esc, '/'));
|
||||
|
||||
if (nm_keyfile_utils_ignore_filename(esc, with_extension))
|
||||
if (nm_keyfile_utils_ignore_filename(esc, with_extension)) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("Escaping filename \"%s\" yielded \"%s\", but this is ignored", filename, esc);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -2319,10 +2319,25 @@ test_machine_id_read(void)
|
|||
char machine_id_str[33];
|
||||
gpointer logstate;
|
||||
|
||||
/* This unit test checks our functions to read /etc/machine-id. As
|
||||
* the path name is not configurable (and the test does not setup
|
||||
* a chroot/mountns), we read the actual file from the system. That
|
||||
* is ugly, as the test depends on the system where it's running.
|
||||
*
|
||||
* Still, better a bad test, than no test. Patch welcome to fix this
|
||||
* shortcoming.
|
||||
*
|
||||
* Also, if you have a sufficiently broken system, the unit test fails.
|
||||
* In particular, if the machine-id file exists but does not contain
|
||||
* a valid ID. Just don't have that. Fix your system. */
|
||||
|
||||
logstate = nmtst_logging_disable(FALSE);
|
||||
/* If you run this test as root, without a valid /etc/machine-id,
|
||||
* the code will try to get the secret-key. That is a bit ugly,
|
||||
* but no real problem. */
|
||||
* but no real problem.
|
||||
*
|
||||
* The real answer is: don't run our unit tests as root. That's
|
||||
* not the way to do it. */
|
||||
machine_id = nm_utils_machine_id_bin();
|
||||
nmtst_logging_reenable(logstate);
|
||||
|
||||
|
|
@ -2338,9 +2353,15 @@ test_machine_id_read(void)
|
|||
* is invalid. Our machine-id is fake, and we have nothing to
|
||||
* compare against. */
|
||||
|
||||
/* NOTE: this test will fail, if you don't have /etc/machine-id,
|
||||
* but a valid "LOCALSTATEDIR/lib/dbus/machine-id" file.
|
||||
* Just don't do that. */
|
||||
if (g_file_test(LOCALSTATEDIR "/lib/dbus/machine-id", G_FILE_TEST_EXISTS)) {
|
||||
/* Hm. So systemd failed to read /etc/machine-id, but we may have the one from D-Bus.
|
||||
* With LOCALSTATEDIR"/lib/dbus/machine-id", we don't really know whether we
|
||||
* parsed that file. Assume we don't know and skip the test on this system. */
|
||||
g_assert(!nm_utils_machine_id_is_fake());
|
||||
return;
|
||||
}
|
||||
|
||||
/* OK, in this case, our function should have generated a random machine ID. */
|
||||
g_assert(nm_utils_machine_id_is_fake());
|
||||
} else {
|
||||
g_assert(!nm_utils_machine_id_is_fake());
|
||||
|
|
|
|||
|
|
@ -2327,13 +2327,14 @@ _do_read_vpn_details_impl1(const char *file,
|
|||
if (nm_streq(_expected[_i].key, _k)) \
|
||||
break; \
|
||||
} \
|
||||
if (_i >= _expected_len) \
|
||||
if (_i >= _expected_len) { \
|
||||
g_error("%s:%d: hash '%s' contains unexpected data key '%s' with value '%s'", \
|
||||
file, \
|
||||
line, \
|
||||
G_STRINGIFY(hash), \
|
||||
_k, \
|
||||
_v); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
for (_i = 0; _i < _expected_len; _i++) { \
|
||||
|
|
@ -2342,7 +2343,7 @@ _do_read_vpn_details_impl1(const char *file,
|
|||
g_assert(_d->key); \
|
||||
g_assert(_d->val); \
|
||||
_v = g_hash_table_lookup(_hash, _d->key); \
|
||||
if (!nm_streq0(_v, _d->val)) \
|
||||
if (!nm_streq0(_v, _d->val)) { \
|
||||
g_error("%s:%d: hash '%s' contains data key '%s' with value %s%s%s but we " \
|
||||
"expected '%s'", \
|
||||
file, \
|
||||
|
|
@ -2351,14 +2352,17 @@ _do_read_vpn_details_impl1(const char *file,
|
|||
_d->key, \
|
||||
NM_PRINT_FMT_QUOTE_STRING(_v), \
|
||||
_d->val); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
g_assert_cmpint(g_hash_table_size(_hash), ==, _expected_len); \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
_assert_hash(data, expected_data, expected_data_len);
|
||||
_assert_hash(secrets, expected_secrets, expected_secrets_len);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
|
||||
#undef _assert_hash
|
||||
return TRUE;
|
||||
|
|
@ -3049,10 +3053,12 @@ check_dbus_properties:
|
|||
break;
|
||||
p_expected_type++;
|
||||
if (p_expected_type >= &expected_types[G_N_ELEMENTS(expected_types)]) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("D-Bus type \"%s\" is not implemented (in property %s.%s)",
|
||||
(const char *) mpr->dbus_type,
|
||||
mif->dbus_iface_name,
|
||||
mpr->dbus_property_name);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3151,6 +3157,7 @@ check_dbus_properties:
|
|||
break;
|
||||
}
|
||||
if (p_expected_type_2 >= &expected_types[G_N_ELEMENTS(expected_types)]) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("D-Bus property \"%s.%s\" (type \"%s\") maps to property \"%s\", "
|
||||
"but that has an unexpected property type %s (expected %s)",
|
||||
mif->dbus_iface_name,
|
||||
|
|
@ -3159,6 +3166,7 @@ check_dbus_properties:
|
|||
pspec->name,
|
||||
g_type_name(pspec->value_type),
|
||||
g_type_name(p_expected_type->default_gtype));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_CLIENT_INSTANCE_FLAGS_NONE = 0,
|
||||
NM_CLIENT_INSTANCE_FLAGS_NO_AUTO_FETCH_PERMISSIONS = 1,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_CLIENT_INSTANCE_FLAGS_NONE = 0,
|
||||
NM_CLIENT_INSTANCE_FLAGS_NO_AUTO_FETCH_PERMISSIONS = 1,
|
||||
} NMClientInstanceFlags;
|
||||
|
||||
#define NM_TYPE_CLIENT (nm_client_get_type())
|
||||
|
|
|
|||
|
|
@ -159,7 +159,9 @@ nmtstc_service_init(void)
|
|||
* via pygobject. */
|
||||
return NULL;
|
||||
}
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("test service %s exited with error code %d", NMTSTC_NM_SERVICE, data.exit_code);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,21 @@ if crypto_gnutls_dep.found()
|
|||
)
|
||||
endif
|
||||
|
||||
libnm_crypto_null = static_library(
|
||||
'nm-crypto-null',
|
||||
sources: 'nm-crypto-null.c',
|
||||
dependencies: [
|
||||
libnm_core_public_dep,
|
||||
],
|
||||
)
|
||||
|
||||
if crypto == 'nss'
|
||||
libnm_crypto = libnm_crypto_nss
|
||||
else
|
||||
assert(crypto == 'gnutls', 'Unexpected setting "crypto=' + crypto + '"')
|
||||
elif crypto == 'gnutls'
|
||||
libnm_crypto = libnm_crypto_gnutls
|
||||
else
|
||||
assert(crypto == 'null', 'Unexpected setting "crypto=' + crypto + '"')
|
||||
libnm_crypto = libnm_crypto_null
|
||||
endif
|
||||
|
||||
libnm_core_settings_sources = files(
|
||||
|
|
|
|||
104
src/libnm-core-impl/nm-crypto-null.c
Normal file
104
src/libnm-core-impl/nm-crypto-null.c
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
/*
|
||||
* Christian Eggers <ceggers@arri.de>
|
||||
* Copyright (C) 2020 - 2022 ARRI Lighting
|
||||
*/
|
||||
|
||||
#include "libnm-glib-aux/nm-default-glib-i18n-lib.h"
|
||||
|
||||
#include "nm-crypto-impl.h"
|
||||
|
||||
#include "libnm-glib-aux/nm-secret-utils.h"
|
||||
#include "nm-errors.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
_nm_crypto_init(GError **error)
|
||||
{
|
||||
g_set_error(error,
|
||||
NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERROR_FAILED,
|
||||
_("Compiled without crypto support."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
guint8 *
|
||||
_nmtst_crypto_decrypt(NMCryptoCipherType cipher,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
const guint8 *iv,
|
||||
gsize iv_len,
|
||||
const guint8 *key,
|
||||
gsize key_len,
|
||||
gsize *out_len,
|
||||
GError **error)
|
||||
{
|
||||
g_set_error(error,
|
||||
NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERROR_FAILED,
|
||||
_("Compiled without crypto support."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
guint8 *
|
||||
_nmtst_crypto_encrypt(NMCryptoCipherType cipher,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
const guint8 *iv,
|
||||
gsize iv_len,
|
||||
const guint8 *key,
|
||||
gsize key_len,
|
||||
gsize *out_len,
|
||||
GError **error)
|
||||
{
|
||||
g_set_error(error,
|
||||
NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERROR_FAILED,
|
||||
_("Compiled without crypto support."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_nm_crypto_verify_x509(const guint8 *data, gsize len, GError **error)
|
||||
{
|
||||
g_set_error(error,
|
||||
NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERROR_FAILED,
|
||||
_("Compiled without crypto support."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_nm_crypto_verify_pkcs12(const guint8 *data, gsize data_len, const char *password, GError **error)
|
||||
{
|
||||
g_set_error(error,
|
||||
NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERROR_FAILED,
|
||||
_("Compiled without crypto support."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_nm_crypto_verify_pkcs8(const guint8 *data,
|
||||
gsize data_len,
|
||||
gboolean is_encrypted,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
g_set_error(error,
|
||||
NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERROR_FAILED,
|
||||
_("Compiled without crypto support."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_nm_crypto_randomize(void *buffer, gsize buffer_len, GError **error)
|
||||
{
|
||||
g_set_error(error,
|
||||
NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERROR_FAILED,
|
||||
_("Compiled without crypto support."));
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -71,32 +71,32 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingConnection,
|
|||
PROP_MUD_URL, );
|
||||
|
||||
typedef struct {
|
||||
GArray *permissions;
|
||||
GArray *secondaries;
|
||||
char *id;
|
||||
char *uuid;
|
||||
char *stable_id;
|
||||
char *interface_name;
|
||||
char *type;
|
||||
char *master;
|
||||
char *slave_type;
|
||||
char *zone;
|
||||
char *mud_url;
|
||||
guint64 timestamp;
|
||||
int autoconnect_slaves;
|
||||
int metered;
|
||||
gint32 autoconnect_priority;
|
||||
gint32 autoconnect_retries;
|
||||
gint32 multi_connect;
|
||||
gint32 auth_retries;
|
||||
gint32 mdns;
|
||||
gint32 llmnr;
|
||||
gint32 dns_over_tls;
|
||||
gint32 wait_device_timeout;
|
||||
gint32 lldp;
|
||||
guint32 gateway_ping_timeout;
|
||||
bool autoconnect;
|
||||
bool read_only;
|
||||
GArray *permissions;
|
||||
NMValueStrv secondaries;
|
||||
char *id;
|
||||
char *uuid;
|
||||
char *stable_id;
|
||||
char *interface_name;
|
||||
char *type;
|
||||
char *master;
|
||||
char *slave_type;
|
||||
char *zone;
|
||||
char *mud_url;
|
||||
guint64 timestamp;
|
||||
int autoconnect_slaves;
|
||||
int metered;
|
||||
gint32 autoconnect_priority;
|
||||
gint32 autoconnect_retries;
|
||||
gint32 multi_connect;
|
||||
gint32 auth_retries;
|
||||
gint32 mdns;
|
||||
gint32 llmnr;
|
||||
gint32 dns_over_tls;
|
||||
gint32 wait_device_timeout;
|
||||
gint32 lldp;
|
||||
guint32 gateway_ping_timeout;
|
||||
bool autoconnect;
|
||||
bool read_only;
|
||||
} NMSettingConnectionPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -757,7 +757,7 @@ nm_setting_connection_get_autoconnect_slaves(NMSettingConnection *setting)
|
|||
GArray *
|
||||
_nm_setting_connection_get_secondaries(NMSettingConnection *setting)
|
||||
{
|
||||
return NM_SETTING_CONNECTION_GET_PRIVATE(setting)->secondaries;
|
||||
return NM_SETTING_CONNECTION_GET_PRIVATE(setting)->secondaries.arr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -771,7 +771,7 @@ nm_setting_connection_get_num_secondaries(NMSettingConnection *setting)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_CONNECTION(setting), 0);
|
||||
|
||||
return nm_g_array_len(NM_SETTING_CONNECTION_GET_PRIVATE(setting)->secondaries);
|
||||
return nm_g_array_len(NM_SETTING_CONNECTION_GET_PRIVATE(setting)->secondaries.arr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -794,14 +794,14 @@ nm_setting_connection_get_secondary(NMSettingConnection *setting, guint32 idx)
|
|||
|
||||
priv = NM_SETTING_CONNECTION_GET_PRIVATE(setting);
|
||||
|
||||
secondaries_len = nm_g_array_len(priv->secondaries);
|
||||
secondaries_len = nm_g_array_len(priv->secondaries.arr);
|
||||
if (idx >= secondaries_len) {
|
||||
/* access one past the length is OK. */
|
||||
g_return_val_if_fail(idx == secondaries_len, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return nm_strvarray_get_idx(priv->secondaries, idx);
|
||||
return nm_strvarray_get_idx(priv->secondaries.arr, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -841,10 +841,10 @@ nm_setting_connection_add_secondary(NMSettingConnection *setting, const char *se
|
|||
|
||||
priv = NM_SETTING_CONNECTION_GET_PRIVATE(setting);
|
||||
|
||||
if (nm_strvarray_find_first(priv->secondaries, sec_uuid) >= 0)
|
||||
if (nm_strvarray_find_first(priv->secondaries.arr, sec_uuid) >= 0)
|
||||
return FALSE;
|
||||
|
||||
nm_strvarray_add(nm_strvarray_ensure(&priv->secondaries), sec_uuid);
|
||||
nm_strvarray_add(nm_strvarray_ensure(&priv->secondaries.arr), sec_uuid);
|
||||
_notify(setting, PROP_SECONDARIES);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -865,9 +865,9 @@ nm_setting_connection_remove_secondary(NMSettingConnection *setting, guint32 idx
|
|||
|
||||
priv = NM_SETTING_CONNECTION_GET_PRIVATE(setting);
|
||||
|
||||
g_return_if_fail(idx < nm_g_array_len(priv->secondaries));
|
||||
g_return_if_fail(idx < nm_g_array_len(priv->secondaries.arr));
|
||||
|
||||
g_array_remove_index(priv->secondaries, idx);
|
||||
g_array_remove_index(priv->secondaries.arr, idx);
|
||||
_notify(setting, PROP_SECONDARIES);
|
||||
}
|
||||
|
||||
|
|
@ -890,7 +890,7 @@ nm_setting_connection_remove_secondary_by_value(NMSettingConnection *setting, co
|
|||
|
||||
priv = NM_SETTING_CONNECTION_GET_PRIVATE(setting);
|
||||
|
||||
if (nm_strvarray_remove_first(priv->secondaries, sec_uuid)) {
|
||||
if (nm_strvarray_remove_first(priv->secondaries.arr, sec_uuid)) {
|
||||
_notify(setting, PROP_SECONDARIES);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1524,7 +1524,7 @@ after_interface_name:
|
|||
return NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
}
|
||||
|
||||
if (!_nm_setting_connection_verify_secondaries(priv->secondaries, error))
|
||||
if (!_nm_setting_connection_verify_secondaries(priv->secondaries.arr, error))
|
||||
return NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -1637,9 +1637,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
case PROP_TIMESTAMP:
|
||||
g_value_set_uint64(value, nm_setting_connection_get_timestamp(setting));
|
||||
break;
|
||||
case PROP_SECONDARIES:
|
||||
g_value_take_boxed(value, nm_strvarray_get_strv_non_empty_dup(priv->secondaries, NULL));
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
|
|
@ -1675,9 +1672,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
case PROP_TIMESTAMP:
|
||||
priv->timestamp = g_value_get_uint64(value);
|
||||
break;
|
||||
case PROP_SECONDARIES:
|
||||
nm_strvarray_set_strv(&priv->secondaries, g_value_get_boxed(value));
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
|
|
@ -1709,7 +1703,7 @@ finalize(GObject *object)
|
|||
NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(object);
|
||||
|
||||
nm_clear_pointer(&priv->permissions, g_array_unref);
|
||||
nm_clear_pointer(&priv->secondaries, g_array_unref);
|
||||
nm_clear_pointer(&priv->secondaries.arr, g_array_unref);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_connection_parent_class)->finalize(object);
|
||||
}
|
||||
|
|
@ -2230,12 +2224,13 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
|
|||
* together with this connection.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_SECONDARIES] = g_param_spec_boxed(
|
||||
NM_SETTING_CONNECTION_SECONDARIES,
|
||||
"",
|
||||
"",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_strv(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_CONNECTION_SECONDARIES,
|
||||
PROP_SECONDARIES,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingConnectionPrivate,
|
||||
secondaries);
|
||||
|
||||
/**
|
||||
* NMSettingConnection:gateway-ping-timeout:
|
||||
|
|
|
|||
|
|
@ -2684,7 +2684,7 @@ nm_ip_routing_rule_validate(const NMIPRoutingRule *self, GError **error)
|
|||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("invalid priority"));
|
||||
_("missing priority"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingMatch,
|
|||
* Since: 1.14
|
||||
*/
|
||||
struct _NMSettingMatch {
|
||||
NMSetting parent;
|
||||
GArray *interface_name;
|
||||
GArray *kernel_command_line;
|
||||
GArray *driver;
|
||||
GArray *path;
|
||||
NMSetting parent;
|
||||
NMValueStrv interface_name;
|
||||
NMValueStrv kernel_command_line;
|
||||
NMValueStrv driver;
|
||||
NMValueStrv path;
|
||||
};
|
||||
|
||||
struct _NMSettingMatchClass {
|
||||
|
|
@ -60,7 +60,7 @@ nm_setting_match_get_num_interface_names(NMSettingMatch *setting)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), 0);
|
||||
|
||||
return nm_g_array_len(setting->interface_name);
|
||||
return nm_g_array_len(setting->interface_name.arr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -77,10 +77,11 @@ nm_setting_match_get_interface_name(NMSettingMatch *setting, int idx)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), NULL);
|
||||
|
||||
g_return_val_if_fail(setting->interface_name && idx >= 0 && idx < setting->interface_name->len,
|
||||
g_return_val_if_fail(setting->interface_name.arr && idx >= 0
|
||||
&& idx < setting->interface_name.arr->len,
|
||||
NULL);
|
||||
|
||||
return nm_strvarray_get_idx(setting->interface_name, idx);
|
||||
return nm_strvarray_get_idx(setting->interface_name.arr, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -98,7 +99,7 @@ nm_setting_match_add_interface_name(NMSettingMatch *setting, const char *interfa
|
|||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
g_return_if_fail(interface_name);
|
||||
|
||||
nm_strvarray_add(nm_strvarray_ensure(&setting->interface_name), interface_name);
|
||||
nm_strvarray_add(nm_strvarray_ensure(&setting->interface_name.arr), interface_name);
|
||||
_notify(setting, PROP_INTERFACE_NAME);
|
||||
}
|
||||
|
||||
|
|
@ -116,9 +117,10 @@ nm_setting_match_remove_interface_name(NMSettingMatch *setting, int idx)
|
|||
{
|
||||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
|
||||
g_return_if_fail(setting->interface_name && idx >= 0 && idx < setting->interface_name->len);
|
||||
g_return_if_fail(setting->interface_name.arr && idx >= 0
|
||||
&& idx < setting->interface_name.arr->len);
|
||||
|
||||
g_array_remove_index(setting->interface_name, idx);
|
||||
g_array_remove_index(setting->interface_name.arr, idx);
|
||||
_notify(setting, PROP_INTERFACE_NAME);
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +141,7 @@ nm_setting_match_remove_interface_name_by_value(NMSettingMatch *setting, const c
|
|||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), FALSE);
|
||||
g_return_val_if_fail(interface_name, FALSE);
|
||||
|
||||
if (nm_strvarray_remove_first(setting->interface_name, interface_name)) {
|
||||
if (nm_strvarray_remove_first(setting->interface_name.arr, interface_name)) {
|
||||
_notify(setting, PROP_INTERFACE_NAME);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -160,8 +162,8 @@ nm_setting_match_clear_interface_names(NMSettingMatch *setting)
|
|||
{
|
||||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
|
||||
if (nm_g_array_len(setting->interface_name) != 0) {
|
||||
nm_clear_pointer(&setting->interface_name, g_array_unref);
|
||||
if (nm_g_array_len(setting->interface_name.arr) != 0) {
|
||||
nm_clear_pointer(&setting->interface_name.arr, g_array_unref);
|
||||
_notify(setting, PROP_INTERFACE_NAME);
|
||||
}
|
||||
}
|
||||
|
|
@ -185,7 +187,7 @@ nm_setting_match_get_interface_names(NMSettingMatch *setting, guint *length)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), NULL);
|
||||
|
||||
return nm_strvarray_get_strv(&setting->interface_name, length);
|
||||
return nm_strvarray_get_strv(&setting->interface_name.arr, length);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -203,7 +205,7 @@ nm_setting_match_get_num_kernel_command_lines(NMSettingMatch *setting)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), 0);
|
||||
|
||||
return nm_g_array_len(setting->kernel_command_line);
|
||||
return nm_g_array_len(setting->kernel_command_line.arr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -220,10 +222,11 @@ nm_setting_match_get_kernel_command_line(NMSettingMatch *setting, guint idx)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), NULL);
|
||||
|
||||
g_return_val_if_fail(setting->kernel_command_line && idx < setting->kernel_command_line->len,
|
||||
g_return_val_if_fail(setting->kernel_command_line.arr
|
||||
&& idx < setting->kernel_command_line.arr->len,
|
||||
NULL);
|
||||
|
||||
return nm_strvarray_get_idx(setting->kernel_command_line, idx);
|
||||
return nm_strvarray_get_idx(setting->kernel_command_line.arr, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -241,7 +244,7 @@ nm_setting_match_add_kernel_command_line(NMSettingMatch *setting, const char *ke
|
|||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
g_return_if_fail(kernel_command_line);
|
||||
|
||||
nm_strvarray_add(nm_strvarray_ensure(&setting->kernel_command_line), kernel_command_line);
|
||||
nm_strvarray_add(nm_strvarray_ensure(&setting->kernel_command_line.arr), kernel_command_line);
|
||||
_notify(setting, PROP_KERNEL_COMMAND_LINE);
|
||||
}
|
||||
|
||||
|
|
@ -259,9 +262,10 @@ nm_setting_match_remove_kernel_command_line(NMSettingMatch *setting, guint idx)
|
|||
{
|
||||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
|
||||
g_return_if_fail(setting->kernel_command_line && idx < setting->kernel_command_line->len);
|
||||
g_return_if_fail(setting->kernel_command_line.arr
|
||||
&& idx < setting->kernel_command_line.arr->len);
|
||||
|
||||
g_array_remove_index(setting->kernel_command_line, idx);
|
||||
g_array_remove_index(setting->kernel_command_line.arr, idx);
|
||||
_notify(setting, PROP_KERNEL_COMMAND_LINE);
|
||||
}
|
||||
|
||||
|
|
@ -283,7 +287,7 @@ nm_setting_match_remove_kernel_command_line_by_value(NMSettingMatch *setting,
|
|||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), FALSE);
|
||||
g_return_val_if_fail(kernel_command_line, FALSE);
|
||||
|
||||
if (nm_strvarray_remove_first(setting->kernel_command_line, kernel_command_line)) {
|
||||
if (nm_strvarray_remove_first(setting->kernel_command_line.arr, kernel_command_line)) {
|
||||
_notify(setting, PROP_KERNEL_COMMAND_LINE);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -304,8 +308,8 @@ nm_setting_match_clear_kernel_command_lines(NMSettingMatch *setting)
|
|||
{
|
||||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
|
||||
if (nm_g_array_len(setting->kernel_command_line) != 0) {
|
||||
nm_clear_pointer(&setting->kernel_command_line, g_array_unref);
|
||||
if (nm_g_array_len(setting->kernel_command_line.arr) != 0) {
|
||||
nm_clear_pointer(&setting->kernel_command_line.arr, g_array_unref);
|
||||
_notify(setting, PROP_KERNEL_COMMAND_LINE);
|
||||
}
|
||||
}
|
||||
|
|
@ -326,7 +330,7 @@ nm_setting_match_get_kernel_command_lines(NMSettingMatch *setting, guint *length
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), NULL);
|
||||
|
||||
return nm_strvarray_get_strv(&setting->kernel_command_line, length);
|
||||
return nm_strvarray_get_strv(&setting->kernel_command_line.arr, length);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -344,7 +348,7 @@ nm_setting_match_get_num_drivers(NMSettingMatch *setting)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), 0);
|
||||
|
||||
return nm_g_array_len(setting->driver);
|
||||
return nm_g_array_len(setting->driver.arr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -361,9 +365,9 @@ nm_setting_match_get_driver(NMSettingMatch *setting, guint idx)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), NULL);
|
||||
|
||||
g_return_val_if_fail(setting->driver && idx < setting->driver->len, NULL);
|
||||
g_return_val_if_fail(setting->driver.arr && idx < setting->driver.arr->len, NULL);
|
||||
|
||||
return nm_strvarray_get_idx(setting->driver, idx);
|
||||
return nm_strvarray_get_idx(setting->driver.arr, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -381,7 +385,7 @@ nm_setting_match_add_driver(NMSettingMatch *setting, const char *driver)
|
|||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
g_return_if_fail(driver);
|
||||
|
||||
nm_strvarray_add(nm_strvarray_ensure(&setting->driver), driver);
|
||||
nm_strvarray_add(nm_strvarray_ensure(&setting->driver.arr), driver);
|
||||
_notify(setting, PROP_DRIVER);
|
||||
}
|
||||
|
||||
|
|
@ -399,9 +403,9 @@ nm_setting_match_remove_driver(NMSettingMatch *setting, guint idx)
|
|||
{
|
||||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
|
||||
g_return_if_fail(setting->driver && idx < setting->driver->len);
|
||||
g_return_if_fail(setting->driver.arr && idx < setting->driver.arr->len);
|
||||
|
||||
g_array_remove_index(setting->driver, idx);
|
||||
g_array_remove_index(setting->driver.arr, idx);
|
||||
_notify(setting, PROP_DRIVER);
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +426,7 @@ nm_setting_match_remove_driver_by_value(NMSettingMatch *setting, const char *dri
|
|||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), FALSE);
|
||||
g_return_val_if_fail(driver, FALSE);
|
||||
|
||||
if (nm_strvarray_remove_first(setting->driver, driver)) {
|
||||
if (nm_strvarray_remove_first(setting->driver.arr, driver)) {
|
||||
_notify(setting, PROP_DRIVER);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -443,8 +447,8 @@ nm_setting_match_clear_drivers(NMSettingMatch *setting)
|
|||
{
|
||||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
|
||||
if (nm_g_array_len(setting->driver) != 0) {
|
||||
nm_clear_pointer(&setting->driver, g_array_unref);
|
||||
if (nm_g_array_len(setting->driver.arr) != 0) {
|
||||
nm_clear_pointer(&setting->driver.arr, g_array_unref);
|
||||
_notify(setting, PROP_DRIVER);
|
||||
}
|
||||
}
|
||||
|
|
@ -465,7 +469,7 @@ nm_setting_match_get_drivers(NMSettingMatch *setting, guint *length)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), NULL);
|
||||
|
||||
return nm_strvarray_get_strv(&setting->driver, length);
|
||||
return nm_strvarray_get_strv(&setting->driver.arr, length);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -483,7 +487,7 @@ nm_setting_match_get_num_paths(NMSettingMatch *setting)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), 0);
|
||||
|
||||
return nm_g_array_len(setting->path);
|
||||
return nm_g_array_len(setting->path.arr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -500,9 +504,9 @@ nm_setting_match_get_path(NMSettingMatch *setting, guint idx)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), NULL);
|
||||
|
||||
g_return_val_if_fail(setting->path && idx < setting->path->len, NULL);
|
||||
g_return_val_if_fail(setting->path.arr && idx < setting->path.arr->len, NULL);
|
||||
|
||||
return nm_strvarray_get_idx(setting->path, idx);
|
||||
return nm_strvarray_get_idx(setting->path.arr, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -520,7 +524,7 @@ nm_setting_match_add_path(NMSettingMatch *setting, const char *path)
|
|||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
g_return_if_fail(path);
|
||||
|
||||
nm_strvarray_add(nm_strvarray_ensure(&setting->path), path);
|
||||
nm_strvarray_add(nm_strvarray_ensure(&setting->path.arr), path);
|
||||
_notify(setting, PROP_PATH);
|
||||
}
|
||||
|
||||
|
|
@ -538,9 +542,9 @@ nm_setting_match_remove_path(NMSettingMatch *setting, guint idx)
|
|||
{
|
||||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
|
||||
g_return_if_fail(setting->path && idx < setting->path->len);
|
||||
g_return_if_fail(setting->path.arr && idx < setting->path.arr->len);
|
||||
|
||||
g_array_remove_index(setting->path, idx);
|
||||
g_array_remove_index(setting->path.arr, idx);
|
||||
_notify(setting, PROP_PATH);
|
||||
}
|
||||
|
||||
|
|
@ -561,7 +565,7 @@ nm_setting_match_remove_path_by_value(NMSettingMatch *setting, const char *path)
|
|||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), FALSE);
|
||||
g_return_val_if_fail(path, FALSE);
|
||||
|
||||
if (nm_strvarray_remove_first(setting->path, path)) {
|
||||
if (nm_strvarray_remove_first(setting->path.arr, path)) {
|
||||
_notify(setting, PROP_PATH);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -582,8 +586,8 @@ nm_setting_match_clear_paths(NMSettingMatch *setting)
|
|||
{
|
||||
g_return_if_fail(NM_IS_SETTING_MATCH(setting));
|
||||
|
||||
if (nm_g_array_len(setting->path) != 0) {
|
||||
nm_clear_pointer(&setting->path, g_array_unref);
|
||||
if (nm_g_array_len(setting->path.arr) != 0) {
|
||||
nm_clear_pointer(&setting->path.arr, g_array_unref);
|
||||
_notify(setting, PROP_PATH);
|
||||
}
|
||||
}
|
||||
|
|
@ -604,58 +608,7 @@ nm_setting_match_get_paths(NMSettingMatch *setting, guint *length)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), NULL);
|
||||
|
||||
return nm_strvarray_get_strv(&setting->path, length);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingMatch *self = NM_SETTING_MATCH(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_INTERFACE_NAME:
|
||||
g_value_take_boxed(value, nm_strvarray_get_strv_non_empty_dup(self->interface_name, NULL));
|
||||
break;
|
||||
case PROP_KERNEL_COMMAND_LINE:
|
||||
g_value_take_boxed(value,
|
||||
nm_strvarray_get_strv_non_empty_dup(self->kernel_command_line, NULL));
|
||||
break;
|
||||
case PROP_DRIVER:
|
||||
g_value_take_boxed(value, nm_strvarray_get_strv_non_empty_dup(self->driver, NULL));
|
||||
break;
|
||||
case PROP_PATH:
|
||||
g_value_take_boxed(value, nm_strvarray_get_strv_non_empty_dup(self->path, NULL));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingMatch *self = NM_SETTING_MATCH(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_INTERFACE_NAME:
|
||||
nm_strvarray_set_strv(&self->interface_name, g_value_get_boxed(value));
|
||||
break;
|
||||
case PROP_KERNEL_COMMAND_LINE:
|
||||
nm_strvarray_set_strv(&self->kernel_command_line, g_value_get_boxed(value));
|
||||
break;
|
||||
case PROP_DRIVER:
|
||||
nm_strvarray_set_strv(&self->driver, g_value_get_boxed(value));
|
||||
break;
|
||||
case PROP_PATH:
|
||||
nm_strvarray_set_strv(&self->path, g_value_get_boxed(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
return nm_strvarray_get_strv(&setting->path.arr, length);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -698,9 +651,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
NMSettingMatch *self = NM_SETTING_MATCH(setting);
|
||||
guint i;
|
||||
|
||||
if (self->interface_name) {
|
||||
for (i = 0; i < self->interface_name->len; i++) {
|
||||
if (nm_str_is_empty(nm_strvarray_get_idx(self->interface_name, i))) {
|
||||
if (self->interface_name.arr) {
|
||||
for (i = 0; i < self->interface_name.arr->len; i++) {
|
||||
if (nm_str_is_empty(nm_strvarray_get_idx(self->interface_name.arr, i))) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -714,9 +667,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (self->kernel_command_line) {
|
||||
for (i = 0; i < self->kernel_command_line->len; i++) {
|
||||
if (nm_str_is_empty(nm_strvarray_get_idx(self->kernel_command_line, i))) {
|
||||
if (self->kernel_command_line.arr) {
|
||||
for (i = 0; i < self->kernel_command_line.arr->len; i++) {
|
||||
if (nm_str_is_empty(nm_strvarray_get_idx(self->kernel_command_line.arr, i))) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -730,9 +683,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (self->driver) {
|
||||
for (i = 0; i < self->driver->len; i++) {
|
||||
if (nm_str_is_empty(nm_strvarray_get_idx(self->driver, i))) {
|
||||
if (self->driver.arr) {
|
||||
for (i = 0; i < self->driver.arr->len; i++) {
|
||||
if (nm_str_is_empty(nm_strvarray_get_idx(self->driver.arr, i))) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -746,9 +699,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (self->path) {
|
||||
for (i = 0; i < self->path->len; i++) {
|
||||
if (nm_str_is_empty(nm_strvarray_get_idx(self->path, i))) {
|
||||
if (self->path.arr) {
|
||||
for (i = 0; i < self->path.arr->len; i++) {
|
||||
if (nm_str_is_empty(nm_strvarray_get_idx(self->path.arr, i))) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -770,10 +723,10 @@ finalize(GObject *object)
|
|||
{
|
||||
NMSettingMatch *self = NM_SETTING_MATCH(object);
|
||||
|
||||
nm_clear_pointer(&self->interface_name, g_array_unref);
|
||||
nm_clear_pointer(&self->kernel_command_line, g_array_unref);
|
||||
nm_clear_pointer(&self->driver, g_array_unref);
|
||||
nm_clear_pointer(&self->path, g_array_unref);
|
||||
nm_clear_pointer(&self->interface_name.arr, g_array_unref);
|
||||
nm_clear_pointer(&self->kernel_command_line.arr, g_array_unref);
|
||||
nm_clear_pointer(&self->driver.arr, g_array_unref);
|
||||
nm_clear_pointer(&self->path.arr, g_array_unref);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_match_parent_class)->finalize(object);
|
||||
}
|
||||
|
|
@ -781,11 +734,12 @@ finalize(GObject *object)
|
|||
static void
|
||||
nm_setting_match_class_init(NMSettingMatchClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
NMSettingClass *setting_class = NM_SETTING_CLASS(klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
NMSettingClass *setting_class = NM_SETTING_CLASS(klass);
|
||||
GArray *properties_override = _nm_sett_info_property_override_create_array();
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
|
@ -810,12 +764,13 @@ nm_setting_match_class_init(NMSettingMatchClass *klass)
|
|||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
obj_properties[PROP_INTERFACE_NAME] = g_param_spec_boxed(
|
||||
NM_SETTING_MATCH_INTERFACE_NAME,
|
||||
"",
|
||||
"",
|
||||
G_TYPE_STRV,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_strv(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MATCH_INTERFACE_NAME,
|
||||
PROP_INTERFACE_NAME,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingMatch,
|
||||
interface_name);
|
||||
|
||||
/**
|
||||
* NMSettingMatch:kernel-command-line
|
||||
|
|
@ -834,12 +789,13 @@ nm_setting_match_class_init(NMSettingMatchClass *klass)
|
|||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
obj_properties[PROP_KERNEL_COMMAND_LINE] = g_param_spec_boxed(
|
||||
NM_SETTING_MATCH_KERNEL_COMMAND_LINE,
|
||||
"",
|
||||
"",
|
||||
G_TYPE_STRV,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_strv(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MATCH_KERNEL_COMMAND_LINE,
|
||||
PROP_KERNEL_COMMAND_LINE,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingMatch,
|
||||
kernel_command_line);
|
||||
|
||||
/**
|
||||
* NMSettingMatch:driver
|
||||
|
|
@ -852,12 +808,13 @@ nm_setting_match_class_init(NMSettingMatchClass *klass)
|
|||
*
|
||||
* Since: 1.26
|
||||
**/
|
||||
obj_properties[PROP_DRIVER] = g_param_spec_boxed(
|
||||
NM_SETTING_MATCH_DRIVER,
|
||||
"",
|
||||
"",
|
||||
G_TYPE_STRV,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_strv(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MATCH_DRIVER,
|
||||
PROP_DRIVER,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingMatch,
|
||||
driver);
|
||||
|
||||
/**
|
||||
* NMSettingMatch:path
|
||||
|
|
@ -892,14 +849,19 @@ nm_setting_match_class_init(NMSettingMatchClass *klass)
|
|||
* example: MATCH_PATH="pci-0000:01:00.0 pci-0000:0c:00.0"
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_PATH] = g_param_spec_boxed(NM_SETTING_MATCH_PATH,
|
||||
"",
|
||||
"",
|
||||
G_TYPE_STRV,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_strv(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MATCH_PATH,
|
||||
PROP_PATH,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingMatch,
|
||||
path);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_MATCH, NULL, NULL, 0);
|
||||
_nm_setting_class_commit(setting_class,
|
||||
NM_META_SETTING_TYPE_MATCH,
|
||||
NULL,
|
||||
properties_override,
|
||||
0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,6 +232,14 @@ gboolean _nm_setting_clear_secrets(NMSetting *setting,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* This holds a property of type NM_VALUE_TYPE_STRV. You probably want
|
||||
* to use nm_strvarray_*() API with this. */
|
||||
typedef struct {
|
||||
GArray *arr;
|
||||
} NMValueStrv;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_SETTING_PARAM_NONE 0
|
||||
|
||||
/* The property of the #NMSetting should be considered during comparisons that
|
||||
|
|
@ -277,6 +285,7 @@ extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int64;
|
|||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint64;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_string;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_bytes;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_strv;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_enum;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_flags;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_mac_address;
|
||||
|
|
@ -774,6 +783,42 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _nm_setting_property_define_direct_strv(properties_override, \
|
||||
obj_properties, \
|
||||
prop_name, \
|
||||
prop_id, \
|
||||
param_flags, \
|
||||
private_struct_type, \
|
||||
private_struct_field, \
|
||||
... /* extra NMSettInfoProperty fields */) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
GParamSpec *_param_spec; \
|
||||
\
|
||||
G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), ~(NM_SETTING_PARAM_FUZZY_IGNORE))); \
|
||||
\
|
||||
_param_spec = \
|
||||
g_param_spec_boxed("" prop_name "", \
|
||||
"", \
|
||||
"", \
|
||||
G_TYPE_STRV, \
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \
|
||||
\
|
||||
(obj_properties)[(prop_id)] = _param_spec; \
|
||||
\
|
||||
_nm_properties_override_gobj((properties_override), \
|
||||
_param_spec, \
|
||||
&nm_sett_info_propert_type_direct_strv, \
|
||||
.direct_offset = \
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(NMValueStrv, \
|
||||
private_struct_type, \
|
||||
private_struct_field), \
|
||||
__VA_ARGS__); \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _nm_setting_property_define_direct_enum(properties_override, \
|
||||
obj_properties, \
|
||||
prop_name, \
|
||||
|
|
|
|||
|
|
@ -774,6 +774,13 @@ _nm_setting_property_get_property_direct(GObject *object,
|
|||
g_value_set_boxed(value, *p_val);
|
||||
return;
|
||||
}
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
{
|
||||
const NMValueStrv *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_take_boxed(value, nm_strvarray_get_strv_non_empty_dup(p_val->arr, NULL));
|
||||
return;
|
||||
}
|
||||
default:
|
||||
goto out_fail;
|
||||
}
|
||||
|
|
@ -909,6 +916,18 @@ _nm_setting_property_set_property_direct(GObject *object,
|
|||
*p_val = v ? g_bytes_ref(v) : NULL;
|
||||
goto out_notify;
|
||||
}
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
{
|
||||
NMValueStrv *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
const char *const *v;
|
||||
|
||||
v = g_value_get_boxed(value);
|
||||
if (nm_strvarray_equal_strv(p_val->arr, v, -1))
|
||||
return;
|
||||
|
||||
nm_strvarray_set_strv(&p_val->arr, v);
|
||||
goto out_notify;
|
||||
}
|
||||
default:
|
||||
goto out_fail;
|
||||
}
|
||||
|
|
@ -1026,6 +1045,11 @@ _init_direct(NMSetting *setting)
|
|||
nm_assert(!(*((const GBytes *const *)
|
||||
_nm_setting_get_private_field(setting, sett_info, property_info))));
|
||||
break;
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
nm_assert(!((const NMValueStrv *)
|
||||
_nm_setting_get_private_field(setting, sett_info, property_info))
|
||||
->arr);
|
||||
break;
|
||||
default:
|
||||
nm_assert_not_reached();
|
||||
break;
|
||||
|
|
@ -1081,6 +1105,13 @@ _finalize_direct(NMSetting *setting)
|
|||
nm_clear_pointer(p_val, g_bytes_unref);
|
||||
break;
|
||||
}
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
{
|
||||
NMValueStrv *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
nm_clear_pointer(&p_val->arr, g_array_unref);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
nm_assert_not_reached();
|
||||
break;
|
||||
|
|
@ -1199,6 +1230,20 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_
|
|||
return NULL;
|
||||
return nm_g_bytes_to_variant_ay(val);
|
||||
}
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
{
|
||||
const NMValueStrv *val;
|
||||
|
||||
/* Strv properties have always NULL as default. Setting "including_default" has no defined meaning
|
||||
* (but it could have). */
|
||||
nm_assert(!property_info->to_dbus_including_default);
|
||||
|
||||
val =
|
||||
(const NMValueStrv *) _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (!val->arr)
|
||||
return NULL;
|
||||
return g_variant_new_strv((const char *const *) val->arr->data, val->arr->len);
|
||||
}
|
||||
default:
|
||||
return nm_assert_unreachable_val(NULL);
|
||||
}
|
||||
|
|
@ -1545,6 +1590,8 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
gs_unref_bytes GBytes *v = NULL;
|
||||
GBytes **p_val;
|
||||
|
||||
nm_assert(!property_info->property_type->from_dbus_direct_allow_transform);
|
||||
|
||||
if (!g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING))
|
||||
goto out_error_wrong_dbus_type;
|
||||
|
||||
|
|
@ -1557,6 +1604,28 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
NM_SWAP(p_val, &v);
|
||||
goto out_notify;
|
||||
}
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
{
|
||||
NMValueStrv *p_val;
|
||||
gs_free const char **ss = NULL;
|
||||
gsize ss_len;
|
||||
|
||||
nm_assert(!property_info->property_type->from_dbus_direct_allow_transform);
|
||||
|
||||
if (!g_variant_is_of_type(value, G_VARIANT_TYPE_STRING_ARRAY))
|
||||
goto out_error_wrong_dbus_type;
|
||||
|
||||
ss = g_variant_get_strv(value, &ss_len);
|
||||
nm_assert(ss_len <= G_MAXUINT);
|
||||
|
||||
p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
if (nm_strvarray_equal_strv(p_val->arr, ss, ss_len))
|
||||
goto out_unchanged;
|
||||
|
||||
nm_strvarray_set_strv(&p_val->arr, ss);
|
||||
goto out_notify;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -2465,6 +2534,9 @@ _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_
|
|||
return nm_streq0(*((const char *const *) p_a), *((const char *const *) p_b));
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
return nm_g_bytes_equal0(*((const GBytes *const *) p_a), *((const GBytes *const *) p_b));
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
return nm_strvarray_equal(((const NMValueStrv *) p_a)->arr,
|
||||
((const NMValueStrv *) p_b)->arr);
|
||||
default:
|
||||
return nm_assert_unreachable_val(TRUE);
|
||||
}
|
||||
|
|
@ -3529,8 +3601,15 @@ const NMSettInfoPropertType nm_sett_info_propert_type_direct_bytes =
|
|||
.compare_fcn = _nm_setting_property_compare_fcn_direct,
|
||||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct,
|
||||
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct,
|
||||
.from_dbus_is_full = TRUE,
|
||||
.from_dbus_direct_allow_transform = TRUE);
|
||||
.from_dbus_is_full = TRUE);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_direct_strv =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING_ARRAY,
|
||||
.direct_type = NM_VALUE_TYPE_STRV,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_direct,
|
||||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct,
|
||||
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct,
|
||||
.from_dbus_is_full = TRUE);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_direct_enum =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_INT32,
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ typedef enum {
|
|||
NM_TEST_GENERAL_META_FLAGS_0x4 = (1 << 4),
|
||||
} NMTestGeneralMetaFlags;
|
||||
|
||||
typedef enum { /*< flags >*/
|
||||
NM_TEST_GENERAL_COLOR_FLAGS_WHITE = 1, /*< skip >*/
|
||||
NM_TEST_GENERAL_COLOR_FLAGS_BLUE = 2,
|
||||
NM_TEST_GENERAL_COLOR_FLAGS_RED = 4,
|
||||
NM_TEST_GENERAL_COLOR_FLAGS_GREEN = 8,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_TEST_GENERAL_COLOR_FLAGS_WHITE = 1, /*< skip >*/
|
||||
NM_TEST_GENERAL_COLOR_FLAGS_BLUE = 2,
|
||||
NM_TEST_GENERAL_COLOR_FLAGS_RED = 4,
|
||||
NM_TEST_GENERAL_COLOR_FLAGS_GREEN = 8,
|
||||
} NMTestGeneralColorFlags;
|
||||
|
||||
#endif /* _NM_TEST_GENERAL_ENUMS_H_ */
|
||||
|
|
|
|||
|
|
@ -5060,7 +5060,7 @@ test_setting_connection_changed_signal(void)
|
|||
ASSERT_CHANGED(nm_setting_connection_add_secondary(s_con, uuid));
|
||||
ASSERT_CHANGED(nm_setting_connection_remove_secondary(s_con, 0));
|
||||
|
||||
NMTST_EXPECT_LIBNM_CRITICAL(NMTST_G_RETURN_MSG(idx < nm_g_array_len(priv->secondaries)));
|
||||
NMTST_EXPECT_LIBNM_CRITICAL(NMTST_G_RETURN_MSG(idx < nm_g_array_len(priv->secondaries.arr)));
|
||||
ASSERT_UNCHANGED(nm_setting_connection_remove_secondary(s_con, 1));
|
||||
g_test_assert_expected_messages();
|
||||
|
||||
|
|
|
|||
|
|
@ -4565,6 +4565,12 @@ test_setting_metadata(void)
|
|||
== _nm_setting_property_to_dbus_fcn_direct);
|
||||
g_assert(sip->param_spec);
|
||||
g_assert(sip->param_spec->value_type == G_TYPE_BYTES);
|
||||
} else if (sip->property_type->direct_type == NM_VALUE_TYPE_STRV) {
|
||||
g_assert(g_variant_type_equal(sip->property_type->dbus_type, "as"));
|
||||
g_assert(sip->property_type->to_dbus_fcn
|
||||
== _nm_setting_property_to_dbus_fcn_direct);
|
||||
g_assert(sip->param_spec);
|
||||
g_assert(sip->param_spec->value_type == G_TYPE_STRV);
|
||||
} else
|
||||
g_assert_not_reached();
|
||||
|
||||
|
|
@ -4653,7 +4659,12 @@ check_done:;
|
|||
}
|
||||
if (sip->property_type->from_dbus_fcn == _nm_setting_property_from_dbus_fcn_direct) {
|
||||
/* for the moment, all direct properties allow transformation. */
|
||||
g_assert(sip->property_type->from_dbus_direct_allow_transform);
|
||||
if (NM_IN_SET(sip->property_type->direct_type,
|
||||
NM_VALUE_TYPE_BYTES,
|
||||
NM_VALUE_TYPE_STRV))
|
||||
g_assert(!sip->property_type->from_dbus_direct_allow_transform);
|
||||
else
|
||||
g_assert(sip->property_type->from_dbus_direct_allow_transform);
|
||||
}
|
||||
|
||||
if (sip->property_type->from_dbus_fcn == _nm_setting_property_from_dbus_fcn_gprop)
|
||||
|
|
@ -4763,10 +4774,12 @@ check_done:;
|
|||
g_assert(NM_IS_SETTING_VPN(setting));
|
||||
g_assert_cmpstr(sip->name, ==, NM_SETTING_VPN_SECRETS);
|
||||
} else {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("secret %s.%s is of unexpected property type %s",
|
||||
nm_setting_get_name(setting),
|
||||
sip->name,
|
||||
g_type_name(sip->param_spec->value_type));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4889,12 +4902,14 @@ check_done:;
|
|||
|
||||
/* the property-types with same content should all be shared. Here we have two that
|
||||
* are the same content, but different instances. Bug. */
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("The identical property type for D-Bus type \"%s\" is used by: %s and %s. "
|
||||
"If a NMSettInfoPropertType is identical, it should be shared by creating "
|
||||
"a common instance of the property type",
|
||||
(const char *) pt->dbus_type,
|
||||
_PROP_IDX_OWNER(h_property_types, pt),
|
||||
_PROP_IDX_OWNER(h_property_types, pt_2));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,14 +189,14 @@ NM_TERNARY_TO_OPTION_BOOL(NMTernary v)
|
|||
|
||||
NMSetting **_nm_connection_get_settings_arr(NMConnection *connection);
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
NM_SETTING_PARSE_FLAGS_NONE = 0,
|
||||
NM_SETTING_PARSE_FLAGS_STRICT = 1LL << 0,
|
||||
NM_SETTING_PARSE_FLAGS_BEST_EFFORT = 1LL << 1,
|
||||
NM_SETTING_PARSE_FLAGS_NORMALIZE = 1LL << 2,
|
||||
typedef enum /*< skip >*/ {
|
||||
NM_SETTING_PARSE_FLAGS_NONE = 0,
|
||||
NM_SETTING_PARSE_FLAGS_STRICT = 1LL << 0,
|
||||
NM_SETTING_PARSE_FLAGS_BEST_EFFORT = 1LL << 1,
|
||||
NM_SETTING_PARSE_FLAGS_NORMALIZE = 1LL << 2,
|
||||
|
||||
_NM_SETTING_PARSE_FLAGS_LAST,
|
||||
NM_SETTING_PARSE_FLAGS_ALL = ((_NM_SETTING_PARSE_FLAGS_LAST - 1) << 1) - 1,
|
||||
_NM_SETTING_PARSE_FLAGS_LAST,
|
||||
NM_SETTING_PARSE_FLAGS_ALL = ((_NM_SETTING_PARSE_FLAGS_LAST - 1) << 1) - 1,
|
||||
} NMSettingParseFlags;
|
||||
|
||||
gboolean _nm_connection_replace_settings(NMConnection *connection,
|
||||
|
|
|
|||
|
|
@ -38,15 +38,15 @@
|
|||
*
|
||||
* 10: NMSettingUser
|
||||
*/
|
||||
typedef enum { /*< skip >*/
|
||||
NM_SETTING_PRIORITY_INVALID = 0,
|
||||
NM_SETTING_PRIORITY_CONNECTION = 1,
|
||||
NM_SETTING_PRIORITY_HW_BASE = 2,
|
||||
NM_SETTING_PRIORITY_HW_NON_BASE = 3,
|
||||
NM_SETTING_PRIORITY_HW_AUX = 4,
|
||||
NM_SETTING_PRIORITY_AUX = 5,
|
||||
NM_SETTING_PRIORITY_IP = 6,
|
||||
NM_SETTING_PRIORITY_USER = 10,
|
||||
typedef enum /*< skip >*/ {
|
||||
NM_SETTING_PRIORITY_INVALID = 0,
|
||||
NM_SETTING_PRIORITY_CONNECTION = 1,
|
||||
NM_SETTING_PRIORITY_HW_BASE = 2,
|
||||
NM_SETTING_PRIORITY_HW_NON_BASE = 3,
|
||||
NM_SETTING_PRIORITY_HW_AUX = 4,
|
||||
NM_SETTING_PRIORITY_AUX = 5,
|
||||
NM_SETTING_PRIORITY_IP = 6,
|
||||
NM_SETTING_PRIORITY_USER = 10,
|
||||
} NMSettingPriority;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -122,15 +122,15 @@ NMSetting *nm_connection_get_setting_by_name(NMConnection *connection, const cha
|
|||
* These flags determine which properties are serialized when calling
|
||||
* nm_connection_to_dbus().
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_CONNECTION_SERIALIZE_ALL = 0x00000000,
|
||||
NM_CONNECTION_SERIALIZE_WITH_NON_SECRET = 0x00000001,
|
||||
NM_CONNECTION_SERIALIZE_NO_SECRETS = 0x00000001,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS = 0x00000002,
|
||||
NM_CONNECTION_SERIALIZE_ONLY_SECRETS = 0x00000002,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED = 0x00000004,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS_SYSTEM_OWNED = 0x00000008,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS_NOT_SAVED = 0x00000010,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_CONNECTION_SERIALIZE_ALL = 0x00000000,
|
||||
NM_CONNECTION_SERIALIZE_WITH_NON_SECRET = 0x00000001,
|
||||
NM_CONNECTION_SERIALIZE_NO_SECRETS = 0x00000001,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS = 0x00000002,
|
||||
NM_CONNECTION_SERIALIZE_ONLY_SECRETS = 0x00000002,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED = 0x00000004,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS_SYSTEM_OWNED = 0x00000008,
|
||||
NM_CONNECTION_SERIALIZE_WITH_SECRETS_NOT_SAVED = 0x00000010,
|
||||
} NMConnectionSerializationFlags;
|
||||
|
||||
GVariant *nm_connection_to_dbus(NMConnection *connection, NMConnectionSerializationFlags flags);
|
||||
|
|
|
|||
|
|
@ -265,12 +265,12 @@ typedef enum {
|
|||
*
|
||||
* General device capability flags.
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_DEVICE_CAP_NONE = 0x00000000,
|
||||
NM_DEVICE_CAP_NM_SUPPORTED = 0x00000001,
|
||||
NM_DEVICE_CAP_CARRIER_DETECT = 0x00000002,
|
||||
NM_DEVICE_CAP_IS_SOFTWARE = 0x00000004,
|
||||
NM_DEVICE_CAP_SRIOV = 0x00000008,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_DEVICE_CAP_NONE = 0x00000000,
|
||||
NM_DEVICE_CAP_NM_SUPPORTED = 0x00000001,
|
||||
NM_DEVICE_CAP_CARRIER_DETECT = 0x00000002,
|
||||
NM_DEVICE_CAP_IS_SOFTWARE = 0x00000004,
|
||||
NM_DEVICE_CAP_SRIOV = 0x00000008,
|
||||
} NMDeviceCapabilities;
|
||||
|
||||
/**
|
||||
|
|
@ -292,21 +292,21 @@ typedef enum { /*< flags >*/
|
|||
*
|
||||
* 802.11 specific device encryption and authentication capabilities.
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_WIFI_DEVICE_CAP_NONE = 0x00000000,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_WEP40 = 0x00000001,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_WEP104 = 0x00000002,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_TKIP = 0x00000004,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_CCMP = 0x00000008,
|
||||
NM_WIFI_DEVICE_CAP_WPA = 0x00000010,
|
||||
NM_WIFI_DEVICE_CAP_RSN = 0x00000020,
|
||||
NM_WIFI_DEVICE_CAP_AP = 0x00000040,
|
||||
NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080,
|
||||
NM_WIFI_DEVICE_CAP_FREQ_VALID = 0x00000100,
|
||||
NM_WIFI_DEVICE_CAP_FREQ_2GHZ = 0x00000200,
|
||||
NM_WIFI_DEVICE_CAP_FREQ_5GHZ = 0x00000400,
|
||||
NM_WIFI_DEVICE_CAP_MESH = 0x00001000,
|
||||
NM_WIFI_DEVICE_CAP_IBSS_RSN = 0x00002000,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_WIFI_DEVICE_CAP_NONE = 0x00000000,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_WEP40 = 0x00000001,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_WEP104 = 0x00000002,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_TKIP = 0x00000004,
|
||||
NM_WIFI_DEVICE_CAP_CIPHER_CCMP = 0x00000008,
|
||||
NM_WIFI_DEVICE_CAP_WPA = 0x00000010,
|
||||
NM_WIFI_DEVICE_CAP_RSN = 0x00000020,
|
||||
NM_WIFI_DEVICE_CAP_AP = 0x00000040,
|
||||
NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080,
|
||||
NM_WIFI_DEVICE_CAP_FREQ_VALID = 0x00000100,
|
||||
NM_WIFI_DEVICE_CAP_FREQ_2GHZ = 0x00000200,
|
||||
NM_WIFI_DEVICE_CAP_FREQ_5GHZ = 0x00000400,
|
||||
NM_WIFI_DEVICE_CAP_MESH = 0x00001000,
|
||||
NM_WIFI_DEVICE_CAP_IBSS_RSN = 0x00002000,
|
||||
} NMDeviceWifiCapabilities;
|
||||
|
||||
/**
|
||||
|
|
@ -320,12 +320,12 @@ typedef enum { /*< flags >*/
|
|||
*
|
||||
* 802.11 access point flags.
|
||||
**/
|
||||
typedef enum { /*< underscore_name=nm_802_11_ap_flags, flags >*/
|
||||
NM_802_11_AP_FLAGS_NONE = 0x00000000,
|
||||
NM_802_11_AP_FLAGS_PRIVACY = 0x00000001,
|
||||
NM_802_11_AP_FLAGS_WPS = 0x00000002,
|
||||
NM_802_11_AP_FLAGS_WPS_PBC = 0x00000004,
|
||||
NM_802_11_AP_FLAGS_WPS_PIN = 0x00000008,
|
||||
typedef enum /*< underscore_name=nm_802_11_ap_flags, flags >*/ {
|
||||
NM_802_11_AP_FLAGS_NONE = 0x00000000,
|
||||
NM_802_11_AP_FLAGS_PRIVACY = 0x00000001,
|
||||
NM_802_11_AP_FLAGS_WPS = 0x00000002,
|
||||
NM_802_11_AP_FLAGS_WPS_PBC = 0x00000004,
|
||||
NM_802_11_AP_FLAGS_WPS_PIN = 0x00000008,
|
||||
} NM80211ApFlags;
|
||||
|
||||
/**
|
||||
|
|
@ -361,22 +361,22 @@ typedef enum { /*< underscore_name=nm_802_11_ap_flags, flags >*/
|
|||
* the current security requirements of an access point as determined from the
|
||||
* access point's beacon.
|
||||
**/
|
||||
typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/
|
||||
NM_802_11_AP_SEC_NONE = 0x00000000,
|
||||
NM_802_11_AP_SEC_PAIR_WEP40 = 0x00000001,
|
||||
NM_802_11_AP_SEC_PAIR_WEP104 = 0x00000002,
|
||||
NM_802_11_AP_SEC_PAIR_TKIP = 0x00000004,
|
||||
NM_802_11_AP_SEC_PAIR_CCMP = 0x00000008,
|
||||
NM_802_11_AP_SEC_GROUP_WEP40 = 0x00000010,
|
||||
NM_802_11_AP_SEC_GROUP_WEP104 = 0x00000020,
|
||||
NM_802_11_AP_SEC_GROUP_TKIP = 0x00000040,
|
||||
NM_802_11_AP_SEC_GROUP_CCMP = 0x00000080,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_PSK = 0x00000100,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_SAE = 0x00000400,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_OWE = 0x00000800,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_OWE_TM = 0x00001000,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192 = 0x00002000,
|
||||
typedef enum /*< underscore_name=nm_802_11_ap_security_flags, flags >*/ {
|
||||
NM_802_11_AP_SEC_NONE = 0x00000000,
|
||||
NM_802_11_AP_SEC_PAIR_WEP40 = 0x00000001,
|
||||
NM_802_11_AP_SEC_PAIR_WEP104 = 0x00000002,
|
||||
NM_802_11_AP_SEC_PAIR_TKIP = 0x00000004,
|
||||
NM_802_11_AP_SEC_PAIR_CCMP = 0x00000008,
|
||||
NM_802_11_AP_SEC_GROUP_WEP40 = 0x00000010,
|
||||
NM_802_11_AP_SEC_GROUP_WEP104 = 0x00000020,
|
||||
NM_802_11_AP_SEC_GROUP_TKIP = 0x00000040,
|
||||
NM_802_11_AP_SEC_GROUP_CCMP = 0x00000080,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_PSK = 0x00000100,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_SAE = 0x00000400,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_OWE = 0x00000800,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_OWE_TM = 0x00001000,
|
||||
NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192 = 0x00002000,
|
||||
} NM80211ApSecurityFlags;
|
||||
|
||||
/**
|
||||
|
|
@ -412,10 +412,10 @@ typedef enum { /*< underscore_name=nm_802_11_mode >*/
|
|||
* #NMBluetoothCapabilities values indicate the usable capabilities of a
|
||||
* Bluetooth device.
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_BT_CAPABILITY_NONE = 0x00000000,
|
||||
NM_BT_CAPABILITY_DUN = 0x00000001,
|
||||
NM_BT_CAPABILITY_NAP = 0x00000002,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_BT_CAPABILITY_NONE = 0x00000000,
|
||||
NM_BT_CAPABILITY_DUN = 0x00000001,
|
||||
NM_BT_CAPABILITY_NAP = 0x00000002,
|
||||
} NMBluetoothCapabilities;
|
||||
|
||||
/**
|
||||
|
|
@ -435,13 +435,13 @@ typedef enum { /*< flags >*/
|
|||
* specific access technologies the device supports use the ModemManager D-Bus
|
||||
* API.
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_DEVICE_MODEM_CAPABILITY_NONE = 0x00000000,
|
||||
NM_DEVICE_MODEM_CAPABILITY_POTS = 0x00000001,
|
||||
NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO = 0x00000002,
|
||||
NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS = 0x00000004,
|
||||
NM_DEVICE_MODEM_CAPABILITY_LTE = 0x00000008,
|
||||
NM_DEVICE_MODEM_CAPABILITY_5GNR = 0x00000040,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_DEVICE_MODEM_CAPABILITY_NONE = 0x00000000,
|
||||
NM_DEVICE_MODEM_CAPABILITY_POTS = 0x00000001,
|
||||
NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO = 0x00000002,
|
||||
NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS = 0x00000004,
|
||||
NM_DEVICE_MODEM_CAPABILITY_LTE = 0x00000008,
|
||||
NM_DEVICE_MODEM_CAPABILITY_5GNR = 0x00000040,
|
||||
} NMDeviceModemCapabilities;
|
||||
/* Note: the numeric values of NMDeviceModemCapabilities must be identical to the values
|
||||
* in MMModemCapability. See the G_STATIC_ASSERT() in nm-modem-broadband.c's get_capabilities(). */
|
||||
|
|
@ -834,16 +834,16 @@ typedef enum {
|
|||
*
|
||||
* #NMSecretAgentGetSecretsFlags values modify the behavior of a GetSecrets request.
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED = 0x4,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_WPS_PBC_ACTIVE = 0x8,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED = 0x4,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_WPS_PBC_ACTIVE = 0x8,
|
||||
|
||||
/* Internal to NM; not part of the D-Bus API */
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS = 0x40000000,
|
||||
/* Internal to NM; not part of the D-Bus API */
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000,
|
||||
NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS = 0x40000000,
|
||||
} NMSecretAgentGetSecretsFlags;
|
||||
|
||||
/**
|
||||
|
|
@ -964,12 +964,12 @@ typedef enum {
|
|||
*
|
||||
* Since: 1.4 (gi flags generated since 1.12)
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_CHECKPOINT_CREATE_FLAG_NONE = 0,
|
||||
NM_CHECKPOINT_CREATE_FLAG_DESTROY_ALL = 0x01,
|
||||
NM_CHECKPOINT_CREATE_FLAG_DELETE_NEW_CONNECTIONS = 0x02,
|
||||
NM_CHECKPOINT_CREATE_FLAG_DISCONNECT_NEW_DEVICES = 0x04,
|
||||
NM_CHECKPOINT_CREATE_FLAG_ALLOW_OVERLAPPING = 0x08,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_CHECKPOINT_CREATE_FLAG_NONE = 0,
|
||||
NM_CHECKPOINT_CREATE_FLAG_DESTROY_ALL = 0x01,
|
||||
NM_CHECKPOINT_CREATE_FLAG_DELETE_NEW_CONNECTIONS = 0x02,
|
||||
NM_CHECKPOINT_CREATE_FLAG_DISCONNECT_NEW_DEVICES = 0x04,
|
||||
NM_CHECKPOINT_CREATE_FLAG_ALLOW_OVERLAPPING = 0x08,
|
||||
} NMCheckpointCreateFlags;
|
||||
|
||||
/**
|
||||
|
|
@ -983,11 +983,11 @@ typedef enum { /*< flags >*/
|
|||
*
|
||||
* Since: 1.4
|
||||
**/
|
||||
typedef enum { /*< skip >*/
|
||||
NM_ROLLBACK_RESULT_OK = 0,
|
||||
NM_ROLLBACK_RESULT_ERR_NO_DEVICE = 1,
|
||||
NM_ROLLBACK_RESULT_ERR_DEVICE_UNMANAGED = 2,
|
||||
NM_ROLLBACK_RESULT_ERR_FAILED = 3,
|
||||
typedef enum /*< skip >*/ {
|
||||
NM_ROLLBACK_RESULT_OK = 0,
|
||||
NM_ROLLBACK_RESULT_ERR_NO_DEVICE = 1,
|
||||
NM_ROLLBACK_RESULT_ERR_DEVICE_UNMANAGED = 2,
|
||||
NM_ROLLBACK_RESULT_ERR_FAILED = 3,
|
||||
} NMRollbackResult;
|
||||
|
||||
/**
|
||||
|
|
@ -1013,12 +1013,12 @@ typedef enum { /*< skip >*/
|
|||
*
|
||||
* Since: 1.12
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_SETTINGS_CONNECTION_FLAG_NONE = 0,
|
||||
NM_SETTINGS_CONNECTION_FLAG_UNSAVED = 0x01,
|
||||
NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED = 0x02,
|
||||
NM_SETTINGS_CONNECTION_FLAG_VOLATILE = 0x04,
|
||||
NM_SETTINGS_CONNECTION_FLAG_EXTERNAL = 0x08,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SETTINGS_CONNECTION_FLAG_NONE = 0,
|
||||
NM_SETTINGS_CONNECTION_FLAG_UNSAVED = 0x01,
|
||||
NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED = 0x02,
|
||||
NM_SETTINGS_CONNECTION_FLAG_VOLATILE = 0x04,
|
||||
NM_SETTINGS_CONNECTION_FLAG_EXTERNAL = 0x08,
|
||||
} NMSettingsConnectionFlags;
|
||||
|
||||
/**
|
||||
|
|
@ -1042,17 +1042,17 @@ typedef enum { /*< flags >*/
|
|||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_ACTIVATION_STATE_FLAG_NONE = 0,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_ACTIVATION_STATE_FLAG_NONE = 0,
|
||||
|
||||
NM_ACTIVATION_STATE_FLAG_IS_MASTER = 0x1,
|
||||
NM_ACTIVATION_STATE_FLAG_IS_SLAVE = 0x2,
|
||||
NM_ACTIVATION_STATE_FLAG_LAYER2_READY = 0x4,
|
||||
NM_ACTIVATION_STATE_FLAG_IP4_READY = 0x8,
|
||||
NM_ACTIVATION_STATE_FLAG_IP6_READY = 0x10,
|
||||
NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES = 0x20,
|
||||
NM_ACTIVATION_STATE_FLAG_LIFETIME_BOUND_TO_PROFILE_VISIBILITY = 0x40,
|
||||
NM_ACTIVATION_STATE_FLAG_EXTERNAL = 0x80,
|
||||
NM_ACTIVATION_STATE_FLAG_IS_MASTER = 0x1,
|
||||
NM_ACTIVATION_STATE_FLAG_IS_SLAVE = 0x2,
|
||||
NM_ACTIVATION_STATE_FLAG_LAYER2_READY = 0x4,
|
||||
NM_ACTIVATION_STATE_FLAG_IP4_READY = 0x8,
|
||||
NM_ACTIVATION_STATE_FLAG_IP6_READY = 0x10,
|
||||
NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES = 0x20,
|
||||
NM_ACTIVATION_STATE_FLAG_LIFETIME_BOUND_TO_PROFILE_VISIBILITY = 0x40,
|
||||
NM_ACTIVATION_STATE_FLAG_EXTERNAL = 0x80,
|
||||
} NMActivationStateFlags;
|
||||
|
||||
/**
|
||||
|
|
@ -1069,11 +1069,11 @@ typedef enum { /*< flags >*/
|
|||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_SETTINGS_ADD_CONNECTION2_FLAG_NONE = 0,
|
||||
NM_SETTINGS_ADD_CONNECTION2_FLAG_TO_DISK = 0x1,
|
||||
NM_SETTINGS_ADD_CONNECTION2_FLAG_IN_MEMORY = 0x2,
|
||||
NM_SETTINGS_ADD_CONNECTION2_FLAG_BLOCK_AUTOCONNECT = 0x20,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SETTINGS_ADD_CONNECTION2_FLAG_NONE = 0,
|
||||
NM_SETTINGS_ADD_CONNECTION2_FLAG_TO_DISK = 0x1,
|
||||
NM_SETTINGS_ADD_CONNECTION2_FLAG_IN_MEMORY = 0x2,
|
||||
NM_SETTINGS_ADD_CONNECTION2_FLAG_BLOCK_AUTOCONNECT = 0x20,
|
||||
} NMSettingsAddConnection2Flags;
|
||||
|
||||
/**
|
||||
|
|
@ -1125,15 +1125,15 @@ typedef enum { /*< flags >*/
|
|||
*
|
||||
* Since: 1.12
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_SETTINGS_UPDATE2_FLAG_NONE = 0,
|
||||
NM_SETTINGS_UPDATE2_FLAG_TO_DISK = 0x1,
|
||||
NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY = 0x2,
|
||||
NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED = 0x4,
|
||||
NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_ONLY = 0x8,
|
||||
NM_SETTINGS_UPDATE2_FLAG_VOLATILE = 0x10,
|
||||
NM_SETTINGS_UPDATE2_FLAG_BLOCK_AUTOCONNECT = 0x20,
|
||||
NM_SETTINGS_UPDATE2_FLAG_NO_REAPPLY = 0x40,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SETTINGS_UPDATE2_FLAG_NONE = 0,
|
||||
NM_SETTINGS_UPDATE2_FLAG_TO_DISK = 0x1,
|
||||
NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY = 0x2,
|
||||
NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACHED = 0x4,
|
||||
NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_ONLY = 0x8,
|
||||
NM_SETTINGS_UPDATE2_FLAG_VOLATILE = 0x10,
|
||||
NM_SETTINGS_UPDATE2_FLAG_BLOCK_AUTOCONNECT = 0x20,
|
||||
NM_SETTINGS_UPDATE2_FLAG_NO_REAPPLY = 0x40,
|
||||
} NMSettingsUpdate2Flags;
|
||||
|
||||
/**
|
||||
|
|
@ -1172,12 +1172,12 @@ typedef enum {
|
|||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_MANAGER_RELOAD_FLAG_NONE = 0, /*< skip >*/
|
||||
NM_MANAGER_RELOAD_FLAG_CONF = 0x1,
|
||||
NM_MANAGER_RELOAD_FLAG_DNS_RC = 0x2,
|
||||
NM_MANAGER_RELOAD_FLAG_DNS_FULL = 0x4,
|
||||
NM_MANAGER_RELOAD_FLAG_ALL = 0x7, /*< skip >*/
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_MANAGER_RELOAD_FLAG_NONE = 0, /*< skip >*/
|
||||
NM_MANAGER_RELOAD_FLAG_CONF = 0x1,
|
||||
NM_MANAGER_RELOAD_FLAG_DNS_RC = 0x2,
|
||||
NM_MANAGER_RELOAD_FLAG_DNS_FULL = 0x4,
|
||||
NM_MANAGER_RELOAD_FLAG_ALL = 0x7, /*< skip >*/
|
||||
} NMManagerReloadFlags;
|
||||
|
||||
/**
|
||||
|
|
@ -1199,15 +1199,15 @@ typedef enum { /*< flags >*/
|
|||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
/* kernel flags */
|
||||
NM_DEVICE_INTERFACE_FLAG_NONE = 0, /*< skip >*/
|
||||
NM_DEVICE_INTERFACE_FLAG_UP = 0x1,
|
||||
NM_DEVICE_INTERFACE_FLAG_LOWER_UP = 0x2,
|
||||
NM_DEVICE_INTERFACE_FLAG_PROMISC = 0x4,
|
||||
/* NM-specific flags */
|
||||
NM_DEVICE_INTERFACE_FLAG_CARRIER = 0x10000,
|
||||
NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED = 0x20000,
|
||||
typedef enum /*< flags >*/ {
|
||||
/* kernel flags */
|
||||
NM_DEVICE_INTERFACE_FLAG_NONE = 0, /*< skip >*/
|
||||
NM_DEVICE_INTERFACE_FLAG_UP = 0x1,
|
||||
NM_DEVICE_INTERFACE_FLAG_LOWER_UP = 0x2,
|
||||
NM_DEVICE_INTERFACE_FLAG_PROMISC = 0x4,
|
||||
/* NM-specific flags */
|
||||
NM_DEVICE_INTERFACE_FLAG_CARRIER = 0x10000,
|
||||
NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED = 0x20000,
|
||||
} NMDeviceInterfaceFlags;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* Since: 1.30
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_KEYFILE_HANDLER_FLAGS_NONE = 0,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_KEYFILE_HANDLER_FLAGS_NONE = 0,
|
||||
} NMKeyfileHandlerFlags;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -75,13 +75,13 @@ typedef enum { /*< underscore_name=nm_setting_802_1x_ck_scheme >*/
|
|||
*
|
||||
* Since: 1.8
|
||||
*/
|
||||
typedef enum { /*< flags, underscore_name=nm_setting_802_1x_auth_flags >*/
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_NONE = 0,
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_DISABLE = 0x1,
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_1_DISABLE = 0x2,
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_2_DISABLE = 0x4,
|
||||
typedef enum /*< underscore_name=nm_setting_802_1x_auth_flags, flags >*/ {
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_NONE = 0,
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_DISABLE = 0x1,
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_1_DISABLE = 0x2,
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_2_DISABLE = 0x4,
|
||||
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_ALL = 0x7,
|
||||
NM_SETTING_802_1X_AUTH_FLAGS_ALL = 0x7,
|
||||
} NMSetting8021xAuthFlags;
|
||||
|
||||
#define NM_TYPE_SETTING_802_1X (nm_setting_802_1x_get_type())
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* DCB feature flags.
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_SETTING_DCB_FLAG_NONE = 0x00000000,
|
||||
NM_SETTING_DCB_FLAG_ENABLE = 0x00000001,
|
||||
NM_SETTING_DCB_FLAG_ADVERTISE = 0x00000002,
|
||||
NM_SETTING_DCB_FLAG_WILLING = 0x00000004
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SETTING_DCB_FLAG_NONE = 0x00000000,
|
||||
NM_SETTING_DCB_FLAG_ENABLE = 0x00000001,
|
||||
NM_SETTING_DCB_FLAG_ADVERTISE = 0x00000002,
|
||||
NM_SETTING_DCB_FLAG_WILLING = 0x00000004
|
||||
} NMSettingDcbFlags;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_IP_ADDRESS_CMP_FLAGS_NONE = 0,
|
||||
NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS = 0x1,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_IP_ADDRESS_CMP_FLAGS_NONE = 0,
|
||||
NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS = 0x1,
|
||||
} NMIPAddressCmpFlags;
|
||||
|
||||
typedef struct NMIPAddress NMIPAddress;
|
||||
|
|
@ -86,9 +86,9 @@ void nm_ip_route_ref(NMIPRoute *route);
|
|||
void nm_ip_route_unref(NMIPRoute *route);
|
||||
gboolean nm_ip_route_equal(NMIPRoute *route, NMIPRoute *other);
|
||||
|
||||
enum { /*< flags >*/
|
||||
NM_IP_ROUTE_EQUAL_CMP_FLAGS_NONE = 0,
|
||||
NM_IP_ROUTE_EQUAL_CMP_FLAGS_WITH_ATTRS = 0x1,
|
||||
enum /*< flags >*/ {
|
||||
NM_IP_ROUTE_EQUAL_CMP_FLAGS_NONE = 0,
|
||||
NM_IP_ROUTE_EQUAL_CMP_FLAGS_WITH_ATTRS = 0x1,
|
||||
};
|
||||
|
||||
NM_AVAILABLE_IN_1_10
|
||||
|
|
@ -277,12 +277,12 @@ gboolean nm_ip_routing_rule_validate(const NMIPRoutingRule *self, GError **error
|
|||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE = 0,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE = 0,
|
||||
|
||||
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET = 0x1,
|
||||
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET6 = 0x2,
|
||||
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE = 0x4,
|
||||
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET = 0x1,
|
||||
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET6 = 0x2,
|
||||
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE = 0x4,
|
||||
} NMIPRoutingRuleAsStringFlags;
|
||||
|
||||
NM_AVAILABLE_IN_1_18
|
||||
|
|
@ -386,14 +386,14 @@ typedef struct _NMSettingIPConfigClass NMSettingIPConfigClass;
|
|||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE = 0x0,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE = 0x0,
|
||||
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE = 0x1,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED = 0x2,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE = 0x4,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE = 0x1,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED = 0x2,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE = 0x4,
|
||||
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS = 0x8,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS = 0x8,
|
||||
|
||||
} NMDhcpHostnameFlags;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,14 +60,14 @@ typedef struct _NMSettingIPTunnelClass NMSettingIPTunnelClass;
|
|||
*
|
||||
* Since: 1.12
|
||||
*/
|
||||
typedef enum { /*< flags, prefix=NM_IP_TUNNEL_FLAG >*/
|
||||
NM_IP_TUNNEL_FLAG_NONE = 0x0,
|
||||
NM_IP_TUNNEL_FLAG_IP6_IGN_ENCAP_LIMIT = 0x1,
|
||||
NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_TCLASS = 0x2,
|
||||
NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_FLOWLABEL = 0x4,
|
||||
NM_IP_TUNNEL_FLAG_IP6_MIP6_DEV = 0x8,
|
||||
NM_IP_TUNNEL_FLAG_IP6_RCV_DSCP_COPY = 0x10,
|
||||
NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_FWMARK = 0x20,
|
||||
typedef enum /*< prefix=NM_IP_TUNNEL_FLAG, flags >*/ {
|
||||
NM_IP_TUNNEL_FLAG_NONE = 0x0,
|
||||
NM_IP_TUNNEL_FLAG_IP6_IGN_ENCAP_LIMIT = 0x1,
|
||||
NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_TCLASS = 0x2,
|
||||
NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_FLOWLABEL = 0x4,
|
||||
NM_IP_TUNNEL_FLAG_IP6_MIP6_DEV = 0x8,
|
||||
NM_IP_TUNNEL_FLAG_IP6_RCV_DSCP_COPY = 0x10,
|
||||
NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_FWMARK = 0x20,
|
||||
} NMIPTunnelFlags;
|
||||
|
||||
NM_AVAILABLE_IN_1_2
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ G_BEGIN_DECLS
|
|||
* @NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_SEND_ALWAYS: the arp_ping link watcher option
|
||||
* 'send_always' is enabled (set to true).
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_NONE = 0, /*< skip >*/
|
||||
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_VALIDATE_ACTIVE = 0x2,
|
||||
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_VALIDATE_INACTIVE = 0x4,
|
||||
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_SEND_ALWAYS = 0x8,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_NONE = 0, /*< skip >*/
|
||||
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_VALIDATE_ACTIVE = 0x2,
|
||||
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_VALIDATE_INACTIVE = 0x4,
|
||||
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_SEND_ALWAYS = 0x8,
|
||||
} NMTeamLinkWatcherArpPingFlags;
|
||||
|
||||
#define NM_TEAM_LINK_WATCHER_ETHTOOL "ethtool"
|
||||
|
|
|
|||
|
|
@ -42,12 +42,10 @@ typedef struct _NMSettingVlanClass NMSettingVlanClass;
|
|||
* A selector for traffic priority maps; these map Linux SKB priorities
|
||||
* to 802.1p priorities used in VLANs.
|
||||
**/
|
||||
/* clang-format off */
|
||||
typedef enum {
|
||||
NM_VLAN_INGRESS_MAP,
|
||||
NM_VLAN_EGRESS_MAP
|
||||
NM_VLAN_EGRESS_MAP,
|
||||
} NMVlanPriorityMap;
|
||||
/* clang-format on */
|
||||
|
||||
/**
|
||||
* NMVlanFlags:
|
||||
|
|
@ -63,17 +61,17 @@ typedef enum {
|
|||
*
|
||||
* #NMVlanFlags values control the behavior of the VLAN interface.
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
typedef enum /*< flags >*/ {
|
||||
|
||||
NM_VLAN_FLAG_REORDER_HEADERS = 0x1,
|
||||
NM_VLAN_FLAG_GVRP = 0x2,
|
||||
NM_VLAN_FLAG_LOOSE_BINDING = 0x4,
|
||||
NM_VLAN_FLAG_MVRP = 0x8,
|
||||
NM_VLAN_FLAG_REORDER_HEADERS = 0x1,
|
||||
NM_VLAN_FLAG_GVRP = 0x2,
|
||||
NM_VLAN_FLAG_LOOSE_BINDING = 0x4,
|
||||
NM_VLAN_FLAG_MVRP = 0x8,
|
||||
|
||||
/* NOTE: if adding flags update nm-setting-vlan.c::verify() */
|
||||
/* NOTE: if adding flags update nm-setting-vlan.c::verify() */
|
||||
|
||||
/* NOTE: these flags must correspond to the value from the kernel
|
||||
* header files. */
|
||||
/* NOTE: these flags must correspond to the value from the kernel
|
||||
* header files. */
|
||||
} NMVlanFlags;
|
||||
|
||||
#define NM_VLAN_FLAGS_ALL \
|
||||
|
|
|
|||
|
|
@ -49,20 +49,20 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* Since: 1.2
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_NONE = 0, /*< skip >*/
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_PHY = 0x2,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST = 0x4,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST = 0x8,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST = 0x10,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_ARP = 0x20,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC = 0x40,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_NONE = 0, /*< skip >*/
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_PHY = 0x2,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST = 0x4,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST = 0x8,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST = 0x10,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_ARP = 0x20,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC = 0x40,
|
||||
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_ALL = 0x7E, /*< skip >*/
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_ALL = 0x7E, /*< skip >*/
|
||||
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT = 0x1,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE = 0x8000,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS = 0x8001, /*< skip >*/
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT = 0x1,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE = 0x8000,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS = 0x8001, /*< skip >*/
|
||||
} NMSettingWiredWakeOnLan;
|
||||
|
||||
#define NM_SETTING_WIRED_PORT "port"
|
||||
|
|
|
|||
|
|
@ -99,12 +99,12 @@ typedef enum {
|
|||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT = 0x00000000,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DISABLED = 0x00000001,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_AUTO = 0x00000002,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PBC = 0x00000004,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PIN = 0x00000008,
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT = 0x00000000,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DISABLED = 0x00000001,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_AUTO = 0x00000002,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PBC = 0x00000004,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PIN = 0x00000008,
|
||||
} NMSettingWirelessSecurityWpsMethod;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ G_BEGIN_DECLS
|
|||
* Since: 1.12
|
||||
*/
|
||||
/* clang-format off */
|
||||
typedef enum { /*< flags >*/
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE = 0, /*< skip >*/
|
||||
NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY = 0x2,
|
||||
NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT = 0x4,
|
||||
|
|
|
|||
|
|
@ -57,13 +57,13 @@ G_BEGIN_DECLS
|
|||
* is to be stored and/or requested when it is needed.
|
||||
*
|
||||
**/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_SETTING_SECRET_FLAG_NONE = 0x00000000,
|
||||
NM_SETTING_SECRET_FLAG_AGENT_OWNED = 0x00000001,
|
||||
NM_SETTING_SECRET_FLAG_NOT_SAVED = 0x00000002,
|
||||
NM_SETTING_SECRET_FLAG_NOT_REQUIRED = 0x00000004
|
||||
typedef enum /*< flags >*/ {
|
||||
NM_SETTING_SECRET_FLAG_NONE = 0x00000000,
|
||||
NM_SETTING_SECRET_FLAG_AGENT_OWNED = 0x00000001,
|
||||
NM_SETTING_SECRET_FLAG_NOT_SAVED = 0x00000002,
|
||||
NM_SETTING_SECRET_FLAG_NOT_REQUIRED = 0x00000004
|
||||
|
||||
/* NOTE: if adding flags, update nm-core-internal.h as well */
|
||||
/* NOTE: if adding flags, update nm-core-internal.h as well */
|
||||
} NMSettingSecretFlags;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@
|
|||
#define NM_VERSION_1_32 (NM_ENCODE_VERSION (1, 32, 0))
|
||||
#define NM_VERSION_1_34 (NM_ENCODE_VERSION (1, 34, 0))
|
||||
#define NM_VERSION_1_36 (NM_ENCODE_VERSION (1, 36, 0))
|
||||
#define NM_VERSION_1_38 (NM_ENCODE_VERSION (1, 38, 0))
|
||||
|
||||
/* For releases, NM_API_VERSION is equal to NM_VERSION.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -313,6 +313,20 @@
|
|||
#define NM_AVAILABLE_IN_1_36
|
||||
#endif
|
||||
|
||||
#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_38
|
||||
#define NM_DEPRECATED_IN_1_38 G_DEPRECATED
|
||||
#define NM_DEPRECATED_IN_1_38_FOR(f) G_DEPRECATED_FOR(f)
|
||||
#else
|
||||
#define NM_DEPRECATED_IN_1_38
|
||||
#define NM_DEPRECATED_IN_1_38_FOR(f)
|
||||
#endif
|
||||
|
||||
#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_38
|
||||
#define NM_AVAILABLE_IN_1_38 G_UNAVAILABLE(1, 38)
|
||||
#else
|
||||
#define NM_AVAILABLE_IN_1_38
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Synchronous API for calling D-Bus in libnm is deprecated. See
|
||||
* https://developer.gnome.org/libnm/stable/usage.html#sync-api
|
||||
|
|
|
|||
|
|
@ -391,6 +391,7 @@ nm_value_type_to_json(NMValueType value_type, GString *gstr, gconstpointer p_fie
|
|||
nm_json_gstr_append_string(gstr, *((const char *const *) p_field));
|
||||
return;
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
case NM_VALUE_TYPE_NONE:
|
||||
case NM_VALUE_TYPE_UNSPEC:
|
||||
break;
|
||||
|
|
@ -428,12 +429,12 @@ nm_value_type_from_json(const NMJsonVt *vt,
|
|||
return (nm_jansson_json_as_string(vt, elem, out_val) > 0);
|
||||
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
case NM_VALUE_TYPE_NONE:
|
||||
case NM_VALUE_TYPE_UNSPEC:
|
||||
break;
|
||||
}
|
||||
nm_assert_not_reached();
|
||||
return FALSE;
|
||||
return nm_assert_unreachable_val(FALSE);
|
||||
}
|
||||
|
||||
#endif /* NM_VALUE_TYPE_DEFINE_FUNCTIONS */
|
||||
|
|
|
|||
|
|
@ -9,54 +9,54 @@
|
|||
|
||||
/* Log domains */
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
LOGD_NONE = 0LL,
|
||||
LOGD_PLATFORM = (1LL << 0), /* Platform services */
|
||||
LOGD_RFKILL = (1LL << 1),
|
||||
LOGD_ETHER = (1LL << 2),
|
||||
LOGD_WIFI = (1LL << 3),
|
||||
LOGD_BT = (1LL << 4),
|
||||
LOGD_MB = (1LL << 5), /* mobile broadband */
|
||||
LOGD_DHCP4 = (1LL << 6),
|
||||
LOGD_DHCP6 = (1LL << 7),
|
||||
LOGD_PPP = (1LL << 8),
|
||||
LOGD_WIFI_SCAN = (1LL << 9),
|
||||
LOGD_IP4 = (1LL << 10),
|
||||
LOGD_IP6 = (1LL << 11),
|
||||
LOGD_AUTOIP4 = (1LL << 12),
|
||||
LOGD_DNS = (1LL << 13),
|
||||
LOGD_VPN = (1LL << 14),
|
||||
LOGD_SHARING = (1LL << 15), /* Connection sharing/dnsmasq */
|
||||
LOGD_SUPPLICANT = (1LL << 16), /* Wi-Fi and 802.1x */
|
||||
LOGD_AGENTS = (1LL << 17), /* Secret agents */
|
||||
LOGD_SETTINGS = (1LL << 18), /* Settings */
|
||||
LOGD_SUSPEND = (1LL << 19), /* Suspend/Resume */
|
||||
LOGD_CORE = (1LL << 20), /* Core daemon and policy stuff */
|
||||
LOGD_DEVICE = (1LL << 21), /* Device state and activation */
|
||||
LOGD_OLPC = (1LL << 22),
|
||||
LOGD_INFINIBAND = (1LL << 23),
|
||||
LOGD_FIREWALL = (1LL << 24),
|
||||
LOGD_ADSL = (1LL << 25),
|
||||
LOGD_BOND = (1LL << 26),
|
||||
LOGD_VLAN = (1LL << 27),
|
||||
LOGD_BRIDGE = (1LL << 28),
|
||||
LOGD_DBUS_PROPS = (1LL << 29),
|
||||
LOGD_TEAM = (1LL << 30),
|
||||
LOGD_CONCHECK = (1LL << 31),
|
||||
LOGD_DCB = (1LL << 32), /* Data Center Bridging */
|
||||
LOGD_DISPATCH = (1LL << 33),
|
||||
LOGD_AUDIT = (1LL << 34),
|
||||
LOGD_SYSTEMD = (1LL << 35),
|
||||
LOGD_VPN_PLUGIN = (1LL << 36),
|
||||
LOGD_PROXY = (1LL << 37),
|
||||
typedef enum {
|
||||
LOGD_NONE = 0LL,
|
||||
LOGD_PLATFORM = (1LL << 0), /* Platform services */
|
||||
LOGD_RFKILL = (1LL << 1),
|
||||
LOGD_ETHER = (1LL << 2),
|
||||
LOGD_WIFI = (1LL << 3),
|
||||
LOGD_BT = (1LL << 4),
|
||||
LOGD_MB = (1LL << 5), /* mobile broadband */
|
||||
LOGD_DHCP4 = (1LL << 6),
|
||||
LOGD_DHCP6 = (1LL << 7),
|
||||
LOGD_PPP = (1LL << 8),
|
||||
LOGD_WIFI_SCAN = (1LL << 9),
|
||||
LOGD_IP4 = (1LL << 10),
|
||||
LOGD_IP6 = (1LL << 11),
|
||||
LOGD_AUTOIP4 = (1LL << 12),
|
||||
LOGD_DNS = (1LL << 13),
|
||||
LOGD_VPN = (1LL << 14),
|
||||
LOGD_SHARING = (1LL << 15), /* Connection sharing/dnsmasq */
|
||||
LOGD_SUPPLICANT = (1LL << 16), /* Wi-Fi and 802.1x */
|
||||
LOGD_AGENTS = (1LL << 17), /* Secret agents */
|
||||
LOGD_SETTINGS = (1LL << 18), /* Settings */
|
||||
LOGD_SUSPEND = (1LL << 19), /* Suspend/Resume */
|
||||
LOGD_CORE = (1LL << 20), /* Core daemon and policy stuff */
|
||||
LOGD_DEVICE = (1LL << 21), /* Device state and activation */
|
||||
LOGD_OLPC = (1LL << 22),
|
||||
LOGD_INFINIBAND = (1LL << 23),
|
||||
LOGD_FIREWALL = (1LL << 24),
|
||||
LOGD_ADSL = (1LL << 25),
|
||||
LOGD_BOND = (1LL << 26),
|
||||
LOGD_VLAN = (1LL << 27),
|
||||
LOGD_BRIDGE = (1LL << 28),
|
||||
LOGD_DBUS_PROPS = (1LL << 29),
|
||||
LOGD_TEAM = (1LL << 30),
|
||||
LOGD_CONCHECK = (1LL << 31),
|
||||
LOGD_DCB = (1LL << 32), /* Data Center Bridging */
|
||||
LOGD_DISPATCH = (1LL << 33),
|
||||
LOGD_AUDIT = (1LL << 34),
|
||||
LOGD_SYSTEMD = (1LL << 35),
|
||||
LOGD_VPN_PLUGIN = (1LL << 36),
|
||||
LOGD_PROXY = (1LL << 37),
|
||||
|
||||
__LOGD_MAX,
|
||||
LOGD_ALL = (((__LOGD_MAX - 1LL) << 1) - 1LL),
|
||||
LOGD_DEFAULT = LOGD_ALL & ~(LOGD_DBUS_PROPS | LOGD_WIFI_SCAN | LOGD_VPN_PLUGIN | 0),
|
||||
__LOGD_MAX,
|
||||
LOGD_ALL = (((__LOGD_MAX - 1LL) << 1) - 1LL),
|
||||
LOGD_DEFAULT = LOGD_ALL & ~(LOGD_DBUS_PROPS | LOGD_WIFI_SCAN | LOGD_VPN_PLUGIN | 0),
|
||||
|
||||
/* aliases: */
|
||||
LOGD_DHCP = LOGD_DHCP4 | LOGD_DHCP6,
|
||||
LOGD_IP = LOGD_IP4 | LOGD_IP6,
|
||||
/* aliases: */
|
||||
LOGD_DHCP = LOGD_DHCP4 | LOGD_DHCP6,
|
||||
LOGD_IP = LOGD_IP4 | LOGD_IP6,
|
||||
|
||||
#define LOGD_DHCPX(is_ipv4) ((is_ipv4) ? LOGD_DHCP4 : LOGD_DHCP6)
|
||||
#define LOGD_IPX(is_ipv4) ((is_ipv4) ? LOGD_IP4 : LOGD_IP6)
|
||||
|
|
@ -64,19 +64,20 @@ typedef enum { /*< skip >*/
|
|||
} NMLogDomain;
|
||||
|
||||
/* Log levels */
|
||||
typedef enum { /*< skip >*/
|
||||
LOGL_TRACE,
|
||||
LOGL_DEBUG,
|
||||
LOGL_INFO,
|
||||
LOGL_WARN,
|
||||
LOGL_ERR,
|
||||
typedef enum {
|
||||
|
||||
_LOGL_N_REAL, /* the number of actual logging levels */
|
||||
LOGL_TRACE,
|
||||
LOGL_DEBUG,
|
||||
LOGL_INFO,
|
||||
LOGL_WARN,
|
||||
LOGL_ERR,
|
||||
|
||||
_LOGL_OFF = _LOGL_N_REAL, /* special logging level that is always disabled. */
|
||||
_LOGL_KEEP, /* special logging level to indicate that the logging level should not be changed. */
|
||||
_LOGL_N_REAL, /* the number of actual logging levels */
|
||||
|
||||
_LOGL_N, /* the number of logging levels including "OFF" */
|
||||
_LOGL_OFF = _LOGL_N_REAL, /* special logging level that is always disabled. */
|
||||
_LOGL_KEEP, /* special logging level to indicate that the logging level should not be changed. */
|
||||
|
||||
_LOGL_N, /* the number of logging levels including "OFF" */
|
||||
} NMLogLevel;
|
||||
|
||||
gboolean _nm_log_enabled_impl(gboolean mt_require_locking, NMLogLevel level, NMLogDomain domain);
|
||||
|
|
|
|||
|
|
@ -184,26 +184,36 @@ _nm_auto_freev(gpointer ptr)
|
|||
* same name for the same warning. */
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
||||
#define NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma("GCC diagnostic push")
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning) \
|
||||
_Pragma("GCC diagnostic push") _Pragma(_NM_PRAGMA_WARNING_DO(warning))
|
||||
#elif defined(__clang__)
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning) \
|
||||
_Pragma("clang diagnostic push") _Pragma(_NM_PRAGMA_WARNING_DO("-Wunknown-warning-option")) \
|
||||
_Pragma(_NM_PRAGMA_WARNING_DO(warning))
|
||||
#else
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
||||
NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma(_NM_PRAGMA_WARNING_DO(warning))
|
||||
#define NM_PRAGMA_WARNING_REENABLE _Pragma("GCC diagnostic pop")
|
||||
#elif defined(__clang__)
|
||||
#define NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma("clang diagnostic push")
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning) \
|
||||
NM_PRAGMA_DIAGNOSTICS_PUSH _Pragma(_NM_PRAGMA_WARNING_DO("-Wunknown-warning-option")) \
|
||||
_Pragma(_NM_PRAGMA_WARNING_DO(warning))
|
||||
#define NM_PRAGMA_WARNING_REENABLE _Pragma("clang diagnostic pop")
|
||||
#else
|
||||
#define NM_PRAGMA_DIAGNOSTICS_PUSH
|
||||
#define NM_PRAGMA_WARNING_DISABLE(warning)
|
||||
#define NM_PRAGMA_WARNING_REENABLE
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Seems gcc-12 has a tendency for false-positive -Wdangling-pointer warnings with
|
||||
* g_error()'s `for(;;);`.
|
||||
*
|
||||
* Work around that, but it's only for gcc 12 (for now). */
|
||||
#if defined(__GNUC__) && __GNUC__ == 12
|
||||
#define NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER NM_PRAGMA_WARNING_DISABLE("-Wdangling-pointer")
|
||||
#else
|
||||
#define NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER NM_PRAGMA_DIAGNOSTICS_PUSH
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* NM_G_ERROR_MSG:
|
||||
* @error: (allow-none): the #GError instance
|
||||
|
|
|
|||
|
|
@ -1130,6 +1130,7 @@ nm_utils_parse_inaddr_bin_full(int addr_family,
|
|||
|
||||
#if NM_MORE_ASSERTS > 10
|
||||
if (addr_family == AF_INET) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
gs_free_error GError *error = NULL;
|
||||
in_addr_t a;
|
||||
|
||||
|
|
@ -1145,6 +1146,7 @@ nm_utils_parse_inaddr_bin_full(int addr_family,
|
|||
error->message);
|
||||
}
|
||||
nm_assert(addrbin.addr4 == a);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3139,6 +3139,33 @@ nm_strvarray_remove_first(GArray *strv, const char *needle)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static inline int
|
||||
nm_strvarray_cmp(const GArray *a, const GArray *b)
|
||||
{
|
||||
NM_CMP_SELF(a, b);
|
||||
|
||||
return nm_strv_cmp_n((const char *const *) a->data,
|
||||
a->len,
|
||||
(const char *const *) b->data,
|
||||
b->len);
|
||||
}
|
||||
|
||||
#define nm_strvarray_equal(a, b) (nm_strvarray_cmp((a), (b)) == 0)
|
||||
|
||||
static inline int
|
||||
_nm_strvarray_cmp_strv(const GArray *strv, const char *const *ss, gsize ss_len)
|
||||
{
|
||||
return nm_strv_cmp_n(strv ? (const char *const *) strv->data : NULL,
|
||||
strv ? ((gssize) strv->len) : -1,
|
||||
ss,
|
||||
ss_len);
|
||||
}
|
||||
#define nm_strvarray_cmp_strv(strv, ss, ss_len) \
|
||||
_nm_strvarray_cmp_strv((strv), NM_CAST_STRV_CC(ss), (ss_len))
|
||||
|
||||
#define nm_strvarray_equal_strv(strv, ss, ss_len) \
|
||||
(nm_strvarray_cmp_strv((strv), (ss), (ss_len)) == 0)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct _NMVariantAttributeSpec {
|
||||
|
|
|
|||
|
|
@ -1714,8 +1714,11 @@ __nmtst_spawn_sync(const char *working_directory,
|
|||
standard_err,
|
||||
&exit_status,
|
||||
&error);
|
||||
if (!success)
|
||||
if (!success) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("nmtst_spawn_sync(%s): %s", ((char **) argv->pdata)[0], error->message);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
g_assert(!error);
|
||||
|
||||
g_assert(!standard_out || *standard_out);
|
||||
|
|
@ -1844,7 +1847,8 @@ _nmtst_assert_resolve_relative_path_equals(const char *f1,
|
|||
|
||||
/* Fixme: later we might need to coalesce repeated '/', "./", and "../".
|
||||
* For now, it's good enough. */
|
||||
if (g_strcmp0(p1, p2) != 0)
|
||||
if (g_strcmp0(p1, p2) != 0) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("%s:%d : filenames don't match \"%s\" vs. \"%s\" // \"%s\" - \"%s\"",
|
||||
file,
|
||||
line,
|
||||
|
|
@ -1852,6 +1856,8 @@ _nmtst_assert_resolve_relative_path_equals(const char *f1,
|
|||
f2,
|
||||
p1,
|
||||
p2);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
#define nmtst_assert_resolve_relative_path_equals(f1, f2) \
|
||||
_nmtst_assert_resolve_relative_path_equals(f1, f2, __FILE__, __LINE__);
|
||||
|
|
@ -2404,9 +2410,11 @@ _nmtst_assert_connection_has_settings(NMConnection *connection,
|
|||
settings = nm_connection_get_settings(connection, &len);
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!g_hash_table_remove(names, nm_setting_get_name(settings[i])) && has_at_most) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error(
|
||||
"nmtst_assert_connection_has_settings(): has setting \"%s\" which is not expected",
|
||||
nm_setting_get_name(settings[i]));
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
if (g_hash_table_size(names) > 0 && has_at_least) {
|
||||
|
|
@ -2419,11 +2427,13 @@ _nmtst_assert_connection_has_settings(NMConnection *connection,
|
|||
settings_names[i] = nm_setting_get_name(settings[i]);
|
||||
has_str = g_strjoinv(" ", (char **) settings_names);
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("nmtst_assert_connection_has_settings(): the setting lacks %u expected settings "
|
||||
"(expected: [%s] vs. has: [%s])",
|
||||
g_hash_table_size(names),
|
||||
expected_str,
|
||||
has_str);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
#define nmtst_assert_connection_has_settings(connection, ...) \
|
||||
|
|
|
|||
|
|
@ -9,25 +9,26 @@
|
|||
typedef enum _nm_packed {
|
||||
NM_VALUE_TYPE_NONE = 0,
|
||||
NM_VALUE_TYPE_UNSPEC = 1,
|
||||
NM_VALUE_TYPE_BOOL = 2,
|
||||
NM_VALUE_TYPE_INT32 = 3,
|
||||
NM_VALUE_TYPE_INT = 4,
|
||||
NM_VALUE_TYPE_INT64 = 5,
|
||||
NM_VALUE_TYPE_UINT32 = 6,
|
||||
NM_VALUE_TYPE_UINT = 7,
|
||||
NM_VALUE_TYPE_UINT64 = 8,
|
||||
|
||||
NM_VALUE_TYPE_BOOL,
|
||||
NM_VALUE_TYPE_INT32,
|
||||
NM_VALUE_TYPE_INT,
|
||||
NM_VALUE_TYPE_INT64,
|
||||
NM_VALUE_TYPE_UINT32,
|
||||
NM_VALUE_TYPE_UINT,
|
||||
NM_VALUE_TYPE_UINT64,
|
||||
|
||||
/* Flags are for G_TYPE_FLAGS. That is, internally they are tracked
|
||||
* as a guint, they have a g_param_spec_flags() property and they are
|
||||
* serialized on D-Bus as "u". */
|
||||
NM_VALUE_TYPE_FLAGS = 9,
|
||||
NM_VALUE_TYPE_FLAGS,
|
||||
|
||||
/* G_TYPE_ENUM */
|
||||
NM_VALUE_TYPE_ENUM = 10,
|
||||
NM_VALUE_TYPE_ENUM,
|
||||
|
||||
NM_VALUE_TYPE_STRING = 11,
|
||||
|
||||
NM_VALUE_TYPE_BYTES = 12,
|
||||
NM_VALUE_TYPE_STRING,
|
||||
NM_VALUE_TYPE_BYTES,
|
||||
NM_VALUE_TYPE_STRV,
|
||||
} NMValueType;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -112,14 +113,17 @@ nm_value_type_cmp(NMValueType value_type, gconstpointer p_a, gconstpointer p_b)
|
|||
return 0;
|
||||
case NM_VALUE_TYPE_STRING:
|
||||
return nm_strcmp0(*((const char *const *) p_a), *((const char *const *) p_b));
|
||||
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
return nm_g_bytes_equal0(*((const GBytes *const *) p_a), *((const GBytes *const *) p_b));
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
/* These types have implementation define memory representations. */
|
||||
break;
|
||||
|
||||
case NM_VALUE_TYPE_NONE:
|
||||
case NM_VALUE_TYPE_UNSPEC:
|
||||
break;
|
||||
}
|
||||
nm_assert_not_reached();
|
||||
return 0;
|
||||
return nm_assert_unreachable_val(0);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
|
|
@ -163,14 +167,12 @@ nm_value_type_copy(NMValueType value_type, gpointer dst, gconstpointer src)
|
|||
*((char **) dst) = g_strdup(*((const char *const *) src));
|
||||
}
|
||||
return;
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
/* self assignment safe! */
|
||||
if (*((GBytes **) dst) != *((const GBytes *const *) src)) {
|
||||
_nm_unused gs_unref_bytes GBytes *old = *((GBytes **) dst);
|
||||
|
||||
*((GBytes **) dst) = g_bytes_ref(*((GBytes *const *) src));
|
||||
}
|
||||
return;
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
/* These types have implementation define memory representations. */
|
||||
break;
|
||||
|
||||
case NM_VALUE_TYPE_NONE:
|
||||
case NM_VALUE_TYPE_UNSPEC:
|
||||
break;
|
||||
|
|
@ -212,14 +214,18 @@ nm_value_type_get_from_variant(NMValueType value_type,
|
|||
return;
|
||||
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
/* These types have implementation define memory representations. */
|
||||
break;
|
||||
|
||||
case NM_VALUE_TYPE_INT:
|
||||
case NM_VALUE_TYPE_UINT:
|
||||
case NM_VALUE_TYPE_ENUM:
|
||||
case NM_VALUE_TYPE_FLAGS:
|
||||
/* These types don't have a defined variant type, because it's not
|
||||
* clear how many bits we would need or how to handle the type. */
|
||||
break;
|
||||
|
||||
/* fall-through */
|
||||
case NM_VALUE_TYPE_NONE:
|
||||
case NM_VALUE_TYPE_UNSPEC:
|
||||
break;
|
||||
|
|
@ -230,8 +236,7 @@ nm_value_type_get_from_variant(NMValueType value_type,
|
|||
static inline GVariant *
|
||||
nm_value_type_to_variant(NMValueType value_type, gconstpointer src)
|
||||
{
|
||||
const char *v_string;
|
||||
const GBytes *v_bytes;
|
||||
const char *v_string;
|
||||
|
||||
switch (value_type) {
|
||||
case NM_VALUE_TYPE_BOOL:
|
||||
|
|
@ -247,9 +252,11 @@ nm_value_type_to_variant(NMValueType value_type, gconstpointer src)
|
|||
case NM_VALUE_TYPE_STRING:
|
||||
v_string = *((const char *const *) src);
|
||||
return v_string ? g_variant_new_string(v_string) : NULL;
|
||||
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
v_bytes = *((const GBytes *const *) src);
|
||||
return v_bytes ? nm_g_bytes_to_variant_ay(v_bytes) : NULL;
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
/* These types have implementation define memory representations. */
|
||||
break;
|
||||
|
||||
case NM_VALUE_TYPE_INT:
|
||||
case NM_VALUE_TYPE_UINT:
|
||||
|
|
@ -257,14 +264,13 @@ nm_value_type_to_variant(NMValueType value_type, gconstpointer src)
|
|||
case NM_VALUE_TYPE_FLAGS:
|
||||
/* These types don't have a defined variant type, because it's not
|
||||
* clear how many bits we would need or how to handle the type. */
|
||||
break;
|
||||
|
||||
/* fall-through */
|
||||
case NM_VALUE_TYPE_NONE:
|
||||
case NM_VALUE_TYPE_UNSPEC:
|
||||
break;
|
||||
}
|
||||
nm_assert_not_reached();
|
||||
return NULL;
|
||||
return nm_assert_unreachable_val(NULL);
|
||||
}
|
||||
|
||||
static inline const GVariantType *
|
||||
|
|
@ -285,6 +291,8 @@ nm_value_type_get_variant_type(NMValueType value_type)
|
|||
return G_VARIANT_TYPE_STRING;
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
return G_VARIANT_TYPE_BYTESTRING;
|
||||
case NM_VALUE_TYPE_STRV:
|
||||
return G_VARIANT_TYPE_STRING_ARRAY;
|
||||
|
||||
case NM_VALUE_TYPE_INT:
|
||||
case NM_VALUE_TYPE_UINT:
|
||||
|
|
|
|||
|
|
@ -1114,20 +1114,22 @@ _linktype_get_type(NMPlatform *platform,
|
|||
return link_type;
|
||||
}
|
||||
|
||||
if (arptype == ARPHRD_LOOPBACK)
|
||||
switch (arptype) {
|
||||
case ARPHRD_LOOPBACK:
|
||||
return NM_LINK_TYPE_LOOPBACK;
|
||||
else if (arptype == ARPHRD_INFINIBAND)
|
||||
case ARPHRD_INFINIBAND:
|
||||
return NM_LINK_TYPE_INFINIBAND;
|
||||
else if (arptype == ARPHRD_SIT)
|
||||
case ARPHRD_SIT:
|
||||
return NM_LINK_TYPE_SIT;
|
||||
else if (arptype == ARPHRD_TUNNEL6)
|
||||
case ARPHRD_TUNNEL6:
|
||||
return NM_LINK_TYPE_IP6TNL;
|
||||
else if (arptype == ARPHRD_PPP)
|
||||
case ARPHRD_PPP:
|
||||
return NM_LINK_TYPE_PPP;
|
||||
else if (arptype == ARPHRD_IEEE802154)
|
||||
case ARPHRD_IEEE802154:
|
||||
return NM_LINK_TYPE_WPAN;
|
||||
else if (arptype == ARPHRD_6LOWPAN)
|
||||
case ARPHRD_6LOWPAN:
|
||||
return NM_LINK_TYPE_6LOWPAN;
|
||||
}
|
||||
|
||||
{
|
||||
NMPUtilsEthtoolDriverInfo driver_info;
|
||||
|
|
@ -8451,6 +8453,7 @@ static gboolean
|
|||
wifi_get_capabilities(NMPlatform *platform, int ifindex, _NMDeviceWifiCapabilities *caps)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, FALSE);
|
||||
|
||||
if (caps)
|
||||
*caps = nm_wifi_utils_get_caps(wifi_data);
|
||||
return TRUE;
|
||||
|
|
@ -8460,6 +8463,7 @@ static guint32
|
|||
wifi_get_frequency(NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, 0);
|
||||
|
||||
return nm_wifi_utils_get_freq(wifi_data);
|
||||
}
|
||||
|
||||
|
|
@ -8471,6 +8475,7 @@ wifi_get_station(NMPlatform *platform,
|
|||
guint32 *out_rate)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, FALSE);
|
||||
|
||||
return nm_wifi_utils_get_station(wifi_data, out_bssid, out_quality, out_rate);
|
||||
}
|
||||
|
||||
|
|
@ -8478,6 +8483,7 @@ static _NM80211Mode
|
|||
wifi_get_mode(NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, _NM_802_11_MODE_UNKNOWN);
|
||||
|
||||
return nm_wifi_utils_get_mode(wifi_data);
|
||||
}
|
||||
|
||||
|
|
@ -8485,6 +8491,7 @@ static void
|
|||
wifi_set_mode(NMPlatform *platform, int ifindex, _NM80211Mode mode)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, );
|
||||
|
||||
nm_wifi_utils_set_mode(wifi_data, mode);
|
||||
}
|
||||
|
||||
|
|
@ -8492,6 +8499,7 @@ static void
|
|||
wifi_set_powersave(NMPlatform *platform, int ifindex, guint32 powersave)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, );
|
||||
|
||||
nm_wifi_utils_set_powersave(wifi_data, powersave);
|
||||
}
|
||||
|
||||
|
|
@ -8499,6 +8507,7 @@ static guint32
|
|||
wifi_find_frequency(NMPlatform *platform, int ifindex, const guint32 *freqs)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, 0);
|
||||
|
||||
return nm_wifi_utils_find_freq(wifi_data, freqs);
|
||||
}
|
||||
|
||||
|
|
@ -8506,6 +8515,7 @@ static void
|
|||
wifi_indicate_addressing_running(NMPlatform *platform, int ifindex, gboolean running)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, );
|
||||
|
||||
nm_wifi_utils_indicate_addressing_running(wifi_data, running);
|
||||
}
|
||||
|
||||
|
|
@ -8513,6 +8523,7 @@ static _NMSettingWirelessWakeOnWLan
|
|||
wifi_get_wake_on_wlan(NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, FALSE);
|
||||
|
||||
return nm_wifi_utils_get_wake_on_wlan(wifi_data);
|
||||
}
|
||||
|
||||
|
|
@ -8520,6 +8531,7 @@ static gboolean
|
|||
wifi_set_wake_on_wlan(NMPlatform *platform, int ifindex, _NMSettingWirelessWakeOnWLan wowl)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, FALSE);
|
||||
|
||||
return nm_wifi_utils_set_wake_on_wlan(wifi_data, wowl);
|
||||
}
|
||||
|
||||
|
|
@ -8565,6 +8577,7 @@ static guint32
|
|||
mesh_get_channel(NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, 0);
|
||||
|
||||
return nm_wifi_utils_get_mesh_channel(wifi_data);
|
||||
}
|
||||
|
||||
|
|
@ -8572,6 +8585,7 @@ static gboolean
|
|||
mesh_set_channel(NMPlatform *platform, int ifindex, guint32 channel)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, FALSE);
|
||||
|
||||
return nm_wifi_utils_set_mesh_channel(wifi_data, channel);
|
||||
}
|
||||
|
||||
|
|
@ -8579,6 +8593,7 @@ static gboolean
|
|||
mesh_set_ssid(NMPlatform *platform, int ifindex, const guint8 *ssid, gsize len)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, FALSE);
|
||||
|
||||
return nm_wifi_utils_set_mesh_ssid(wifi_data, ssid, len);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2092,7 +2092,10 @@ nm_platform_link_release(NMPlatform *self, int master, int ifindex)
|
|||
if (nm_platform_link_get_master(self, ifindex) != master)
|
||||
return FALSE;
|
||||
|
||||
_LOG3D("link: releasing from master '%s'", nm_platform_link_get_name(self, master));
|
||||
_LOG3D("link: releasing %d from master '%s' (%d)",
|
||||
ifindex,
|
||||
nm_platform_link_get_name(self, master),
|
||||
master);
|
||||
return klass->link_release(self, master, ifindex);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -259,17 +259,17 @@ struct _NMPlatformLink {
|
|||
bool initialized : 1;
|
||||
};
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
NM_PLATFORM_SIGNAL_ID_NONE,
|
||||
NM_PLATFORM_SIGNAL_ID_LINK,
|
||||
NM_PLATFORM_SIGNAL_ID_IP4_ADDRESS,
|
||||
NM_PLATFORM_SIGNAL_ID_IP6_ADDRESS,
|
||||
NM_PLATFORM_SIGNAL_ID_IP4_ROUTE,
|
||||
NM_PLATFORM_SIGNAL_ID_IP6_ROUTE,
|
||||
NM_PLATFORM_SIGNAL_ID_ROUTING_RULE,
|
||||
NM_PLATFORM_SIGNAL_ID_QDISC,
|
||||
NM_PLATFORM_SIGNAL_ID_TFILTER,
|
||||
_NM_PLATFORM_SIGNAL_ID_LAST,
|
||||
typedef enum {
|
||||
NM_PLATFORM_SIGNAL_ID_NONE,
|
||||
NM_PLATFORM_SIGNAL_ID_LINK,
|
||||
NM_PLATFORM_SIGNAL_ID_IP4_ADDRESS,
|
||||
NM_PLATFORM_SIGNAL_ID_IP6_ADDRESS,
|
||||
NM_PLATFORM_SIGNAL_ID_IP4_ROUTE,
|
||||
NM_PLATFORM_SIGNAL_ID_IP6_ROUTE,
|
||||
NM_PLATFORM_SIGNAL_ID_ROUTING_RULE,
|
||||
NM_PLATFORM_SIGNAL_ID_QDISC,
|
||||
NM_PLATFORM_SIGNAL_ID_TFILTER,
|
||||
_NM_PLATFORM_SIGNAL_ID_LAST,
|
||||
} NMPlatformSignalIdType;
|
||||
|
||||
guint _nm_platform_signal_id_get(NMPlatformSignalIdType signal_type);
|
||||
|
|
|
|||
|
|
@ -91,17 +91,17 @@ typedef struct _NMPWireGuardPeer {
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
NMP_OBJECT_TO_STRING_ID,
|
||||
NMP_OBJECT_TO_STRING_PUBLIC,
|
||||
NMP_OBJECT_TO_STRING_ALL,
|
||||
typedef enum {
|
||||
NMP_OBJECT_TO_STRING_ID,
|
||||
NMP_OBJECT_TO_STRING_PUBLIC,
|
||||
NMP_OBJECT_TO_STRING_ALL,
|
||||
} NMPObjectToStringMode;
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
NMP_CACHE_OPS_UNCHANGED = NM_PLATFORM_SIGNAL_NONE,
|
||||
NMP_CACHE_OPS_ADDED = NM_PLATFORM_SIGNAL_ADDED,
|
||||
NMP_CACHE_OPS_UPDATED = NM_PLATFORM_SIGNAL_CHANGED,
|
||||
NMP_CACHE_OPS_REMOVED = NM_PLATFORM_SIGNAL_REMOVED,
|
||||
typedef enum {
|
||||
NMP_CACHE_OPS_UNCHANGED = NM_PLATFORM_SIGNAL_NONE,
|
||||
NMP_CACHE_OPS_ADDED = NM_PLATFORM_SIGNAL_ADDED,
|
||||
NMP_CACHE_OPS_UPDATED = NM_PLATFORM_SIGNAL_CHANGED,
|
||||
NMP_CACHE_OPS_REMOVED = NM_PLATFORM_SIGNAL_REMOVED,
|
||||
} NMPCacheOpsType;
|
||||
|
||||
/* The NMPCacheIdType are the different index types.
|
||||
|
|
|
|||
|
|
@ -131,11 +131,13 @@ test_nmp_link_mode_all_advertised_modes_bits(void)
|
|||
|
||||
for (i = 0; i < (int) G_N_ELEMENTS(_nmp_link_mode_all_advertised_modes); i++) {
|
||||
if (flags[i] != _nmp_link_mode_all_advertised_modes[i]) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("_nmp_link_mode_all_advertised_modes[%d] should be 0x%0x but is 0x%0x "
|
||||
"(according to the bits in _nmp_link_mode_all_advertised_modes_bits)",
|
||||
i,
|
||||
flags[i],
|
||||
_nmp_link_mode_all_advertised_modes[i]);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -384,8 +384,10 @@ wifi_nl80211_find_freq(NMWifiUtils *data, const guint32 *freqs)
|
|||
int i;
|
||||
int j;
|
||||
|
||||
for (i = 0; i < self->num_freqs; i++) {
|
||||
for (j = 0; freqs[j] != 0; j++) {
|
||||
/* It's important to check the values in the order of @freqs, because
|
||||
* that array might be sorted to contain preferred frequencies first. */
|
||||
for (j = 0; freqs[j] != 0; j++) {
|
||||
for (i = 0; i < self->num_freqs; i++) {
|
||||
if (self->freqs[i] == freqs[j])
|
||||
return freqs[j];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -255,8 +255,10 @@ wifi_wext_find_freq(NMWifiUtils *data, const guint32 *freqs)
|
|||
guint i;
|
||||
guint j;
|
||||
|
||||
for (i = 0; i < wext->num_freqs; i++) {
|
||||
for (j = 0; freqs[j] != 0; j++) {
|
||||
/* It's important to check the values in the order of @freqs, because
|
||||
* that array might be sorted to contain preferred frequencies first. */
|
||||
for (j = 0; freqs[j] != 0; j++) {
|
||||
for (i = 0; i < wext->num_freqs; i++) {
|
||||
if (wext->freqs[i] == freqs[j])
|
||||
return freqs[j];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ _NM80211Mode
|
|||
nm_wifi_utils_get_mode(NMWifiUtils *data)
|
||||
{
|
||||
g_return_val_if_fail(data != NULL, _NM_802_11_MODE_UNKNOWN);
|
||||
|
||||
return NM_WIFI_UTILS_GET_CLASS(data)->get_mode(data);
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +119,7 @@ guint32
|
|||
nm_wifi_utils_get_freq(NMWifiUtils *data)
|
||||
{
|
||||
g_return_val_if_fail(data != NULL, 0);
|
||||
|
||||
return NM_WIFI_UTILS_GET_CLASS(data)->get_freq(data);
|
||||
}
|
||||
|
||||
|
|
@ -126,6 +128,7 @@ nm_wifi_utils_find_freq(NMWifiUtils *data, const guint32 *freqs)
|
|||
{
|
||||
g_return_val_if_fail(data != NULL, 0);
|
||||
g_return_val_if_fail(freqs != NULL, 0);
|
||||
|
||||
return NM_WIFI_UTILS_GET_CLASS(data)->find_freq(data, freqs);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ nmc_print_qrcode(const char *str)
|
|||
* Example of @passwd_file contents:
|
||||
* wifi.psk:tajne heslo
|
||||
* 802-1x.password:krakonos
|
||||
* 802-11-wireless-security:leap-password:my leap password
|
||||
* 802-11-wireless-security.leap-password:my leap password
|
||||
*
|
||||
* Returns: (transfer full): hash table with parsed passwords, or %NULL on an error
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -38,15 +38,15 @@
|
|||
*
|
||||
* 10: NMSettingUser
|
||||
*/
|
||||
typedef enum { /*< skip >*/
|
||||
NM_SETTING_PRIORITY_INVALID = 0,
|
||||
NM_SETTING_PRIORITY_CONNECTION = 1,
|
||||
NM_SETTING_PRIORITY_HW_BASE = 2,
|
||||
NM_SETTING_PRIORITY_HW_NON_BASE = 3,
|
||||
NM_SETTING_PRIORITY_HW_AUX = 4,
|
||||
NM_SETTING_PRIORITY_AUX = 5,
|
||||
NM_SETTING_PRIORITY_IP = 6,
|
||||
NM_SETTING_PRIORITY_USER = 10,
|
||||
typedef enum /*< skip >*/ {
|
||||
NM_SETTING_PRIORITY_INVALID = 0,
|
||||
NM_SETTING_PRIORITY_CONNECTION = 1,
|
||||
NM_SETTING_PRIORITY_HW_BASE = 2,
|
||||
NM_SETTING_PRIORITY_HW_NON_BASE = 3,
|
||||
NM_SETTING_PRIORITY_HW_AUX = 4,
|
||||
NM_SETTING_PRIORITY_AUX = 5,
|
||||
NM_SETTING_PRIORITY_IP = 6,
|
||||
NM_SETTING_PRIORITY_USER = 10,
|
||||
} NMSettingPriority;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@ nm_http_client_get(NMHttpClient *self,
|
|||
curl_easy_setopt(edata->ehandle, CURLOPT_WRITEFUNCTION, _get_writefunction_cb);
|
||||
curl_easy_setopt(edata->ehandle, CURLOPT_WRITEDATA, edata);
|
||||
curl_easy_setopt(edata->ehandle, CURLOPT_PRIVATE, edata);
|
||||
curl_easy_setopt(edata->ehandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
|
||||
|
||||
if (http_headers) {
|
||||
for (i = 0; http_headers[i]; ++i) {
|
||||
|
|
|
|||
|
|
@ -530,8 +530,11 @@ test_generic(const char *file, const char *override_vpn_ip_iface)
|
|||
|
||||
g_assert((!denv && error_message) || (denv && !error_message));
|
||||
|
||||
if (error_message)
|
||||
if (error_message) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
g_error("FAILED: %s", error_message);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
if (g_strv_length(denv) != g_hash_table_size(expected_env)) {
|
||||
_print_env(NM_CAST_STRV_CC(denv), expected_env);
|
||||
|
|
@ -552,8 +555,10 @@ test_generic(const char *file, const char *override_vpn_ip_iface)
|
|||
|
||||
foo = g_hash_table_lookup(expected_env, i_value);
|
||||
if (!foo) {
|
||||
NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
|
||||
_print_env(NM_CAST_STRV_CC(denv), expected_env);
|
||||
g_error("Failed to find %s in environment", i_value);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
#if HAVE_EDITLINE_READLINE
|
||||
|
|
@ -118,8 +117,7 @@ typedef struct {
|
|||
} ArgsInfo;
|
||||
|
||||
/* --- Global variables --- */
|
||||
GMainLoop *loop = NULL;
|
||||
struct termios termios_orig;
|
||||
GMainLoop *loop = NULL;
|
||||
|
||||
NM_CACHED_QUARK_FCN("nmcli-error-quark", nmcli_error_quark);
|
||||
|
||||
|
|
@ -935,7 +933,6 @@ nmc_clear_sigint(void)
|
|||
void
|
||||
nmc_exit(void)
|
||||
{
|
||||
tcsetattr(STDIN_FILENO, TCSADRAIN, &termios_orig);
|
||||
nmc_cleanup_readline();
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -1026,9 +1023,6 @@ main(int argc, char *argv[])
|
|||
textdomain(GETTEXT_PACKAGE);
|
||||
#endif
|
||||
|
||||
/* Save terminal settings */
|
||||
tcgetattr(STDIN_FILENO, &termios_orig);
|
||||
|
||||
nm_cli.return_text = g_string_new(_("Success"));
|
||||
loop = g_main_loop_new(NULL, FALSE);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@
|
|||
#include "nm-utils.h"
|
||||
#include "libnmt-newt/nmt-newt.h"
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
NMT_MAC_ENTRY_TYPE_MAC,
|
||||
NMT_MAC_ENTRY_TYPE_CLONED,
|
||||
typedef enum {
|
||||
NMT_MAC_ENTRY_TYPE_MAC,
|
||||
NMT_MAC_ENTRY_TYPE_CLONED,
|
||||
} NmtMacEntryType;
|
||||
|
||||
#define NMT_TYPE_MAC_ENTRY (nmt_mac_entry_get_type())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue